sweep-plot2d.py 807 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env python3
  2. # -*- coding: UTF-8 -*-
  3. import numpy as np
  4. import matplotlib.pyplot as plt
  5. import os
  6. from glob import glob
  7. paths = glob('sweep_*.fsp.results.npy')
  8. import re
  9. def atoi(text):
  10. return int(text) if text.isdigit() else text
  11. def natural_keys(text):
  12. '''
  13. alist.sort(key=natural_keys) sorts in human order
  14. http://nedbatchelder.com/blog/200712/human_sorting.html
  15. (See Toothy's implementation in the comments)
  16. '''
  17. return [ atoi(c) for c in re.split('(\d+)', text) ]
  18. paths.sort(key=natural_keys)
  19. a = np.load('sweep_1.fsp.results.npy')
  20. spectra_len = len(a)
  21. r_len = len(paths)
  22. data = np.zeros((r_len,spectra_len ))
  23. for dirname, i in zip(paths,range(len(paths))):
  24. a = np.load(dirname)
  25. data[i] = a
  26. # dir_list = next(os.walk('.'))[1]
  27. # print(dir_list)
  28. #main()