Skip to content

Commit a6d24a7

Browse files
authored
Merge pull request #263 from jkrick/codex/review-tutorial-numbering-and-headings
Standardize headings, wording, and inline comments across tutorials
2 parents 756888b + fd339c7 commit a6d24a7

10 files changed

Lines changed: 80 additions & 79 deletions

tutorials/euclid/1_Euclid_intro_MER_images.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -237,58 +237,58 @@ science_images['filters'][science_images['filters']== 'VIS_VIS'] = "VIS"
237237
science_images['filters']
238238
```
239239

240-
## The image above is very large, so let's cut out a smaller image to inspect these data.
240+
## 4. Define cutout parameters for a smaller region of interest
241241

242242
```{code-cell} ipython3
243243
######################## User defined section ############################
244-
## How large do you want the image cutout to be?
244+
# Set the image cutout size
245245
im_cutout = 1.0 * u.arcmin
246246
247-
## What is the center of the cutout?
248-
## For now choosing a random location on the image
249-
## because the star itself is saturated
247+
# Set the cutout center coordinates
248+
# For now choose a random location on the image
249+
# because the star itself is saturated
250250
ra = 273.8667
251251
dec = 64.525
252252
253-
## Bright star position
253+
# Bright star position
254254
# ra = 273.474451
255255
# dec = 64.397273
256256
257257
coords_cutout = SkyCoord(ra, dec, unit='deg', frame='icrs')
258258
259259
##########################################################################
260260
261-
## Iterate through each filter
261+
# Iterate through each filter
262262
263263
cutout_list = []
264264
265265
for url in urls:
266-
## Use fsspec to interact with the fits file without downloading the full file
266+
# Use fsspec to interact with the fits file without downloading the full file
267267
hdu = fits.open(url, use_fsspec=True)
268268
print(f"Opened {url}")
269269
270-
## Store the header
270+
# Store the header
271271
header = hdu[0].header
272272
273-
## Read in the cutout of the image that you want
273+
# Read in the cutout of the image that you want
274274
cutout_data = Cutout2D(hdu[0].section, position=coords_cutout, size=im_cutout, wcs=WCS(hdu[0].header))
275275
276-
## Close the file
276+
# Close the file
277277
# hdu.close()
278278
279-
## Define a new fits file based on this smaller cutout, with accurate WCS based on the cutout size
279+
# Define a new fits file based on this smaller cutout, with accurate WCS based on the cutout size
280280
new_hdu = fits.PrimaryHDU(data=cutout_data.data, header=header)
281281
new_hdu.header.update(cutout_data.wcs.to_header())
282282
283-
## Append the cutout to the list
283+
# Append the cutout to the list
284284
cutout_list.append(new_hdu)
285285
286-
## Combine all cutouts into a single HDUList and display information
286+
# Combine all cutouts into a single HDUList and display information
287287
final_hdulist = fits.HDUList(cutout_list)
288288
final_hdulist.info()
289289
```
290290

291-
## 3. Visualize multiwavelength Euclid Q1 MER cutouts
291+
## 5. Visualize multiwavelength Euclid Q1 MER cutouts
292292

293293
We need to determine the number of images for the grid layout, and then plot each cutout.
294294

@@ -308,15 +308,15 @@ for idx, (ax, filt) in enumerate(zip(axes, science_images['filters'])):
308308
ax.set_ylabel('Dec')
309309
ax.text(0.05, 0.05, filt, color='white', fontsize=14, transform=ax.transAxes, va='bottom', ha='left')
310310
311-
## Remove empty subplots if any
311+
# Remove empty subplots if any
312312
for ax in axes[num_images:]:
313313
fig.delaxes(ax)
314314
315315
plt.tight_layout()
316316
plt.show()
317317
```
318318

319-
## 4. Use the Python package sep to identify and measure sources in the Euclid Q1 MER cutouts
319+
## 6. Identify and measure sources in Euclid Q1 MER cutouts with sep
320320

321321
First we list all the filters so you can choose which cutout you want to extract sources on. We will choose VIS.
322322

