Skip to content

Commit 5276b82

Browse files
committed
MAINT: pandas--astropy cleanup for euclid2
1 parent 89d4fdd commit 5276b82

1 file changed

Lines changed: 28 additions & 29 deletions

File tree

tutorials/euclid_access/2_Euclid_intro_MER_catalog.md

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -101,30 +101,28 @@ The MER catalog contains 476 columns, below are a few highlights:
101101

102102
### Define the following ADQL query to find the first 10k stars in the MER catalog
103103

104-
Since we are just using the MER catalog alone, it does not have a column for classification. We can use the point_like_flag = 1 or point_like_prob>0.99 for stars.
104+
Since we are just using the MER catalog alone, it does not have a column for classification.
105+
We can use the `point_like_flag = 1` or `point_like_prob > 0.99` for stars.
105106

106-
Set all the fluxes to be greater than 0 so the object is detected in all four Euclid MER mosaic images
107+
Set all the fluxes to be greater than 0 so the object is detected in all four Euclid MER mosaic images.
107108

108109
```{code-cell} ipython3
109-
adql_stars = ("SELECT TOP 10000 mer.object_id, mer.ra, mer.dec, mer.flux_vis_psf, mer.fluxerr_vis_psf, mer.flux_y_templfit,mer.fluxerr_y_templfit, "
110-
"mer.flux_j_templfit, mer.fluxerr_j_templfit, mer.flux_h_templfit, mer.fluxerr_h_templfit, mer.point_like_prob, mer.extended_prob "
111-
f"FROM {table_mer} AS mer "
112-
"WHERE mer.flux_vis_psf > 0 "
113-
"AND mer.flux_y_templfit > 0 "
114-
"AND mer.flux_j_templfit > 0 "
115-
"AND mer.flux_h_templfit > 0 "
116-
"AND mer.point_like_flag = 1 ")
117-
118-
# Run the query
119-
120-
result_stars = Irsa.query_tap(adql_stars)
110+
adql_stars = ("SELECT TOP 10000 mer.object_id, mer.ra, mer.dec, mer.flux_vis_psf, mer.fluxerr_vis_psf, "
111+
"mer.flux_y_templfit,mer.fluxerr_y_templfit, mer.flux_j_templfit, mer.fluxerr_j_templfit, "
112+
"mer.flux_h_templfit, mer.fluxerr_h_templfit, mer.point_like_prob, mer.extended_prob "
113+
f"FROM {table_mer} AS mer "
114+
"WHERE mer.flux_vis_psf > 0 "
115+
"AND mer.flux_y_templfit > 0 "
116+
"AND mer.flux_j_templfit > 0 "
117+
"AND mer.flux_h_templfit > 0 "
118+
"AND mer.point_like_flag = 1 ")
121119
```
122120

123-
```{code-cell} ipython3
124-
df_s_irsa = result_stars.to_table().to_pandas() # Convert to Pandas DataFrame
121+
We can run the query with the TAP service, and then look at some of the results.
125122

126-
# Display first few rows
127-
df_s_irsa.head()
123+
```{code-cell} ipython3
124+
result_stars = Irsa.query_tap(adql_stars).to_table()
125+
result_stars[:5]
128126
```
129127

130128
## 2. Make a color-magnitude diagram using the catalogs pulled from IRSA
@@ -134,29 +132,30 @@ df_s_irsa.head()
134132
- Plot the color-magnitude diagram
135133

136134
```{code-cell} ipython3
137-
mag_y_s_irsa=-2.5*np.log10(df_s_irsa["flux_y_templfit"]) + 23.9 # Y
138-
mag_h_s_irsa=-2.5*np.log10(df_s_irsa["flux_h_templfit"]) + 23.9 # H
135+
mag_y = -2.5 * np.log10(result_stars["flux_y_templfit"]) + 23.9
136+
mag_h = -2.5 * np.log10(result_stars["flux_h_templfit"]) + 23.9
139137
140-
x_s_irsa = mag_y_s_irsa - mag_h_s_irsa # Y - H
141-
y_s_irsa = mag_y_s_irsa
138+
x = mag_y - mag_h # Y - H
139+
y = mag_y
142140
143-
xerr_s_irsa= 2.5 / np.log(10) * np.sqrt((df_s_irsa["fluxerr_y_templfit"] / df_s_irsa["flux_y_templfit"])**2
144-
+ (df_s_irsa["fluxerr_h_templfit"] / df_s_irsa["flux_h_templfit"])**2)
145-
yerr_s_irsa= 2.5 / np.log(10) * (df_s_irsa["fluxerr_y_templfit"] / df_s_irsa["flux_y_templfit"])
141+
xerr = (2.5 / np.log(10) * np.sqrt((result_stars["fluxerr_y_templfit"] / result_stars["flux_y_templfit"])**2
142+
+ (result_stars["fluxerr_h_templfit"] / result_stars["flux_h_templfit"])**2))
143+
yerr = (2.5 / np.log(10) * (result_stars["fluxerr_y_templfit"] / result_stars["flux_y_templfit"]))
146144
147-
plt.errorbar(x_s_irsa, y_s_irsa, xerr=xerr_s_irsa, yerr=yerr_s_irsa, fmt='o', markersize=1.5, ecolor='lightgrey', elinewidth=0.5, capsize=2)
145+
plt.errorbar(x, y, xerr=xerr, yerr=yerr,
146+
fmt='o', markersize=1.5, ecolor='lightgrey', elinewidth=0.5, capsize=2)
148147
149148
plt.xlabel('Y-H')
150149
plt.ylabel('Y')
151-
plt.xlim(-10,10)
152-
plt.ylim(10,35)
150+
plt.xlim(-10, 10)
151+
plt.ylim(10, 35)
153152
plt.title('10k Stars in MER catalog -- IRSA')
154153
```
155154

156155
## About this Notebook
157156

158157
**Author**: Tiffany Meshkat, Anahita Alavi, Anastasia Laity, Andreas Faisst, Brigitta Sipőcz, Dan Masters, Harry Teplitz, Jaladh Singhal, Shoubaneh Hemmati, Vandana Desai
159158

160-
**Updated**: 2025-03-31
159+
**Updated**: 2025-04-09
161160

162161
**Contact:** [the IRSA Helpdesk](https://irsa.ipac.caltech.edu/docs/help_desk.html) with questions or reporting problems.

0 commit comments

Comments
 (0)