Skip to content

Commit 44f4bcb

Browse files
committed
Enforce one sentence per line
1 parent bc75f76 commit 44f4bcb

File tree

2 files changed

+43
-24
lines changed

2 files changed

+43
-24
lines changed

tutorials/spherex/spherex_cutouts.md

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ kernelspec:
1717

1818
- Perform a query for the list of SPHEREx Spectral Image Multi-Extension FITS files (MEFs) that overlap a given coordinate.
1919
- Retrieve cutouts for every entry in this list and package the cutouts as a new MEF.
20-
- Learn how to use parallel or serial processing to retrieve the cutouts
20+
- Learn how to use parallel or serial processing to retrieve the cutouts.
2121

2222
## 2. SPHEREx Overview
2323

24-
SPHEREx is a NASA Astrophysics Medium Explorer mission that launched in March 2025. During its planned two-year mission, SPHEREx will obtain 0.75-5 micron spectroscopy over the entire sky, with deeper data in the SPHEREx Deep Fields. SPHEREx data will be used to:
24+
SPHEREx is a NASA Astrophysics Medium Explorer mission that launched in March 2025.
25+
During its planned two-year mission, SPHEREx will obtain 0.75-5 micron spectroscopy over the entire sky, with deeper data in the SPHEREx Deep Fields.
26+
SPHEREx data will be used to:
2527

2628
* **constrain the physics of inflation** by measuring its imprints on the three-dimensional large-scale distribution of matter,
2729
* **trace the history of galactic light production** through a deep multi-band measurement of large-scale clustering,
@@ -83,7 +85,9 @@ output_filename = 'spherex_cutouts_mef.fits'
8385
## 5. Query IRSA for a list of cutouts that satisfy the criteria specified above.
8486

8587
Here we show how to use the `pyvo` TAP SQL query to retrieve all images that overlap with the position defined above.
86-
This query will retrieve a table of URLs that link to the MEF cutouts. Each row in the table corresponds to a single cutout and includes the data access URL and an observation timestamp. The results are sorted from oldest to newest.
88+
This query will retrieve a table of URLs that link to the MEF cutouts.
89+
Each row in the table corresponds to a single cutout and includes the data access URL and an observation timestamp.
90+
The results are sorted from oldest to newest.
8791

