[PIPE2D-525] PostISRCCD exposures cannot be written for a subset of LAM data Created: 19/Mar/20  Updated: 10/Apr/20  Resolved: 21/Mar/20

Status: Done
Project: DRP 2-D Pipeline
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Normal
Reporter: hassan Assignee: price
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File detrend_postisrccd.log    
Issue Links:
Relates
relates to PIPE2D-536 Correct header info for ReduceArc and... Done
relates to PIPE2D-543 Extend visit range when fixing W_XHP2... Done
relates to INSTRM-925 Duplicate key W_XHP2FR present in raw... Done
Reviewers: hassan

 Description   

This ticket relates to an update needed to the LSST stack, for which a separate ticket on the LSST JIRA service will be raised, but is written here so that the PFS team are aware of the problem.

While processing LAM data, it was found that postISRCCD exposures for visits 17190 and range 17244..17297 (5 May 2019 data) could not be written to file. There are probably more visits affected.

A log of an example run using detrend.py is attached. The actual error is shown below:

  File "/tigress/HSC/PFS/stack/20190925/stack/miniconda3-4.5.12-1172c30/Linux64/afw/18.1.0/python/lsst/afw/image/image/fitsIoWithOptions.py", line 127, in exposureWriteFitsWithOptions
    self.writeFits(dest, **writeOptionDict)
lsst.pex.exceptions.wrappers.TypeError: 
  File "src/PropertySet.cc", line 232, in std::vector<T> lsst::daf::base::PropertySet::getArray(const string&) const [with T = std::basic_string<char>; std::string = std::basic_string<char>]
    W_XHP2FR {0}
lsst::pex::exceptions::TypeError: 'W_XHP2FR

The FITS key W_XHP2FR is duplicated in the header (an issue which is addressed in a separate ticket, INSTRM-925). In the case of these LAM visits, the value of both duplicates is Undefined:

W_XHP2FR=  / frac power to spreader heater: 0 or 1 NOT CURRENT
[...]
W_XHP2FR=  / frac power to shield: 0 or 1 NOT CURRENT 

This problem had also appeared when writing other exposure outputs such as calexp's again using detrend.py, but in this case, if the value is set to a legitimate value ('0') through the header patching mechanism (PIPE2D-405), then the error disappears and a valid calexp is created.

So it seems that the problem is only present if a) a card is duplicated and b) the value is undefined.

The header patching mechanism requires one to have access to the metadata of the exposure, which is then modified in memory. This mechanism therefore cannot be applied to postISRCCD products, as these products are written to file from within the LSST stack (specifically in the IsrTask), so there is no possibility in PFS software to intercept the metadata prior to its being written to file.



 Comments   
Comment by hassan [ 19/Mar/20 ]

Prior to LAM visit 16803 (prior to the start of day 2019-05-03), FITS key W_XHP2FR had a value of 'NO CURRENT VALUE'. For visits with this value, postISRCCD exposures are generated successfully.

From visit 16804 onwards, the value for this key was empty/Undefined. postISRCCD generation fails for those visits.

Comment by hassan [ 20/Mar/20 ]

Filed ticket https://jira.lsstcorp.org/browse/DM-23928 to address this.

Comment by hassan [ 20/Mar/20 ]

arnaud.lefur mentions that 6364 LAM raw data files have the problematic W_XHP2FR values, or 3182 visits.

Comment by hassan [ 20/Mar/20 ]

Latest feedback from the LSST development team: The particular scenario of failures writing out headers with duplicate and empty cards cannot be easily fixed in the LSST stack. So to process the problematic data, we may need to modify the headers of the raw data.

Comment by price [ 21/Mar/20 ]

I've pushed a solution to tickets/PIPE2D-525 of obs_pfs. hassan, would you please test it for me? Note that you'll need to run scons on obs_pfs to build the corrections.

Comment by hassan [ 21/Mar/20 ]

Fix works perfectly. Running

detrend.py ${repo} --calib ${calibDir} --rerun ${rerun} --id visit=${visit} arm=r -c isr.doWrite=True --doraise

on LAM visits 17244..17297 results in zero errors, and populated postISRCCD and calexp files (116Mb each). Viewing postISRCCD calexp exposures shows the expected spots from 10 fibers.

Comment by price [ 21/Mar/20 ]

Credit to rhl for reminding me about CameraMapper.std_raw.

Comment by hassan [ 21/Mar/20 ]

I would suggest that the docstring for the std_raw method should be updated to mention that other header fixes are applied in addition to the old ADC fix https://github.com/Subaru-PFS/obs_pfs/blob/dcbd8f4ba86e17fac894c6248db045832f145b92/python/lsst/obs/pfs/pfsMapper.py#L192

Comment by price [ 21/Mar/20 ]

Done and merged to master.

Generated at Sat Feb 10 15:54:25 JST 2024 using Jira 8.3.4#803005-sha1:1f96e09b3c60279a408a2ae47be3c745f571388b.