sdss / lvmdrp

Local Volume Mapper (LVM) Data Reduction Pipeline
BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

Fixes crash when exposures missing spectrographs/channels. #64

Closed havok2063 closed 4 months ago

havok2063 commented 4 months ago

This PR fixes an issue where the DRP crashes when an exposure doesn't have all spectrograph or channels. The original errors were seen in https://data.sdss5.org/sas/sdsswork/lvm/spectro/redux/master/drp_errors.txt. For example,

ERROR on tileid, mjd, exposure: 1028742, 60216, 5755
Traceback (most recent call last):
  File "/uufs/chpc.utah.edu/common/home/sdss50/software/git/sdss/lvmdrp/master/python/lvmdrp/functions/run_drp.py", line 1523, in run_drp
    quick_science_reduction(expnum, use_fiducial_master=True)
  File "/uufs/chpc.utah.edu/common/home/sdss50/software/git/sdss/lvmdrp/master/python/lvmdrp/functions/run_quickdrp.py", line 279, in quick_science_reduction
    flux_tasks.apply_fluxcal(in_rss=sci_path, out_rss=sci_path)
  File "/uufs/chpc.utah.edu/common/home/sdss50/software/git/sdss/lvmdrp/master/python/lvmdrp/functions/fluxCalMethod.py", line 164, in apply_fluxcal
    rss._data *= sens_ave * 10**(0.4*ext*(sci_secz)) / exptimes[:, None]
ValueError: operands could not be broadcast together with shapes (1296,4401) (1944,4401) (1296,4401) 

These errors were from the old pipeline. When running on the latest master, I would get the following crash

[INFO]: stacking frames in lvm-xobject-b1-00008544.fits,lvm-xobject-b2-00008544.fits along fiber ID axis
[ERROR]: Failed to reduce science frame mjd 60278 exposure 8544: RSS.from_spectrographs() missing 1 required positional argument: 'rss_sp3'
Traceback (most recent call last):
  File "/Users/brian/Work/git/sdss/lvmdrp/python/lvmdrp/functions/run_drp.py", line 1530, in run_drp
    quick_science_reduction(expnum, use_fiducial_master=True, **kwargs)
  File "/Users/brian/Work/git/sdss/lvmdrp/python/lvmdrp/functions/run_quickdrp.py", line 191, in quick_science_reduction
    rss_tasks.stack_spectrographs(in_rsss=xsci_paths, out_rss=xsci_path)
  File "/Users/brian/Work/git/sdss/lvmdrp/python/lvmdrp/functions/rssMethod.py", line 2892, in stack_spectrographs
    rss_out = RSS.from_spectrographs(*rsss)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: RSS.from_spectrographs() missing 1 required positional argument: 'rss_sp3'

Comparing the errors in the file with the observing log, they all seem to be cases where not all spectrographs or channels were taken during the night. This PR fixes the crashes so the pipeline exits gracefully now with the following:

[INFO]: writing extracted spectra to lvm-xobject-b2-00008544.fits
[INFO]: stacking frames in lvm-xobject-b1-00008544.fits,lvm-xobject-b2-00008544.fits along fiber ID axis
[ERROR]: Cannot stack spectrographs: RSS.from_spectrographs() missing 1 required positional argument: 'rss_sp3'
[ERROR]: No stacked file found: /Users/brian/Work/sdss/sas/sdsswork/lvm/spectro/redux/0.1.2dev/1041XX/1041497/60278/ancillary/lvm-xobject-b-00008544.fits. Skipping remaining pipeline.
[INFO]: stacking frames in  along fiber ID axis
[ERROR]: Cannot stack spectrographs: RSS.from_spectrographs() missing 3 required positional arguments: 'rss_sp1', 'rss_sp2', and 'rss_sp3'
[ERROR]: No stacked file found: /Users/brian/Work/sdss/sas/sdsswork/lvm/spectro/redux/0.1.2dev/1041XX/1041497/60278/ancillary/lvm-xobject-r-00008544.fits. Skipping remaining pipeline.
[INFO]: stacking frames in  along fiber ID axis
[ERROR]: Cannot stack spectrographs: RSS.from_spectrographs() missing 3 required positional arguments: 'rss_sp1', 'rss_sp2', and 'rss_sp3'
[ERROR]: No stacked file found: /Users/brian/Work/sdss/sas/sdsswork/lvm/spectro/redux/0.1.2dev/1041XX/1041497/60278/ancillary/lvm-xobject-z-00008544.fits. Skipping remaining pipeline.
[ERROR]: No fframe files found.  Cannot join spectrograph channels. Exiting pipeline.