8892
```{code-cell} ipython3
8993
# Define the service endpoint for IRSA's Table Access Protocol (TAP)
@@ -115,6 +119,7 @@ print("Number of images found: {}".format(len(results)))
115119
## 6. Define a function that processes a list of SPHEREx Spectral Image Cutouts
116120

117121
This function takes in a row of the catalog that we created above and does the following:
122+
118123
- It downloads the cutout
119124
- It computes the wavelength of the center pixel of the cutout (in micro-meters)
120125
- It combines the image HDUs into a new HDU and adds it to the table row.
@@ -166,16 +171,20 @@ def process_cutout(row, ra, dec, cache):
166171

167172
## 7. Download the Cutouts
168173

169-
This process can take a while. If run in series, it can take about 5 minutes for 700 images on a typical laptop machine.
170-
Here, we therefore exploit two different methods. First we show the serial approach and next we show how to parallelize the methods. The later can be run on many CPUs and is therefore significantly faster.
174+
This process can take a while.
175+
If run in series, it can take about 5 minutes for 700 images on a typical laptop machine.
176+
Here, we therefore exploit two different methods.
177+
First we show the serial approach and next we show how to parallelize the methods.
178+
The latter can be run on many CPUs and is therefore significantly faster.
171179

172180
### 7.1 Serial Approach
173181

174182
First, we implement the serial approach -- a simple `for` loop.
175183
Before that, we turn the results into an astropy table and add some place holders that will be filled in by the `process_cutout()` function.
176184

177185
```{warning}
178-
Running the cell below may take a while for a large number of cutouts. Approximately 5-7 minutes for 700 images of cutout size 0.01 degree on a typical machine.
186+
Running the cell below may take a while for a large number of cutouts.
187+
Approximately 5-7 minutes for 700 images of cutout size 0.01 degree on a typical machine.
179188
```
180189

181190
```{tip}
@@ -203,14 +212,19 @@ print("Time to create cutouts in serial mode: {:2.2f} minutes.".format((time.tim
203212
### 7.2 Parallel Approach
204213

205214
Next, we implement parallel processing, which will make the cutout creation faster.
206-
The maximal number of workers can be limited by setting the `max_workers` argument. The choice of this value depends on the number of cores but also on the number of parallel calls that can be digested by the IRSA server.
215+
The maximal number of workers can be limited by setting the `max_workers` argument.
216+
The choice of this value depends on the number of cores but also on the number of parallel calls that can be digested by the IRSA server.
207217

208218
```{tip}
209219
A good value for the maximum number of workers is between 7 and 12 for a machine with 8 cores.
210220
```
211221

212222
```{tip}
213-
The astropy `fits.open()` supports a caching argument. This can be passed through in the `process_cutout()` function. If cache=True is set, the images are cached and the cutout creation is sped up next time the code is run (even if the Jupyter kernel is restarted!). The downside is that the images are saved on the machine where this notebook is run. If many cutouts are created, this can sum up to a large cached data volume, in which case cache=False is preferred.
223+
The astropy `fits.open()` supports a caching argument.
224+
This can be passed through in the `process_cutout()` function.
225+
If cache=True is set, the images are cached and the cutout creation is sped up next time the code is run (even if the Jupyter kernel is restarted!).
226+
The downside is that the images are saved on the machine where this notebook is run.
227+
If many cutouts are created, this can sum up to a large cached data volume, in which case cache=False is preferred.
214228
```
215229

216230
Again, before running the cutout processing we define some place holders.
@@ -233,7 +247,7 @@ print("Time to create cutouts in parallel mode: {:2.2f} minutes.".format((time.t
233247
In the following, we continue to use the output of the parallel mode.
234248
The following cell does the following:
235249

236-
- Create a summary FITS table
250+
- Create a summary FITS table.
237251
- Create the final FITS HDU including the summary table.
238252

239253
```{code-cell} ipython3
@@ -309,16 +323,13 @@ plt.show()
309323

310324
## About this notebook
311325

312-
**Authors:** IRSA Data Science Team, including Vandana Desai, Andreas Faisst, Troy Raen, Brigitta Sipőcz, Jessica Krick,
313-
Shoubaneh Hemmati
326+
**Authors:** IRSA Data Science Team, including Vandana Desai, Andreas Faisst, Troy Raen, Brigitta Sipőcz, Jessica Krick, Shoubaneh Hemmati
314327

315328
**Updated:** 2025-09-10
316329

317-
**Contact:** [IRSA Helpdesk](https://irsa.ipac.caltech.edu/docs/help_desk.html) with questions
318-
or problems.
330+
**Contact:** [IRSA Helpdesk](https://irsa.ipac.caltech.edu/docs/help_desk.html) with questions or problems.
319331

320-
**Runtime:** As of the date above, this notebook takes about 3 minutes to run to completion on
321-
a machine with 8GB RAM and 4 CPU.
332+
**Runtime:** As of the date above, this notebook takes about 3 minutes to run to completion on a machine with 8GB RAM and 4 CPU.
322333
(Note: This notebook doesn't take significant time to run, but please report actual numbers and
323334
machine details for your notebook if it is expected to run longer or requires specific machines,
324335
e.g., on Fornax. Also, if querying archives, please include a statement like, "This runtime is

tutorials/spherex/spherex_psf.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ kernelspec:
2525

2626
## 2. SPHEREx Overview
2727

28-
SPHEREx is a NASA Astrophysics Medium Explorer mission that launched in March 2025. During its planned two-year mission, SPHEREx will obtain 0.75-5 micron spectroscopy over the entire sky, with deeper data in the SPHEREx Deep Fields. SPHEREx data will be used to:
28+
SPHEREx is a NASA Astrophysics Medium Explorer mission that launched in March 2025.
29+
During its planned two-year mission, SPHEREx will obtain 0.75-5 micron spectroscopy over the entire sky, with deeper data in the SPHEREx Deep Fields.
30+
SPHEREx data will be used to:
2931

3032
* **constrain the physics of inflation** by measuring its imprints on the three-dimensional large-scale distribution of matter,
3133
* **trace the history of galactic light production** through a deep multi-band measurement of large-scale clustering,
@@ -62,7 +64,9 @@ from astropy.wcs import WCS
6264

6365
## 4. Get SPHEREx Cutout
6466

65-
We first obtain a SPHEREx cutout for a given coordinate of interest from IRSA archive. For this we define a coordinate and a size of the cutout. Both should be defined using `astropy` units.
67+
We first obtain a SPHEREx cutout for a given coordinate of interest from IRSA archive.
68+
For this we define a coordinate and a size of the cutout.
69+
Both should be defined using `astropy` units.
6670
The goal is to obtain the cutout and then extract the PSF corresponding to the coordinates of interest.
6771

6872
```{tip}
@@ -128,16 +132,19 @@ with fits.open(spectral_image_url) as hdul:
128132
```
129133

130134
The downloaded SPHEREx image cutout contains 5 FITS layers, which are described in the [SPHEREx Explanatory Supplement](https://irsa.ipac.caltech.edu/data/SPHEREx/docs/SPHEREx_Expsupp_QR.pdf).
131-
We focus in this example on the extensions `IMAGE` and `PSF`. We have already loaded their data as well as their header.
135+
We focus in this example on the extensions `IMAGE` and `PSF`.
136+
We have already loaded their data as well as their header.
132137

133138
```{code-cell} ipython3
134139
psfcube.shape
135140
```
136141

137-
The shape of the `psfcube` is (121,101,101). This corresponds to a grid of 11x11 PSFs across the image, each of them of the size 101x101 pixels.
142+
The shape of the `psfcube` is (121,101,101).
143+
This corresponds to a grid of 11x11 PSFs across the image, each of them of the size 101x101 pixels.
138144

139145
```{note}
140-
Remember that the PSFs are oversampled by a factor of 10. This means that the actual size of the PSFs is about 10x10 SPHEREx pixels, which corresponds to about 60x60 arcseconds.
146+
Remember that the PSFs are oversampled by a factor of 10.
147+
This means that the actual size of the PSFs is about 10x10 SPHEREx pixels, which corresponds to about 60x60 arcseconds.
141148
```
142149

143150
+++
@@ -149,11 +156,13 @@ psf_header[22:40]
149156
```
150157

151158
We confirm that the oversampling factor (`OVERSAMP`) is 10.
152-
The PSFs are distributed in an even grid with 11x11 zones. Each of the 121 PSFs is responsible for one of these zones.
159+
The PSFs are distributed in an even grid with 11x11 zones.
160+
Each of the 121 PSFs is responsible for one of these zones.
153161
The PSF header therefore includes the center position of these zones as well as the width of the zones.
154162
These center coordinate are specified with `XCTR_i` and `YCTR_i`, respectively, where i = 1...121.
155163
The widths are specified with `XWID_i` and `YWID_i`, respectively, where again i = 1...121.
156-
The zones have equal widths and are arranged in an even grid. In principle, the zones can have any size, but this arrangement is enough to capture well the changes of the PSF size and structure with wavelength and spatial coordinates.
164+
The zones have equal widths and are arranged in an even grid.
165+
In principle, the zones can have any size, but this arrangement is enough to capture well the changes of the PSF size and structure with wavelength and spatial coordinates.
157166

158167
The goal of this tutorial now is to find the PSF corresponding to our input coordinates of interest.
159168

@@ -262,7 +271,6 @@ plt.show()
262271

263272
**Updated:** 2025-09-25
264273

265-
**Contact:** Contact [IRSA Helpdesk](https://irsa.ipac.caltech.edu/docs/help_desk.html) with questions
266-
or problems.
274+
**Contact:** Contact [IRSA Helpdesk](https://irsa.ipac.caltech.edu/docs/help_desk.html) with questions or problems.
267275

268276
**Runtime:** Approximately 30 seconds.

0 commit comments

Comments
 (0)