Skip to content

Commit

Permalink
Don't immediately fail if TA concats exist
Browse files Browse the repository at this point in the history
  • Loading branch information
JarronL committed Dec 11, 2024
1 parent 77cd0dc commit 02f2304
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 7 additions & 1 deletion spaceKLIP/imagetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3149,13 +3149,16 @@ def create_rec_mask(h, w, center=None, z=None):

# Loop through concatenations.
database_temp = deepcopy(self.database.obs)
sci_good = False
for i, key in enumerate(self.database.obs.keys()):
log.info('--> Concatenation ' + key)

# Find science and reference files.
ww_sci = np.where(self.database.obs[key]['TYPE'] == 'SCI')[0]
if len(ww_sci) == 0:
raise UserWarning('Could not find any science files')
print(f'Warning: Could not find any science files. Skipping {key}.')
continue
sci_good = True
ww_ref = np.where(self.database.obs[key]['TYPE'] == 'REF')[0]
ww_all = np.append(ww_sci, ww_ref)

Expand Down Expand Up @@ -3395,6 +3398,9 @@ def create_rec_mask(h, w, center=None, z=None):
log.info(f" Plot saved in {output_file}")
plt.show()
plt.close(fig)

if not sci_good:
raise(ValueError('No science frames found in database concatenations'))

@plt.style.context('spaceKLIP.sk_style')
def subtract_nircam_coron_background(self,
Expand Down
10 changes: 7 additions & 3 deletions spaceKLIP/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,16 +549,20 @@ def display_image_comparisons(database,

# Check if any SCI data remains after filtering.
if not any(row['TYPE'] == 'SCI' for row in filtered_table):
print(f"No SCI type files found in key: {key}."
f" Exiting. Check 'restrict_to' criteria.")
return
print(f"No SCI type files found in key: {key}.")
# f" Exiting. Check 'restrict_to' criteria.")
continue

# Identify the first SCI frame for subtraction, store it for later use.
first_sci_file = next((row['FITSFILE'] for row in filtered_table if row['TYPE'] == 'SCI'), None)
root_dir = first_sci_file.split(os.sep)[0]
for base_dir in base_dirs:
image_files[base_dir]['first_sci_file'] = os.path.join(root_dir, base_dir, os.path.basename(first_sci_file))

if len(filtered_files)==0:
print("No files found. Check 'restrict_to' criteria. Exiting.")
return

# Create figure of appropriate size.
num_dirs = len(base_dirs)
num_rows, num_cols = (1, num_dirs) if num_dirs <= 3 else (2, (num_dirs + 1) // 2)
Expand Down

0 comments on commit 02f2304

Please sign in to comment.