Skip to content

Commit db88c78

Browse files
authored
Merge pull request #10 from bsipocz/CONT_adding_firefly
CONT: adding firefly tutorials
2 parents 64a2951 + 5abf9f1 commit db88c78

File tree

5 files changed

+898
-4
lines changed

5 files changed

+898
-4
lines changed

.github/workflows/ci_tests_run_notebooks.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,8 @@ jobs:
4646
run: python -m pip install --upgrade tox
4747

4848
- name: Test with tox
49-
run: tox ${{ matrix.toxargs }} -e ${{ matrix.toxenv }} -- ${{ matrix.toxposargs }}
49+
run: |
50+
# Workaround for OSX for https://jira.ipac.caltech.edu/browse/FIREFLY-1528
51+
bash -c 'if echo ${{ runner.os }} | grep -i macos; then echo tutorials/firefly >> ignore_testing; fi'
52+
53+
tox ${{ matrix.toxargs }} -e ${{ matrix.toxenv }} -- ${{ matrix.toxposargs }}

index.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,19 @@ tutorials/cosmodc2/cosmoDC2_TAP_access.md
3737
```
3838

3939

40-
<!---
4140

42-
## Visualizations
41+
## Visualizations with Firefly
42+
4343
```{toctree}
4444
---
4545
maxdepth: 1
4646
---
4747
48+
tutorials/firefly/SEDs_in_Firefly
49+
tutorials/firefly/NEOWISE_light_curve_demo
50+
4851
```
49-
-->
52+
5053

5154

5255
## IRSA in the cloud
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
---
2+
jupytext:
3+
text_representation:
4+
extension: .md
5+
format_name: myst
6+
format_version: 0.13
7+
jupytext_version: 1.16.2
8+
kernelspec:
9+
display_name: Python 3 (ipykernel)
10+
language: python
11+
name: python3
12+
---
13+
14+
# Finding Light Curves of Solar System Objects
15+
16+
## Learning Goals
17+
18+
By the end of this tutorial, you will:
19+
20+
- Construct a TAP query to download the necessary data and visualize it via the web browser with an instantiated Firefly environment.
21+
- Plot light curves from NEOWISE data using the Firefly Python API.
22+
- Format cells containing tables, charts and images viewed in the client.
23+
- Overlay a catalog of data onto a HiPS image.
24+
25+
+++
26+
27+
## Introduction
28+
29+
This tutorial demonstrates how to plot light curves from NEOWISE data while also flaunting the many useful capabilities of the Firefly Python API. Using the 'Known Solar System Object Possible Association List' catalog from the NEOWISE-R database, we can easily compose a light curve of the faint asteroid `558 Carmen` and show its observed positions in the sky solely through the `firefly_client` package. Minor planet light curves are important in determining their size, spectral class, rotation period and many other properties.
30+
31+
Firefly is an astronomical data access and visualization written by Caltech/IPAC-IRSA. The visualization provides user with an integrated experience with brushing and linking capabilities among images, catalogs, and plots. Firefly is used in IRSA GUIs to query and visualize data from missions such as WISE, Spitzer, SOFIA, ZTF, PTF, etc. and a large number of highly-used contributed data products from a diverse set of astrophysics projects.
32+
33+
The `firefly_client` package provides a lightweight client class that includes a Python interface to Firefly’s Javascript API.
34+
35+
For documentation on the firefly client visit https://caltech-ipac.github.io/firefly_client/.
36+
37+
+++
38+
39+
## Imports
40+
41+
- *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
43+
- *astropy.utils.data* for downloading the catalog data via TAP query
44+
45+
```{code-cell} ipython3
46+
from firefly_client import FireflyClient
47+
import firefly_client.plot as ffplt
48+
import astropy.utils.data
49+
```
50+
51+
## Step 1
52+
53+
Instantiate the client via and view it in a different tab in the web browser.
54+
55+
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/.
56+
57+
```{code-cell} ipython3
58+
url = 'https://irsa.ipac.caltech.edu/irsaviewer'
59+
# url='http://127.0.0.1:8080/firefly' # if you have firefly server running locally (preferably through docker)
60+
61+
fc = FireflyClient.make_client(url)
62+
ffplt.use_client(fc)
63+
```
64+
65+
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).
66+
67+
```{code-cell} ipython3
68+
# fc.reinit_viewer(); # The semi-colon suppresses the output of the method when ran
69+
```
70+
71+
## Step 2
72+
73+
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:
74+
75+
- 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>
76+
- 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)%'"
77+
78+
Construction of the query can be found in the [`IRSA TAP documentation page`](https://irsa.ipac.caltech.edu/docs/program_interface/TAP.html).
79+
80+
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.
81+
82+
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.
83+
84+
```{code-cell} ipython3
85+
r = fc.add_cell(0, 0, 4, 2, 'tables', 'main')
86+
87+
if r['success']:
88+
table_url = ("https://irsa.ipac.caltech.edu/TAP/sync?QUERY=SELECT+*+FROM+neowiser_p1ba_mch+AS+n+WHERE+n.objid+like+'(558)%'")
89+
fc.show_table(table_url, tbl_id='tableneo', title='558 Carmen NeoWise Catalog', page_size=50)
90+
```
91+
92+
```{code-cell} ipython3
93+
# r = fc.add_cell(0, 0, 4, 2, 'tables', 'main')
94+
95+
# if r['success']:
96+
# table_url = ("https://irsa.ipac.caltech.edu/TAP/sync?QUERY=SELECT+*+FROM+neowiser_p1ba_mch+AS+n+WHERE+n.objid+like+'(558)%'")
97+
# tablename = astropy.utils.data.download_file(table_url, timeout=120, cache=True)
98+
99+
# file = fc.upload_file(tablename)
100+
# fc.show_table(file, tbl_id='tableneo', title='558 Carmen Catalog', page_size=50)
101+
```
102+
103+
## Step 3
104+
105+
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.
106+
107+
```{code-cell} ipython3
108+
r = fc.add_cell(2, 0, 2, 2, 'plot-image', 'light-curve')
109+
if r['success']:
110+
status = fc.show_xyplot(tbl_id='tableneo', xCol='mjd', yCol='w1mpro', yOptions='flip')
111+
```
112+
113+
## Step 4
114+
115+
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.
116+
117+
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.
118+
119+
```{code-cell} ipython3
120+
r = fc.add_cell(2, 2, 2, 2, 'catalog-image', 'target')
121+
if r['success']:
122+
fc.show_coverage();
123+
```
124+
125+
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.
126+
127+
```{code-cell} ipython3
128+
target='229.851396;-9.720647;EQ_J2000'
129+
viewer_id = 'hipsDiv'
130+
hips_url = 'http://alasky.u-strasbg.fr/AllWISE/RGB-W4-W2-W1'
131+
132+
r = fc.add_cell(2, 2, 2, 2, 'catalog-image', 'target')
133+
if r['success']:
134+
status = fc.show_hips(viewer_id=viewer_id, plot_id='aHipsID1-1', hips_root_url = hips_url,
135+
Title='HiPS-WISE', WorldPt=target)
136+
```
137+
138+
## Summary
139+
140+
Firefly allows you to visualize data for specific targets. In conjuction with Astropy, one can manipulate a catalog of observations to display a light curve in an instantiated Firefly enviroment on their web browser.
141+
142+
1. We import all necessary modules to create a Firefly client and to download the catalog of data for our target.
143+
144+
2. We start the client in our web browser and prep the layout to appropiately display our tables, plots and images.
145+
146+
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.
147+
148+
4. We finally overlay the catalog onto a HiPS image to dynamically view where our target has been observed in space.
149+
150+
+++
151+
152+
***
153+
154+
## About This Notebook
155+
156+
+++
157+
158+
**Author:** Eric Bratton II (IRSA Scientist) in conjunction with the IRSA Science Team<br>
159+
**Updated On:** 2024-07-31<br>
160+
**Contact:** [email protected] or https://irsa.ipac.caltech.edu/docs/help_desk.html

0 commit comments

Comments
 (0)