Conversation
There was a problem hiding this comment.
I am thoroughly confused trying to understand this section, so I have suggested more clarification. I understand this probably wasn't what you wanted, but adding a note to the end of something that doesn't make sense doesn't clarify anything. My suggested changes are below.
If this is too difficult to implement, I would suggest just the link to the tutorial and the myst note, and not the 3 items in the enumerated list which, as stated, are only confusing and do not help users with this task.
I do not need to touch this again.
suggestions:
The spatially-varying PSF is represented as an image cube with 121 planes (an 11×11 grid of detector regions).
Each plane is a 101x101 pixel image representing a PSF for a different region of the detector.
Users interested in performing photometry on a cutout will need to select the correct PSF plane for their desired position in the cutout.
The basic steps are described below, and a Python notebook tutorial walks through, in detail, a complete implementation.
SPHEREx FITS header keywords follow the FITS 1-based pixel convention (first pixel = 1),
while Python tools such as astropy return 0-based pixel coordinates (first pixel = 0).
This affects two places in the steps below: the `+1` in step 2 bridges these conventions
when using `CRPIX1A`/`CRPIX2A`, and in step 3 the PSF cube must be indexed as `i − 1`
even though the header keyword suffix `i` runs from 1 to 121.
-
Determine the 0-based pixel coordinates of the position of interest in the cutout IMAGE HDU .
Astropy's world_to_pixel() function returns 0-based coordinates directly and is a natural choice for this. -
Convert to 0-based pixel coordinates in the original Spectral Image using the CRPIX1A and CRPIX2A header keywords:
xpix_orig = 1 + xpix_cutout - CRPIX1A
ypix_orig = 1 + ypix_cutout - CRPIX2A
CRPIX1A and CRPIX2A are FITS keywords stored in 1-based convention.
The +1 converts xpix_cutout from 0-based to 1-based before subtracting, so that xpix_orig comes out 0-based, which is then consistent with the PSF zone coordinates in step 3.
- Identify the PSF cube plane by comparing (xpix_orig, ypix_orig) against the zone centers in the PSF HDU header.
The PSF HDU header contains keywords XCTR_i and YCTR_i for i = 1 to 121.
The values of XCTR_i and YCTR_i are 0-based pixel coordinates in the original Spectral Image, so they can be compared directly to xpix_orig and ypix_orig.
Find the index i whose center is closest to your position (functionality for this is provided in the tutorial linked above).
The corresponding PSF is in cube plane i − 1 (the keyword index i is 1-based, but the cube array is 0-indexed).
|
suggestions look terrible in the comment above, I was trying to give each sentence its own line, so please read like markdown. |
Closes IRSA-7282
Clarifies 0- vs 1-based indexing by adding the same line as was added to the notebook in Caltech-IPAC/irsa-tutorials#293.