Skip to content

Commit f3e1bd9

Browse files
authored
Merge pull request #36 from jaladh-singhal/update-firefly-tut
Update firefly tutorials as per the latest firefly-client API
2 parents fa18b12 + 8cfe2b3 commit f3e1bd9

File tree

2 files changed

+43
-53
lines changed

2 files changed

+43
-53
lines changed

tutorials/firefly/NEOWISE_light_curve_demo.md

Lines changed: 31 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ For documentation on the firefly client visit https://caltech-ipac.github.io/fir
3939
## Imports
4040

4141
- *firefly_client FireflyClient* - Python API to Firefly for displaying tables, images and charts
42-
- *firefly_client.plot* for visualizing the light curve in the client
4342
- *astropy.utils.data* for downloading the catalog data via TAP query
43+
- *urllib.parse* for converting regular query string to url-safe string
4444

4545
```{code-cell} ipython3
4646
# Uncomment the next line to install dependencies if needed.
@@ -49,13 +49,13 @@ For documentation on the firefly client visit https://caltech-ipac.github.io/fir
4949

5050
```{code-cell} ipython3
5151
from firefly_client import FireflyClient
52-
import firefly_client.plot as ffplt
5352
import astropy.utils.data
53+
import urllib.parse
5454
```
5555

5656
## Step 1
5757

58-
Instantiate the client via and view it in a different tab in the web browser.
58+
Instantiate the client and view it in a different tab in the web browser.
5959

6060
In this example, we use the IRSA Viewer - a public firefly server. The firefly server can also be run locally, e.g. via a Firefly Docker image obtained from https://hub.docker.com/r/ipac/firefly/tags/.
6161

@@ -64,79 +64,70 @@ url = 'https://irsa.ipac.caltech.edu/irsaviewer'
6464
# url='http://127.0.0.1:8080/firefly' # if you have firefly server running locally (preferably through docker)
6565
6666
fc = FireflyClient.make_client(url)
67-
ffplt.use_client(fc)
6867
```
6968

70-
You can re-initizialize the viewer to return to a clean slate with [`reinit_viewer`](https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.reinit_viewer).
69+
You can re-initizialize the viewer to return to a clean state with [`reinit_viewer`](https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.reinit_viewer).
7170

7271
```{code-cell} ipython3
7372
# fc.reinit_viewer(); # The semi-colon suppresses the output of the method when ran
7473
```
7574

7675
## Step 2
7776

78-
Setup the layout of viewer and TAP search the 'Known Solar System Object Possible Association List' catalog from the NEOWISE-R database. The specific target we are looking for is minor planet `558 Carmen`. We can query this target using a TAP search through IRSA; the `table_url` is broken down as follows:
77+
TAP search the 'Known Solar System Object Possible Association List' catalog from the NEOWISE-R database. The specific target we are looking for is minor planet `558 Carmen`. We can query this target using a TAP search through IRSA; the `table_url` is broken down as follows:
7978

