Skip to content

Commit cc261a2

Browse files
committed
Don't make smoothed flat unless necessary
1 parent df48f2a commit cc261a2

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

jwst/clean_flicker_noise/clean_flicker_noise.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,12 +1068,13 @@ def _read_flat_file(input_model, flat_filename):
10681068

10691069
# Set any zeros or non-finite values in the flat data to a smoothed local value
10701070
bad_data = (flat_data == 0) | ~np.isfinite(flat_data)
1071-
smoothed_flat = background_level(flat_data, ~bad_data, background_method='model')
1072-
try:
1073-
flat_data[bad_data] = smoothed_flat[bad_data]
1074-
except IndexError:
1075-
# 2D model failed, median value returned instead
1076-
flat_data[bad_data] = smoothed_flat
1071+
if np.any(bad_data):
1072+
smoothed_flat = background_level(flat_data, ~bad_data, background_method='model')
1073+
try:
1074+
flat_data[bad_data] = smoothed_flat[bad_data]
1075+
except IndexError:
1076+
# 2D model failed, median value returned instead
1077+
flat_data[bad_data] = smoothed_flat
10771078

10781079
return flat_data
10791080

0 commit comments

Comments
 (0)