Skip to content

Commit a8ea38e

Browse files
desaidesai
authored andcommitted
Documentation on cutouts, mostly
1 parent 4011c89 commit a8ea38e

File tree

2 files changed

+146
-8
lines changed

2 files changed

+146
-8
lines changed

documentation/spherex_data_access.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ IRSA provides layered access to these data to support a variety of use cases and
55
These layers include:
66

77
* **Browsable Directories:** SPHEREx on-premises data products are laid out in directories that can be navigated with standard web browsers.
8-
* **Application Program Interfaces:** IRSA provides SPHEREx data access APIs that are compliant with International Virtual Observatory Alliance (IVOA) standards.
8+
* **Application Program Interfaces:** IRSA provides SPHEREx data access APIs, most of which are compliant with International Virtual Observatory Alliance (IVOA) standards.
99
* **Python Packages:** SPHEREx data at IRSA are accessible via the Python packages pyvo and astroquery
1010
* **SPHEREx Data Explorer:** IRSA provides a web-based Graphical User Interface (GUI) that makes it easy to search for, visualize, and download SPHEREx data.
1111

@@ -35,6 +35,8 @@ The content of each subdirectory is described in greater detail in the Data Prod
3535

3636
## Application Program Interfaces (APIs)
3737

38+
### SPHEREx Spectral Image MEFs and Calibration Files are available through the IVOA Simple Image Access Protocol
39+
3840
IRSA provides API access to SPHEREx Spectral Images through version 2 of the VO Simple Image Access (SIA2) protocol.
3941
SIA2 allows users to query for a list of images that satisfy constraints based on position(s) on the sky, band, time, ID, and instrument.
4042
The list returned by the service includes data access URLs, which can be used to retrieve some or all of the images in the list using wget or curl.
@@ -47,7 +49,7 @@ Due to the nature of the ingestion process, new SPHEREx data will first be avail
4749
Availability via SIA2 and Python libraries like Astroquery and PyVO will lag on the order of a day.
4850
:::
4951

50-
IRSA's generric SIA2 endpoint is:
52+
IRSA's generic SIA2 endpoint is:
5153

5254
`https://irsa.ipac.caltech.edu/SIA?`
5355

@@ -63,9 +65,21 @@ Users must add a `COLLECTION` parameter to this endpoint to specify which datase
6365
You can use `wget` or `curl` to submit SIA2 queries from the command line.
6466
For example:
6567

66-
* `wget -O example1.html "https://irsatest.ipac.caltech.edu/SIA?COLLECTION=spherex_qr&POS=circle+127.69444+-39.17760+0.01&RESPONSEFORMAT=HTML"`
68+
* `wget -O example1.html "https://irsa.ipac.caltech.edu/SIA?COLLECTION=spherex_qr&POS=circle+127.69444+-39.17760+0.01&RESPONSEFORMAT=HTML"`
69+
70+
See the section on Python packages to learn how to use Python wrappers around IRSA’s SIA2 service.
71+
72+
### Cutouts of SPHEREx Spectral Image MEFs
73+
74+
SPHEREx Spectral Image MEFs are available on premises at IPAC and on the cloud.
75+
76+
If you have identified the access URL for an on-premises Spectral Image, you can request a cutout of this MEF by appending a query string containing the center and size parameters. The parameters are described in more detail here:
77+
78+
`https://irsa.ipac.caltech.edu/ibe/cutouts.html`
79+
80+
**Example:**
6781

68-
See the next section to learn how to use Python wrappers around IRSA’s SIA2 service.
82+
`curl -o cutout.fits "https://irsa.ipac.caltech.edu/ibe/data/spherex/qr/level2/2025W19_2B/l2b-v11-2025-163/3/level2_2025W19_2B_0073_2D3_spx_l2b-v11-2025-163.fits?center=156.09328159,-41.64466331&size=0.1"`
6983

7084
## Python packages: PyVO & Astroquery
7185

documentation/spherex_data_products.md

