Skip to content

Commit 4802690

Browse files
committed
Some code simplification and notebook cleanup (empty cells, metadata, etc)
1 parent d07c763 commit 4802690

File tree

1 file changed

+29
-118
lines changed

1 file changed

+29
-118
lines changed

tutorials/euclid_access/4_Euclid_intro_PHZ_catalog.md

Lines changed: 29 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ By the end of this tutorial, you will:
2626
- Pull and plot a spectrum of one of the galaxies in that catalog.
2727
- Learn how to upload images and catalogs to Firefly to inspect individual sources in greater detail.
2828

29-
3029
+++
3130

3231
## Introduction
@@ -41,10 +40,6 @@ The photometry of every source is processed through a photometric redshift fitti
4140

4241
+++
4342

44-
### NOTE to testers -- please log in to IPAC vpn to access the IRSAdev data. After the Q1 data release, we will not need to use the IPAC VPN or the irsadev site.
45-
46-
+++
47-
4843
## Imports
4944

5045
```{code-cell} ipython3
@@ -79,16 +74,14 @@ import pyvo as vo
7974

8075
## 1. Find the MER Tile ID that corresponds to a given RA and Dec
8176

82-
In this case, choose random coordinates to show a different MER mosaic image. Search a radius around these coordinates.
77+
In this case, choose random coordinates to show a different MER mosaic image. Search a radius around these coordinates.
8378

8479
```{code-cell} ipython3
85-
## User selected inputs:
86-
ra=268
87-
dec=66
88-
search_radius= 10*units.arcsec
80+
ra = 268
81+
dec = 66
82+
search_radius= 10 * u.arcsec
8983
90-
pos = SkyCoord(ra=ra, dec=dec, unit='deg')
91-
coord = SkyCoord(ra, dec, unit=(units.deg,units.deg), frame='icrs')
84+
coord = SkyCoord(ra, dec, unit='deg', frame='icrs')
9285
```
9386

9487
### Use IRSA to search for all Euclid data on this target
@@ -98,22 +91,18 @@ This searches specifically in the euclid_DpdMerBksMosaic "collection" which is t
9891
```{code-cell} ipython3
9992
irsa_service= vo.dal.sia2.SIA2Service('https://irsadev.ipac.caltech.edu/SIA')
10093
101-
im_table = irsa_service.search(pos=(pos.ra.deg, pos.dec.deg, search_radius),
102-
collection='euclid_DpdMerBksMosaic')
94+
image_table = irsa_service.search(pos=(coord, search_radius), collection='euclid_DpdMerBksMosaic').to_table()
95+
```
10396

104-
## Convert the table to pandas dataframe
105-
df_im_irsa=im_table.to_table().to_pandas()
97+
```{note}
98+
This table lists all MER mosaic images available in this position. These mosaics include the Euclid VIS, Y, J, H images, as well as ground-based telescopes which have been put on the same pixel scale. For more information, see the [Euclid documentation at IPAC](https://euclid.caltech.edu/page/euclid-faq-tech/).
10699
```
107100

108101
```{code-cell} ipython3
109-
## Change the settings so we can see all the columns in the dataframe and the full column width
110-
## (to see the full long URL)
111-
pd.set_option('display.max_columns', None)
112-
pd.set_option('display.max_colwidth', None)
102+
# Convert the table to pandas dataframe
103+
df_im_irsa=image_table.to_pandas()
113104
```
114105

115-
#### This table lists all MER mosaic images available in this position. These mosaics include the Euclid VIS, Y, J, H images, as well as ground-based telescopes which have been put on the same pixel scale. For more information, see here: https://euclid.caltech.edu/page/euclid-faq-tech/
116-
117106
```{code-cell} ipython3
118107
df_im_euclid=df_im_irsa[ (df_im_irsa['dataproduct_subtype']=='science') & (df_im_irsa['facility_name']=='Euclid')]
119108
@@ -176,17 +165,7 @@ We note that the phz_catalog on IRSA has more columns than it does on the ESA ar
176165

177166
The fluxes are different from the fluxes derived in the MER catalog. The _unif fluxes are: "Unified flux recomputed after correction from galactic extinction and filter shifts"
178167

179-
```{code-cell} ipython3
180-
## Change the settings so we can see all the columns in the dataframe and the full column width
181-
## (to see the full long URL)
182-
pd.set_option('display.max_columns', None)
183-
pd.set_option('display.max_colwidth', None)
184-
185-
186-
## Can use the following lines to reset the max columns and column width of pandas
187-
# pd.reset_option('display.max_columns')
188-
# pd.reset_option('display.max_colwidth')
189-
```
168+
+++
190169

191170
## Find some galaxies between 1.4 and 1.6 at a selected RA and Dec
192171

@@ -197,9 +176,7 @@ We specify the following conditions on our search:
197176
- Using the phz_90_int1 and phz_90_int2, we select just the galaxies where the error on the photometric redshift is less than 15%
198177
- Select just the galaxies between a median redshift of 1.4 and 1.6
199178

200-
```{code-cell} ipython3
201-
202-
```
179+
+++
203180

204181
### Search based on tileID
205182

@@ -232,12 +209,6 @@ df_g_irsa = result.to_table().to_pandas()
232209
df_g_irsa.head()
233210
```
234211

235-
236-
237-
```{code-cell} ipython3
238-
239-
```
240-
241212
## 3. Read in the MER image from IRSA directly
242213

243214
```{code-cell} ipython3
@@ -260,10 +231,6 @@ print(filename_dev)
260231
#####################
261232
```
262233

263-
```{code-cell} ipython3
264-
265-
```
266-
267234
```{code-cell} ipython3
268235
##Download the MER image -- note this file is about 1.46 GB
269236
@@ -295,8 +262,6 @@ plt.imshow(im_mer_irsa, cmap='gray', origin='lower',
295262
colorbar = plt.colorbar()
296263
```
297264

298-
299-
300265
## 4. Overplot the catalog on the MER mosaic image
301266

302267
```{code-cell} ipython3
@@ -338,10 +303,6 @@ plt.title('Galaxies between z = 1.4 and 1.6')
338303
plt.show()
339304
```
340305

341-
```{code-cell} ipython3
342-
343-
```
344-
345306
## Pull the spectra on the top brightest source based on object ID
346307

347308
```{code-cell} ipython3
@@ -397,21 +358,21 @@ plt.ylabel('Flux (erg / (Angstrom s cm2))')
397358
plt.title('Object ID is '+str(obj_id))
398359
```
399360

400-
## Lets cut out a very small patch of the MER image to see what this galaxy looks like
361+
## Lets cut out a very small patch of the MER image to see what this galaxy looks like
401362

402363
```{code-cell} ipython3
403364
df_g_irsa[df_g_irsa['object_id']==obj_id]['ra']
404365
```
405366

406367
```{code-cell} ipython3
407368
## How large do you want the image cutout to be?
408-
im_cutout= 2.0 * units.arcsec
369+
im_cutout= 2.0 * u.arcsec
409370
410371
## Use the ra and dec of the galaxy
411372
ra = df_g_irsa[df_g_irsa['object_id']==obj_id]['ra'].iloc[0]
412373
dec = df_g_irsa[df_g_irsa['object_id']==obj_id]['dec'].iloc[0]
413374
414-
coords_cutout = SkyCoord(ra, dec, unit=(units.deg,units.deg), frame='icrs')
375+
coords_cutout = SkyCoord(ra, dec, unit=(u.deg,u.deg), frame='icrs')
415376
```
416377

417378
### Use fsspec to download a cutout of the fits file
@@ -444,18 +405,22 @@ colorbar = plt.colorbar()
444405

445406
+++
446407

447-
### Save the data locally if you have not already done so, in order to upload to IRSA viewer
408+
Save the data locally if you have not already done so, in order to upload to IRSA viewer.
448409

449410
```{code-cell} ipython3
450-
# download_path = '/your_path/'
451-
# hdu_mer_irsa.writeto(download_path+'./MER_image_VIS.fits', overwrite=True)
411+
download_path = "data"
412+
if os.path.exists(download_path):
413+
print("Output directory already created.")
414+
else:
415+
print("Creating data directory.")
416+
os.mkdir(dowload_path)
452417
```
453418

454419
### Vizualize the image with Firefly
455420

456421
First initialize the client, then set the path to the image, upload it to firefly, load it and align with WCS.
457422

458-
Note this can take a while to upload the full MER image.
423+
Note this can take a while to upload the full MER image.
459424

460425
```{code-cell} ipython3
461426
fc = FireflyClient.make_client('https://irsa.ipac.caltech.edu/irsaviewer')
@@ -468,8 +433,8 @@ fc.align_images(lock_match=True)
468433
### Save the table as a CSV for Firefly upload
469434

470435
```{code-cell} ipython3
471-
# csv_path = download_path+'/mer_df.csv'
472-
# df_g_irsa.to_csv(csv_path, index=False)
436+
csv_path = os.path.join(download_path, "mer_df.csv")
437+
df_g_irsa.to_csv(csv_path, index=False)
473438
```
474439

475440
### Upload the CSV table to Firefly and display as an overlay on the FITS image
@@ -481,64 +446,10 @@ print(f"Uploaded Table URL: {uploaded_table}")
481446
fc.show_table(uploaded_table)
482447
```
483448

484-
```{code-cell} ipython3
485-
486-
```
487-
488-
```{code-cell} ipython3
489-
490-
```
491-
492-
### Optional -- Access the data from the ESA archive website directly
493-
494-
+++
495-
496-
#### 1. Download and read in data from the ESA archive
497-
498-
- Go to https://easidr.esac.esa.int/sas/ and sign in with your credentials.
499-
- Click Search and go to the ADQL form and enter a query which matches the query above.
500-
501-
+++
502-
503-
Download the results, gunzip in the command line. You should now have a VOT table
504-
505-
NOTE: Need to do the following in the command line:
506-
507-
mv original_cat.vot.gz to mer_cat.vot
508-
509-
to remove the .gz extension
510-
511-
+++
512-
513-
## Additional Resources
514-
515-
If you have any issues accessing data from the archives, please contact the helpdesk directly: IRSA ([email protected]) and ESA (https://support.cosmos.esa.int/euclid).
516-
517-
+++
518-
519449
## About this Notebook
520450

521-
**Author(s)**: Tiffany Meshkat <br>
522-
**Keyword(s)**: Euclid, Q1, phz catalog <br>
523-
**First published**: March 19, 2025 <br>
524-
**Last updated**: March 19, 2025
451+
**Author**: Tiffany Meshkat (IPAC Scientist)
525452

526-
+++
527-
528-
529-
530-
```{code-cell} ipython3
531-
532-
```
533-
534-
```{code-cell} ipython3
453+
**Updated**: 2025-03-19
535454

536-
```
537-
538-
```{code-cell} ipython3
539-
540-
```
541-
542-
```{code-cell} ipython3
543-
544-
```
455+
**Contact:** [the IRSA Helpdesk](https://irsa.ipac.caltech.edu/docs/help_desk.html) with questions or reporting problems.

0 commit comments

Comments
 (0)