jwst icon indicating copy to clipboard operation
jwst copied to clipboard

Write universal DMS to detector function based on FASTAXIS and SLOWAXIS keywords

Open jdavies-st opened this issue 1 year ago • 0 comments

Currently in RefPixStep, there are a number of class methods called Dataset.DMS_to_detector() and Dataset.detector_to_DMS() which make copies (or in some cases return views) converting detector array layout to DMS layout via flips and rotations, i.e. how it is read out by the readout electronics onboard the spacecraft vs layout in the JWST focal plane. These transforms are completely described by the keywords FASTAXIS and SLOWAXIS, and a general function could be written to do the transformation, preferably returning a numpy view so as not to waste memory.

This function could be made available in jwst.lib, so that other code can use it in the future (say 1/f correction). And each method in jwst.refpix.reference_pixels.Dataset and its subclasses can call the universal function.

Implementation:

  • [ ] Implement universal to_dms() and from_dms() functions to generate numpy views using FASTAXIS and SLOWAXIS keywords
  • [ ] Use the universal functions to write unit tests confirming it does correctly what is already done by Dataset.DMS_to_detector() and Dataset. detector_to_DMS() methods do.
  • [ ] Replace code in subclasses for the above methods with universal function in the Dataset base class, writing down future technical debt.

Generally when trying to understand JWST readout noise issues, it's good to be able to get a vector of the readout per channel, in the order it was read out, so this is useful outside of RefPixStep. An extra method or dict returning the detector data separated by readout channel would also be useful, or at least slice info to produced such a file, something similar to

https://github.com/spacetelescope/jwst/blob/731ac25b347f792a41613f43c6e5b7ebde528bb6/jwst/refpix/reference_pixels.py#L62C1-L76

And a question, are these transforms used by any other steps besides RefPixStep? I'm not aware of any, currently, though I suspect there's code in reference file creation from the instrument teams that needs these transforms.

jdavies-st avatar Feb 19 '24 10:02 jdavies-st