From 5e14383069a6d843cc6d73fdc23b46aca331dfb1 Mon Sep 17 00:00:00 2001 From: KeunhoKim-astro <99432679+KeunhoKim-astro@users.noreply.github.com> Date: Thu, 8 Oct 2026 15:18:41 -0700 Subject: [PATCH 01/27] Update tutorial to reflect Euclid DR1 SIR 1D spectra --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index 7f5b5756..bbe13424 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -33,7 +33,7 @@ authors: +++ By the end of this tutorial, you will: -- Understand the basic characteristics of Euclid Q1 SIR 1D spectra. +- Understand the basic characteristics of Euclid DR1 SIR 1D spectra. - Examine the provided boolean masks - Make a simple plot of a Euclid spectrum. From 2c55dd4d90f8d353e0a4f3f2155eb7c4015ec46a Mon Sep 17 00:00:00 2001 From: KeunhoKim-astro <99432679+KeunhoKim-astro@users.noreply.github.com> Date: Thu, 8 Oct 2026 15:19:39 -0700 Subject: [PATCH 02/27] Clean up introduction section of Euclid document Removed unnecessary comment from the introduction section. --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index bbe13424..353177d6 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -41,6 +41,8 @@ By the end of this tutorial, you will: ## Introduction +#This part is not needed to change + Euclid launched in July 2023 as a European Space Agency (ESA) mission with involvement by NASA. The primary science goals of Euclid are to better understand the composition and evolution of the dark Universe. The Euclid mission is providing space-based imaging and spectroscopy as well as supporting ground-based imaging to achieve these primary goals. From fc6cbe2c93a76a34a9856703da5b4180d75f11b5 Mon Sep 17 00:00:00 2001 From: KeunhoKim-astro <99432679+KeunhoKim-astro@users.noreply.github.com> Date: Thu, 8 Oct 2026 15:20:01 -0700 Subject: [PATCH 03/27] Fix formatting in Euclid intro document --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index 353177d6..f94c4f07 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -41,7 +41,7 @@ By the end of this tutorial, you will: ## Introduction -#This part is not needed to change +%This part is not needed to change Euclid launched in July 2023 as a European Space Agency (ESA) mission with involvement by NASA. The primary science goals of Euclid are to better understand the composition and evolution of the dark Universe. From 26d6ca676ef9d8d0f7b7d70e132021d3288667a4 Mon Sep 17 00:00:00 2001 From: KeunhoKim-astro <99432679+KeunhoKim-astro@users.noreply.github.com> Date: Thu, 8 Oct 2026 15:21:25 -0700 Subject: [PATCH 04/27] Update 3_Euclid_intro_1D_spectra.md --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index f94c4f07..277bcb02 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -41,7 +41,7 @@ By the end of this tutorial, you will: ## Introduction -%This part is not needed to change + Euclid launched in July 2023 as a European Space Agency (ESA) mission with involvement by NASA. The primary science goals of Euclid are to better understand the composition and evolution of the dark Universe. From f88105603493a9ee46169b426d76179dea396a92 Mon Sep 17 00:00:00 2001 From: KeunhoKim-astro <99432679+KeunhoKim-astro@users.noreply.github.com> Date: Mon, 12 Oct 2026 20:00:14 -0700 Subject: [PATCH 05/27] updated text to incorporate the dr1 spectra description Updated text for clarity and accuracy regarding the Euclid mission and data releases. --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index 277bcb02..dd107c7a 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -40,24 +40,22 @@ By the end of this tutorial, you will: +++ ## Introduction - - -Euclid launched in July 2023 as a European Space Agency (ESA) mission with involvement by NASA. +Euclid launched in July 2023 as a European Space Agency (ESA) mission with contributions from NASA. The primary science goals of Euclid are to better understand the composition and evolution of the dark Universe. -The Euclid mission is providing space-based imaging and spectroscopy as well as supporting ground-based imaging to achieve these primary goals. -These data will be archived by multiple global repositories, including IRSA, where they will support transformational work in many areas of astrophysics. +The Euclid mission provides space-based imaging and spectroscopy, complemented by ground-based imaging, to achieve these goals. +These data will be archived by multiple global repositories, including IRSA, where they will support a wide range of astrophysical research. -Euclid Quick Release 1 (Q1) consists of consists of ~30 TB of imaging, spectroscopy, and catalogs covering four non-contiguous fields: -Euclid Deep Field North (22.9 sq deg), Euclid Deep Field Fornax (12.1 sq deg), Euclid Deep Field South (28.1 sq deg), and LDN1641. +Euclid Data Release 1 (DR1) will include imaging, spectroscopy, and catalogs covering approximately 1,900 square degrees of the Euclid Wide Survey, along with observations of the Euclid Deep Fields. -Among the data products included in the Q1 release are the 1D spectra created by the SIR Processing Function. -This notebook provides an introduction to these SIR 1D spectra. +Among the DR1 data products are the one-dimensional (1D) spectra extracted from NISP slitless spectroscopic observations by the SIR Processing Function. +This notebook provides an introduction to the Euclid DR1 SIR 1D spectra. If you have questions about it, please contact the [IRSA helpdesk](https://irsa.ipac.caltech.edu/docs/help_desk.html). +++ ## Imports + ```{important} We rely on ``astroquery`` features that have been recently added, so please make sure you have version v0.4.10 or newer installed. From fc441af1613d69e397784e8242a4d7b1356fde00 Mon Sep 17 00:00:00 2001 From: KeunhoKim-astro <99432679+KeunhoKim-astro@users.noreply.github.com> Date: Fri, 16 Oct 2026 09:16:35 -0700 Subject: [PATCH 06/27] Update 3_Euclid_intro_1D_spectra.md --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index dd107c7a..95fc39e1 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -24,7 +24,7 @@ authors: - name: Jessica Krick --- -# Euclid Q1: SIR 1D Spectra +# Euclid DR1: SIR 1D Spectra +++ From 02931bfb78ddda6270b2b4701ef23bf83065fe42 Mon Sep 17 00:00:00 2001 From: KeunhoKim-astro <99432679+KeunhoKim-astro@users.noreply.github.com> Date: Fri, 16 Oct 2026 09:45:41 -0700 Subject: [PATCH 07/27] Update 3_Euclid_intro_1D_spectra.md --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index 95fc39e1..4e6fc51c 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -46,7 +46,8 @@ The primary science goals of Euclid are to better understand the composition and The Euclid mission provides space-based imaging and spectroscopy, complemented by ground-based imaging, to achieve these goals. These data will be archived by multiple global repositories, including IRSA, where they will support a wide range of astrophysical research. -Euclid Data Release 1 (DR1) will include imaging, spectroscopy, and catalogs covering approximately 1,900 square degrees of the Euclid Wide Survey, along with observations of the Euclid Deep Fields. +Euclid Data Release 1 (DR1) will include imaging, spectroscopy, and catalogs covering approximately 1,900 square degrees of the Euclid Wide Survey, along with observations of the Euclid Deep Fields. Further information about Euclid DR1 can be found at: https://euclid.caltech.edu/page/euclid-dr1 + Among the DR1 data products are the one-dimensional (1D) spectra extracted from NISP slitless spectroscopic observations by the SIR Processing Function. This notebook provides an introduction to the Euclid DR1 SIR 1D spectra. From 0905afedefa277f79ccbc0b17789118f82a89410 Mon Sep 17 00:00:00 2001 From: KeunhoKim-astro <99432679+KeunhoKim-astro@users.noreply.github.com> Date: Thu, 22 Oct 2026 15:49:58 -0700 Subject: [PATCH 08/27] Modify galaxy coordinates and search radius Updated coordinates and search radius for galaxy spectrum query. --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index 4e6fc51c..87277656 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -117,11 +117,12 @@ euclid_ssa_collection = 'euclid_DpdSirCombinedSpectra' ```{code-cell} ipython3 coord = SkyCoord( - ra=269.7 * u.deg, - dec=66.0 * u.deg + ra=265.57990643 * u.deg, + dec=66.9992372 * u.deg, + frame="icrs" ) -search_radius = 5.0 * u.arcsec +search_radius = 1.0 * u.arcsec ``` Query the IRSA SSA service for spectra near this position From 37b97316d0818590e24a155b154dbdd0069b7059 Mon Sep 17 00:00:00 2001 From: KeunhoKim-astro <99432679+KeunhoKim-astro@users.noreply.github.com> Date: Thu, 22 Oct 2026 15:50:48 -0700 Subject: [PATCH 09/27] Update variable name for Euclid SSA collection (euclid_dr1_ part) --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index 87277656..3a69dc88 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -110,7 +110,7 @@ Irsa.list_collections(servicetype="ssa") ``` ```{code-cell} ipython3 -euclid_ssa_collection = 'euclid_DpdSirCombinedSpectra' +euclid_ssa_collection = 'euclid_dr1_DpdSirCombinedSpectra' ``` ## 2. Search for the spectrum of a specific galaxy in the 1D spectra table From dcc41436242cdf323a34db4590007d4107b0fac5 Mon Sep 17 00:00:00 2001 From: KeunhoKim-astro <99432679+KeunhoKim-astro@users.noreply.github.com> Date: Thu, 22 Oct 2026 15:57:24 -0700 Subject: [PATCH 10/27] Update SSA query collection name for DR1 --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index 3a69dc88..5add38aa 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -128,10 +128,15 @@ search_radius = 1.0 * u.arcsec Query the IRSA SSA service for spectra near this position ```{code-cell} ipython3 -ssa_result = Irsa.query_ssa( +#=====This part to be updated once the dr1 becomes public==== +irsa_dev = IrsaClass() +irsa_dev.ssa_url = "https://irsadev.ipac.caltech.edu/SSA" +#============================================================ + +ssa_result = irsa_dev.query_ssa( pos=coord, radius=search_radius, - collection=euclid_ssa_collection, + collection="euclid_dr1_DpdSirCombinedSpectra", ) #check whether any spectra were found From 3f105a808e0ae6ced819627c3b50bc5b0b89b4d8 Mon Sep 17 00:00:00 2001 From: KeunhoKim-astro <99432679+KeunhoKim-astro@users.noreply.github.com> Date: Thu, 22 Oct 2026 15:59:22 -0700 Subject: [PATCH 11/27] Revise comments for SSA service code block Updated comments in the code cell regarding the public release of dr1. --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index 5add38aa..5b227ad0 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -128,11 +128,12 @@ search_radius = 1.0 * u.arcsec Query the IRSA SSA service for spectra near this position ```{code-cell} ipython3 -#=====This part to be updated once the dr1 becomes public==== +#=====This part to be removed once the dr1 becomes public==== irsa_dev = IrsaClass() irsa_dev.ssa_url = "https://irsadev.ipac.caltech.edu/SSA" #============================================================ +#===ssa_result = irsa_dev.query_ssa --> ssa_result = Irsa.query_ssa, once the dr1 becomes public== ssa_result = irsa_dev.query_ssa( pos=coord, radius=search_radius, From a6caab12dc34d41d6351b755161ee72b911f2660 Mon Sep 17 00:00:00 2001 From: KeunhoKim-astro <99432679+KeunhoKim-astro@users.noreply.github.com> Date: Fri, 23 Oct 2026 08:22:53 -0700 Subject: [PATCH 12/27] Change galaxy coordinates in 1D spectra example Updated the coordinates for the galaxy search in the 1D spectra table. --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index 5b227ad0..f3920830 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -117,8 +117,8 @@ euclid_ssa_collection = 'euclid_dr1_DpdSirCombinedSpectra' ```{code-cell} ipython3 coord = SkyCoord( - ra=265.57990643 * u.deg, - dec=66.9992372 * u.deg, + ra=271.335 * u.deg, + dec=64.216 * u.deg, frame="icrs" ) From 4592645ff6ca90634812fd4a83f87af52c6635dc Mon Sep 17 00:00:00 2001 From: KeunhoKim-astro <99432679+KeunhoKim-astro@users.noreply.github.com> Date: Fri, 23 Oct 2026 08:38:24 -0700 Subject: [PATCH 13/27] Adjust y-axis limits for spectrum plot --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index f3920830..b0b232ac 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -204,7 +204,7 @@ plt.plot(spectrum['WAVELENGTH'], np.ma.masked_where(~bad_mask, spectrum['SIGNAL' plt.plot(spectrum['WAVELENGTH'], np.sqrt(spectrum['VAR']), color='grey', label='Error') plt.legend(loc='upper right') -plt.ylim(-0.15, 0.25) +plt.ylim(-0.10, 0.20) plt.title(f"Euclid SIR 1D Spectrum at RA={coord.ra.deg:.4f}°, Dec={coord.dec.deg:.4f}°") ``` From 20da33b2257b7b5f505d714650110bfde331de5c Mon Sep 17 00:00:00 2001 From: KeunhoKim-astro <99432679+KeunhoKim-astro@users.noreply.github.com> Date: Fri, 23 Oct 2026 09:49:47 -0700 Subject: [PATCH 14/27] Update 3_Euclid_intro_1D_spectra.md --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index b0b232ac..8dbf1e12 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -117,8 +117,8 @@ euclid_ssa_collection = 'euclid_dr1_DpdSirCombinedSpectra' ```{code-cell} ipython3 coord = SkyCoord( - ra=271.335 * u.deg, - dec=64.216 * u.deg, + ra=272.1469 * u.deg, + dec=67.6729 * u.deg, frame="icrs" ) From adb1ef0deaf4cfa2011fe562b145fd884391be78 Mon Sep 17 00:00:00 2001 From: KeunhoKim-astro <99432679+KeunhoKim-astro@users.noreply.github.com> Date: Mon, 26 Oct 2026 12:19:16 -0700 Subject: [PATCH 15/27] Change galaxy coordinates in search example Updated coordinates for galaxy search in 1D spectra table. --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index 8dbf1e12..5b95b4e2 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -117,8 +117,8 @@ euclid_ssa_collection = 'euclid_dr1_DpdSirCombinedSpectra' ```{code-cell} ipython3 coord = SkyCoord( - ra=272.1469 * u.deg, - dec=67.6729 * u.deg, + ra=272.3240 * u.deg, + dec=68.2962 * u.deg, frame="icrs" ) From 64eb97f2f839e9c5247b12cca368e5f5a82cf8c4 Mon Sep 17 00:00:00 2001 From: KeunhoKim-astro <99432679+KeunhoKim-astro@users.noreply.github.com> Date: Mon, 26 Oct 2026 12:27:33 -0700 Subject: [PATCH 16/27] Document steps to retrieve and plot galaxy spectra Added steps for querying and plotting galaxy spectra. --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index 5b95b4e2..a1210006 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -208,6 +208,104 @@ plt.ylim(-0.10, 0.20) plt.title(f"Euclid SIR 1D Spectrum at RA={coord.ra.deg:.4f}°, Dec={coord.dec.deg:.4f}°") ``` +## 5. Repeat Steps 2-4 for a different galaxy +## 2. Search for the spectrum of a specific galaxy in the 1D spectra table + +```{code-cell} ipython3 +coord = SkyCoord( + ra=271.2353 * u.deg, + dec=65.0631 * u.deg, + frame="icrs" +) + +search_radius = 1.0 * u.arcsec +``` + +Query the IRSA SSA service for spectra near this position + +```{code-cell} ipython3 +#=====This part to be removed once the dr1 becomes public==== +irsa_dev = IrsaClass() +irsa_dev.ssa_url = "https://irsadev.ipac.caltech.edu/SSA" +#============================================================ + +#===ssa_result = irsa_dev.query_ssa --> ssa_result = Irsa.query_ssa, once the dr1 becomes public== +ssa_result = irsa_dev.query_ssa( + pos=coord, + radius=search_radius, + collection="euclid_dr1_DpdSirCombinedSpectra", +) + +#check whether any spectra were found +len(ssa_result) +``` + +Pull out the file name from the ``result`` table: + +```{code-cell} ipython3 +# Extract the single SSA result row +row = ssa_result[0] #in case there is more than one spectra in the search radius + + +# Each SSA row provides a direct URL to the spectrum file +spectrum_path = row["access_url"] +spectrum_path +``` + +## 3. Read in the spectrum for only our specific object + +`spectrum_path` is a url that will return a VOTable containing the spectrum of our object. + +```{code-cell} ipython3 +spectrum = QTable.read(spectrum_path) +``` + +```{code-cell} ipython3 +spectrum +``` + +## 4. Plot the image of the extracted spectrum + +```{tip} +As we use astropy.visualization's ``quantity_support``, matplotlib automatically picks up the axis units from the quantities we plot. +``` + +```{code-cell} ipython3 +quantity_support() +``` + +```{note} +The 1D combined spectra table contains 6 columns, below are a few highlights: + +- WAVELENGTH is in Angstroms by default. +- SIGNAL is the flux. The values are scaled and the scaling factor is included in the column's units. This value corresponds to the `'FSCALE'` entry in the HDU header of the original FITS file. +- MASK values can be used to determine which flux bins to discard. MASK = odd and MASK >=64 means the flux bins not be used. +``` + +We investigate the MASK column to see which flux bins are recommended to keep vs "Do Not Use" + +```{code-cell} ipython3 +plt.plot(spectrum['WAVELENGTH'].to(u.micron), spectrum['MASK']) +plt.ylabel('Mask value') +plt.title('Values of MASK by flux bin') +``` + +We use the MASK column to create a boolean mask for values to ignore. We use the inverse of this mask to mark the flux bins to use. + +```{code-cell} ipython3 +bad_mask = (spectrum['MASK'].value % 2 == 1) | (spectrum['MASK'].value >= 64) + +plt.plot(spectrum['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask, spectrum['SIGNAL']), color='black', label='Spectrum') +plt.plot(spectrum['WAVELENGTH'], np.ma.masked_where(~bad_mask, spectrum['SIGNAL']), color='red', label='Do not use') +plt.plot(spectrum['WAVELENGTH'], np.sqrt(spectrum['VAR']), color='grey', label='Error') + +plt.legend(loc='upper right') +plt.ylim(-0.10, 0.20) +plt.title(f"Euclid SIR 1D Spectrum at RA={coord.ra.deg:.4f}°, Dec={coord.dec.deg:.4f}°") +``` + + + ## About this Notebook **Updated**: 2026-01-13 From 5c85bb60489cdbf2decdfb89f614e3776fae1334 Mon Sep 17 00:00:00 2001 From: KeunhoKim-astro <99432679+KeunhoKim-astro@users.noreply.github.com> Date: Mon, 26 Oct 2026 12:36:38 -0700 Subject: [PATCH 17/27] Add instructions for querying galaxy spectrum data Added steps to query and plot the spectrum of a specific galaxy using the IRSA SSA service. Included code cells for searching, reading, and visualizing the spectrum data. --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index a1210006..69d2d3e8 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -304,6 +304,101 @@ plt.ylim(-0.10, 0.20) plt.title(f"Euclid SIR 1D Spectrum at RA={coord.ra.deg:.4f}°, Dec={coord.dec.deg:.4f}°") ``` +## 6. Repeat Steps 2-4 for a different galaxy +## 2. Search for the spectrum of a specific galaxy in the 1D spectra table + +```{code-cell} ipython3 +coord = SkyCoord( + ra=270.7769 * u.deg, + dec=64.7781 * u.deg, + frame="icrs" +) + +search_radius = 1.0 * u.arcsec +``` + +Query the IRSA SSA service for spectra near this position + +```{code-cell} ipython3 +#=====This part to be removed once the dr1 becomes public==== +irsa_dev = IrsaClass() +irsa_dev.ssa_url = "https://irsadev.ipac.caltech.edu/SSA" +#============================================================ + +#===ssa_result = irsa_dev.query_ssa --> ssa_result = Irsa.query_ssa, once the dr1 becomes public== +ssa_result = irsa_dev.query_ssa( + pos=coord, + radius=search_radius, + collection="euclid_dr1_DpdSirCombinedSpectra", +) + +#check whether any spectra were found +len(ssa_result) +``` + +Pull out the file name from the ``result`` table: + +```{code-cell} ipython3 +# Extract the single SSA result row +row = ssa_result[0] #in case there is more than one spectra in the search radius + + +# Each SSA row provides a direct URL to the spectrum file +spectrum_path = row["access_url"] +spectrum_path +``` + +## 3. Read in the spectrum for only our specific object + +`spectrum_path` is a url that will return a VOTable containing the spectrum of our object. + +```{code-cell} ipython3 +spectrum = QTable.read(spectrum_path) +``` + +```{code-cell} ipython3 +spectrum +``` + +## 4. Plot the image of the extracted spectrum + +```{tip} +As we use astropy.visualization's ``quantity_support``, matplotlib automatically picks up the axis units from the quantities we plot. +``` + +```{code-cell} ipython3 +quantity_support() +``` + +```{note} +The 1D combined spectra table contains 6 columns, below are a few highlights: + +- WAVELENGTH is in Angstroms by default. +- SIGNAL is the flux. The values are scaled and the scaling factor is included in the column's units. This value corresponds to the `'FSCALE'` entry in the HDU header of the original FITS file. +- MASK values can be used to determine which flux bins to discard. MASK = odd and MASK >=64 means the flux bins not be used. +``` + +We investigate the MASK column to see which flux bins are recommended to keep vs "Do Not Use" + +```{code-cell} ipython3 +plt.plot(spectrum['WAVELENGTH'].to(u.micron), spectrum['MASK']) +plt.ylabel('Mask value') +plt.title('Values of MASK by flux bin') +``` + +We use the MASK column to create a boolean mask for values to ignore. We use the inverse of this mask to mark the flux bins to use. + +```{code-cell} ipython3 +bad_mask = (spectrum['MASK'].value % 2 == 1) | (spectrum['MASK'].value >= 64) + +plt.plot(spectrum['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask, spectrum['SIGNAL']), color='black', label='Spectrum') +plt.plot(spectrum['WAVELENGTH'], np.ma.masked_where(~bad_mask, spectrum['SIGNAL']), color='red', label='Do not use') +plt.plot(spectrum['WAVELENGTH'], np.sqrt(spectrum['VAR']), color='grey', label='Error') + +plt.legend(loc='upper right') +plt.ylim(-0.10, 0.20) +plt.title(f"Euclid SIR 1D Spectrum at RA={coord.ra.deg:.4f}°, Dec={coord.dec.deg:.4f}°") +``` ## About this Notebook From 57cc4d55ecda7cc350e74a99a2a7058afd366451 Mon Sep 17 00:00:00 2001 From: KeunhoKim-astro <99432679+KeunhoKim-astro@users.noreply.github.com> Date: Tue, 27 Oct 2026 21:27:20 -0700 Subject: [PATCH 18/27] Enhance spectrum plotting with blue grism data --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 54 ++++++++++++++----- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index 69d2d3e8..d5910131 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -149,11 +149,15 @@ Pull out the file name from the ``result`` table: ```{code-cell} ipython3 # Extract the single SSA result row row = ssa_result[0] #in case there is more than one spectra in the search radius +row_blue = ssa_result[1] #the blue grism of the same galaxy within the deep field # Each SSA row provides a direct URL to the spectrum file spectrum_path = row["access_url"] spectrum_path + +spectrum_path_blue = row_blue["access_url"] +spectrum_path_blue ``` ## 3. Read in the spectrum for only our specific object @@ -162,6 +166,7 @@ spectrum_path ```{code-cell} ipython3 spectrum = QTable.read(spectrum_path) +spectrum_blue = QTable.read(spectrum_path_blue) ``` ```{code-cell} ipython3 @@ -189,7 +194,8 @@ The 1D combined spectra table contains 6 columns, below are a few highlights: We investigate the MASK column to see which flux bins are recommended to keep vs "Do Not Use" ```{code-cell} ipython3 -plt.plot(spectrum['WAVELENGTH'].to(u.micron), spectrum['MASK']) +plt.plot(spectrum['WAVELENGTH'].to(u.micron), spectrum['MASK'], alpha=0.6, color='red') +plt.plot(spectrum_blue['WAVELENGTH'].to(u.micron), spectrum_blue['MASK'], alpha=0.6, color='blue') plt.ylabel('Mask value') plt.title('Values of MASK by flux bin') ``` @@ -198,13 +204,17 @@ We use the MASK column to create a boolean mask for values to ignore. We use the ```{code-cell} ipython3 bad_mask = (spectrum['MASK'].value % 2 == 1) | (spectrum['MASK'].value >= 64) +bad_mask_blue = (spectrum_blue['MASK'].value % 2 == 1) | (spectrum_blue['MASK'].value >= 64) -plt.plot(spectrum['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask, spectrum['SIGNAL']), color='black', label='Spectrum') -plt.plot(spectrum['WAVELENGTH'], np.ma.masked_where(~bad_mask, spectrum['SIGNAL']), color='red', label='Do not use') +plt.plot(spectrum['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask, spectrum['SIGNAL']), alpha=0.6, color='red', label='Red Spectrum') +plt.plot(spectrum['WAVELENGTH'], np.ma.masked_where(~bad_mask, spectrum['SIGNAL']), color='red', label='Do not use (Red)', linewidth=2.0) plt.plot(spectrum['WAVELENGTH'], np.sqrt(spectrum['VAR']), color='grey', label='Error') +plt.plot(spectrum_blue['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask_blue, spectrum_blue['SIGNAL']), alpha=0.5, color='blue', label='Blue Spectrum')#, #color='black', label='Spectrum') +plt.plot(spectrum_blue['WAVELENGTH'], np.ma.masked_where(~bad_mask_blue, spectrum_blue['SIGNAL']), color='blue', label='Do not use (Blue)', linewidth=2.0) +plt.plot(spectrum_blue['WAVELENGTH'], np.sqrt(spectrum_blue['VAR']), color='grey', label='Error') plt.legend(loc='upper right') -plt.ylim(-0.10, 0.20) +plt.ylim(-0.05, 0.55) plt.title(f"Euclid SIR 1D Spectrum at RA={coord.ra.deg:.4f}°, Dec={coord.dec.deg:.4f}°") ``` @@ -245,11 +255,15 @@ Pull out the file name from the ``result`` table: ```{code-cell} ipython3 # Extract the single SSA result row row = ssa_result[0] #in case there is more than one spectra in the search radius +row_blue = ssa_result[1] #the blue grism of the same galaxy within the deep field # Each SSA row provides a direct URL to the spectrum file spectrum_path = row["access_url"] spectrum_path + +spectrum_path_blue = row_blue["access_url"] +spectrum_path_blue ``` ## 3. Read in the spectrum for only our specific object @@ -258,6 +272,7 @@ spectrum_path ```{code-cell} ipython3 spectrum = QTable.read(spectrum_path) +spectrum_blue = QTable.read(spectrum_path_blue) ``` ```{code-cell} ipython3 @@ -285,7 +300,8 @@ The 1D combined spectra table contains 6 columns, below are a few highlights: We investigate the MASK column to see which flux bins are recommended to keep vs "Do Not Use" ```{code-cell} ipython3 -plt.plot(spectrum['WAVELENGTH'].to(u.micron), spectrum['MASK']) +plt.plot(spectrum['WAVELENGTH'].to(u.micron), spectrum['MASK'], alpha=0.6, color='red') +plt.plot(spectrum_blue['WAVELENGTH'].to(u.micron), spectrum_blue['MASK'], alpha=0.6, color='blue') plt.ylabel('Mask value') plt.title('Values of MASK by flux bin') ``` @@ -294,13 +310,17 @@ We use the MASK column to create a boolean mask for values to ignore. We use the ```{code-cell} ipython3 bad_mask = (spectrum['MASK'].value % 2 == 1) | (spectrum['MASK'].value >= 64) +bad_mask_blue = (spectrum_blue['MASK'].value % 2 == 1) | (spectrum_blue['MASK'].value >= 64) -plt.plot(spectrum['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask, spectrum['SIGNAL']), color='black', label='Spectrum') -plt.plot(spectrum['WAVELENGTH'], np.ma.masked_where(~bad_mask, spectrum['SIGNAL']), color='red', label='Do not use') +plt.plot(spectrum['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask, spectrum['SIGNAL']), alpha=0.6, color='red', label='Red Spectrum') +plt.plot(spectrum['WAVELENGTH'], np.ma.masked_where(~bad_mask, spectrum['SIGNAL']), color='red', label='Do not use (Red)', linewidth=2.0) plt.plot(spectrum['WAVELENGTH'], np.sqrt(spectrum['VAR']), color='grey', label='Error') +plt.plot(spectrum_blue['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask_blue, spectrum_blue['SIGNAL']), alpha=0.5, color='blue', label='Blue Spectrum')#, #color='black', label='Spectrum') +plt.plot(spectrum_blue['WAVELENGTH'], np.ma.masked_where(~bad_mask_blue, spectrum_blue['SIGNAL']), color='blue', label='Do not use (Blue)', linewidth=2.0) +plt.plot(spectrum_blue['WAVELENGTH'], np.sqrt(spectrum_blue['VAR']), color='grey', label='Error') plt.legend(loc='upper right') -plt.ylim(-0.10, 0.20) +plt.ylim(-0.05, 0.55) plt.title(f"Euclid SIR 1D Spectrum at RA={coord.ra.deg:.4f}°, Dec={coord.dec.deg:.4f}°") ``` @@ -341,11 +361,15 @@ Pull out the file name from the ``result`` table: ```{code-cell} ipython3 # Extract the single SSA result row row = ssa_result[0] #in case there is more than one spectra in the search radius +row_blue = ssa_result[1] #the blue grism of the same galaxy within the deep field # Each SSA row provides a direct URL to the spectrum file spectrum_path = row["access_url"] spectrum_path + +spectrum_path_blue = row_blue["access_url"] +spectrum_path_blue ``` ## 3. Read in the spectrum for only our specific object @@ -354,6 +378,7 @@ spectrum_path ```{code-cell} ipython3 spectrum = QTable.read(spectrum_path) +spectrum_blue = QTable.read(spectrum_path_blue) ``` ```{code-cell} ipython3 @@ -381,7 +406,8 @@ The 1D combined spectra table contains 6 columns, below are a few highlights: We investigate the MASK column to see which flux bins are recommended to keep vs "Do Not Use" ```{code-cell} ipython3 -plt.plot(spectrum['WAVELENGTH'].to(u.micron), spectrum['MASK']) +plt.plot(spectrum['WAVELENGTH'].to(u.micron), spectrum['MASK'], alpha=0.6, color='red') +plt.plot(spectrum_blue['WAVELENGTH'].to(u.micron), spectrum_blue['MASK'], alpha=0.6, color='blue') plt.ylabel('Mask value') plt.title('Values of MASK by flux bin') ``` @@ -390,13 +416,17 @@ We use the MASK column to create a boolean mask for values to ignore. We use the ```{code-cell} ipython3 bad_mask = (spectrum['MASK'].value % 2 == 1) | (spectrum['MASK'].value >= 64) +bad_mask_blue = (spectrum_blue['MASK'].value % 2 == 1) | (spectrum_blue['MASK'].value >= 64) -plt.plot(spectrum['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask, spectrum['SIGNAL']), color='black', label='Spectrum') -plt.plot(spectrum['WAVELENGTH'], np.ma.masked_where(~bad_mask, spectrum['SIGNAL']), color='red', label='Do not use') +plt.plot(spectrum['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask, spectrum['SIGNAL']), alpha=0.6, color='red', label='Red Spectrum') +plt.plot(spectrum['WAVELENGTH'], np.ma.masked_where(~bad_mask, spectrum['SIGNAL']), color='red', label='Do not use (Red)', linewidth=2.0) plt.plot(spectrum['WAVELENGTH'], np.sqrt(spectrum['VAR']), color='grey', label='Error') +plt.plot(spectrum_blue['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask_blue, spectrum_blue['SIGNAL']), alpha=0.5, color='blue', label='Blue Spectrum')#, #color='black', label='Spectrum') +plt.plot(spectrum_blue['WAVELENGTH'], np.ma.masked_where(~bad_mask_blue, spectrum_blue['SIGNAL']), color='blue', label='Do not use (Blue)', linewidth=2.0) +plt.plot(spectrum_blue['WAVELENGTH'], np.sqrt(spectrum_blue['VAR']), color='grey', label='Error') plt.legend(loc='upper right') -plt.ylim(-0.10, 0.20) +plt.ylim(-0.05, 0.55) plt.title(f"Euclid SIR 1D Spectrum at RA={coord.ra.deg:.4f}°, Dec={coord.dec.deg:.4f}°") ``` From 0819e7aae03fa2e83c7208a6a2dec5265365c561 Mon Sep 17 00:00:00 2001 From: KeunhoKim-astro <99432679+KeunhoKim-astro@users.noreply.github.com> Date: Tue, 3 Nov 2026 09:54:55 -0800 Subject: [PATCH 19/27] Change linestyle for unused spectrum plots --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index d5910131..21843724 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -207,10 +207,10 @@ bad_mask = (spectrum['MASK'].value % 2 == 1) | (spectrum['MASK'].value >= 64) bad_mask_blue = (spectrum_blue['MASK'].value % 2 == 1) | (spectrum_blue['MASK'].value >= 64) plt.plot(spectrum['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask, spectrum['SIGNAL']), alpha=0.6, color='red', label='Red Spectrum') -plt.plot(spectrum['WAVELENGTH'], np.ma.masked_where(~bad_mask, spectrum['SIGNAL']), color='red', label='Do not use (Red)', linewidth=2.0) +plt.plot(spectrum['WAVELENGTH'], np.ma.masked_where(~bad_mask, spectrum['SIGNAL']), color='red', label='Do not use (Red)', linestyle=':', linewidth=2.0) plt.plot(spectrum['WAVELENGTH'], np.sqrt(spectrum['VAR']), color='grey', label='Error') plt.plot(spectrum_blue['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask_blue, spectrum_blue['SIGNAL']), alpha=0.5, color='blue', label='Blue Spectrum')#, #color='black', label='Spectrum') -plt.plot(spectrum_blue['WAVELENGTH'], np.ma.masked_where(~bad_mask_blue, spectrum_blue['SIGNAL']), color='blue', label='Do not use (Blue)', linewidth=2.0) +plt.plot(spectrum_blue['WAVELENGTH'], np.ma.masked_where(~bad_mask_blue, spectrum_blue['SIGNAL']), color='blue', label='Do not use (Blue)', linestyle=':', linewidth=2.0) plt.plot(spectrum_blue['WAVELENGTH'], np.sqrt(spectrum_blue['VAR']), color='grey', label='Error') plt.legend(loc='upper right') @@ -313,10 +313,10 @@ bad_mask = (spectrum['MASK'].value % 2 == 1) | (spectrum['MASK'].value >= 64) bad_mask_blue = (spectrum_blue['MASK'].value % 2 == 1) | (spectrum_blue['MASK'].value >= 64) plt.plot(spectrum['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask, spectrum['SIGNAL']), alpha=0.6, color='red', label='Red Spectrum') -plt.plot(spectrum['WAVELENGTH'], np.ma.masked_where(~bad_mask, spectrum['SIGNAL']), color='red', label='Do not use (Red)', linewidth=2.0) +plt.plot(spectrum['WAVELENGTH'], np.ma.masked_where(~bad_mask, spectrum['SIGNAL']), color='red', label='Do not use (Red)', linestyle=':', linewidth=2.0) plt.plot(spectrum['WAVELENGTH'], np.sqrt(spectrum['VAR']), color='grey', label='Error') plt.plot(spectrum_blue['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask_blue, spectrum_blue['SIGNAL']), alpha=0.5, color='blue', label='Blue Spectrum')#, #color='black', label='Spectrum') -plt.plot(spectrum_blue['WAVELENGTH'], np.ma.masked_where(~bad_mask_blue, spectrum_blue['SIGNAL']), color='blue', label='Do not use (Blue)', linewidth=2.0) +plt.plot(spectrum_blue['WAVELENGTH'], np.ma.masked_where(~bad_mask_blue, spectrum_blue['SIGNAL']), color='blue', label='Do not use (Blue)', linestyle=':', linewidth=2.0) plt.plot(spectrum_blue['WAVELENGTH'], np.sqrt(spectrum_blue['VAR']), color='grey', label='Error') plt.legend(loc='upper right') @@ -419,10 +419,10 @@ bad_mask = (spectrum['MASK'].value % 2 == 1) | (spectrum['MASK'].value >= 64) bad_mask_blue = (spectrum_blue['MASK'].value % 2 == 1) | (spectrum_blue['MASK'].value >= 64) plt.plot(spectrum['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask, spectrum['SIGNAL']), alpha=0.6, color='red', label='Red Spectrum') -plt.plot(spectrum['WAVELENGTH'], np.ma.masked_where(~bad_mask, spectrum['SIGNAL']), color='red', label='Do not use (Red)', linewidth=2.0) +plt.plot(spectrum['WAVELENGTH'], np.ma.masked_where(~bad_mask, spectrum['SIGNAL']), color='red', label='Do not use (Red)', linestyle=':', linewidth=2.0) plt.plot(spectrum['WAVELENGTH'], np.sqrt(spectrum['VAR']), color='grey', label='Error') plt.plot(spectrum_blue['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask_blue, spectrum_blue['SIGNAL']), alpha=0.5, color='blue', label='Blue Spectrum')#, #color='black', label='Spectrum') -plt.plot(spectrum_blue['WAVELENGTH'], np.ma.masked_where(~bad_mask_blue, spectrum_blue['SIGNAL']), color='blue', label='Do not use (Blue)', linewidth=2.0) +plt.plot(spectrum_blue['WAVELENGTH'], np.ma.masked_where(~bad_mask_blue, spectrum_blue['SIGNAL']), color='blue', label='Do not use (Blue)', linestyle=':', linewidth=2.0) plt.plot(spectrum_blue['WAVELENGTH'], np.sqrt(spectrum_blue['VAR']), color='grey', label='Error') plt.legend(loc='upper right') From 205c571f45815b7ea524da0a35228b4c724bbd78 Mon Sep 17 00:00:00 2001 From: xoubish Date: Fri, 6 Nov 2026 08:40:52 -0800 Subject: [PATCH 20/27] Restructure 1D spectra notebook to reach the first plot sooner Plot the spectrum with the most usable flux bins right after reading the spectra, and move the grism and deep/wide tile explanation, the best-spectrum selection, the redshift lookup and the emission-line plot after it. Use the UNCERTAINTY column instead of sqrt(VAR), call quantity_support in the imports cell, trim the learning goals, and note that IRSA temporarily removed the DR1 SSA collection. --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 533 +++++++++--------- 1 file changed, 272 insertions(+), 261 deletions(-) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index 21843724..6ea2f5a9 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -33,406 +33,417 @@ authors: +++ By the end of this tutorial, you will: -- Understand the basic characteristics of Euclid DR1 SIR 1D spectra. -- Examine the provided boolean masks -- Make a simple plot of a Euclid spectrum. +- know how to search for and retrieve the spectra of a galaxy with IRSA's Simple Spectral Access (SSA) service; +- know how to use the MASK column to pick the flux bins to plot; +- understand why a galaxy can have several spectra, from the red and blue grisms and from the deep and wide tiles, and how to pick the best one; +- know how to get the spectroscopic redshift of a galaxy from the DR1 SPE catalog and mark the emission lines on its spectrum; +- know how to explore the spectra of randomly selected galaxies. +++ ## Introduction - -Euclid launched in July 2023 as a European Space Agency (ESA) mission with contributions from NASA. -The primary science goals of Euclid are to better understand the composition and evolution of the dark Universe. -The Euclid mission provides space-based imaging and spectroscopy, complemented by ground-based imaging, to achieve these goals. -These data will be archived by multiple global repositories, including IRSA, where they will support a wide range of astrophysical research. -Euclid Data Release 1 (DR1) will include imaging, spectroscopy, and catalogs covering approximately 1,900 square degrees of the Euclid Wide Survey, along with observations of the Euclid Deep Fields. Further information about Euclid DR1 can be found at: https://euclid.caltech.edu/page/euclid-dr1 ++++ +Euclid launched in July 2023 as a European Space Agency (ESA) mission with involvement by NASA. +The primary science goals of Euclid are to better understand the composition and evolution of the dark Universe. +The Euclid mission is providing space-based imaging and spectroscopy as well as supporting ground-based imaging to achieve these primary goals. +These data are archived by multiple global repositories, including IRSA, where they will support transformational work in many areas of astrophysics. -Among the DR1 data products are the one-dimensional (1D) spectra extracted from NISP slitless spectroscopic observations by the SIR Processing Function. +Euclid Data Release 1 (DR1) comprises about 1900 sq deg of imaging, spectroscopy, and catalogs from the Euclid Wide Survey (EWS), which will eventually cover about 14,000 sq deg, and from the Euclid Deep Survey (EDS), which covers about 53 sq deg in the three Euclid Deep Fields (North, South, and Fornax). +It follows Quick Release 1 (Q1), which covered about 63 sq deg with a single pass over each of the three Euclid Deep Fields and the dark cloud LDN 1641; all of the DR1 data, including the areas observed in Q1, have been reprocessed with updated pipelines and calibrations. +Further information about Euclid DR1 can be found at https://euclid.caltech.edu/page/euclid-dr1. + +Among the data products included in DR1 are the one-dimensional (1D) spectra extracted from the NISP slitless spectroscopic observations by the SIR (Spectroscopic Imaging Reduction) processing function. This notebook provides an introduction to the Euclid DR1 SIR 1D spectra. If you have questions about it, please contact the [IRSA helpdesk](https://irsa.ipac.caltech.edu/docs/help_desk.html). +++ ## Imports - ```{important} We rely on ``astroquery`` features that have been recently added, so please make sure you have version v0.4.10 or newer installed. ``` ```{code-cell} ipython3 -# Uncomment the next line to install dependencies if needed -# !pip install matplotlib astropy 'astroquery>=0.4.10' +# Uncomment the next line to install dependencies if needed. +# !pip install numpy matplotlib astropy 'astroquery>=0.4.10' ``` ```{code-cell} ipython3 +import warnings +from urllib.error import HTTPError + import numpy as np + import matplotlib.pyplot as plt -from astropy.io import fits -from astropy.table import QTable -from astropy import units as u from astropy.coordinates import SkyCoord +from astropy.table import QTable from astropy.utils.data import conf from astropy.visualization import quantity_support +from astropy import units as u from astroquery.ipac.irsa import Irsa -#suppress warnings about deprecated units -import warnings -warnings.filterwarnings( - "ignore", - message="The unit 'Angstrom' has been deprecated", - category=u.UnitsWarning, -) - -warnings.filterwarnings( - "ignore", - message="The unit 'erg' has been deprecated", - category=u.UnitsWarning, -) - -# The Euclid spectrum files are large and the time it takes to read -# them can exceed astropy's default timeout limit. Increase it. -conf.remote_timeout = 120 -``` +# Suppress warnings about deprecated units in the spectrum files +warnings.filterwarnings('ignore', message="The unit 'Angstrom' has been deprecated", category=u.UnitsWarning) +warnings.filterwarnings('ignore', message="The unit 'erg' has been deprecated", category=u.UnitsWarning) -## 1. Search for the spectrum of a specific galaxy +# Let matplotlib pick up the axis units from the quantities we plot +quantity_support() -First, explore what Euclid catalogs are available. Note that we need to use the object ID for our targets to be able to download their spectrum. +# The Euclid spectrum files can take a while to read, +# which can exceed astropy's default timeout limit. Increase it. +conf.remote_timeout = 120 +``` -Search for spectra collections in IRSA. + ```{code-cell} ipython3 -Irsa.list_collections(servicetype="ssa") +# DR1 is not public yet, so we query IRSA's development server. +Irsa.tap_url = 'https://irsadev.ipac.caltech.edu/TAP' +Irsa.ssa_url = 'https://irsadev.ipac.caltech.edu/SSA' ``` + + ```{code-cell} ipython3 -euclid_ssa_collection = 'euclid_dr1_DpdSirCombinedSpectra' -``` +# TEMPORARY: the SSA service does not return DR1 spectra yet, so we emulate +# Irsa.query_ssa with a TAP query on IRSA's CAOM tables, which already have them. +from astropy.table import Table -## 2. Search for the spectrum of a specific galaxy in the 1D spectra table -```{code-cell} ipython3 -coord = SkyCoord( - ra=272.3240 * u.deg, - dec=68.2962 * u.deg, - frame="icrs" -) +def query_ssa_from_caom(*, pos, radius, collection): + query = f""" + SELECT a.uri + FROM euclid.plane_euclid_dr1 AS p + JOIN euclid.observation_euclid_dr1 AS o ON o.obsid = p.obsid + JOIN euclid.artifact_euclid_dr1 AS a ON a.planeid = p.planeid + WHERE o.collection = '{collection}' + AND CONTAINS(p.pt, CIRCLE('ICRS', {pos.ra.deg}, {pos.dec.deg}, {radius.to(u.deg).value})) = 1 + """ + uris = Irsa.query_tap(query, async_job=True).to_table()['uri'] + return Table({'s_ra': [pos.ra.deg] * len(uris), 's_dec': [pos.dec.deg] * len(uris), + 'access_url': [f'https://irsadev.ipac.caltech.edu/{uri}' for uri in uris]}) + -search_radius = 1.0 * u.arcsec +Irsa.query_ssa = query_ssa_from_caom ``` -Query the IRSA SSA service for spectra near this position +## 1. Search for the spectra of a galaxy + +IRSA's SSA service serves several spectra collections; they can be listed with the `list_collections` method. +The DR1 SIR 1D spectra are in the `euclid_dr1_DpdSirCombinedSpectra` collection (`euclid_DpdSirCombinedSpectra` holds the Q1 spectra). ```{code-cell} ipython3 -#=====This part to be removed once the dr1 becomes public==== -irsa_dev = IrsaClass() -irsa_dev.ssa_url = "https://irsadev.ipac.caltech.edu/SSA" -#============================================================ - -#===ssa_result = irsa_dev.query_ssa --> ssa_result = Irsa.query_ssa, once the dr1 becomes public== -ssa_result = irsa_dev.query_ssa( - pos=coord, - radius=search_radius, - collection="euclid_dr1_DpdSirCombinedSpectra", -) - -#check whether any spectra were found -len(ssa_result) +Irsa.list_collections(servicetype='ssa') ``` -Pull out the file name from the ``result`` table: - ```{code-cell} ipython3 -# Extract the single SSA result row -row = ssa_result[0] #in case there is more than one spectra in the search radius -row_blue = ssa_result[1] #the blue grism of the same galaxy within the deep field - - -# Each SSA row provides a direct URL to the spectrum file -spectrum_path = row["access_url"] -spectrum_path - -spectrum_path_blue = row_blue["access_url"] -spectrum_path_blue +euclid_ssa_collection = 'euclid_dr1_DpdSirCombinedSpectra' ``` -## 3. Read in the spectrum for only our specific object - -`spectrum_path` is a url that will return a VOTable containing the spectrum of our object. +We start with a galaxy in the Euclid Deep Field North, and search the collection for spectra within 1 arcsec of it: ```{code-cell} ipython3 -spectrum = QTable.read(spectrum_path) -spectrum_blue = QTable.read(spectrum_path_blue) +coord = SkyCoord(272.3240, 68.2962, unit='deg', frame='icrs') +search_radius = 1 * u.arcsec + +ssa_result = Irsa.query_ssa(pos=coord, radius=search_radius, collection=euclid_ssa_collection) + +print(f'Found {len(ssa_result)} spectra') ``` +Each row of the result is one spectrum, and its `access_url` column gives the URL of the spectrum file. +A galaxy can have several spectra; we explain why in section 3. + ```{code-cell} ipython3 -spectrum +ssa_result['s_ra', 's_dec', 'access_url'] ``` -## 4. Plot the image of the extracted spectrum +## 2. Read in the spectra and plot one of them -```{tip} -As we use astropy.visualization's ``quantity_support``, matplotlib automatically picks up the axis units from the quantities we plot. -``` +Each `access_url` returns a VOTable containing the spectrum, which we read into an astropy table: ```{code-cell} ipython3 -quantity_support() +spectra = [QTable.read(url) for url in ssa_result['access_url']] ``` ```{note} -The 1D combined spectra table contains 6 columns, below are a few highlights: +Some highlights of the columns of the 1D spectra: - WAVELENGTH is in Angstroms by default. - SIGNAL is the flux. The values are scaled and the scaling factor is included in the column's units. This value corresponds to the `'FSCALE'` entry in the HDU header of the original FITS file. -- MASK values can be used to determine which flux bins to discard. MASK = odd and MASK >=64 means the flux bins not be used. +- VAR is the variance of the flux, and UNCERTAINTY is its square root, the flux uncertainty. +- MASK values can be used to determine which flux bins to discard: flux bins with an odd MASK value or a MASK value of 64 or more should not be used. +- NDITH is the number of dithered exposures that contribute to each flux bin. ``` -We investigate the MASK column to see which flux bins are recommended to keep vs "Do Not Use" +Before plotting, we use the MASK column to find the flux bins not to use: ```{code-cell} ipython3 -plt.plot(spectrum['WAVELENGTH'].to(u.micron), spectrum['MASK'], alpha=0.6, color='red') -plt.plot(spectrum_blue['WAVELENGTH'].to(u.micron), spectrum_blue['MASK'], alpha=0.6, color='blue') -plt.ylabel('Mask value') -plt.title('Values of MASK by flux bin') +def bad_flux_bins(spectrum): + mask = spectrum['MASK'].value + return (mask % 2 == 1) | (mask >= 64) ``` -We use the MASK column to create a boolean mask for values to ignore. We use the inverse of this mask to mark the flux bins to use. +Let's plot the spectrum with the most usable flux bins, with the flux as a solid line and its uncertainty as a thin line: ```{code-cell} ipython3 -bad_mask = (spectrum['MASK'].value % 2 == 1) | (spectrum['MASK'].value >= 64) -bad_mask_blue = (spectrum_blue['MASK'].value % 2 == 1) | (spectrum_blue['MASK'].value >= 64) - -plt.plot(spectrum['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask, spectrum['SIGNAL']), alpha=0.6, color='red', label='Red Spectrum') -plt.plot(spectrum['WAVELENGTH'], np.ma.masked_where(~bad_mask, spectrum['SIGNAL']), color='red', label='Do not use (Red)', linestyle=':', linewidth=2.0) -plt.plot(spectrum['WAVELENGTH'], np.sqrt(spectrum['VAR']), color='grey', label='Error') -plt.plot(spectrum_blue['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask_blue, spectrum_blue['SIGNAL']), alpha=0.5, color='blue', label='Blue Spectrum')#, #color='black', label='Spectrum') -plt.plot(spectrum_blue['WAVELENGTH'], np.ma.masked_where(~bad_mask_blue, spectrum_blue['SIGNAL']), color='blue', label='Do not use (Blue)', linestyle=':', linewidth=2.0) -plt.plot(spectrum_blue['WAVELENGTH'], np.sqrt(spectrum_blue['VAR']), color='grey', label='Error') - -plt.legend(loc='upper right') -plt.ylim(-0.05, 0.55) -plt.title(f"Euclid SIR 1D Spectrum at RA={coord.ra.deg:.4f}°, Dec={coord.dec.deg:.4f}°") -``` +spectrum = max(spectra, key=lambda spectrum: np.sum(~bad_flux_bins(spectrum))) -## 5. Repeat Steps 2-4 for a different galaxy -## 2. Search for the spectrum of a specific galaxy in the 1D spectra table - -```{code-cell} ipython3 -coord = SkyCoord( - ra=271.2353 * u.deg, - dec=65.0631 * u.deg, - frame="icrs" -) +bad = bad_flux_bins(spectrum) +wavelength = spectrum['WAVELENGTH'].to(u.micron) -search_radius = 1.0 * u.arcsec +fig, ax = plt.subplots(figsize=(12, 4)) +ax.plot(wavelength, np.ma.masked_where(bad, spectrum['SIGNAL']), color='tab:red', label='Flux') +ax.plot(wavelength, np.ma.masked_where(bad, spectrum['UNCERTAINTY']), color='tab:red', linewidth=0.5, label='Uncertainty') +ax.set_title(f'Euclid SIR 1D spectrum at RA={coord.ra.deg:.4f}°, Dec={coord.dec.deg:.4f}°') +ax.legend() +plt.show() ``` -Query the IRSA SSA service for spectra near this position +The strong emission line near 1.76 micron is Hα, and the lines near 1.3 micron are Hβ and [OIII]; we will confirm this with the redshift of the galaxy in section 4. -```{code-cell} ipython3 -#=====This part to be removed once the dr1 becomes public==== -irsa_dev = IrsaClass() -irsa_dev.ssa_url = "https://irsadev.ipac.caltech.edu/SSA" -#============================================================ - -#===ssa_result = irsa_dev.query_ssa --> ssa_result = Irsa.query_ssa, once the dr1 becomes public== -ssa_result = irsa_dev.query_ssa( - pos=coord, - radius=search_radius, - collection="euclid_dr1_DpdSirCombinedSpectra", -) - -#check whether any spectra were found -len(ssa_result) -``` +## 3. Why several spectra? Red and blue grisms, deep and wide tiles -Pull out the file name from the ``result`` table: +NISP takes slitless spectra with two kinds of grisms: -```{code-cell} ipython3 -# Extract the single SSA result row -row = ssa_result[0] #in case there is more than one spectra in the search radius -row_blue = ssa_result[1] #the blue grism of the same galaxy within the deep field +* **Red grisms** cover about 1.2 to 1.9 micron and are used in both the Euclid Wide Survey and the Euclid Deep Survey. +* **The blue grism** covers about 0.9 to 1.4 micron and is used only in the Euclid Deep Survey. +A galaxy in the Euclid Wide Survey has only red grism spectra, while a galaxy in the Euclid Deep Fields can have spectra from both kinds of grism. +Each spectrum is a separate entry in IRSA's spectra collection. -# Each SSA row provides a direct URL to the spectrum file -spectrum_path = row["access_url"] -spectrum_path +A galaxy can also have several spectra from the same kind of grism. +As with the MER mosaics (see the [MER mosaics notebook](1_Euclid_intro_MER_images.md)), the Euclid Deep Fields are covered by both deep and wide tiles: the deep tiles combine all of the observations, while the wide tiles have several spectra built from different subsets of them. +These spectra differ in depth, and some of them have no usable flux bins at all. -spectrum_path_blue = row_blue["access_url"] -spectrum_path_blue -``` +We tell the red and blue grism spectra apart by their wavelength range (blue grism spectra start below 1.1 micron): -## 3. Read in the spectrum for only our specific object +```{code-cell} ipython3 +def grism_name(spectrum): + return 'Blue grism' if spectrum['WAVELENGTH'].min() < 1.1 * u.micron else 'Red grism' +``` -`spectrum_path` is a url that will return a VOTable containing the spectrum of our object. +Let's compare the spectra we found: their grism, wavelength range, the largest number of dithered exposures in a flux bin, and the number of usable flux bins: ```{code-cell} ipython3 -spectrum = QTable.read(spectrum_path) -spectrum_blue = QTable.read(spectrum_path_blue) +summary = QTable({ + 'grism': [grism_name(spectrum) for spectrum in spectra], + 'min_wavelength': [spectrum['WAVELENGTH'].min().to(u.micron) for spectrum in spectra], + 'max_wavelength': [spectrum['WAVELENGTH'].max().to(u.micron) for spectrum in spectra], + 'max_ndith': [spectrum['NDITH'].max() for spectrum in spectra], + 'usable_bins': [np.sum(~bad_flux_bins(spectrum)) for spectrum in spectra], +}) +summary.sort(['grism', 'usable_bins'], reverse=True) +summary ``` +The spectra with many dithered exposures come from the deep tile, and the others from the wide tiles; some of the wide tile spectra have no usable flux bins at all. +The spectrum we plotted above is the deep red grism one. +For each kind of grism, we keep the spectrum with the most usable flux bins: + ```{code-cell} ipython3 -spectrum -``` +def best_spectra(spectra): + best = {} + for spectrum in sorted(spectra, key=lambda spectrum: np.sum(~bad_flux_bins(spectrum)), reverse=True): + best.setdefault(grism_name(spectrum), spectrum) + return best -## 4. Plot the image of the extracted spectrum -```{tip} -As we use astropy.visualization's ``quantity_support``, matplotlib automatically picks up the axis units from the quantities we plot. +best = best_spectra(spectra) +list(best) ``` +## 4. Get the redshift of the galaxy + +To identify the emission lines in the spectra, we need the redshift of the galaxy. +The DR1 SPE catalog gives the spectroscopic redshifts measured from these spectra, but it has no coordinates, so we join it with the MER catalog on `object_id` (see the [MER catalogs notebook](2_Euclid_intro_MER_catalog.md)). +Our galaxy is in a deep tile, so we use the deep versions of both catalogs, and keep the best redshift estimate (`spe_rank = 0`): + ```{code-cell} ipython3 -quantity_support() -``` +def get_redshift(coord, search_radius=1 * u.arcsec): + query = f""" + SELECT mer.object_id, mer.ra, mer.dec, spe.spe_z, spe.spe_z_prob + FROM euclid_dr1_mer_catalogue_deep_survey AS mer + JOIN euclid_dr1_spectro_z_spe_galaxy_candidates_deep AS spe ON spe.object_id = mer.object_id + WHERE spe.spe_rank = 0 + AND CONTAINS(POINT('ICRS', mer.ra, mer.dec), + CIRCLE('ICRS', {coord.ra.deg}, {coord.dec.deg}, {search_radius.to(u.deg).value})) = 1 + """ + return Irsa.query_tap(query, async_job=True).to_table() -```{note} -The 1D combined spectra table contains 6 columns, below are a few highlights: -- WAVELENGTH is in Angstroms by default. -- SIGNAL is the flux. The values are scaled and the scaling factor is included in the column's units. This value corresponds to the `'FSCALE'` entry in the HDU header of the original FITS file. -- MASK values can be used to determine which flux bins to discard. MASK = odd and MASK >=64 means the flux bins not be used. +galaxy = get_redshift(coord) +galaxy ``` -We investigate the MASK column to see which flux bins are recommended to keep vs "Do Not Use" - ```{code-cell} ipython3 -plt.plot(spectrum['WAVELENGTH'].to(u.micron), spectrum['MASK'], alpha=0.6, color='red') -plt.plot(spectrum_blue['WAVELENGTH'].to(u.micron), spectrum_blue['MASK'], alpha=0.6, color='blue') -plt.ylabel('Mask value') -plt.title('Values of MASK by flux bin') +redshift = galaxy['spe_z'][0] ``` -We use the MASK column to create a boolean mask for values to ignore. We use the inverse of this mask to mark the flux bins to use. +## 5. Plot the best spectra and mark the emission lines + +These are the rest-frame vacuum wavelengths of some of the strongest emission lines of galaxies; at the redshift of the galaxy, they are shifted by a factor of (1 + z). +Hα is blended with the [NII] lines, and the [SII] and [OII] doublets are not resolved at the resolution of the Euclid spectra, so we mark each of them with a single label. ```{code-cell} ipython3 -bad_mask = (spectrum['MASK'].value % 2 == 1) | (spectrum['MASK'].value >= 64) -bad_mask_blue = (spectrum_blue['MASK'].value % 2 == 1) | (spectrum_blue['MASK'].value >= 64) - -plt.plot(spectrum['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask, spectrum['SIGNAL']), alpha=0.6, color='red', label='Red Spectrum') -plt.plot(spectrum['WAVELENGTH'], np.ma.masked_where(~bad_mask, spectrum['SIGNAL']), color='red', label='Do not use (Red)', linestyle=':', linewidth=2.0) -plt.plot(spectrum['WAVELENGTH'], np.sqrt(spectrum['VAR']), color='grey', label='Error') -plt.plot(spectrum_blue['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask_blue, spectrum_blue['SIGNAL']), alpha=0.5, color='blue', label='Blue Spectrum')#, #color='black', label='Spectrum') -plt.plot(spectrum_blue['WAVELENGTH'], np.ma.masked_where(~bad_mask_blue, spectrum_blue['SIGNAL']), color='blue', label='Do not use (Blue)', linestyle=':', linewidth=2.0) -plt.plot(spectrum_blue['WAVELENGTH'], np.sqrt(spectrum_blue['VAR']), color='grey', label='Error') - -plt.legend(loc='upper right') -plt.ylim(-0.05, 0.55) -plt.title(f"Euclid SIR 1D Spectrum at RA={coord.ra.deg:.4f}°, Dec={coord.dec.deg:.4f}°") +emission_lines = { + '[OII]': 3728.5 * u.AA, + '[NeIII]': 3870.9 * u.AA, + 'Hγ': 4341.7 * u.AA, + 'Hβ': 4862.7 * u.AA, + '[OIII]': 5008.2 * u.AA, + 'Hα': 6564.6 * u.AA, + '[SII]': 6725.5 * u.AA, +} ``` -## 6. Repeat Steps 2-4 for a different galaxy -## 2. Search for the spectrum of a specific galaxy in the 1D spectra table +We now wrap the plotting into a function that plots the best spectrum of each grism. +We plot the flux bins to use as solid lines, the flux bins not to use as dotted lines, and the flux uncertainty as thin lines. +We set the y-axis range from the flux bins to use, so that the bad flux bins do not stretch it, and mark the emission lines that fall in the wavelength range of the spectra. ```{code-cell} ipython3 -coord = SkyCoord( - ra=270.7769 * u.deg, - dec=64.7781 * u.deg, - frame="icrs" -) +grism_colors = {'Red grism': 'tab:red', 'Blue grism': 'tab:blue'} -search_radius = 1.0 * u.arcsec -``` -Query the IRSA SSA service for spectra near this position +def plot_spectra(spectra, title, redshift=None): + fig, ax = plt.subplots(figsize=(12, 4.5)) + for name, spectrum in spectra.items(): + wavelength = spectrum['WAVELENGTH'].to(u.micron) + bad = bad_flux_bins(spectrum) + color = grism_colors[name] -```{code-cell} ipython3 -#=====This part to be removed once the dr1 becomes public==== -irsa_dev = IrsaClass() -irsa_dev.ssa_url = "https://irsadev.ipac.caltech.edu/SSA" -#============================================================ - -#===ssa_result = irsa_dev.query_ssa --> ssa_result = Irsa.query_ssa, once the dr1 becomes public== -ssa_result = irsa_dev.query_ssa( - pos=coord, - radius=search_radius, - collection="euclid_dr1_DpdSirCombinedSpectra", -) - -#check whether any spectra were found -len(ssa_result) -``` + ax.plot(wavelength, np.ma.masked_where(bad, spectrum['SIGNAL']), color=color, alpha=0.8, label=name) + ax.plot(wavelength, np.ma.masked_where(~bad, spectrum['SIGNAL']), color=color, linestyle=':', alpha=0.6) + ax.plot(wavelength, spectrum['UNCERTAINTY'], color=color, linewidth=0.5, alpha=0.5) -Pull out the file name from the ``result`` table: + good_flux = np.concatenate([spectrum['SIGNAL'][~bad_flux_bins(spectrum)].filled(np.nan) + for spectrum in spectra.values()]) + low, high = np.nanpercentile(good_flux, [1, 100]) + ax.set_ylim(low - 0.1 * (high - low), high + 0.25 * (high - low)) -```{code-cell} ipython3 -# Extract the single SSA result row -row = ssa_result[0] #in case there is more than one spectra in the search radius -row_blue = ssa_result[1] #the blue grism of the same galaxy within the deep field + # Mark the emission lines at the redshift of the galaxy + if redshift is not None: + wave_min = min(spectrum['WAVELENGTH'].min() for spectrum in spectra.values()) + wave_max = max(spectrum['WAVELENGTH'].max() for spectrum in spectra.values()) + for line, rest_wavelength in emission_lines.items(): + observed = (rest_wavelength * (1 + redshift)).to(u.micron) + if wave_min < observed < wave_max: + ax.axvline(observed, color='grey', linestyle='--', linewidth=0.8) + ax.text(observed.value, 0.98, f' {line}', transform=ax.get_xaxis_transform(), + rotation=90, va='top', ha='right', fontsize=9) + title = f'{title}, z = {redshift:.3f}' + + # Legend entries for the line styles + ax.plot([], [], color='grey', linestyle=':', label='Do not use') + ax.plot([], [], color='grey', linewidth=0.5, label='Uncertainty') + ax.set_title(title) + ax.legend(loc='upper left', bbox_to_anchor=(1.01, 1), fontsize='small') + plt.show() -# Each SSA row provides a direct URL to the spectrum file -spectrum_path = row["access_url"] -spectrum_path -spectrum_path_blue = row_blue["access_url"] -spectrum_path_blue +plot_spectra(best, f'Euclid SIR 1D spectra at RA={coord.ra.deg:.4f}°, Dec={coord.dec.deg:.4f}°', redshift) ``` -## 3. Read in the spectrum for only our specific object +## 6. Look closer at the spectrum table and the MASK column -`spectrum_path` is a url that will return a VOTable containing the spectrum of our object. +Now that we have seen the spectra, let's look at the usable flux bins of the red grism spectrum: ```{code-cell} ipython3 -spectrum = QTable.read(spectrum_path) -spectrum_blue = QTable.read(spectrum_path_blue) +red_spectrum = best['Red grism'] +red_spectrum[~bad_flux_bins(red_spectrum)] ``` -```{code-cell} ipython3 -spectrum -``` - -## 4. Plot the image of the extracted spectrum - -```{tip} -As we use astropy.visualization's ``quantity_support``, matplotlib automatically picks up the axis units from the quantities we plot. -``` +The MASK values are bit flags, so each value combines several conditions. +Let's plot them as a function of wavelength, to see where the flux bins not to use are: ```{code-cell} ipython3 -quantity_support() +fig, ax = plt.subplots(figsize=(12, 3)) +for name, spectrum in best.items(): + ax.plot(spectrum['WAVELENGTH'].to(u.micron), spectrum['MASK'], color=grism_colors[name], alpha=0.6, label=name) +ax.set_ylabel('MASK value') +ax.set_title('Values of MASK by flux bin') +ax.legend() +plt.show() ``` -```{note} -The 1D combined spectra table contains 6 columns, below are a few highlights: +Most of the flux bins not to use are at the edges of the wavelength range of each grism, where its throughput is low. -- WAVELENGTH is in Angstroms by default. -- SIGNAL is the flux. The values are scaled and the scaling factor is included in the column's units. This value corresponds to the `'FSCALE'` entry in the HDU header of the original FITS file. -- MASK values can be used to determine which flux bins to discard. MASK = odd and MASK >=64 means the flux bins not be used. -``` +## 7. Explore the spectra of random galaxies -We investigate the MASK column to see which flux bins are recommended to keep vs "Do Not Use" +Now it's your turn to explore! +We select galaxies from the DR1 SPE and MER deep catalogs in a region of the Euclid Deep Field North, pick a few of them at random, and plot their spectra with their emission lines. +To avoid stars and problematic sources, we keep only sources with a high redshift probability (`spe_z_prob`), a low probability of being point-like (`point_like_prob`), and no MER detection quality flags set (`det_quality_flag = 0`), for example for blending with a neighbor. +Change the parameters below to look at other regions, redshift ranges, or numbers of galaxies; change or remove the random seed to get a different selection. +Each time you rerun the plotting cell, it picks new galaxies from the same selection. +Most of these galaxies are much fainter than our first example, so their spectra are noisier, and their emission lines can be weak or missing. ```{code-cell} ipython3 -plt.plot(spectrum['WAVELENGTH'].to(u.micron), spectrum['MASK'], alpha=0.6, color='red') -plt.plot(spectrum_blue['WAVELENGTH'].to(u.micron), spectrum_blue['MASK'], alpha=0.6, color='blue') -plt.ylabel('Mask value') -plt.title('Values of MASK by flux bin') -``` - -We use the MASK column to create a boolean mask for values to ignore. We use the inverse of this mask to mark the flux bins to use. +######################## User defined section ############################ +# Center and radius of the region to select galaxies from +region_center = SkyCoord(271.0, 66.0, unit='deg', frame='icrs') +region_radius = 6 * u.arcmin + +# Redshift range, the minimum probability of the redshift estimate, +# and the maximum probability of the source being point-like +z_min, z_max = 0.9, 1.8 +min_z_prob = 0.99 +max_point_like_prob = 0.5 + +# Number of galaxies to plot, and the random seed +n_galaxies = 3 +rng = np.random.default_rng(seed=42) +########################################################################## + +query = f""" + SELECT mer.object_id, mer.ra, mer.dec, spe.spe_z, spe.spe_z_prob + FROM euclid_dr1_mer_catalogue_deep_survey AS mer + JOIN euclid_dr1_spectro_z_spe_galaxy_candidates_deep AS spe ON spe.object_id = mer.object_id + WHERE spe.spe_rank = 0 + AND spe.spe_z BETWEEN {z_min} AND {z_max} + AND spe.spe_z_prob > {min_z_prob} + AND mer.point_like_prob < {max_point_like_prob} + AND mer.det_quality_flag = 0 + AND CONTAINS(POINT('ICRS', mer.ra, mer.dec), + CIRCLE('ICRS', {region_center.ra.deg}, {region_center.dec.deg}, {region_radius.to(u.deg).value})) = 1 +""" +galaxies = Irsa.query_tap(query, async_job=True).to_table() +print(f'Found {len(galaxies)} galaxies') +``` + +We wrap sections 1 to 3 into a function, which returns the best spectrum of each grism near a position. +If a spectrum file cannot be read, we skip it and use the other spectra of the galaxy: ```{code-cell} ipython3 -bad_mask = (spectrum['MASK'].value % 2 == 1) | (spectrum['MASK'].value >= 64) -bad_mask_blue = (spectrum_blue['MASK'].value % 2 == 1) | (spectrum_blue['MASK'].value >= 64) - -plt.plot(spectrum['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask, spectrum['SIGNAL']), alpha=0.6, color='red', label='Red Spectrum') -plt.plot(spectrum['WAVELENGTH'], np.ma.masked_where(~bad_mask, spectrum['SIGNAL']), color='red', label='Do not use (Red)', linestyle=':', linewidth=2.0) -plt.plot(spectrum['WAVELENGTH'], np.sqrt(spectrum['VAR']), color='grey', label='Error') -plt.plot(spectrum_blue['WAVELENGTH'].to(u.micron), np.ma.masked_where(bad_mask_blue, spectrum_blue['SIGNAL']), alpha=0.5, color='blue', label='Blue Spectrum')#, #color='black', label='Spectrum') -plt.plot(spectrum_blue['WAVELENGTH'], np.ma.masked_where(~bad_mask_blue, spectrum_blue['SIGNAL']), color='blue', label='Do not use (Blue)', linestyle=':', linewidth=2.0) -plt.plot(spectrum_blue['WAVELENGTH'], np.sqrt(spectrum_blue['VAR']), color='grey', label='Error') - -plt.legend(loc='upper right') -plt.ylim(-0.05, 0.55) -plt.title(f"Euclid SIR 1D Spectrum at RA={coord.ra.deg:.4f}°, Dec={coord.dec.deg:.4f}°") +def get_best_spectra(coord, search_radius=1 * u.arcsec): + ssa_result = Irsa.query_ssa(pos=coord, radius=search_radius, collection=euclid_ssa_collection) + + spectra = [] + for url in ssa_result['access_url']: + try: + spectra.append(QTable.read(url)) + except HTTPError as error: + print(f'Skipping a spectrum that could not be read ({error}): {url}') + return best_spectra(spectra) ``` +```{code-cell} ipython3 +for galaxy in galaxies[rng.choice(len(galaxies), size=min(n_galaxies, len(galaxies)), replace=False)]: + galaxy_coord = SkyCoord(galaxy['ra'], galaxy['dec'], unit='deg') + galaxy_spectra = get_best_spectra(galaxy_coord) + if not galaxy_spectra: + print(f"No spectra found for object {galaxy['object_id']}") + continue + plot_spectra(galaxy_spectra, f"Object {galaxy['object_id']}", galaxy['spe_z']) +``` ## About this Notebook -**Updated**: 2026-01-13 +**Updated**: 2026-11-12 **Contact:** [the IRSA Helpdesk](https://irsa.ipac.caltech.edu/docs/help_desk.html) with questions or reporting problems. From 30b2f0ccac9156e44a8a214a64d3aa83fc87bfe1 Mon Sep 17 00:00:00 2001 From: xoubish Date: Fri, 6 Nov 2026 09:02:52 -0800 Subject: [PATCH 21/27] Cite the DR1 SIR paper and update the gallery description for notebook 3 Add Euclid Collaboration: Scodeggio et al. (2026, in prep.) to the introduction and a References section, and describe the DR1 version of the notebook in notebook_metadata.yml. --- notebook_metadata.yml | 2 +- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/notebook_metadata.yml b/notebook_metadata.yml index 12a8f26f..5c9292e1 100644 --- a/notebook_metadata.yml +++ b/notebook_metadata.yml @@ -13,7 +13,7 @@ - title: SIR 1D Spectra file: tutorials/euclid/3_Euclid_intro_1D_spectra.md section: Euclid - description: Load a galaxy spectrum and plot it. Understand the wavelength, flux, and mask values. + description: Search for the Euclid DR1 SIR spectra of a galaxy, pick the best red and blue grism spectra, and plot them with their emission lines. - title: PHZ Catalogs file: tutorials/euclid/4_Euclid_intro_PHZ_catalog.md section: Euclid diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index 6ea2f5a9..0221248d 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -55,6 +55,7 @@ It follows Quick Release 1 (Q1), which covered about 63 sq deg with a single pas Further information about Euclid DR1 can be found at https://euclid.caltech.edu/page/euclid-dr1. Among the data products included in DR1 are the one-dimensional (1D) spectra extracted from the NISP slitless spectroscopic observations by the SIR (Spectroscopic Imaging Reduction) processing function. +The SIR processing for DR1 is described in detail in Euclid Collaboration: Scodeggio et al. (2026), see the [References](#references) section below. This notebook provides an introduction to the Euclid DR1 SIR 1D spectra. If you have questions about it, please contact the [IRSA helpdesk](https://irsa.ipac.caltech.edu/docs/help_desk.html). @@ -442,6 +443,14 @@ for galaxy in galaxies[rng.choice(len(galaxies), size=min(n_galaxies, len(galaxi plot_spectra(galaxy_spectra, f"Object {galaxy['object_id']}", galaxy['spe_z']) ``` +## References + + + +- Euclid Collaboration: Scodeggio, M., et al. 2026, *Euclid Data Release 1 (DR1): The SIR spectroscopic processing*, A&A, in prep. + ++++ + ## About this Notebook **Updated**: 2026-11-12 From f733bf1ebf56595e138fa106df92ec5f44409cf6 Mon Sep 17 00:00:00 2001 From: xoubish Date: Fri, 6 Nov 2026 11:57:52 -0800 Subject: [PATCH 22/27] Find the spectra of a galaxy from its object ID instead of the SSA service The DR1 SIR spectra will not be served by SSA/ObsTAP/CAOM at release, so find the galaxy and its redshift with one TAP query on the MER and SPE catalogs, look up its spectrum files and HDUs in euclid.objectid_spectrafile_association_dr1, and read them through the spectrumDM service. Drop the temporary SSA stand-in and the collection listing, note the coming SSA access, and add the spe_z_rel reliability cut to the random galaxy selection. --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 166 ++++++++---------- 1 file changed, 74 insertions(+), 92 deletions(-) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index 0221248d..929d8cd1 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -33,10 +33,11 @@ authors: +++ By the end of this tutorial, you will: -- know how to search for and retrieve the spectra of a galaxy with IRSA's Simple Spectral Access (SSA) service; +- know how to find a galaxy and its spectroscopic redshift in the DR1 MER and SPE catalogs with IRSA's Table Access Protocol (TAP) service; +- know how to find and retrieve the spectra of a galaxy from its object ID; - know how to use the MASK column to pick the flux bins to plot; -- understand why a galaxy can have several spectra, from the red and blue grisms and from the deep and wide tiles, and how to pick the best one; -- know how to get the spectroscopic redshift of a galaxy from the DR1 SPE catalog and mark the emission lines on its spectrum; +- understand the difference between the red and blue grism spectra, and how to pick the best spectrum of each grism; +- know how to plot a Euclid spectrum and mark its emission lines; - know how to explore the spectra of randomly selected galaxies. +++ @@ -105,71 +106,87 @@ conf.remote_timeout = 120 ```{code-cell} ipython3 # DR1 is not public yet, so we query IRSA's development server. Irsa.tap_url = 'https://irsadev.ipac.caltech.edu/TAP' -Irsa.ssa_url = 'https://irsadev.ipac.caltech.edu/SSA' ``` - +## 1. Find a galaxy and its redshift in the DR1 catalogs -```{code-cell} ipython3 -# TEMPORARY: the SSA service does not return DR1 spectra yet, so we emulate -# Irsa.query_ssa with a TAP query on IRSA's CAOM tables, which already have them. -from astropy.table import Table +We start with a galaxy in the Euclid Deep Field North. +To find its spectra, we need its Euclid object ID, and to identify the emission lines in the spectra, we need its redshift. +Both come from the DR1 catalogs: the MER catalog gives the object ID of the source at a position, and the SPE catalog gives the spectroscopic redshift measured from its spectra (see the [MER catalogs notebook](2_Euclid_intro_MER_catalog.md) and the [SPE catalogs notebook](5_Euclid_intro_SPE_catalog.md)). +The SPE catalog has no coordinates, so we join it with the MER catalog on `object_id`. +Our galaxy is in a deep tile, so we use the deep versions of both catalogs, and keep the best redshift estimate (`spe_rank = 0`): +```{code-cell} ipython3 +coord = SkyCoord(272.3240, 68.2962, unit='deg', frame='icrs') +search_radius = 1 * u.arcsec +``` -def query_ssa_from_caom(*, pos, radius, collection): +```{code-cell} ipython3 +def find_galaxy(coord, search_radius=1 * u.arcsec): query = f""" - SELECT a.uri - FROM euclid.plane_euclid_dr1 AS p - JOIN euclid.observation_euclid_dr1 AS o ON o.obsid = p.obsid - JOIN euclid.artifact_euclid_dr1 AS a ON a.planeid = p.planeid - WHERE o.collection = '{collection}' - AND CONTAINS(p.pt, CIRCLE('ICRS', {pos.ra.deg}, {pos.dec.deg}, {radius.to(u.deg).value})) = 1 + SELECT mer.object_id, mer.ra, mer.dec, spe.spe_z, spe.spe_z_prob + FROM euclid_dr1_mer_catalogue_deep_survey AS mer + JOIN euclid_dr1_spectro_z_spe_galaxy_candidates_deep AS spe ON spe.object_id = mer.object_id + WHERE spe.spe_rank = 0 + AND CONTAINS(POINT('ICRS', mer.ra, mer.dec), + CIRCLE('ICRS', {coord.ra.deg}, {coord.dec.deg}, {search_radius.to(u.deg).value})) = 1 """ - uris = Irsa.query_tap(query, async_job=True).to_table()['uri'] - return Table({'s_ra': [pos.ra.deg] * len(uris), 's_dec': [pos.dec.deg] * len(uris), - 'access_url': [f'https://irsadev.ipac.caltech.edu/{uri}' for uri in uris]}) + return Irsa.query_tap(query, async_job=True).to_table() -Irsa.query_ssa = query_ssa_from_caom +galaxy = find_galaxy(coord) +galaxy ``` -## 1. Search for the spectra of a galaxy - -IRSA's SSA service serves several spectra collections; they can be listed with the `list_collections` method. -The DR1 SIR 1D spectra are in the `euclid_dr1_DpdSirCombinedSpectra` collection (`euclid_DpdSirCombinedSpectra` holds the Q1 spectra). - ```{code-cell} ipython3 -Irsa.list_collections(servicetype='ssa') +object_id = galaxy['object_id'][0] +redshift = galaxy['spe_z'][0] ``` -```{code-cell} ipython3 -euclid_ssa_collection = 'euclid_dr1_DpdSirCombinedSpectra' -``` +## 2. Find the spectra of the galaxy -We start with a galaxy in the Euclid Deep Field North, and search the collection for spectra within 1 arcsec of it: +The DR1 SIR 1D spectra are stored in large FITS files, one per MER tile, with one extension (HDU) per spectrum. +The table `euclid.objectid_spectrafile_association_dr1` at IRSA lists, for each object ID, the file and the HDU of each of its spectra: ```{code-cell} ipython3 -coord = SkyCoord(272.3240, 68.2962, unit='deg', frame='icrs') -search_radius = 1 * u.arcsec +def find_spectra(object_id): + query = f""" + SELECT objectid, tileid, path, hdu + FROM euclid.objectid_spectrafile_association_dr1 + WHERE objectid = {object_id} + """ + return Irsa.query_tap(query).to_table() -ssa_result = Irsa.query_ssa(pos=coord, radius=search_radius, collection=euclid_ssa_collection) -print(f'Found {len(ssa_result)} spectra') +spectrum_files = find_spectra(object_id) +spectrum_files ``` -Each row of the result is one spectrum, and its `access_url` column gives the URL of the spectrum file. -A galaxy can have several spectra; we explain why in section 3. +IRSA's spectrumDM service converts a given HDU of a spectrum file into a VOTable. +We build the URL of each spectrum from its file path and HDU: + + ```{code-cell} ipython3 -ssa_result['s_ra', 's_dec', 'access_url'] +def spectrum_url(spectrum_file): + return (f"https://irsadev.ipac.caltech.edu/api/spectrumdm/convert/{spectrum_file['path']}" + f"?dataset_id=euclid_combspec&hdu={spectrum_file['hdu']}") + + +spectrum_urls = [spectrum_url(spectrum_file) for spectrum_file in spectrum_files] +spectrum_urls ``` -## 2. Read in the spectra and plot one of them +```{note} +IRSA's Simple Spectral Access (SSA) service will also serve the DR1 SIR 1D spectra, which will allow searching for them by position; this notebook will be updated when it is available. +``` + +## 3. Read in the spectra and plot one of them -Each `access_url` returns a VOTable containing the spectrum, which we read into an astropy table: +Each URL returns a VOTable containing the spectrum, which we read into an astropy table: ```{code-cell} ipython3 -spectra = [QTable.read(url) for url in ssa_result['access_url']] +spectra = [QTable.read(url) for url in spectrum_urls] ``` ```{note} @@ -201,28 +218,22 @@ wavelength = spectrum['WAVELENGTH'].to(u.micron) fig, ax = plt.subplots(figsize=(12, 4)) ax.plot(wavelength, np.ma.masked_where(bad, spectrum['SIGNAL']), color='tab:red', label='Flux') ax.plot(wavelength, np.ma.masked_where(bad, spectrum['UNCERTAINTY']), color='tab:red', linewidth=0.5, label='Uncertainty') -ax.set_title(f'Euclid SIR 1D spectrum at RA={coord.ra.deg:.4f}°, Dec={coord.dec.deg:.4f}°') +ax.set_title(f'Euclid SIR 1D spectrum of object {object_id}') ax.legend() plt.show() ``` -The strong emission line near 1.76 micron is Hα, and the lines near 1.3 micron are Hβ and [OIII]; we will confirm this with the redshift of the galaxy in section 4. +The strong emission line near 1.76 micron is Hα, and the lines near 1.3 micron are Hβ and [OIII]; we will confirm this with the redshift of the galaxy in section 5. -## 3. Why several spectra? Red and blue grisms, deep and wide tiles +## 4. Red and blue grism spectra NISP takes slitless spectra with two kinds of grisms: * **Red grisms** cover about 1.2 to 1.9 micron and are used in both the Euclid Wide Survey and the Euclid Deep Survey. * **The blue grism** covers about 0.9 to 1.4 micron and is used only in the Euclid Deep Survey. -A galaxy in the Euclid Wide Survey has only red grism spectra, while a galaxy in the Euclid Deep Fields can have spectra from both kinds of grism. -Each spectrum is a separate entry in IRSA's spectra collection. - -A galaxy can also have several spectra from the same kind of grism. -As with the MER mosaics (see the [MER mosaics notebook](1_Euclid_intro_MER_images.md)), the Euclid Deep Fields are covered by both deep and wide tiles: the deep tiles combine all of the observations, while the wide tiles have several spectra built from different subsets of them. -These spectra differ in depth, and some of them have no usable flux bins at all. - -We tell the red and blue grism spectra apart by their wavelength range (blue grism spectra start below 1.1 micron): +A galaxy in the Euclid Wide Survey has only a red grism spectrum, while a galaxy in the Euclid Deep Fields, like ours, has spectra from both kinds of grism, each of them a separate spectrum in the files. +We tell them apart by their wavelength range (blue grism spectra start below 1.1 micron): ```{code-cell} ipython3 def grism_name(spectrum): @@ -243,9 +254,8 @@ summary.sort(['grism', 'usable_bins'], reverse=True) summary ``` -The spectra with many dithered exposures come from the deep tile, and the others from the wide tiles; some of the wide tile spectra have no usable flux bins at all. -The spectrum we plotted above is the deep red grism one. -For each kind of grism, we keep the spectrum with the most usable flux bins: +The spectrum we plotted above is the red grism one. +A galaxy can also have several spectra of the same kind of grism, for example when it is covered by several tiles; these can differ in depth, so in general we keep, for each kind of grism, the spectrum with the most usable flux bins: ```{code-cell} ipython3 def best_spectra(spectra): @@ -259,33 +269,6 @@ best = best_spectra(spectra) list(best) ``` -## 4. Get the redshift of the galaxy - -To identify the emission lines in the spectra, we need the redshift of the galaxy. -The DR1 SPE catalog gives the spectroscopic redshifts measured from these spectra, but it has no coordinates, so we join it with the MER catalog on `object_id` (see the [MER catalogs notebook](2_Euclid_intro_MER_catalog.md)). -Our galaxy is in a deep tile, so we use the deep versions of both catalogs, and keep the best redshift estimate (`spe_rank = 0`): - -```{code-cell} ipython3 -def get_redshift(coord, search_radius=1 * u.arcsec): - query = f""" - SELECT mer.object_id, mer.ra, mer.dec, spe.spe_z, spe.spe_z_prob - FROM euclid_dr1_mer_catalogue_deep_survey AS mer - JOIN euclid_dr1_spectro_z_spe_galaxy_candidates_deep AS spe ON spe.object_id = mer.object_id - WHERE spe.spe_rank = 0 - AND CONTAINS(POINT('ICRS', mer.ra, mer.dec), - CIRCLE('ICRS', {coord.ra.deg}, {coord.dec.deg}, {search_radius.to(u.deg).value})) = 1 - """ - return Irsa.query_tap(query, async_job=True).to_table() - - -galaxy = get_redshift(coord) -galaxy -``` - -```{code-cell} ipython3 -redshift = galaxy['spe_z'][0] -``` - ## 5. Plot the best spectra and mark the emission lines These are the rest-frame vacuum wavelengths of some of the strongest emission lines of galaxies; at the redshift of the galaxy, they are shifted by a factor of (1 + z). @@ -348,7 +331,7 @@ def plot_spectra(spectra, title, redshift=None): plt.show() -plot_spectra(best, f'Euclid SIR 1D spectra at RA={coord.ra.deg:.4f}°, Dec={coord.dec.deg:.4f}°', redshift) +plot_spectra(best, f'Euclid SIR 1D spectra of object {object_id}', redshift) ``` ## 6. Look closer at the spectrum table and the MASK column @@ -379,7 +362,7 @@ Most of the flux bins not to use are at the edges of the wavelength range of eac Now it's your turn to explore! We select galaxies from the DR1 SPE and MER deep catalogs in a region of the Euclid Deep Field North, pick a few of them at random, and plot their spectra with their emission lines. -To avoid stars and problematic sources, we keep only sources with a high redshift probability (`spe_z_prob`), a low probability of being point-like (`point_like_prob`), and no MER detection quality flags set (`det_quality_flag = 0`), for example for blending with a neighbor. +To avoid stars and problematic sources, we keep only sources with a reliable redshift (`spe_z_prob` and `spe_z_rel`, see the [SPE catalogs notebook](5_Euclid_intro_SPE_catalog.md)), a low probability of being point-like (`point_like_prob`), and no MER detection quality flags set (`det_quality_flag = 0`), for example for blending with a neighbor. Change the parameters below to look at other regions, redshift ranges, or numbers of galaxies; change or remove the random seed to get a different selection. Each time you rerun the plotting cell, it picks new galaxies from the same selection. Most of these galaxies are much fainter than our first example, so their spectra are noisier, and their emission lines can be weak or missing. @@ -390,10 +373,11 @@ Most of these galaxies are much fainter than our first example, so their spectra region_center = SkyCoord(271.0, 66.0, unit='deg', frame='icrs') region_radius = 6 * u.arcmin -# Redshift range, the minimum probability of the redshift estimate, +# Redshift range, the minimum probability and reliability of the redshift estimate, # and the maximum probability of the source being point-like z_min, z_max = 0.9, 1.8 min_z_prob = 0.99 +min_z_rel = 0.05 max_point_like_prob = 0.5 # Number of galaxies to plot, and the random seed @@ -402,12 +386,13 @@ rng = np.random.default_rng(seed=42) ########################################################################## query = f""" - SELECT mer.object_id, mer.ra, mer.dec, spe.spe_z, spe.spe_z_prob + SELECT mer.object_id, mer.ra, mer.dec, spe.spe_z, spe.spe_z_prob, spe.spe_z_rel FROM euclid_dr1_mer_catalogue_deep_survey AS mer JOIN euclid_dr1_spectro_z_spe_galaxy_candidates_deep AS spe ON spe.object_id = mer.object_id WHERE spe.spe_rank = 0 AND spe.spe_z BETWEEN {z_min} AND {z_max} AND spe.spe_z_prob > {min_z_prob} + AND spe.spe_z_rel > {min_z_rel} AND mer.point_like_prob < {max_point_like_prob} AND mer.det_quality_flag = 0 AND CONTAINS(POINT('ICRS', mer.ra, mer.dec), @@ -417,15 +402,13 @@ galaxies = Irsa.query_tap(query, async_job=True).to_table() print(f'Found {len(galaxies)} galaxies') ``` -We wrap sections 1 to 3 into a function, which returns the best spectrum of each grism near a position. +We wrap sections 2 to 4 into a function, which returns the best spectrum of each grism of an object. If a spectrum file cannot be read, we skip it and use the other spectra of the galaxy: ```{code-cell} ipython3 -def get_best_spectra(coord, search_radius=1 * u.arcsec): - ssa_result = Irsa.query_ssa(pos=coord, radius=search_radius, collection=euclid_ssa_collection) - +def get_best_spectra(object_id): spectra = [] - for url in ssa_result['access_url']: + for url in map(spectrum_url, find_spectra(object_id)): try: spectra.append(QTable.read(url)) except HTTPError as error: @@ -435,8 +418,7 @@ def get_best_spectra(coord, search_radius=1 * u.arcsec): ```{code-cell} ipython3 for galaxy in galaxies[rng.choice(len(galaxies), size=min(n_galaxies, len(galaxies)), replace=False)]: - galaxy_coord = SkyCoord(galaxy['ra'], galaxy['dec'], unit='deg') - galaxy_spectra = get_best_spectra(galaxy_coord) + galaxy_spectra = get_best_spectra(galaxy['object_id']) if not galaxy_spectra: print(f"No spectra found for object {galaxy['object_id']}") continue From f58deacc341f4d3692429bee2ac224b59d5a5613 Mon Sep 17 00:00:00 2001 From: xoubish Date: Fri, 6 Nov 2026 12:01:42 -0800 Subject: [PATCH 23/27] Build the spectrum URLs with IRSA's recipe Use the irsacloud spectrumDM endpoint with the euclid_combspec_dr1 dataset, and build the URL in the ADQL query on the association table, as recommended by IRSA. --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index 929d8cd1..8a67898d 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -146,12 +146,15 @@ redshift = galaxy['spe_z'][0] ## 2. Find the spectra of the galaxy The DR1 SIR 1D spectra are stored in large FITS files, one per MER tile, with one extension (HDU) per spectrum. -The table `euclid.objectid_spectrafile_association_dr1` at IRSA lists, for each object ID, the file and the HDU of each of its spectra: +The table `euclid.objectid_spectrafile_association_dr1` at IRSA lists, for each object ID, the file (`path`) and the HDU of each of its spectra. +IRSA's spectrumDM service converts a given HDU of a spectrum file into a VOTable; its URL is built from the file path and HDU, which we do directly in the query: ```{code-cell} ipython3 def find_spectra(object_id): query = f""" - SELECT objectid, tileid, path, hdu + SELECT objectid, tileid, hdu, + 'https://irsacloud.ipac.caltech.edu/api/spectrumdm/convert/' || path + || '?dataset_id=euclid_combspec_dr1&hdu=' || hdu AS url FROM euclid.objectid_spectrafile_association_dr1 WHERE objectid = {object_id} """ @@ -162,21 +165,6 @@ spectrum_files = find_spectra(object_id) spectrum_files ``` -IRSA's spectrumDM service converts a given HDU of a spectrum file into a VOTable. -We build the URL of each spectrum from its file path and HDU: - - - -```{code-cell} ipython3 -def spectrum_url(spectrum_file): - return (f"https://irsadev.ipac.caltech.edu/api/spectrumdm/convert/{spectrum_file['path']}" - f"?dataset_id=euclid_combspec&hdu={spectrum_file['hdu']}") - - -spectrum_urls = [spectrum_url(spectrum_file) for spectrum_file in spectrum_files] -spectrum_urls -``` - ```{note} IRSA's Simple Spectral Access (SSA) service will also serve the DR1 SIR 1D spectra, which will allow searching for them by position; this notebook will be updated when it is available. ``` @@ -186,7 +174,7 @@ IRSA's Simple Spectral Access (SSA) service will also serve the DR1 SIR 1D spect Each URL returns a VOTable containing the spectrum, which we read into an astropy table: ```{code-cell} ipython3 -spectra = [QTable.read(url) for url in spectrum_urls] +spectra = [QTable.read(url) for url in spectrum_files['url']] ``` ```{note} @@ -408,7 +396,7 @@ If a spectrum file cannot be read, we skip it and use the other spectra of the g ```{code-cell} ipython3 def get_best_spectra(object_id): spectra = [] - for url in map(spectrum_url, find_spectra(object_id)): + for url in find_spectra(object_id)['url']: try: spectra.append(QTable.read(url)) except HTTPError as error: From 79e4a3629ed823d632bf4d028043e5a6b63f8767 Mon Sep 17 00:00:00 2001 From: xoubish Date: Mon, 9 Nov 2026 15:51:43 -0800 Subject: [PATCH 24/27] Address review comments on notebook 3 --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 207 +++++++++++++----- 1 file changed, 154 insertions(+), 53 deletions(-) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index 8a67898d..29b6af2e 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -38,7 +38,7 @@ By the end of this tutorial, you will: - know how to use the MASK column to pick the flux bins to plot; - understand the difference between the red and blue grism spectra, and how to pick the best spectrum of each grism; - know how to plot a Euclid spectrum and mark its emission lines; -- know how to explore the spectra of randomly selected galaxies. +- know how to select galaxies from the catalogs and explore their spectra. +++ @@ -75,7 +75,6 @@ We rely on ``astroquery`` features that have been recently added, so please make ```{code-cell} ipython3 import warnings -from urllib.error import HTTPError import numpy as np @@ -123,6 +122,20 @@ search_radius = 1 * u.arcsec ```{code-cell} ipython3 def find_galaxy(coord, search_radius=1 * u.arcsec): + """Find the galaxies near a position and their best spectroscopic redshift. + + Parameters + ---------- + coord : astropy.coordinates.SkyCoord + Position to search around. + search_radius : astropy.units.Quantity, optional + Radius of the search. + + Returns + ------- + astropy.table.Table + One row per galaxy, with its MER object ID, coordinates, and best (rank 0) SPE redshift and its probability. + """ query = f""" SELECT mer.object_id, mer.ra, mer.dec, spe.spe_z, spe.spe_z_prob FROM euclid_dr1_mer_catalogue_deep_survey AS mer @@ -134,7 +147,7 @@ def find_galaxy(coord, search_radius=1 * u.arcsec): return Irsa.query_tap(query, async_job=True).to_table() -galaxy = find_galaxy(coord) +galaxy = find_galaxy(coord, search_radius) galaxy ``` @@ -147,18 +160,53 @@ redshift = galaxy['spe_z'][0] The DR1 SIR 1D spectra are stored in large FITS files, one per MER tile, with one extension (HDU) per spectrum. The table `euclid.objectid_spectrafile_association_dr1` at IRSA lists, for each object ID, the file (`path`) and the HDU of each of its spectra. -IRSA's spectrumDM service converts a given HDU of a spectrum file into a VOTable; its URL is built from the file path and HDU, which we do directly in the query: +To read a spectrum, we don't download its whole file: IRSA's spectrumDM service reads a single HDU of a spectrum file in the cloud and returns it as a VOTable following the IVOA Spectrum Data Model, which astropy can read directly. +Its URL is built from the file path and the HDU number: ```{code-cell} ipython3 +SPECTRUMDM_URL = 'https://irsacloud.ipac.caltech.edu/api/spectrumdm/convert/' +SPECTRUM_DATASET_ID = 'euclid_combspec_dr1' + + +def spectrum_url(path, hdu): + """Build the spectrumDM URL of one spectrum. + + Parameters + ---------- + path : str + Path of the spectrum file, from the ``path`` column of the association table. + hdu : int + Number of the HDU of the spectrum in the file. + + Returns + ------- + str + URL that returns the spectrum as a VOTable. + """ + return f'{SPECTRUMDM_URL}{path}?dataset_id={SPECTRUM_DATASET_ID}&hdu={hdu}' + + def find_spectra(object_id): + """Find the spectra of an object in the spectrum association table. + + Parameters + ---------- + object_id : int + MER object ID of the source. + + Returns + ------- + astropy.table.Table + One row per spectrum, with the file path and HDU number of the spectrum, and its spectrumDM URL. + """ query = f""" - SELECT objectid, tileid, hdu, - 'https://irsacloud.ipac.caltech.edu/api/spectrumdm/convert/' || path - || '?dataset_id=euclid_combspec_dr1&hdu=' || hdu AS url + SELECT objectid, tileid, path, hdu FROM euclid.objectid_spectrafile_association_dr1 WHERE objectid = {object_id} """ - return Irsa.query_tap(query).to_table() + spectrum_files = Irsa.query_tap(query).to_table() + spectrum_files['url'] = [spectrum_url(path, hdu) for path, hdu in zip(spectrum_files['path'], spectrum_files['hdu'])] + return spectrum_files spectrum_files = find_spectra(object_id) @@ -183,48 +231,88 @@ Some highlights of the columns of the 1D spectra: - WAVELENGTH is in Angstroms by default. - SIGNAL is the flux. The values are scaled and the scaling factor is included in the column's units. This value corresponds to the `'FSCALE'` entry in the HDU header of the original FITS file. - VAR is the variance of the flux, and UNCERTAINTY is its square root, the flux uncertainty. -- MASK values can be used to determine which flux bins to discard: flux bins with an odd MASK value or a MASK value of 64 or more should not be used. +- MASK is a bit mask of quality flags (Scodeggio et al. 2026, Table 2). Bit 0 (`NOT_USE`, an odd MASK value) marks invalid flux bins and bit 6 (`ABS_FLUX`, a MASK value of 64 or more) a suspicious absolute flux calibration; flux bins with either flag should not be used. The other bits are warnings. - NDITH is the number of dithered exposures that contribute to each flux bin. ``` -Before plotting, we use the MASK column to find the flux bins not to use: +We use the MASK column to find the flux bins not to use: ```{code-cell} ipython3 def bad_flux_bins(spectrum): + """Find the flux bins of a spectrum that should not be used. + + Parameters + ---------- + spectrum : astropy.table.QTable + Spectrum, with a MASK column. + + Returns + ------- + numpy.ndarray + Boolean array, True for the flux bins with an odd MASK value or a MASK value of 64 or more. + """ mask = spectrum['MASK'].value return (mask % 2 == 1) | (mask >= 64) ``` -Let's plot the spectrum with the most usable flux bins, with the flux as a solid line and its uncertainty as a thin line: +Let's look at the spectrum with the most usable flux bins. +Each row of the table is one flux bin: ```{code-cell} ipython3 spectrum = max(spectra, key=lambda spectrum: np.sum(~bad_flux_bins(spectrum))) +spectrum +``` +We plot it with the usable flux bins as a solid line, the flux bins not to use as a dotted line, and the flux uncertainty of the usable bins as a thin line. +Below it, we plot the MASK values as a function of wavelength. +They are bit flags, so each value combines several conditions: + +```{code-cell} ipython3 bad = bad_flux_bins(spectrum) wavelength = spectrum['WAVELENGTH'].to(u.micron) -fig, ax = plt.subplots(figsize=(12, 4)) -ax.plot(wavelength, np.ma.masked_where(bad, spectrum['SIGNAL']), color='tab:red', label='Flux') -ax.plot(wavelength, np.ma.masked_where(bad, spectrum['UNCERTAINTY']), color='tab:red', linewidth=0.5, label='Uncertainty') -ax.set_title(f'Euclid SIR 1D spectrum of object {object_id}') -ax.legend() +fig, (ax_flux, ax_mask) = plt.subplots(2, 1, figsize=(12, 6), sharex=True, height_ratios=[3, 1]) +ax_flux.plot(wavelength, np.ma.masked_where(bad, spectrum['SIGNAL']), color='tab:red', label='Flux') +ax_flux.plot(wavelength, np.ma.masked_where(~bad, spectrum['SIGNAL']), color='tab:red', linestyle=':', alpha=0.6, + label='Flux, do not use') +ax_flux.plot(wavelength, np.ma.masked_where(bad, spectrum['UNCERTAINTY']), color='tab:red', linewidth=0.5, + label='Uncertainty') +ax_flux.set_xlabel('') +ax_flux.set_title(f'Euclid SIR 1D spectrum of object {object_id}') +ax_flux.legend() + +ax_mask.plot(wavelength, spectrum['MASK'], color='tab:red') +ax_mask.set_ylabel('MASK value') plt.show() ``` +Most of the flux bins not to use are at the edges of the wavelength range of the spectrum, where the throughput of the grism is low. The strong emission line near 1.76 micron is Hα, and the lines near 1.3 micron are Hβ and [OIII]; we will confirm this with the redshift of the galaxy in section 5. ## 4. Red and blue grism spectra NISP takes slitless spectra with two kinds of grisms: -* **Red grisms** cover about 1.2 to 1.9 micron and are used in both the Euclid Wide Survey and the Euclid Deep Survey. -* **The blue grism** covers about 0.9 to 1.4 micron and is used only in the Euclid Deep Survey. +* **Red grisms** cover about 1.2 to 1.9 micron, with a resolving power R > 480, and are used in both the Euclid Wide Survey and the Euclid Deep Survey. +* **The blue grism** covers about 0.92 to 1.37 micron, with a resolving power R > 400, and is used only in the Euclid Deep Survey. A galaxy in the Euclid Wide Survey has only a red grism spectrum, while a galaxy in the Euclid Deep Fields, like ours, has spectra from both kinds of grism, each of them a separate spectrum in the files. We tell them apart by their wavelength range (blue grism spectra start below 1.1 micron): ```{code-cell} ipython3 def grism_name(spectrum): + """Tell which kind of grism a spectrum comes from. + + Parameters + ---------- + spectrum : astropy.table.QTable + Spectrum, with a WAVELENGTH column. + + Returns + ------- + str + ``'Blue grism'`` if the spectrum starts below 1.1 micron, ``'Red grism'`` otherwise. + """ return 'Blue grism' if spectrum['WAVELENGTH'].min() < 1.1 * u.micron else 'Red grism' ``` @@ -247,6 +335,18 @@ A galaxy can also have several spectra of the same kind of grism, for example wh ```{code-cell} ipython3 def best_spectra(spectra): + """Pick the spectrum with the most usable flux bins for each kind of grism. + + Parameters + ---------- + spectra : list of astropy.table.QTable + Spectra of one object. + + Returns + ------- + dict + Best spectrum of each kind of grism, keyed by the name of the grism. + """ best = {} for spectrum in sorted(spectra, key=lambda spectrum: np.sum(~bad_flux_bins(spectrum)), reverse=True): best.setdefault(grism_name(spectrum), spectrum) @@ -283,6 +383,17 @@ grism_colors = {'Red grism': 'tab:red', 'Blue grism': 'tab:blue'} def plot_spectra(spectra, title, redshift=None): + """Plot the spectra of an object, and mark its emission lines. + + Parameters + ---------- + spectra : dict + Spectra to plot, keyed by the name of their grism, as returned by `best_spectra`. + title : str + Title of the plot. + redshift : float, optional + Redshift of the object. If given, the emission lines in the wavelength range are marked. + """ fig, ax = plt.subplots(figsize=(12, 4.5)) for name, spectrum in spectra.items(): wavelength = spectrum['WAVELENGTH'].to(u.micron) @@ -291,7 +402,7 @@ def plot_spectra(spectra, title, redshift=None): ax.plot(wavelength, np.ma.masked_where(bad, spectrum['SIGNAL']), color=color, alpha=0.8, label=name) ax.plot(wavelength, np.ma.masked_where(~bad, spectrum['SIGNAL']), color=color, linestyle=':', alpha=0.6) - ax.plot(wavelength, spectrum['UNCERTAINTY'], color=color, linewidth=0.5, alpha=0.5) + ax.plot(wavelength, np.ma.masked_where(bad, spectrum['UNCERTAINTY']), color=color, linewidth=0.5, alpha=0.5) good_flux = np.concatenate([spectrum['SIGNAL'][~bad_flux_bins(spectrum)].filled(np.nan) for spectrum in spectra.values()]) @@ -322,36 +433,12 @@ def plot_spectra(spectra, title, redshift=None): plot_spectra(best, f'Euclid SIR 1D spectra of object {object_id}', redshift) ``` -## 6. Look closer at the spectrum table and the MASK column - -Now that we have seen the spectra, let's look at the usable flux bins of the red grism spectrum: - -```{code-cell} ipython3 -red_spectrum = best['Red grism'] -red_spectrum[~bad_flux_bins(red_spectrum)] -``` - -The MASK values are bit flags, so each value combines several conditions. -Let's plot them as a function of wavelength, to see where the flux bins not to use are: - -```{code-cell} ipython3 -fig, ax = plt.subplots(figsize=(12, 3)) -for name, spectrum in best.items(): - ax.plot(spectrum['WAVELENGTH'].to(u.micron), spectrum['MASK'], color=grism_colors[name], alpha=0.6, label=name) -ax.set_ylabel('MASK value') -ax.set_title('Values of MASK by flux bin') -ax.legend() -plt.show() -``` - -Most of the flux bins not to use are at the edges of the wavelength range of each grism, where its throughput is low. - -## 7. Explore the spectra of random galaxies +## 6. Select galaxies and explore their spectra Now it's your turn to explore! We select galaxies from the DR1 SPE and MER deep catalogs in a region of the Euclid Deep Field North, pick a few of them at random, and plot their spectra with their emission lines. -To avoid stars and problematic sources, we keep only sources with a reliable redshift (`spe_z_prob` and `spe_z_rel`, see the [SPE catalogs notebook](5_Euclid_intro_SPE_catalog.md)), a low probability of being point-like (`point_like_prob`), and no MER detection quality flags set (`det_quality_flag = 0`), for example for blending with a neighbor. -Change the parameters below to look at other regions, redshift ranges, or numbers of galaxies; change or remove the random seed to get a different selection. +The selection is not random: to avoid stars and problematic sources, we keep only sources with a reliable redshift (`spe_z_prob` and `spe_z_rel`, see the [SPE catalogs notebook](5_Euclid_intro_SPE_catalog.md)), a low probability of being point-like (`point_like_prob`), and no MER detection quality flags set (`det_quality_flag = 0`), for example for blending with a neighbor. +Change the parameters below to look at other regions, redshift ranges, or numbers of galaxies; change or remove the random seed to pick different galaxies from the selection. Each time you rerun the plotting cell, it picks new galaxies from the same selection. Most of these galaxies are much fainter than our first example, so their spectra are noisier, and their emission lines can be weak or missing. @@ -391,33 +478,47 @@ print(f'Found {len(galaxies)} galaxies') ``` We wrap sections 2 to 4 into a function, which returns the best spectrum of each grism of an object. -If a spectrum file cannot be read, we skip it and use the other spectra of the galaxy: +If a spectrum cannot be read (for example, because of a network error or a timeout), we skip it and use the other spectra of the galaxy: ```{code-cell} ipython3 def get_best_spectra(object_id): + """Read the spectra of an object and pick the best one of each kind of grism. + + Spectra that cannot be read are skipped, with a message. + + Parameters + ---------- + object_id : int + MER object ID of the source. + + Returns + ------- + dict + Best spectrum of each kind of grism, keyed by the name of the grism; empty if no spectrum could be read. + """ spectra = [] for url in find_spectra(object_id)['url']: try: spectra.append(QTable.read(url)) - except HTTPError as error: + except OSError as error: print(f'Skipping a spectrum that could not be read ({error}): {url}') return best_spectra(spectra) ``` ```{code-cell} ipython3 -for galaxy in galaxies[rng.choice(len(galaxies), size=min(n_galaxies, len(galaxies)), replace=False)]: - galaxy_spectra = get_best_spectra(galaxy['object_id']) +for random_galaxy in galaxies[rng.choice(len(galaxies), size=min(n_galaxies, len(galaxies)), replace=False)]: + galaxy_spectra = get_best_spectra(random_galaxy['object_id']) if not galaxy_spectra: - print(f"No spectra found for object {galaxy['object_id']}") + print(f"No spectra found for object {random_galaxy['object_id']}") continue - plot_spectra(galaxy_spectra, f"Object {galaxy['object_id']}", galaxy['spe_z']) + plot_spectra(galaxy_spectra, f"Object {random_galaxy['object_id']}", random_galaxy['spe_z']) ``` ## References -- Euclid Collaboration: Scodeggio, M., et al. 2026, *Euclid Data Release 1 (DR1): The SIR spectroscopic processing*, A&A, in prep. +- Euclid Collaboration: Scodeggio, M., Copin, Y., et al. 2026, *Euclid Data Release 1 (DR1): From spectrograms to spectra: The SIR spectroscopic processing function*, A&A, in prep. +++ From 6b063bd8fe8cb2eca7f34634c782c32f5d3a2603 Mon Sep 17 00:00:00 2001 From: xoubish Date: Tue, 10 Nov 2026 14:22:40 -0800 Subject: [PATCH 25/27] Note that the blue and red grism spectra can differ where they overlap --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index 29b6af2e..c7f147b0 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -433,6 +433,11 @@ def plot_spectra(spectra, title, redshift=None): plot_spectra(best, f'Euclid SIR 1D spectra of object {object_id}', redshift) ``` +```{note} +The blue and red grism spectra of a galaxy can have different continuum levels where they overlap (about 1.2 to 1.37 micron), sometimes by a factor of two or more, and the blue grism spectra can have spikes and other artifacts that are not flagged in the MASK column. +This is a limitation of the DR1 spectra, not a problem with how they are read in here: see Scodeggio et al. (2026) and the [Euclid DR1 documentation](https://euclid.caltech.edu/page/euclid-dr1) for the details. +``` + ## 6. Select galaxies and explore their spectra Now it's your turn to explore! From e43bbe4b6e097f21b6339c88d8715a5c523e0a7c Mon Sep 17 00:00:00 2001 From: xoubish Date: Tue, 10 Nov 2026 14:30:14 -0800 Subject: [PATCH 26/27] Clarify why a galaxy has two spectra, from Anahita's comments --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index c7f147b0..a3d3fd86 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -213,6 +213,9 @@ spectrum_files = find_spectra(object_id) spectrum_files ``` +The table has one row, and one URL, for each spectrum of the galaxy. +Our galaxy has two spectra: as we will see in section 4, one is from the blue grism and the other from the red grism, as expected for a galaxy in the Euclid Deep Fields. + ```{note} IRSA's Simple Spectral Access (SSA) service will also serve the DR1 SIR 1D spectra, which will allow searching for them by position; this notebook will be updated when it is available. ``` @@ -255,7 +258,8 @@ def bad_flux_bins(spectrum): return (mask % 2 == 1) | (mask >= 64) ``` -Let's look at the spectrum with the most usable flux bins. +We will compare the two spectra of the galaxy in section 4. +For now, let's look at one of them as an example; we pick the one with the most usable flux bins. Each row of the table is one flux bin: ```{code-cell} ipython3 From bc8864134a4a6214a27771072b4755b9218a4c5e Mon Sep 17 00:00:00 2001 From: xoubish Date: Wed, 11 Nov 2026 08:14:24 -0800 Subject: [PATCH 27/27] Point the notebook to the production IRSA services for DR1 --- tutorials/euclid/3_Euclid_intro_1D_spectra.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tutorials/euclid/3_Euclid_intro_1D_spectra.md b/tutorials/euclid/3_Euclid_intro_1D_spectra.md index a3d3fd86..bab7333c 100644 --- a/tutorials/euclid/3_Euclid_intro_1D_spectra.md +++ b/tutorials/euclid/3_Euclid_intro_1D_spectra.md @@ -100,13 +100,6 @@ quantity_support() conf.remote_timeout = 120 ``` - - -```{code-cell} ipython3 -# DR1 is not public yet, so we query IRSA's development server. -Irsa.tap_url = 'https://irsadev.ipac.caltech.edu/TAP' -``` - ## 1. Find a galaxy and its redshift in the DR1 catalogs We start with a galaxy in the Euclid Deep Field North.