Skip to content

Commit cb93d92

Browse files
committed
x-axis file produced. this refs #245
1 parent 25fa957 commit cb93d92

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

notebooks/__code/normalization_tof/normalization_for_timepix.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,22 @@ def retrieve_list_of_tif(folder: str) -> list:
8787
return list_tif
8888

8989

90+
def create_x_axis_file(lambda_array: np.ndarray = None,
91+
energy_array: np.ndarray = None,
92+
output_folder: str = "./") -> str:
93+
"""create x axis file with lambda, energy and tof arrays"""
94+
x_axis_data = {
95+
"file_index": np.arange(len(lambda_array)),
96+
"lambda (Angstroms)": lambda_array,
97+
"energy (eV)": energy_array,
98+
}
99+
x_axis_file_name = os.path.join(output_folder, "x_axis.txt")
100+
pd_dataframe = pd.DataFrame(x_axis_data)
101+
pd_dataframe.to_csv(x_axis_file_name, index=False, sep=",")
102+
103+
logging.info(f"X axis file created: {x_axis_file_name}")
104+
105+
90106
def normalization_with_list_of_runs(sample_run_numbers: list = None,
91107
ob_run_numbers: list = None,
92108
output_folder: str ="./",
@@ -137,13 +153,15 @@ def normalization_with_list_of_runs(sample_run_numbers: list = None,
137153
export_corrected_integrated_sample_data = export_mode.get("sample_integrated", False)
138154
export_corrected_integrated_ob_data = export_mode.get("ob_integrated", False)
139155
export_corrected_integrated_normalized_data = export_mode.get("normalized_integrated", False)
156+
export_x_axis = export_mode.get("x_axis", True)
140157

141158
logging.info(f"{export_corrected_stack_of_sample_data = }")
142159
logging.info(f"{export_corrected_stack_of_ob_data = }")
143160
logging.info(f"{export_corrected_stack_of_normalized_data = }")
144161
logging.info(f"{export_corrected_integrated_sample_data = }")
145162
logging.info(f"{export_corrected_integrated_ob_data = }")
146163
logging.info(f"{export_corrected_integrated_normalized_data = }")
164+
logging.info(f"{export_x_axis = }")
147165

148166
sample_master_dict, sample_status_metadata = create_master_dict(list_run_numbers=sample_run_numbers,
149167
data_type=DataType.sample,
@@ -387,6 +405,12 @@ def normalization_with_list_of_runs(sample_run_numbers: list = None,
387405
spectra_file = sample_master_dict[_sample_run_number][MasterDictKeys.spectra_file_name]
388406
shutil.copy(spectra_file, full_output_folder)
389407

408+
# create x-axis file
409+
create_x_axis_file(lambda_array=lambda_array,
410+
energy_array=energy_array,
411+
output_folder=output_stack_folder,
412+
)
413+
390414
logging.info(f"Normalization and export is done!")
391415
if verbose:
392416
display(HTML(f"Normalization and export is done!"))

notebooks/__code/normalization_tof/normalization_tof.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,10 @@ def run_normalization_with_list_of_runs(self, preview=False):
425425
'normalized_stack': self.export_corrected_stack_of_normalized_data.value,
426426
'sample_integrated': self.export_corrected_integrated_sample_data.value,
427427
'ob_integrated': self.export_corrected_integrated_ob_data.value,
428-
'normalized_integrated': self.export_corrected_integrated_normalized_data.value,}
429-
428+
'normalized_integrated': self.export_corrected_integrated_normalized_data.value,
429+
'x_axis': True, # always export x axis
430+
}
431+
430432
detecor_delay_us = None
431433
if self.instrument == "SNAP":
432434
detecor_delay_us = self.detector_offset_us.value

notebooks/normalization_tof.ipynb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,20 @@
216216
"source": [
217217
"o_norm.run_normalization_with_list_of_runs(preview=True)"
218218
]
219+
},
220+
{
221+
"cell_type": "code",
222+
"execution_count": null,
223+
"metadata": {},
224+
"outputs": [],
225+
"source": []
226+
},
227+
{
228+
"cell_type": "code",
229+
"execution_count": null,
230+
"metadata": {},
231+
"outputs": [],
232+
"source": []
219233
}
220234
],
221235
"metadata": {

0 commit comments

Comments
 (0)