@@ -365,13 +365,13 @@ data_sub = img2 - bkg
365365
```{code-cell} ipython3
366366
######################## User defined section ############################
367367
368-
## Sigma threshold to consider this a detection above the global RMS
368+
# Sigma threshold to consider this a detection above the global RMS
369369
threshold= 3
370370
371-
## Minimum number of pixels required for an object. Default is 5.
371+
# Minimum number of pixels required for an object. Default is 5.
372372
minarea_0=2
373373
374-
## Minimum contrast ratio used for object deblending. Default is 0.005. To entirely disable deblending, set to 1.0.
374+
# Minimum contrast ratio used for object deblending. Default is 0.005. To entirely disable deblending, set to 1.0.
375375
deblend_cont_0= 0.005
376376
377377
flux_threshold= 0.01
@@ -383,7 +383,7 @@ sources_thr = sources[sources['flux'] > flux_threshold]
383383
print("Found", len(sources_thr), "objects above flux threshold")
384384
```
385385

386-
## Lets have a look at the objects that were detected with sep in the cutout
386+
## 7. Review detected sources on the VIS cutout
387387

388388

389389
We plot the VIS cutout with the sources detected overplotted with a red ellipse
@@ -393,7 +393,7 @@ fig, ax = plt.subplots()
393393
m, s = np.mean(data_sub), np.std(data_sub)
394394
im = ax.imshow(data_sub, cmap='gray', origin='lower', norm=ImageNormalize(img2, interval=ZScaleInterval(), stretch=SquaredStretch()))
395395
396-
## Plot an ellipse for each object detected with sep
396+
# Plot an ellipse for each object detected with sep
397397
398398
for i in range(len(sources_thr)):
399399
e = Ellipse(xy=(sources_thr['x'][i], sources_thr['y'][i]),

tutorials/euclid/4_Euclid_intro_PHZ_catalog.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,10 @@ Search based on ``tileID``:
198198

199199
```{code-cell} ipython3
200200
######################## User defined section ############################
201-
## How large do you want the image cutout to be?
201+
# Set the image cutout size
202202
im_cutout= 5 * u.arcmin
203203
204-
## What is the center of the cutout?
204+
# Set the center of the cutout
205205
ra_cutout = 267.8
206206
dec_cutout = 66
207207
@@ -227,7 +227,7 @@ adql = ("SELECT DISTINCT mer.object_id, mer.ra, mer.dec, "
227227
"AND phz.phz_median BETWEEN 1.4 AND 1.6")
228228
229229
230-
## Use TAP with this ADQL string
230+
# Use TAP with this ADQL string
231231
result_galaxies = Irsa.query_tap(adql).to_table()
232232
result_galaxies[:5]
233233
```
@@ -247,13 +247,13 @@ Once the bug is fixed, we plan to update the code in this notebook and simplify
247247
Due to the large field of view of the MER mosaic, let's cut out a smaller section (5'x5') of the MER mosaic to inspect the image.
248248

249249
```{code-cell} ipython3
250-
## Use fsspec to interact with the fits file without downloading the full file
250+
# Use fsspec to interact with the fits file without downloading the full file
251251
hdu = fits.open(filename, use_fsspec=True)
252252
253-
## Store the header
253+
# Store the header
254254
header = hdu[0].header
255255
256-
## Read in the cutout of the image that you want
256+
# Read in the cutout of the image that you want
257257
cutout_image = Cutout2D(hdu[0].section, position=coords_cutout, size=im_cutout, wcs=WCS(header))
258258
```
259259

@@ -287,7 +287,7 @@ plt.scatter(result_galaxies['ra'], result_galaxies['dec'], s=36, facecolors='non
287287
_ = plt.title('Galaxies between z = 1.4 and 1.6')
288288
```
289289

290-
## 5. Pull the spectra on the top brightest source based on object ID
290+
## 5. Pull spectra for one of the brightest sources by object ID
291291

292292
```{code-cell} ipython3
293293
result_galaxies.sort(keys='flux_h_unif', reverse=True)
@@ -311,7 +311,7 @@ We will use TAP and an ASQL query to find the spectral data for this particular
311311
```{code-cell} ipython3
312312
adql_object = f"SELECT * FROM {table_1dspectra} WHERE objectid = {obj_id}"
313313
314-
## Pull the data on this particular galaxy
314+
# Pull the data on this particular galaxy
315315
result_spectra = Irsa.query_tap(adql_object).to_table()
316316
result_spectra
317317
```
@@ -352,7 +352,7 @@ result_galaxies[index]
352352
```
353353

354354
```{code-cell} ipython3
355-
## How large do you want the image cutout to be?
355+
# Set the image cutout size for the selected galaxy
356356
size_galaxy_cutout = 2.0 * u.arcsec
357357
```
358358

@@ -381,7 +381,7 @@ ax.imshow(cutout_galaxy.data, cmap='gray', origin='lower',
381381
norm=ImageNormalize(cutout_galaxy.data, interval=PercentileInterval(99.9), stretch=AsinhStretch()))
382382
```
383383

384-
## 6. Load the image on Firefly to be able to interact with the data directly
384+
## 6. Load the image in Firefly for interactive exploration
385385

386386
+++
387387

tutorials/euclid/5_Euclid_intro_SPE_catalog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ Irsa.list_columns(catalog=table_1dspectra, full=True)
185185
columns_info
186186
```
187187

188-
## Find some objects with spectra in our tileID
188+
## 3. Find some objects with spectra in our tileID
189189

190190
We specify the following conditions on our search:
191191
- Signal to noise ratio column (_gf = gaussian fit) should be greater than 5

tutorials/euclid/Euclid_ERO.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ import matplotlib as mpl
9999
Next, we define some parameters for `Matplotlib` plotting.
100100

101101
```{code-cell} ipython3
102-
## Plotting stuff
102+
# Plotting stuff
103103
mpl.rcParams['font.size'] = 14
104104
mpl.rcParams['axes.labelpad'] = 7
105105
mpl.rcParams['xtick.major.pad'] = 7
@@ -125,7 +125,7 @@ mpl.rcParams['hatch.linewidth'] = 1
125125
def_cols = plt.rcParams['axes.prop_cycle'].by_key()['color']
126126
```
127127

128-
## Setting up the Environment
128+
## 1. Setting up the Environment
129129

130130
Next, we set up the environment. This includes
131131
* setting up an output data directory (will be created if it does not exist)
@@ -150,7 +150,7 @@ cutout_size = 1.5 * u.arcmin # cutout size
150150
coord = SkyCoord.from_name('NGC 6397')
151151
```
152152

153-
## Search Euclid ERO Images
153+
## 2. Search Euclid ERO Images
154154

155155
Now, we search for the Euclid ERO images using the `astroquery` package.
156156
Note that the Euclid ERO images are no in the cloud currently, but we access them directly from IRSA using IRSA's *Simple Image Access* (SIA) methods.
@@ -229,7 +229,7 @@ Let's check out the summary table that we have created. We see that we have all
229229
summary_table
230230
```
231231

232-
## Create Cutout Images
232+
## 3. Create Cutout Images
233233

234234
Now that we have a list of data products, we can create the cutouts. This is important as the full Euclid ERO images would be too large to run extraction and photometry software on them (they would simply fail due to memory issues).
235235

@@ -267,7 +267,7 @@ for ii,filt in tqdm(enumerate(filters)):
267267
hdu.header["FILTER"] = filt.upper()
268268
hdulcutout.append(hdu)
269269
270-
## Save the HDUL cube:
270+
# Save the HDUL cube:
271271
hdulcutout.writeto("./data/euclid_images_test.fits", overwrite=True)
272272
```
273273

@@ -296,7 +296,7 @@ for ii,filt in enumerate(filters):
296296
plt.show()
297297
```
298298

299-
## Extract Sources and Measure their Photometry on the VIS Image
299+
## 4. Extract Sources and Measure their Photometry on the VIS Image
300300

301301
Now that we have the images in memory (and on disk - but we do not need them, yet), we can measure the fluxes of the individual stars.
302302
Our simple photometry pipeline has different parts:
@@ -310,7 +310,7 @@ Our simple photometry pipeline has different parts:
310310
We start by extracting the sources using `sep`. We first isolate the data that we want to look at (the VIS image only).
311311

312312
```{code-cell} ipython3
313-
## Get Data (this will be replaced later)
313+
# Get Data (this will be replaced later)
314314
img = hdulcutout["VIS_SCIENCE"].data
315315
hdr = hdulcutout["VIS_SCIENCE"].header
316316
img[img == 0] = np.nan
@@ -380,7 +380,7 @@ resimage = psfphot.make_residual_image(data = img-median, psf_shape = (9, 9))
380380
We now want to add the best-fit coordinates (R.A. and Decl.) to the VIS photometry catalog. For this, we have to convert the image coordinates into sky coordinates using the WCS information. We will need these coordinates because we want to use them as positional priors for the photometry measurement on the NISP images.
381381

382382
```{code-cell} ipython3
383-
## Add coordinates to catalog
383+
# Add coordinates to catalog
384384
wcs1 = WCS(hdr) # VIS
385385
radec = wcs1.all_pix2world(phot["x_fit"],phot["y_fit"],0)
386386
phot["ra_fit"] = radec[0]
@@ -426,7 +426,7 @@ ax1.set_yscale('log')
426426
plt.show()
427427
```
428428

429-
## Measure the Photometry on the NISP Images
429+
## 5. Measure the Photometry on the NISP Images
430430

431431
We now have the photometry and the position of sources on the VIS image. We can now proceed with similar steps on the NISP images. Because the NISP PSF and pixel scale are larger that those of the VIS images, we utilize the advantage of position prior-based forced photometry.
432432
For this, we use the positions of the VIS measurements and perform PSF fitting on the NISP image using these priors.
@@ -510,7 +510,7 @@ ax2.plot(phot2["x_fit"], phot2["y_fit"] , "o", markersize=8 , markeredgecolor="r
510510
plt.show()
511511
```
512512

513-
## Load Gaia Catalog
513+
## 6. Load Gaia Catalog
514514

515515
We now load the Gaia sources at the location of the globular clusters. The goal is to compare the photometry of Gaia to the one derived above for the Euclid VIS and NISP images. This is scientifically useful, for example we can compute the colors of the stars in the Gaia optical bands and the Euclid near-IR bands.
516516
To search for Gaia sources, we use `astroquery` again.
@@ -565,7 +565,7 @@ ax2.set_title("NISP")
565565
plt.show()
566566
```
567567

568-
## Match the Gaia Catalog to the VIS and NISP Catalogs
568+
## 7. Match the Gaia Catalog to the VIS and NISP Catalogs
569569

570570
Now, we match the Gaia source positions to the extracted sources in the VIS and NISP images.
571571

@@ -630,7 +630,7 @@ ax1.set_ylabel("I$_E$ [mag]")
630630
plt.show()
631631
```
632632

633-
## Visualization with Firefly
633+
## 8. Visualization with Firefly
634634

635635
At the end of this Notebook, we demonstrate how we can visualize the images and catalogs created above in `Firefly`.
636636

tutorials/simulated-data/OpenUniverse2024Preview_Firefly.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ from reproject import reproject_interp
9090
from io import BytesIO
9191
```
9292

93-
## Learn where the OpenUniverse2024 data are hosted in the cloud.
93+
## 1. Learn where the OpenUniverse2024 data are hosted in the cloud
9494

9595
The OpenUniverse2024 data preview is hosted in the cloud via Amazon Web Services (AWS). To access these data, you need to create a client to read data from Amazon's Simple Storage Service (s3) buckets, and you need to know some information about those buckets. The OpenUniverse2024 data preview contains simulations of the Roman Wide-Area Survey (WAS) and the Roman Time Domain Survey (TDS). In this tutorial, we will focus on the WAS.
9696

@@ -104,7 +104,7 @@ RUBIN_PREFIX = "openuniverse2024/rubin/preview"
104104
RUBIN_COADD_PATH = f"{RUBIN_PREFIX}/u/descdm/preview_data_step3_2877_19_w_2024_12/20240403T150003Z/deepCoadd_calexp/2877/19"
105105
```
106106

107-
## Roman Coadds
107+
## 2. Roman Coadds
108108

109109
The Nancy Grace Roman Space Telescope will carry out a wide-area survey (WAS) in the near infrared. The OpenUniverse2024 data preview includes coadded mosaics of simulated WAS data, created with the IMCOM algorithm (Rowe et al. 2011). Bands include F184, H158, J129, K213, Y106. In this section, we define some functions that make it convenient to retrieve a given cloud-hosted simulated Roman coadd based on position and filter.
110110

@@ -241,7 +241,7 @@ plt.imshow(coadd_roman['data'], origin='lower',
241241
plt.plot(*coord_arr_idx, 'r+', markersize=15)
242242
```
243243

244-
## Rubin Coadds
244+
## 3. Rubin Coadds
245245

246246
The OpenUniverse2024 data preview includes coadded mosaics in the following filters: u, g, r, i, z, y. In this section, we define some functions that make it convenient to retrieve a given cloud-hosted simulated Roman coadd based on position and filter.
247247

@@ -331,7 +331,7 @@ coadd_s3_fpath_rubin = get_rubin_coadd_fpath(filter_rubin)
331331
https_url(coadd_s3_fpath_rubin)
332332
```
333333

334-
## Compare simulated Roman and Rubin cutouts for a selected position
334+
## 4. Compare simulated Roman and Rubin cutouts for a selected position
335335

336336
+++
337337

@@ -370,7 +370,7 @@ fig.suptitle(f"Cutouts at ({coord.ra}, {coord.dec}) with {cutout_size} size", fo
370370
plt.tight_layout(rect=[0, 0, 1, 0.97])
371371
```
372372

373-
## Use Firefly to interactively identify a blended source
373+
## 5. Use Firefly to interactively identify a blended source
374374

375375
Clearly, the simulated Roman coadd has higher spatial resolution than the Rubin simulated coadd. Let's try to locate blended objects to compare in the simulated Rubin and Roman images. We will use Firefly's interactive visualization to make this task easier.
376376

@@ -456,7 +456,7 @@ point_region = f'icrs;point {coords_of_interest.ra.value}d {coords_of_interest.d
456456
fc.add_region_data(region_data=point_region, region_layer_id=roman_regions_id)
457457
```
458458

459-
## Plot cutouts of the identified blended source
459+
## 6. Plot cutouts of the identified blended source
460460

461461
```{code-cell} ipython3
462462
coadd_roman = get_roman_coadd(coords_of_interest, filter_roman)
@@ -505,7 +505,7 @@ plt.tight_layout(rect=[0, 0, 1, 0.97])
505505
# plt.savefig("plot.pdf", bbox_inches='tight', pad_inches=0.2)
506506
```
507507

508-
## Use Firefly to visualize the OpenUniverse2024 data preview catalogs
508+
## 7. Use Firefly to visualize the OpenUniverse2024 data preview catalogs
509509
Let's inspect the properties of sources in the Rubin coadd image. For this we will use the input truth files present in S3 bucket.
510510

511511
The OpenUniverse2024 data preview includes the input truth files that were used to create the simulated images. These files are in Parquet and HDF5 format, and include information about the properties of galaxies, stars, and transients.
@@ -618,7 +618,7 @@ point_region = f'icrs;point {high_z_gal_coords.ra.value}d {high_z_gal_coords.dec
618618
fc.add_region_data(region_data=point_region, region_layer_id=roman_regions_id)
619619
```
620620

621-
## Plot 3-color Roman coadd containing your region of interest
621+
## 8. Plot 3-color Roman coadd containing your region of interest
622622
Let's inspect WCS of Roman coadd first
623623

624624
```{code-cell} ipython3

0 commit comments

Comments
 (0)