Skip to content
Snippets Groups Projects
Commit 51dc5ce6 authored by Gröne, Tjark Leon Raphael's avatar Gröne, Tjark Leon Raphael
Browse files

Update file maxwell_integrate_to_h5.py

parent 91ec1538
No related branches found
No related tags found
No related merge requests found
......@@ -181,7 +181,7 @@ def integrate_ims_in_dir(path_im, path_int, dtype_im=".tif", dtype_int=".dat"):
# Use a lambda function to pass the subdir_path_int to the integration_thread
# Map async allows us to run the integration in parallel, with trace back of varibles
async_result = pool.map_async(
lambda fname_im: integration_thread(fname_im, subdir_path_int),
lambda fname_im: integration_thread(fname_im),
filtered_fnames
)
......@@ -261,10 +261,7 @@ def integrate_ims_in_dir(path_im, path_int, dtype_im=".tif", dtype_int=".dat"):
for idx, result in enumerate(results_data, start=1):
# Drop unfinished scans (usually last scan due to closed shutter)
if not result["q"].size or not result["I"].size:
print(f"Skipping invalid scan data for entry {entry_name}")
continue
try:
# Here one could use the image sequence number from the metadata, however, we use the index as it seemes cleaner
entry_name = f"{idx:05d}.1"
......@@ -273,8 +270,6 @@ def integrate_ims_in_dir(path_im, path_int, dtype_im=".tif", dtype_int=".dat"):
entry["title"] = "Collected Q-I scans"
entry.attrs["NX_class"] = "NXentry"
# Set time attributes for the entry
entry.create_dataset("time", data=results_metadata[idx-1]["dateString"].encode('utf-8'), dtype=h5py.string_dtype(encoding='utf-8'))
......@@ -376,6 +371,10 @@ def integrate_ims_in_dir(path_im, path_int, dtype_im=".tif", dtype_int=".dat"):
if idx == len(results_data): # mark the last one as global default
entry["last_plot"] = h5py.SoftLink(f"/{subdir_name}/{entry_name}/measurement")
except Exception as e:
print(f"Error processing file {result['filename']}: {e}")
continue
print(f"✅ HDF5 file '{output_file}' created with {len(results_data)} spectra.")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment