Skip to content

Commit

Permalink
When trying to load splines that do not yet exist, create them.
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdstein committed Mar 15, 2021
1 parent 95101e4 commit c82a513
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions flarestack/utils/make_SoB_splines.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,21 +507,33 @@ def make_background_spline(season):
def load_spline(season, **kwargs):
path = SoB_spline_path(season, **kwargs)

logger.debug("Loading from {0}".format(path))
logger.debug(f"Loading from {path}")

with open(path, "rb") as f:
res = Pickle.load(f)
try:
with open(path, "rb") as f:
res = Pickle.load(f)
except FileNotFoundError:
logger.info(f"No cached spline found at {path}. Creating this file instead.")
make_spline(season)
with open(path, "rb") as f:
res = Pickle.load(f)

return res


def load_bkg_spatial_spline(season):
path = bkg_spline_path(season)

logger.debug("Loading from {0}".format(path))
logger.debug(f"Loading from {path}")

with open(path, "rb") as f:
res = Pickle.load(f)
try:
with open(path, "rb") as f:
res = Pickle.load(f)
except FileNotFoundError:
logger.info(f"No cached spline found at {path}. Creating this file instead.")
make_background_spline(season)
with open(path, "rb") as f:
res = Pickle.load(f)

return res

Expand Down

0 comments on commit c82a513

Please sign in to comment.