Skip to content

Commit

Permalink
replace nans in sky brightness array before IntRounded is applied
Browse files Browse the repository at this point in the history
  • Loading branch information
ehneilsen committed Nov 2, 2023
1 parent 9a5eb91 commit 657e3b8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions rubin_sim/scheduler/basis_functions/basis_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1320,12 +1320,19 @@ def __init__(self, nside=None, filtername="r", sbmin=20.0, sbmax=30.0):
def _calc_value(self, conditions, indx=None):
result = self.result.copy()

# Replace non-finite values so IntRounded works, then set
# the result to nan.
sky_brightness = conditions.skybrightness[self.filtername].copy()
not_finite = np.where(~np.isfinite(sky_brightness))
sky_brightness[not_finite] = 0
rounded_sky_brightness = IntRounded(sky_brightness)
good = np.where(
np.bitwise_and(
IntRounded(conditions.skybrightness[self.filtername]) > self.min,
IntRounded(conditions.skybrightness[self.filtername]) < self.max,
rounded_sky_brightness > self.min,
rounded_sky_brightness < self.max,
)
)
result[not_finite] = np.nan
result[good] = 1.0

return result
Expand Down

0 comments on commit 657e3b8

Please sign in to comment.