Skip to content

Commit

Permalink
Prevent zero division issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
mairanteodoro committed Dec 30, 2024
1 parent 40ef234 commit 337134f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions romancal/resample/resample_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,10 @@ def add_var_sky_array(input_models: ModelLibrary):
ref_img = input_models.borrow(index=0)
input_models.shelve(model=ref_img, index=0)
for i, img in enumerate(input_models):
img["var_sky"] = img.var_rnoise + img.var_poisson / img.data * np.median(
img.data
)
if np.all(img.data != 0):
img["var_sky"] = (
img.var_rnoise + img.var_poisson / img.data * np.median(img.data)
)
else:
raise ValueError("Input model contains invalid data array.")
input_models.shelve(img, i, modify=True)

0 comments on commit 337134f

Please sign in to comment.