From 229f978cd7498ff8bd25f8a1726e6c7a47b748e5 Mon Sep 17 00:00:00 2001 From: Marshall Perrin Date: Mon, 1 Apr 2024 20:20:01 -0400 Subject: [PATCH] add auto download of OPDS as needed for trending plots. --- webbpsf/trending.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/webbpsf/trending.py b/webbpsf/trending.py index 0ae432a1..de2e4c05 100644 --- a/webbpsf/trending.py +++ b/webbpsf/trending.py @@ -17,9 +17,12 @@ import poppy import webbpsf -def _read_opd(filename): - """Trivial utilty function to read OPD from a WSS-output FITS file""" +def _read_opd(filename, auto_download=True): + """Trivial utilty function to read OPD from a WSS-output FITS file + If the file does not exist locally, try to retrieve it from MAST automatically.""" full_file_path = os.path.join(webbpsf.utils.get_webbpsf_data_path(), 'MAST_JWST_WSS_OPDs', filename) + if not os.path.exists(full_file_path) and auto_download: + webbpsf.mast_wss.mast_retrieve_opd(filename) opdhdu = fits.open(full_file_path) opd = opdhdu[1].data.copy() return opd, opdhdu