Skip to content

Commit 437ad45

Browse files
Convert links to hyperlinks
Add pip install cell
1 parent e0e1b94 commit 437ad45

File tree

1 file changed

+24
-44
lines changed

1 file changed

+24
-44
lines changed

tutorials/firefly/OpenUniverse2024Preview_Firefly.md

Lines changed: 24 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,13 @@ OpenUniverse2024 is a project to simulate spatially overlapping imaging surveys
3939
- Overlapping Roman Wide-Area Survey (WAS) in the same region
4040
- A deep-field calibration region of the Roman WAS in the same region
4141

42-
This data preview release consists of a subset of data from each of the five categories above. More information about data preview can be found at:
43-
https://irsa.ipac.caltech.edu/data/theory/openuniverse2024/overview.html
42+
This data preview release consists of a subset of data from each of the five categories above. More information about data preview can be found at [IRSA holding of this dataset](https://irsa.ipac.caltech.edu/data/theory/openuniverse2024/overview.html).
4443

45-
Firefly is an open-source web-based UI library for astronomical data archive access and visualization developed at Caltech and used by multiple space- and ground-based astrophysics archives. More information can be found here:
46-
https://github.com/Caltech-IPAC/firefly/blob/dev/README.md
44+
Firefly is an open-source web-based UI library for astronomical data archive access and visualization developed at Caltech and used by multiple space- and ground-based astrophysics archives. More information on Firefly can be found [here](https://github.com/Caltech-IPAC/firefly/blob/dev/README.md).
4745

48-
In addition to being used to make web applications, Firefly can be used from Python. More information can be found here:
49-
https://caltech-ipac.github.io/firefly_client/usage/index.html
46+
In addition to being used to make web applications, Firefly can be used from Python. More information on Firefly Python client can be found [here](https://caltech-ipac.github.io/firefly_client/usage/index.html).
5047

51-
The Firefly JupyterLab Extension makes it particularly easy to use Firefly to efficiently visualize cloud-hosted astronomical data using cloud-based JupyterLab instances. More information can be found here:
52-
53-
https://github.com/Caltech-IPAC/jupyter_firefly_extensions/blob/master/README.md
48+
The Firefly JupyterLab Extension makes it particularly easy to use Firefly to efficiently visualize cloud-hosted astronomical data using JupyterLab instances running locally or on cloud. More information on Firefly JupyterLab Extension can be found [here](https://github.com/Caltech-IPAC/jupyter_firefly_extensions/blob/master/README.md).
5449

5550
+++
5651

@@ -70,6 +65,11 @@ https://github.com/Caltech-IPAC/jupyter_firefly_extensions/blob/master/README.md
7065
- reproject.reproject_interp to convert Roman coadds from STG to TAN projection
7166
- io.BytesIO for writing a fits file to an in-memory stream
7267

68+
```{code-cell} ipython3
69+
# Uncomment the next line to install dependencies if needed.
70+
# !pip install numpy astropy s3fs matplotlib firefly_client reproject
71+
```
72+
7373
```{code-cell} ipython3
7474
from astropy.io import fits
7575
import numpy as np
@@ -155,7 +155,7 @@ def get_roman_coadd_fpath(coord, filter):
155155
return coadd_fpath
156156
```
157157

158-
Now we use this access path and prefix it with `s3://` and use astropy.fits to extract a subset of it (for more info see https://docs.astropy.org/en/stable/io/fits/usage/cloud.html#subsetting-fits-files-hosted-in-amazon-s3-cloud-storage).
158+
Now we use this access path and prefix it with `s3://` and use astropy.fits to extract a subset of it (for more info see [this section](https://docs.astropy.org/en/stable/io/fits/usage/cloud.html#subsetting-fits-files-hosted-in-amazon-s3-cloud-storage) of astropy docs).
159159

160160
We use `.section` to retrieve just the science image data from fits HDU as a 2D `numpy.array`, and extract WCS information from fits header as `astropy.wcs.WCS` object. The following function returns a dictionary of both.
161161

@@ -389,9 +389,7 @@ fc.reinit_viewer() # to clean the state, if this cell ran earlier
389389

390390
### Send the simulated Rubin coadd to Firefly using show_fits.
391391

392-
For more information on `show_fits`, see:
393-
394-
https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.show_fits
392+
For displaying the FITS image of Rubin coadd in Firefly, we use [`show_fits`](https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.show_fits):
395393

396394
```{code-cell} ipython3
397395
coadd_ff_id_rubin = 'rubin-coadd-filter-r'
@@ -404,11 +402,9 @@ fc.show_fits(url=https_url(coadd_s3_fpath_rubin),
404402
### Use ds9 region syntax to overplot the simulated Roman image blocks on the interactive display
405403

406404
The Firefly client includes several methods related to controlling ds9 region overlays. To
407-
overlay a region layer on the loaded FITS images, we can use `overlay_region_layer`:
408-
409-
https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.overlay_region_layer
405+
overlay a region layer on the loaded FITS images, we can use [`overlay_region_layer`](https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.overlay_region_layer).
410406

411-
Region data is defined in ds9 region syntax that can be found at https://ds9.si.edu/doc/ref/region.html
407+
Region data is defined in ds9 region syntax that can be found [here](https://ds9.si.edu/doc/ref/region.html).
412408

413409
```{code-cell} ipython3
414410
# mark the roman coadd blocks as boxes
@@ -443,17 +439,13 @@ coords_of_interest = SkyCoord('0h38m25.35s -44d00m10.1s', frame='icrs') # locate
443439
coords_of_interest
444440
```
445441

446-
We can now use this `SkyCoord` object to compare our coadds. More information on `SkyCoord` can be found here:
447-
448-
https://docs.astropy.org/en/stable/api/astropy.coordinates.SkyCoord.html#astropy.coordinates.SkyCoord
442+
We can now use this [astropy `SkyCoord` object](https://docs.astropy.org/en/stable/api/astropy.coordinates.SkyCoord.html#astropy.coordinates.SkyCoord) to compare our coadds.
449443

450444
+++
451445

452446
### Use ds9 region syntax to overplot the selected position
453447

454-
For this we use the id of the region layer we defined above, and add more region data using `add_region_data`:
455-
456-
https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.add_region_data
448+
For this we use the id of the region layer we defined above, and add more region data using [`add_region_data`](https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.add_region_data).
457449

458450
```{code-cell} ipython3
459451
point_region = f'icrs;point {coords_of_interest.ra.value}d {coords_of_interest.dec.value}d # point=cross 15 text={{Blended source}}'
@@ -540,11 +532,7 @@ The input truth files cover a region much larger than the data preview, so we de
540532

541533
+++
542534

543-
You can visualize catalogs interactively with Firefly using `show_table`. This capability can take many parameters. Here we will simply send our catalog to Firefly so that we can (a) see an interactive table; (b) see this table plotted over the image that we've already sent; and (c) use the GUI to quickly create exploratory plots. See if you can use the GUI to quickly determine approximately how many galaxies cover the Rubin image and what the redshift distribution of these galaxies is.
544-
545-
For more information on `show_table`, see:
546-
547-
https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.show_table
535+
You can visualize catalogs interactively with Firefly using [`show_table`](https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.show_table). This capability can take many parameters. Here we will simply send our catalog to Firefly so that we can (a) see an interactive table; (b) see this table plotted over the image that we've already sent; and (c) use the GUI to quickly create exploratory plots. See if you can use the GUI to quickly determine approximately how many galaxies cover the Rubin image and what the redshift distribution of these galaxies is.
548536

549537
```{code-cell} ipython3
550538
cat_filters = [
@@ -577,7 +565,7 @@ For each row in the table you can notice a marker in the image. Selecting a row
577565

578566
High redshift galaxies are the most interesting, so let's filter the table we sent to Firefly to only include z>3 galaxies. Notice how the table display and image overlay change. Notice how the chart becomes a scatterplot from a heatmap because the sources reduce. You can remove this filter or add new ones through the GUI.
579567

580-
For filtering, we will use `apply_table_filters` method on the galaxy table we loaded above. More info about this method: https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.apply_table_filters
568+
For filtering, we will use [`apply_table_filters`](https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.apply_table_filters) method on the galaxy table we loaded above.
581569

582570
```{code-cell} ipython3
583571
fc.apply_table_filters(tbl_id=gal_cat_tbl_id,
@@ -596,9 +584,7 @@ ROMAN_RGB_FILTERS = ['H158', 'J129', 'Y106']
596584
RUBIN_RGB_FILTERS = ['r', 'g', 'u']
597585
```
598586

599-
We already have Rubin coadd with catalog overlaid, let's make a 3 color image to see colors of marked objects more clearly. For this we will use `show_fits_3color` method:
600-
601-
https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.show_fits_3color
587+
We already have Rubin coadd with catalog overlaid, let's make a 3 color image to see colors of marked objects more clearly. For this we will use [`show_fits_3color`](https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.show_fits_3color) method:
602588

603589
```{code-cell} ipython3
604590
coadd_ff_id_rubin_3color = 'rubin-coadd-3color'
@@ -694,11 +680,7 @@ for filter_name in ROMAN_RGB_FILTERS:
694680

695681
### Use Firefly's show_fits_3color to create a 3 color image of Roman coadds
696682

697-
Now we upload each fits stream (in-memory fits file) to firefly using `upload_fits_data()` and prepare color params to pass to the `show_fits_3color()`. More info here:
698-
699-
- https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.upload_fits_data
700-
701-
- https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.show_fits_3color
683+
Now we upload each fits stream (in-memory fits file) to firefly using [`upload_fits_data()`](https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.upload_fits_data) and prepare color params to pass to the [`show_fits_3color()`](https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.show_fits_3color).
702684

703685
```{code-cell} ipython3
704686
three_color_params = [
@@ -717,10 +699,10 @@ fc.show_fits_3color(three_color_params=three_color_params,
717699
We can see 3 color image of Roman coadd containing the high-redshift galaxy sources. Try panning and zomming out, you can notice it spans over one block compared to the Rubin coadd which is much larger.
718700

719701
### Use Firefly's pan/zoom/align methods to locate high redshift sources
720-
Now, let's pan & zoom to the region where we located high-redshift galaxy sources. Also align & lock all images being displayed by WCS. For these operations we use these 3 methods:
721-
- `set_pan`: https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.set_pan
722-
- `set_zoom`: https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.set_zoom
723-
- `align_images`: https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.align_images
702+
Now, let's pan & zoom to the region where we located high-redshift galaxy sources. Also align & lock all images being displayed by WCS. For these operations we use these 3 methods (click on them to see their documentation):
703+
- [`set_pan`](https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.set_pan)
704+
- [`set_zoom`](https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.set_zoom)
705+
- [`align_images`](https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.align_images)
724706

725707
```{code-cell} ipython3
726708
fc.set_pan(plot_id=coadd_ff_id_roman_3color, x=high_z_gal_coords.ra.deg, y=high_z_gal_coords.dec.deg, coord='j2000')
@@ -730,9 +712,7 @@ fc.align_images(lock_match=True)
730712

731713
### Use Firefly's set_stretch method to change the stretch of the image display via Python
732714

733-
The image has a lot of noise that obscures our high redshift sources of interest. You can use the Firefly GUI to change the stretch of the image display. We identify that squared stretch from -2 to 10 sigma highlights the colors of our sources better. You can also use the Firefly client's `set_stretch` to do this via Python. This is helpful for reproducibility and for scaling up to many images.
734-
735-
More info about this method: https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.set_stretch
715+
The image has a lot of noise that obscures our high redshift sources of interest. You can use the Firefly GUI to change the stretch of the image display. We identify that squared stretch from -2 to 10 sigma highlights the colors of our sources better. You can also use the Firefly client's [`set_stretch`](https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.set_stretch) to do this via Python. This is helpful for reproducibility and for scaling up to many images.
736716

737717
```{code-cell} ipython3
738718
fc.set_stretch(plot_id=coadd_ff_id_roman_3color, stype='sigma', algorithm='squared',

0 commit comments

Comments
 (0)