80-
- We want to search the data through IRSA, which supports TAP querying, and we want it streamed directly to us via a synchronous search: <br>"https://<!---->irsa.ipac.caltech.edu/TAP/sync?"<br><br>
81-
- Next, we want to structure query to only retrieve (558) Carmen data from the NEOWISE-R 'Known Solar System Object Possible Association List' catalog. The table name of the catalog can be found using [IRSAViewer](https://irsa.ipac.caltech.edu/irsaviewer/?__action=layout.showDropDown&view=MultiTableSearchCmd) and clicking the **VO TAP Search** tab and changing the 'Project' to **neowiser**. We query all columns of data and we search the target by its object id, which is its name, and use the 'like' condition to only write (558) with a wildcard: <br>"QUERY=SELECT+*+FROM+neowiser_p1ba_mch+AS+n+WHERE+n.objid+like+'(558)%'"
79+
- We want to search the data through IRSA, which supports TAP querying, and we want it streamed directly to us via a synchronous search: <br>"https://<!---->irsa.ipac.caltech.edu/TAP/sync"<br><br>
80+
- Next, we want to structure query to only retrieve (558) Carmen data from the NEOWISE-R 'Known Solar System Object Possible Association List' catalog. The table name of the catalog can be found using [IRSAViewer](https://irsa.ipac.caltech.edu/irsaviewer/?__action=layout.showDropDown&view=MultiTableSearchCmd) and clicking the **VO TAP Search** tab and changing the 'Project' to **neowiser**. We query all columns of data and we search the target by its object id, which is its name, and use the 'like' condition to only write (558) with a wildcard as shown in the cell below.
8281

8382
Construction of the query can be found in the [`IRSA TAP documentation page`](https://irsa.ipac.caltech.edu/docs/program_interface/TAP.html).
8483

85-
We first add a cell to the layout that will hold the table; this cell is shown at row = 0, col = 0, with width = 4, height = 2. Once the cell is created, we can request the necessary data from the catalog and display the data as a table using the [`show_table`](https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.show_table) method.
84+
```{code-cell} ipython3
85+
BASE_URL = "https://irsa.ipac.caltech.edu/TAP/sync"
86+
QUERY = """
87+
SELECT *
88+
FROM neowiser_p1ba_mch AS n
89+
WHERE n.objid LIKE '(558)%'
90+
"""
91+
table_url = f"{BASE_URL}?QUERY={urllib.parse.quote_plus(QUERY)}"
92+
table_url
93+
```
94+
95+
Now, we can request the necessary data from the catalog and display the data as a table in the Firefly client, using the [`show_table`](https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.show_table) method.
8696

8797
Alternatively, we can download data from the catalog using [`astropy.utils.data.download_file`](https://docs.astropy.org/en/stable/api/astropy.utils.data.download_file.html) and upload it to the Firefly client shown in the cell below the first method.
8898

8999
```{code-cell} ipython3
90-
r = fc.add_cell(0, 0, 4, 2, 'tables', 'main')
91-
92-
if r['success']:
93-
table_url = ("https://irsa.ipac.caltech.edu/TAP/sync?QUERY=SELECT+*+FROM+neowiser_p1ba_mch+AS+n+WHERE+n.objid+like+'(558)%'")
94-
fc.show_table(table_url, tbl_id='tableneo', title='558 Carmen NeoWise Catalog', page_size=50)
100+
fc.show_table(table_url, tbl_id='tableneo', title='558 Carmen NeoWise Catalog', page_size=50)
95101
```
96102

97103
```{code-cell} ipython3
98-
# r = fc.add_cell(0, 0, 4, 2, 'tables', 'main')
104+
# tablename = astropy.utils.data.download_file(table_url, timeout=120, cache=True)
105+
# file = fc.upload_file(tablename)
106+
# fc.show_table(file, tbl_id='tableneo', title='558 Carmen Catalog', page_size=50)
107+
```
99108

100-
# if r['success']:
101-
# table_url = ("https://irsa.ipac.caltech.edu/TAP/sync?QUERY=SELECT+*+FROM+neowiser_p1ba_mch+AS+n+WHERE+n.objid+like+'(558)%'")
102-
# tablename = astropy.utils.data.download_file(table_url, timeout=120, cache=True)
109+
Note that along with the table, firefly also displays the coverage and chart associated with the table. It overlays colored squares for each row of the table onto a HiPS image, because the table contains recognizable celestial coordinates. It also creates a scatter plot of ra and dec from the table.
103110

104-
# file = fc.upload_file(tablename)
105-
# fc.show_table(file, tbl_id='tableneo', title='558 Carmen Catalog', page_size=50)
106-
```
111+
+++
107112

108113
## Step 3
109114

110115
After retrieving the data and displaying it in the client, we can now create a light curve by plotting the Modified Julian Date ('mjd') in the abscissa and the magnitude from band W1 ('w1mpro') in the ordinate. We also flip the ordinate to accurately display magnitude.
111116

112117
```{code-cell} ipython3
113-
r = fc.add_cell(2, 0, 2, 2, 'plot-image', 'light-curve')
114-
if r['success']:
115-
status = fc.show_xyplot(tbl_id='tableneo', xCol='mjd', yCol='w1mpro', yOptions='flip')
118+
fc.show_xyplot(tbl_id='tableneo', xCol='mjd', yCol='w1mpro', yOptions='flip')
116119
```
117120

118121
## Step 4
119122

120-
Finally, we can overlay the catalog of data in the table onto a HiPS image using the [`show_coverage`](https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.show_coverage) method.
121-
122-
You will notice that there are colored squares that signify where the object was observed based on the RA and Dec given in the catalog.
123-
124-
```{code-cell} ipython3
125-
r = fc.add_cell(2, 2, 2, 2, 'catalog-image', 'target')
126-
if r['success']:
127-
fc.show_coverage();
128-
```
129-
130-
Alternatively, we can queue a HiPS image using the method [`show_hips`](https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.show_hips). However, this method requires target coordinates for the object you want to analyze.
123+
Finally, we can overlay the catalog of data in the table onto a HiPS image of our choice, using the method [`show_hips`](https://caltech-ipac.github.io/firefly_client/api/firefly_client.FireflyClient.html#firefly_client.FireflyClient.show_hips). However, this method requires target coordinates for the object you want to analyze.
131124

132125
```{code-cell} ipython3
133126
target='229.851396;-9.720647;EQ_J2000'
134127
viewer_id = 'hipsDiv'
135128
hips_url = 'http://alasky.u-strasbg.fr/AllWISE/RGB-W4-W2-W1'
136129
137-
r = fc.add_cell(2, 2, 2, 2, 'catalog-image', 'target')
138-
if r['success']:
139-
status = fc.show_hips(viewer_id=viewer_id, plot_id='aHipsID1-1', hips_root_url = hips_url,
130+
fc.show_hips(viewer_id=viewer_id, plot_id='aHipsID1-1', hips_root_url = hips_url,
140131
Title='HiPS-WISE', WorldPt=target)
141132
```
142133

@@ -146,7 +137,7 @@ Firefly allows you to visualize data for specific targets. In conjuction with As
146137

147138
1. We import all necessary modules to create a Firefly client and to download the catalog of data for our target.
148139

149-
2. We start the client in our web browser and prep the layout to appropiately display our tables, plots and images.
140+
2. We start the client in our web browser to appropiately display our tables, plots and images.
150141

151142
3. We use the TAP schema to display the data for our target &mdash; [`558 Carmen`](https://irsa.ipac.caltech.edu/irsaviewer/?__action=table.search&request=%7B%22startIdx%22%3A0%2C%22SearchMethod%22%3A%22AllSky%22%2C%22RequestedDataSet%22%3A%22NEOWISE%20Reactivation%20Database%22%2C%22id%22%3A%22GatorQuery%22%2C%22tbl_id%22%3A%22tbl_id-cf48-45%22%2C%22META_INFO%22%3A%7B%22title%22%3A%22WISE-neowiser_p1ba_mch%20(AllSky)%22%2C%22tbl_id%22%3A%22tbl_id-cf48-45%22%2C%22tbl_pref_key%22%3A%22WISE-neowiser_p1ba_mch%22%7D%2C%22catalogProject%22%3A%22WISE%22%2C%22catalog%22%3A%22neowiser_p1ba_mch%22%2C%22constraints%22%3A%22objid%20like%20%27%25(558)%20Carmen%25%27%22%2C%22pageSize%22%3A100%7D&options=%7B%22backgroundable%22%3Atrue%2C%22pageSize%22%3A100%7D) &mdash; via a table and visualize such data through charts.
152143

@@ -161,5 +152,5 @@ Firefly allows you to visualize data for specific targets. In conjuction with As
161152
+++
162153

163154
**Author:** Eric Bratton II (IRSA Scientist) in conjunction with the IRSA Science Team<br>
164-
**Updated On:** 2024-07-31<br>
155+
**Updated On:** 2024-10-17<br>
165156
**Contact:** [email protected] or https://irsa.ipac.caltech.edu/docs/help_desk.html

tutorials/firefly/SEDs_in_Firefly.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ phot_tbl
553553

554554
This notebook assumes that [jupyter_firefly_extensions](https://github.com/Caltech-IPAC/jupyter_firefly_extensions) has been installed, and that the Firefly server to use has been specified before Jupyterlab was started.
555555

556-
If everything has been properly configured, executing the next cell will bring up a Firefly tab in Jupyterlab with the message "Firefly Ready":
556+
If everything has been properly configured, executing the next cell will bring up a Firefly tab in Jupyterlab with the welcome message.
557557

558558
```{code-cell} ipython3
559559
# Uncomment to use the jupyter_firefly_extensions
@@ -566,7 +566,6 @@ fc = FireflyClient.make_client(url="https://irsa.ipac.caltech.edu/irsaviewer")
566566
In the event that there are problems with the tab opened above, run the below command to obtain a web link that can be opened in a browser directly:
567567

568568
```{code-cell} ipython3
569-
# Temporary work-around to Firefly error for Slate and/or Internet connection problems
570569
fc.display_url()
571570
```
572571

@@ -577,7 +576,7 @@ tblpath = "./phot_tbl.fits"
577576
phot_tbl.write(tblpath, format="fits", overwrite=True)
578577
```
579578

580-
Upload the table to Firefly:
579+
Upload the table (FITS file) to Firefly:
581580

582581
```{code-cell} ipython3
583582
tval = fc.upload_file(tblpath)
@@ -667,9 +666,9 @@ j_fname, h_fname, k_fname = get_2mass_images(target)
667666
```
668667

669668
```{code-cell} ipython3
670-
fc.show_fits(fc.upload_file(j_fname), plot_id="2MASS J")
671-
fc.show_fits(fc.upload_file(h_fname), plot_id="2MASS H")
672-
fc.show_fits(fc.upload_file(k_fname), plot_id="2MASS K")
669+
fc.show_fits(fc.upload_file(j_fname), plot_id="2MASS J", title="2MASS J")
670+
fc.show_fits(fc.upload_file(h_fname), plot_id="2MASS H", title="2MASS H")
671+
fc.show_fits(fc.upload_file(k_fname), plot_id="2MASS K", title="2MASS K")
673672
```
674673

675674
```{code-cell} ipython3
@@ -684,14 +683,14 @@ fc.set_pan(plot_id="2MASS K", x=target.ra.deg,
684683
y=target.dec.deg, coord="j2000")
685684
```
686685

687-
In the future, the user should be able to implement turning on "Align and Lock by WCS" using the Python API as part of this notebook.
686+
For turning on "Align and Lock by WCS" in these images, there's no dedicated method in Firefly but you can use this workaround (using low-level API):
688687

689-
+++
690-
691-
The current alternative is to use the following link to launch IRSA Finder Chart in a separate browser and turn on that function there:
692-
https://irsa.ipac.caltech.edu/applications/finderchart/servlet/api?mode=getResult&locstr=270.599026+-24.147018+Equ+J2000&subsize=0.0167&sources=2MASS&DoSearch=true
688+
```{code-cell} ipython3
689+
fc.dispatch('ImagePlotCntlr.wcsMatch',
690+
payload=dict(matchType='Standard', lockMatch=True))
691+
```
693692

694-
In that Firefly display, it should be possible to turn on "Align and Lock by WCS" in the image toolbar.
693+
Note that zooming or panning one image will do the same in the other images as well.
695694

696695
+++
697696

@@ -705,7 +704,7 @@ In that Firefly display, it should be possible to turn on "Align and Lock by WCS
705704

706705
**Author:** David Shupe (IRSA Scientist) and Joyce Kim (IRSA Scientist) in conjunction with the IRSA Science Team
707706

708-
**Updated On:** 2024-07-31
707+
**Updated On:** 2024-10-17
709708

710709
**Contact:** [email protected] or https://irsa.ipac.caltech.edu/docs/help_desk.html
711710

0 commit comments

Comments
 (0)