Skip to content

Commit 9d3bbe1

Browse files
committed
Bugfix comments
1 parent 0496d5e commit 9d3bbe1

3 files changed

Lines changed: 21 additions & 8 deletions

File tree

tutorials/spherex/spherex_cutouts.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ def process_cutout_with_error_handling(row, ra, dec, cache):
212212
'''
213213
try:
214214
process_cutout(row, ra, dec, cache=cache)
215-
# IncompleteRead: https://github.com/Caltech-IPAC/irsa-tutorials/issues/165#issuecomment-3821504954
216215
except (urllib.error.HTTPError, http.client.IncompleteRead):
217216
# Transient read errors. Skip this cutout.
218217
row["hdus"] = None

tutorials/spherex/spherex_intro.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,26 @@ You can put this URL into a browser to download the file. Or you can work with i
156156

157157
+++
158158

159-
Use Astropy to examine the header of the URL from the previous step.
159+
First, use Astropy to load the data using the URL from the previous step.
160+
Transient read errors occur sometimes, so we'll catch those and retry a few times.
160161

161162
```{code-cell} ipython3
162-
Max number of times to retry HTTP errors.
163+
# Max number of times to retry HTTP errors.
163164
max_retries = 3
164165
for attempt in range(max_retries):
165166
try:
167+
# Load the data.
166168
hdulist = fits.open(spectral_image_url)
167169
break
168170
except (urllib.error.HTTPError, http.client.IncompleteRead):
169171
if attempt == max_retries - 1:
170172
raise
171173
time.sleep(10 * (attempt + 1))
174+
```
175+
176+
Examine the header.
177+
178+
```{code-cell} ipython3
172179
hdulist.info()
173180
```
174181

tutorials/spherex/spherex_psf.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,19 @@ print(spectral_image_url)
135135
## 5. Read in a SPHEREx Cutout
136136

137137
Next, we use standard astropy tools to open the fits image and to read the different headers and data.
138+
Transient read errors occur sometimes, so we'll catch those and retry a few times.
138139

139140
```{tip}
140141
As we do below, you can use `hdul.info()` to print the list of FITS layers of the downloaded cutout.
141142
```
142143

143144
```{code-cell} ipython3
144-
Max number of times to retry transient read errors.
145+
# Max number of times to retry transient read errors.
145146
max_retries = 3
146147
for attempt in range(max_retries):
147148
try:
149+
# Read the data.
148150
with fits.open(spectral_image_url) as hdul:
149-
hdul.info()
150151
cutout_header = hdul['IMAGE'].header
151152
psf_header = hdul['PSF'].header
152153
cutout = hdul['IMAGE'].data
@@ -158,6 +159,12 @@ for attempt in range(max_retries):
158159
time.sleep(10 * (attempt + 1))
159160
```
160161

162+
Examine the header.
163+
164+
```{code-cell} ipython3
165+
hdul.info()
166+
```
167+
161168
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).
162169
We focus in this example on the extensions `IMAGE` and `PSF`.
163170
We have already loaded their data as well as their header.
@@ -290,11 +297,11 @@ plt.show()
290297

291298
## 9. Using the SPHEREx PSF in Forward Modeling (e.g., Tractor)
292299

293-
The PSF returned by this notebook is oversampled relative to the native SPHEREx detector pixel grid.
300+
The PSF returned by this notebook is oversampled relative to the native SPHEREx detector pixel grid.
294301
This is intentional: the PSF is evaluated on a fine sub-pixel grid so that it can represent different intra-pixel source positions accurately.
295302

296-
Tools such as Tractor do not expect an oversampled PSF directly.
297-
Instead, they require a PSF that is pixel-integrated at the native detector resolution and evaluated at the correct sub-pixel phase of the source.
303+
Tools such as Tractor do not expect an oversampled PSF directly.
304+
Instead, they require a PSF that is pixel-integrated at the native detector resolution and evaluated at the correct sub-pixel phase of the source.
298305
If you pass the oversampled PSF directly into Tractor without resampling, the effective PSF width and normalization will be incorrect, which can lead to systematic differences relative to the SPHEREx Spectrophotometry Tool.
299306

300307
To use this PSF for forward modeling or fitting, you must:

0 commit comments

Comments
 (0)