Skip to content

Commit

Permalink
Do not delete old SkyModelPre attributes until we know if new ones ar…
Browse files Browse the repository at this point in the history
…e valid
  • Loading branch information
ehneilsen committed Oct 31, 2023
1 parent cbecfc0 commit dc73eea
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions rubin_sim/skybrightness_pre/sky_model_pre.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,6 @@ def _load_data(self, mjd, filename=None, npyfile=None):
npyfile : `str` (None)
If sky brightness data not in npz file, checks the .npy file with same root name.
"""
del self.sb
del self.filter_names
del self.timestep_max

if filename is None:
# Figure out which file to load.
Expand All @@ -174,6 +171,23 @@ def _load_data(self, mjd, filename=None, npyfile=None):
else:
self.loaded_range = None

# Use three separate try/excepet blocks so that if any of them throw
# exceptions, we still get the others.
try:
del self.sb
except AttributeError:
pass

try:
del self.filter_names
except AttributeError:
pass

try:
del self.timestep_max
except AttributeError:
pass

if self.verbose:
print("Loading file %s" % filename)
h5 = h5py.File(filename, "r")
Expand Down

0 comments on commit dc73eea

Please sign in to comment.