Skip to content

Commit

Permalink
If the timeseries code crashes, fix issue with renaming temp files
Browse files Browse the repository at this point in the history
  • Loading branch information
jotaylor committed Oct 22, 2023
1 parent 5c5bbb0 commit 8800f6e
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions ullyses/timeseries_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,14 @@ def create_serendipitous_timeseries(datadir, tss_outdir, targ, tss_params, min_e
for grat in tss_params["gratings"]:
# Create the exposure level time-series spectra
outfile = os.path.join(tss_outdir, f"hlsp_ullyses_hst_{ins}_{targ}_{grat}_{VERSION.lower()}_tss.fits")
timeseries.process_files(grat.upper(), outfile, datadir, overwrite=True,
ins=ins.upper(), min_exptime=min_exptime)
try:
timeseries.process_files(grat.upper(), outfile, datadir, overwrite=True,
ins=ins.upper(), min_exptime=min_exptime)
except:
without = glob.glob(os.path.join(datadir, "*without*fits"))
for newname in without:
origname = newname.replace("_without.fits", "_x1d.fits")
os.rename(newname, origname)

return tss_outdir

Expand Down Expand Up @@ -444,11 +450,23 @@ def create_monitoring_timeseries(datadir, tss_outdir, targ, tss_params):
# First create the exposure level time-series spectra
indir = os.path.join(datadir, grat, "exp")
outfile = os.path.join(tss_outdir, f"hlsp_ullyses_hst_cos_{targ}_{grat}_{VERSION.lower()}_tss.fits")
timeseries.process_files(grat.upper(), outfile, indir, overwrite=True)
try:
timeseries.process_files(grat.upper(), outfile, indir, overwrite=True)
except:
without = glob.glob(os.path.join(datadir, "*without*fits"))
for newname in without:
origname = newname.replace("_without.fits", "_x1d.fits")
os.rename(newname, origname)

indir = os.path.join(datadir, grat, "split")
outfile = os.path.join(tss_outdir, f"hlsp_ullyses_hst_cos_{targ}_{grat}_{VERSION.lower()}_split-tss.fits")
timeseries.process_files(grating=grat.upper(), outfile=outfile, indir=indir,
try:
timeseries.process_files(grating=grat.upper(), outfile=outfile, indir=indir,
except:
without = glob.glob(os.path.join(datadir, "*without*fits"))
for newname in without:
origname = newname.replace("_without.fits", "_x1d.fits")
os.rename(newname, origname)
wavelength_binning=wl_bin, min_exptime=min_exptime,
overwrite=True)

Expand Down

0 comments on commit 8800f6e

Please sign in to comment.