@@ -177,23 +177,45 @@ We specify the following conditions on our search:
177177- phz_classification =2 means we select only galaxies
178178- Using the phz_90_int1 and phz_90_int2, we select just the galaxies where the error on the photometric redshift is less than 20%
179179- Select just the galaxies between a median redshift of 1.4 and 1.6
180+ - We search just a 3 arcminute box around an RA and Dec
180181
181182+++
182183
183184Search based on `` tileID `` :
184185
186+ ``` {code-cell} ipython3
187+ ######################## User defined section ############################
188+ ## How large do you want the image cutout to be?
189+ im_cutout= 5 * u.arcmin
190+
191+ ## What is the center of the cutout?
192+ ra_cutout = 267.8
193+ dec_cutout = 66
194+
195+ coords_cutout = SkyCoord(ra_cutout, dec_cutout, unit=(u.deg, u.deg), frame='icrs')
196+ ##########################################################################
197+ im_cutout_deg=im_cutout.to(u.deg).value
198+
199+ ## Create ra and dec bounds for the box
200+ ra0=ra_cutout-im_cutout_deg/2
201+ ra1=ra_cutout+im_cutout_deg/2
202+
203+ dec0=dec_cutout-im_cutout_deg/2
204+ dec1=dec_cutout+im_cutout_deg/2
205+ ```
206+
185207``` {code-cell} ipython3
186208adql = f"SELECT DISTINCT mer.object_id,mer.ra, mer.dec, phz.flux_vis_unif, phz.flux_y_unif, \
187209phz.flux_j_unif, phz.flux_h_unif, phz.phz_classification, phz.phz_median, phz.phz_90_int1, phz.phz_90_int2 \
188210FROM {table_mer} AS mer \
189211JOIN {table_phz} as phz \
190212ON mer.object_id = phz.object_id \
191- WHERE phz.flux_vis_unif> 0 \
213+ WHERE 1 = CONTAINS(POINT('ICRS', mer.ra, mer.dec), CIRCLE('ICRS', {ra_cutout}, {dec_cutout}, {im_cutout_deg/2})) \
214+ AND phz.flux_vis_unif> 0 \
192215AND phz.flux_y_unif > 0 \
193216AND phz.flux_j_unif > 0 \
194217AND phz.flux_h_unif > 0 \
195218AND phz.phz_classification = 2 \
196- AND mer.tileid = {tileID} \
197219AND ((phz.phz_90_int2 - phz.phz_90_int1) / (1 + phz.phz_median)) < 0.20 \
198220AND phz.phz_median BETWEEN 1.4 AND 1.6 \
199221"
@@ -211,39 +233,45 @@ df_g_irsa = result.to_table().to_pandas()
211233df_g_irsa.head()
212234```
213235
214- ## 3. Read in the MER image from IRSA directly
215-
216- +++
236+ ``` {code-cell} ipython3
237+ len(df_g_irsa)
238+ ```
217239
218- Download the MER image -- note this file is about 1.46 GB
240+ ## 3. Read in a cutout of the MER image from IRSA directly
219241
220242``` {code-cell} ipython3
221- fname = download_file(filename, cache=True)
222- hdu_mer_irsa = fits.open(fname)
223- head_mer_irsa = hdu_mer_irsa[0].header
243+ ## Use fsspec to interact with the fits file without downloading the full file
244+ hdu = fits.open(filename, use_fsspec=True)
224245
225- print(hdu_mer_irsa.info())
226- ```
246+ ## Store the header
247+ header = hdu[0].header
227248
228- Extract just the primary image
249+ ## Read in the cutout of the image that you want
250+ cutout_data = Cutout2D(hdu[0].section, position=coords_cutout, size=im_cutout, wcs=WCS(hdu[0].header))
251+
252+ ## Define a new fits file based on this smaller cutout, with accurate WCS based on the cutout size
253+ new_hdu = fits.PrimaryHDU(data=cutout_data.data, header=header)
254+ new_hdu.header.update(cutout_data.wcs.to_header())
255+ ```
229256
230257``` {code-cell} ipython3
231- im_mer_irsa=hdu_mer_irsa[0] .data
258+ im_mer_irsa = new_hdu .data
232259```
233260
234- ``` {tip}
235- Now you've downloaded this large file, if you would like to save it to disk, uncomment the following cell
261+ ``` {code-cell} ipython3
262+ im_mer_irsa.shape
236263```
237264
238265``` {code-cell} ipython3
239- # download_path='/yourlocalpath/'
240- # hdu_mer_irsa.writeto(download_path+'./MER_image_VIS.fits ', overwrite=True )
266+ norm = ImageNormalize(im_mer_irsa, interval=PercentileInterval(99.9), stretch=AsinhStretch())
267+ plt.imshow(im_mer_irsa, cmap='gray ', origin='lower', norm=norm )
241268```
242269
243270## 4. Overplot the catalog on the MER mosaic image
244271
245272``` {code-cell} ipython3
246273## Use the WCS package to extract the coordinates from the header of the image
274+ head_mer_irsa=new_hdu.header
247275wcs_irsa=WCS(head_mer_irsa) # VIS
248276```
249277
@@ -257,30 +285,16 @@ df_g_irsa['x_pix']=xy_irsa[0]
257285df_g_irsa['y_pix']=xy_irsa[1]
258286```
259287
260- Due to the large field of view of the MER mosaic, let's cut out a smaller section (30'x30 ')of the MER mosaic to inspect the image
288+ Due to the large field of view of the MER mosaic, let's cut out a smaller section (3'x3 ')of the MER mosaic to inspect the image
261289
262- ``` {code-cell} ipython3
263- cutout_x0=7200
264- cutout_x1=9000
265- cutout_y0=7200
266- cutout_y1=9000
267-
268- im_cutout=im_mer_irsa[cutout_x0:cutout_x1, cutout_y0:cutout_y1]
269-
270- # Filter galaxy positions within the cutout region
271- cutout_mask = (df_g_irsa['x_pix'] >= cutout_x0) & (df_g_irsa['x_pix'] < cutout_x1) & \
272- (df_g_irsa['y_pix'] >= cutout_y0) & (df_g_irsa['y_pix'] < cutout_y1)
273-
274- x_cutout = df_g_irsa['x_pix'][cutout_mask] - cutout_x0 # Shift to cutout frame
275- y_cutout = df_g_irsa['y_pix'][cutout_mask] - cutout_y0
276- ```
290+ +++
277291
278- Plot MER catalog sources on the Euclid VIS image 30'x30 ' cutout
292+ Plot MER catalog sources on the Euclid VIS image 3'x3 ' cutout
279293
280294``` {code-cell} ipython3
281- plt.imshow(im_cutout , cmap='gray', origin='lower', norm=ImageNormalize(im_cutout , interval=PercentileInterval(99.9), stretch=LogStretch()))
295+ plt.imshow(im_mer_irsa , cmap='gray', origin='lower', norm=ImageNormalize(im_mer_irsa , interval=PercentileInterval(99.9), stretch=LogStretch()))
282296colorbar = plt.colorbar()
283- plt.scatter(x_cutout, y_cutout , s=36, facecolors='none', edgecolors='red')
297+ plt.scatter(df_g_irsa['x_pix'], df_g_irsa['y_pix'] , s=36, facecolors='none', edgecolors='red')
284298
285299plt.title('Galaxies between z = 1.4 and 1.6')
286300plt.show()
@@ -289,16 +303,16 @@ plt.show()
289303Pull the spectra on the top brightest source based on object ID
290304
291305``` {code-cell} ipython3
292- df_g_irsa_sort=df_g_irsa[cutout_mask] .sort_values(by='flux_h_unif',ascending=False)
306+ df_g_irsa_sort=df_g_irsa.sort_values(by='flux_h_unif',ascending=False)
293307```
294308
295309``` {code-cell} ipython3
296- df_g_irsa_sort[0:3]
310+ df_g_irsa_sort.iloc [0:3]
297311```
298312
299313``` {code-cell} ipython3
300- obj_id=df_g_irsa_sort['object_id'].iloc[1 ]
301- redshift = df_g_irsa_sort['phz_median'].iloc[1 ]
314+ obj_id=df_g_irsa_sort['object_id'].iloc[2 ]
315+ redshift = df_g_irsa_sort['phz_median'].iloc[2 ]
302316
303317## Pull the data on these objects
304318adql_object = f"SELECT * \
0 commit comments