forked from a-rouxel/simca
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmulti_acq_script.py
61 lines (35 loc) · 2.24 KB
/
multi_acq_script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import matplotlib.pyplot as plt
from simca import CassiSystem
from simca.functions_general_purpose import *
import os
config_dataset = load_yaml_config("simca/configs/dataset.yml")
config_system = load_yaml_config("simca/configs/cassi_system.yml")
config_patterns = load_yaml_config("simca/configs/pattern.yml")
config_acquisition = load_yaml_config("simca/configs/acquisition.yml")
dataset_name = "indian_pines"
results_directory = "./data/results/lego_test_1"
nb_of_acq = 10
if __name__ == '__main__':
# Initialize the CASSI system
cassi_system = CassiSystem(system_config=config_system)
# DATASET : Load the hyperspectral dataset
cassi_system.load_dataset(dataset_name, config_dataset["datasets directory"])
cassi_system.generate_multiple_patterns(config_patterns,nb_of_acq)
# PROPAGATION : Propagate the pattern grid to the detector plane
cassi_system.propagate_coded_aperture_grid()
# FILTERING CUBE : Generate the filtering cubes
cassi_system.generate_multiple_filtering_cubes(nb_of_acq)
# ACQUISITION : Simulate the acquisition with psf (use_psf is optional)
cassi_system.multiple_image_acquisitions(use_psf=False,nb_of_filtering_cubes=nb_of_acq,chunck_size=50)
# Save the acquisition
cassi_system.result_directory =results_directory
os.makedirs(results_directory, exist_ok=True)
save_config_file("config_system", cassi_system.system_config, cassi_system.result_directory)
save_config_file("config_pattern", config_patterns,cassi_system.result_directory)
save_config_file("config_acquisition", config_acquisition, cassi_system.result_directory)
save_data_in_hdf5("interpolated_scene",cassi_system.interpolated_scene, cassi_system.result_directory)
save_data_in_hdf5("panchro",cassi_system.panchro,cassi_system.result_directory)
save_data_in_hdf5("wavelengths",cassi_system.optical_model.system_wavelengths,cassi_system.result_directory)
save_data_in_hdf5("list_of_compressed_measurements",cassi_system.list_of_measurements,cassi_system.result_directory)
save_data_in_hdf5("list_of_filtering_cubes",cassi_system.list_of_filtering_cubes,cassi_system.result_directory)
save_data_in_hdf5("list_of_patterns",cassi_system.list_of_patterns,cassi_system.result_directory)