Skip to content

Commit

Permalink
Refactor add_flats_and_darks function for improved error handling and…
Browse files Browse the repository at this point in the history
… clarity"
  • Loading branch information
ashmeigh committed May 15, 2024
1 parent 69f5e70 commit 9bfed9e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
15 changes: 3 additions & 12 deletions scripts/operations_tests/operations_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,23 +181,14 @@ def add_flats_and_darks(self, params):
for frame_type in ['flat_before', 'dark_before', 'flat_after', 'dark_after']:
if frame_type in params:
filename_group = FilenameGroup.from_file(config_manager.load_sample)
filename_group.find_all_files()
filename_group.find_related(getattr(FILE_TYPES, frame_type.upper()))

image_stack = self.load_specific_image_stack(filename_group, frame_type)
related_filename_group = filename_group.find_related(getattr(FILE_TYPES, frame_type.upper()))
related_filename_group.find_all_files()
image_stack = loader.load(filename_group=related_filename_group)
if image_stack is not None:
params[frame_type] = image_stack
else:
print(f"Failed to load image stack for {frame_type}")

def load_specific_image_stack(self, filename_group, frame_type):
try:
image_stack = loader.load(filename_group=filename_group)
return image_stack
except Exception as e:
print(f"Error loading image stack for {frame_type}: {e}")
return None

def compare_mode(self):
for operation, test_case_info in TEST_CASES.items():
print(f"Running tests for {operation}:")
Expand Down
2 changes: 1 addition & 1 deletion scripts/operations_tests/test_cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@
}
]
},
"Flat-fielding": {
"Flat-fielding": {
"params": {
"use_dark": true,
"selected_flat_fielding": "Both, concatenated"
Expand Down

0 comments on commit 9bfed9e

Please sign in to comment.