make_dataset.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import snlay as snlay
  2. import h5py
  3. import numpy as np
  4. from scattnlay import scattnlay
  5. import time
  6. import progressbar
  7. dataset_size = 100000
  8. # parameters of the dataset
  9. num_layers = 8
  10. num_lpoints = 250
  11. lam_min = 300
  12. lam_max = 1200
  13. size_min = 30
  14. size_max = 70
  15. #make the materials list here
  16. mats = [3, 4, 3, 4, 3, 4, 3, 4] # 2 - silicon, silicon.dat, 1 - gold, gold.dat
  17. # 3 - silica, silica.dat, 4 - titania, tio2.dat
  18. #generate a huge array and then reshape
  19. dataset_X = np.random.randint(size_min,size_max+1,num_layers*dataset_size).astype(float).reshape(dataset_size, num_layers)
  20. lams = np.linspace(lam_min, lam_max, num_lpoints)
  21. dataset_Y = np.zeros((dataset_size,num_lpoints))
  22. for ind in progressbar.progressbar(np.arange(dataset_size)):
  23. kr, m = snlay.make_xm(dataset_X[ind,:], mats, lams)
  24. terms, dataset_Y[ind,:], Qsca, Qabs, Qbk, Qpr, g, Albedo, S1, S2 = scattnlay(kr, m)
  25. h5f = h5py.File('./datasets/s8_sio2tio2.h5', 'w')
  26. h5f.create_dataset('sizes', data=dataset_X)
  27. h5f.create_dataset('spectrum', data=dataset_Y)
  28. h5f.close()