#!/usr/bin/env python3 # -*- coding: UTF-8 -*- import numpy as np import matplotlib.pyplot as plt import os from glob import glob paths = glob('sweep_*.fsp.results.npy') import re def atoi(text): return int(text) if text.isdigit() else text def natural_keys(text): ''' alist.sort(key=natural_keys) sorts in human order http://nedbatchelder.com/blog/200712/human_sorting.html (See Toothy's implementation in the comments) ''' return [ atoi(c) for c in re.split('(\d+)', text) ] paths.sort(key=natural_keys) a = np.load('sweep_1.fsp.results.npy') spectra_len = len(a) r_len = len(paths) data = np.zeros((r_len,spectra_len )) for dirname, i in zip(paths,range(len(paths))): a = np.load(dirname) data[i] = a # dir_list = next(os.walk('.'))[1] # print(dir_list) #main()