Lines changed: 128 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ This summary includes filenaming conventions, for which we adopt the following d
77
- `Planning Period` designates the survey plan uploaded to the spacecraft, e.g. `2025W18_2B`.
88
Each planning period covers approximately 3.5 days of operation.
99

10-
- `Observation ID` includes the survey planning period and the large and small slew counters, e.g. `2025W18_2B_0001_1`.
10+
- `Observation ID` includes the survey planning period and the large
11+
and small slew counters, e.g. `2025W18_2B_0001_1`. Each large slew
12+
has a maximum of 4 small slews, so the allowed small slew counter
13+
range is 1 to 4. Some large slews will have less than 4 small
14+
slews.
1115

1216
- `Detector` is an integer from 1 through 6.
1317

@@ -19,8 +23,11 @@ Each planning period covers approximately 3.5 days of operation.
1923
## Main Science Data Product: Spectral Image Multi-Extension FITS Files (MEF)
2024

2125
The main Quick Release data product is the Level 2 Spectral Image MEF.
22-
There are 6 Spectral MEFs (one for each detector) for each sky pointing.
23-
Each Spectral MEF is approximately 70 MB and contains 6 extensions:
26+
There are 6 Spectral MEFs (one for each detector) for each sky
27+
pointing. Because data quality assessments are evaluated per spectral
28+
image band, some observations will not include all 6 bands in the
29+
archive. Each Spectral MEF is approximately 70 MB and contains 6
30+
extensions:
2431

2532
HDU 1: IMAGE
2633
: Calibrated surface brightness flux density in units of MJy/sr, stored as a 2040 x 2040 image.
@@ -40,7 +47,7 @@ HDU 1: IMAGE
4047

