Skip to content

Commit e84d6d9

Browse files
committed
Do not assume that dark files end with "003"
Signed-off-by: Brianna Major <[email protected]>
1 parent b6ee03c commit e84d6d9

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

hexrdgui/llnl_import_tool_dialog.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -480,22 +480,25 @@ def load_detector_images(self):
480480
self.ui.detector_files_label.setText(file_name)
481481
self.loaded_images.append(selected_file)
482482
self.detector_images[self.detector]['data'] = selected_file
483-
elif file_name.endswith('003'):
483+
else:
484484
self.ui.dark_files_label.setText(file_name)
485485
self.detector_images[self.detector]['dark'] = selected_file
486486
selected = self.detector_images[self.detector]
487487

488488
# Create regex pattern to try to match data and dark images
489489
# ex:
490-
# TD_TC000-000_FIDDLE_CAMERA-02-DB_SHOT_RAW-FIDDLE-CAMERA_N240717-001-003.h5
490+
# TD_TC000-000_FIDDLE_CAMERA-02-DB_SHOT_RAW-FIDDLE-CAMERA_N240717-001-999.h5
491491
# ->
492492
# TD_TC000-000_FIDDLE_CAMERA-*-DB_SHOT_RAW-FIDDLE-CAMERA_N240717-001-*.h5
493493
image = re.sub("CAMERA-\d{2}-", "CAMERA-*-", selected_file)
494-
data_files = re.sub("-\d{3}.h", "-999.h", image)
495-
dark_files = re.sub("-\d{3}.h", "-003.h", image)
496-
497-
data_matches = sorted(glob.glob(data_files))
498-
dark_matches = sorted(glob.glob(dark_files))
494+
files = re.sub("-\d{3}.h", "-*.h", image)
495+
496+
# Sort matched files. We know that those ending in -999 are data files.
497+
# Dark files may have different values at the end (-003, -005, etc.) so
498+
# we separate as data file (-999) and *not* data (anything else).
499+
matches = sorted(glob.glob(files))
500+
data_matches = [m for m in matches if m.endswith('-999.h5')]
501+
dark_matches = [m for m in matches if m not in data_matches]
499502

500503
if len(data_matches) == len(dark_matches) == len(self.detectors):
501504
# All data and dark files have been found for all detectors

0 commit comments

Comments
 (0)