cylammarco / ASPIRED

Automated SpectroPhotometric Image REDuction (ASPIRED)
https://aspired.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
30 stars 4 forks source link

WCS in adu_resampled FITS extensions #22

Closed rjs3273 closed 3 years ago

rjs3273 commented 4 years ago

When I save with OneDSpec.save_fits(output='flux_resampled+wavecal+flux+adu+adu_resampled') I was interpreting flux_resampled and adu_resampled as being the same size arrays and the same wavelength coordinates. Is that correct? Certainly they are the same dimensions. By contrast 'adu' has the same dimensions as the original CCD without resampling.

SO my question is, is the WCS in 'adu_resampled' the same as 'flux_resampled'. Can I simply read the WCS from 'flux_resampled' and use if for 'adu_resampled'? Will the WCS eventually be written into 'adu_resampled' too?

cylammarco commented 4 years ago

@rjs3273 What does WCS mean here? World Coordinate System? I don't understand how that works for a 1D spectrum, is the WCS the same as that from the acquisition image, or is it conventionally used to represent something else in a spectral dataset?

'flux_resampled' is the 'adu_resampled' multiplied by the sensitivity function, so the spatial+dispersal meta-data of the two are the same. Does it answer your question?

For the very last question, I am thinking about copying all the header information from the raw data to the Primary HDU header and leave the Primary HDU data empty, reduced data populate in the Extended HDUs only. How does it sound?

rjs3273 commented 4 years ago

Yes, by WCS I mean World Coordinate System. In this context that is the wavelength calibration rather than spatial. My point in my original question (and I have not retested recently so this may no longer be so) was that when I read the flux_resampled extension, the FITS header had the wavelengths set in the header (CRVAL, CRPIX etc) so I knew from that FITS extension alone what wavelength mapped to each pixel in the array. The adu_resampled was exactly the same array dimensions so I assumed the wavelengths were exactly the same, but there was nothing to specify that in the FITS header.

Is that any clearer than my first attempt?

Much of the data can be copied from the raw header, but the WCS in particular cannot since you have resampled the data when applying the arc fit. I would assume that the WCS (wavelength scale) parameters for adu_resampled can be cloned identically from flux_resampled. Really I would have thought those parameters get created in the process of applying the arc and all data from there on would naturally have the same spectra WCS. (Unless us course you were later to resample the spectral range for some other reason. E.g., if you resampled to the instrument's true resolution instead of its native dispersion.)

cylammarco commented 3 years ago

Has this already fixed the problem?

https://github.com/cylammarco/ASPIRED/blob/86e9dab4b702bf7e34a83052b1b13ae7842c3ae3/aspired/spectral_reduction.py#L930-L992

If not, can you @rjs3273 give me some specific FITS header keywords, please?

cylammarco commented 3 years ago

Will fix in #23 in one go.