4148
HDU 2: FLAGS
4249
: Bitmap of per-pixel status and processing flags, stored as a 2040 x 2040 image.
43-
The definition of the flags are provided in Table 8 of the [SPHEREx Explanatory Supplement](https://irsa.ipac.caltech.edu/data/SPHEREx/docs/SPHEREx_Expsupp_QR.pdf).
50+
The definition of the flags are provided in Table 10 of the [SPHEREx Explanatory Supplement](https://irsa.ipac.caltech.edu/data/SPHEREx/docs/SPHEREx_Expsupp_QR.pdf).
4451

4552
HDU 3: VARIANCE
4653
: Variance of calibrated surface brightness flux in units of (MJy/sr)^2, stored as a 2,040 x 2,040 image.
@@ -78,6 +85,123 @@ HDU 6: WCS-WAVE
7885

7986
- `level2_2025W18_2B_0001_1D1_spx_l2b-v12-2025-164.fits`
8087

88+
## Cutouts of Spectral Image MEFs
89+
90+
IRSA enables users to access rectangular cutouts of a SPHEREx Spectral
91+
Image MEF by simply appending a [query
92+
string](https://irsa.ipac.caltech.edu/ibe/cutouts.html) containing
93+
center and size parameters to the image URL. These cutout MEFs contain
94+
the same HDUs as the original Spectral Images (IMAGE, FLAGS, VARIANCE,
95+
ZODI, PSF, WCS-WAVE). However, the IMAGE, FLAGS, VARIANCE, AND ZODI
96+
HDUs have been modified to include only those pixels within the
97+
specified cutout size. The WCS-WAVE HDU has also modified to provide
98+
the correct mapping between the pixels in the cutout to
99+
wavelength. The PSF HDU from the original spectral image is included
100+
unmodified in the cutout MEF.
101+
102+
The spatially-varying PSF is represented as an image cube with 121
103+
planes representing different regions of the original, full Spectral
104+
Image. Users interested in performing photometry on a cutout using the
105+
information in the cutout PSF HDU will need to understand how to find
106+
the most applicable PSF cube plane for each pixel in the cutout. The
107+
steps are described below:
108+
109+
1. Determine the 0-based pixel coordinates of the position of interest
110+
in the IMAGE HDU of the cutout.
111+
112+
2. Determine the 0-based pixel coordinates of the position of interest
113+
in the IMAGE HDU of the original Spectral Image.
114+
115+
```python
116+
xpix_orig = 1 + xpix_cutout - CRPIX1A
117+
ypix_orig = 1 + ypix_cutout - CRPIX2A
118+
```
119+
120+
3. Examine the header of the PSF HDU of the cutout to determine the
121+
PSF zone and cube plane corresponding to the pixel of interest in the original
122+
Spectral Image.
123+
124+
The PSF HDU has a header containing the keywords `XCTR_*`, `YCTR_*`,
125+
`XWID_*`, and `YWID_*`, where * goes from [1 to 121]. To determine if
126+
a pixel in the original Spectral Image falls within a PSF zone, simply
127+
find the closest `XCTR_*` and `YCTR_*` to determine the cube plane
128+
that contains the corresponding PSF for this zone.
129+
130+
**Example:**
131+
132+
Consider this cutout:
133+
134+
`spectral_image_url = "https://irsa.ipac.caltech.edu/ibe/cutout?ra=305.59875000000005&dec=41.14888888888889&size=0.01&path=spherex/qr/level2/2025W18_1B/l2b-v13-2025-198/4/level2_2025W18_1B_0023_2D4_spx_l2b-v13-2025-198.fits"`
135+
136+
`cutout_hdulist = fits.open(spectral_image_url)`
137+
138+
1. Let's say that we are interested in the requested position:
139+
140+
```
141+
ra_deg = 305.59875000000005
142+
dec_deg = 41.14888888888889
143+
```
144+
145+
We can use the WCS header in the cutout to determine that these coordinates correspond to
146+
147+
```
148+
cutout_header = cutout_hdulist[1].header
149+
150+
xpix_cutout, ypix_cutout = wcs.world_to_pixel(SkyCoord(ra=ra, dec=dec, unit="deg"))
151+
152+
print(xpix_cutout, ypix_cutout)
153+
154+
2.180467000669851 2.341315802377096
155+
```
156+
157+
2. We can then use the values of CRPIX1A and CRPIX2A in the cutout header to
158+
calculate what pixels these coordinates correspond to in the original
159+
Spectral Image:
160+
161+
```
162+
CRPIX1A = -220.0
163+
CRPIX2A = -2004.0
164+
165+
xpix_orig = 1 + xpix_cutout - CRPIX1A = 1 + 2.180467000669851 - -220.0 = 223.180467001
166+
ypix_orig = 1 + xpix_cutout - CRPIX2A = 1 + 2.341315802377096 - -2004.0 = 2007.3413158
167+
```
168+
169+
3. Looking at the header of the cutout PSF HDU, we see that the XCTR_* values are:
170+
171+
```
172+
XCTR zone0 = 93.22727273
173+
XCTR zone1 = 278.68181818
174+
XCTR zone2 = 464.13636364
175+
XCTR zone3 = 649.59090909
176+
XCTR zone4 = 835.04545455
177+
XCTR zone5 = 1020.5
178+
XCTR zone6 = 1205.95454545
179+
XCTR zone7 = 1391.40909091
180+
XCTR zone8 = 81576.86363636
181+
XCTR zone9 = 1762.31818182
182+
XCTR zone10 = 1947.77272727
183+
```
184+
185+
and the `YCTR_*` values are:
186+
187+
```
188+
YCTR zone0 = 93.22727273
189+
YCTR zone1 = 278.68181818
190+
YCTR zone2 = 464.13636364
191+
YCTR zone3 = 649.59090909
192+
YCTR zone4 = 835.04545455
193+
YCTR zone5 = 1020.5
194+
YCTR zone6 = 1205.95454545
195+
YCTR zone7 = 1391.40909091
196+
YCTR zone8 = 1576.86363636
197+
YCTR zone9 = 1762.31818182
198+
YCTR zone10 = 1947.77272727
199+
```
200+
201+
Our original pixel coordates of 223.180467001, 2007.3413158 fall
202+
closest to `XCTR` zone1 and `YCTR` zone10. This PSF for this zone is
203+
stored in cube plane 22.
204+
81205

82206
## Calibration Product: Absolute Gain Matrix
83207

0 commit comments

Comments
 (0)