This notebook demonstrates the simplified plot interface. The philosophy of the plot
module is similar to how import matplotlib.pyplot as plt
is used to select a backend and make simple plotting commands available, with the object-oriented interface still available for advanced applications.
The goal of the notebook is to easily show tables, make plots, and display images. The data items can be uploaded directly as files to Firefly, or as objects with serialization methods.
When the plot method is imported, a search will be conducted for an instance of FireflyClient
:
FireflyClient
with a web browser connected, it will be used.FIREFLY_URL
is defined, an instance of FireflyClient
will be created using that URL.http://localhost:8080/firefly
, it will be used.import firefly_client.plot as ffplt
The next cell will attempt to launch a browser, if there is not already a web page connected to the instance of FireflyClient
.
ffplt.open_browser()
If the browser launch is unsuccessful, a link will be displayed for your web browser.
The next cell will display a clickable link
ffplt.display_url()
By default, a channel is generated for you. If you find it more convenient to use a specific server and channel, uncomment out the next cell to generate a channel from your username.
#import os
#my_channel = os.environ['USER'] + '-plot-module'
#ffplt.reset_server(url='https://lsst-demo.ncsa.illinois.edu/firefly', channel=my_channel)
If needed, clear the viewer and reset the layout to the defaults.
ffplt.clear()
ffplt.reset_layout()
import astropy.utils.data
For the case of a file already on disk, pass the path and a title for the table. Here we download a file.
m31_table_fname = astropy.utils.data.download_file(
'http://web.ipac.caltech.edu/staff/roby/demo/m31-2mass-2412-row.tbl',
timeout=120, cache=True)
Upload the table file from disk, and enable the coverage image
tbl_id = ffplt.upload_table(m31_table_fname, title='M31 2MASS', view_coverage=True)
Make a histogram from the last uploaded table, with the minimum required parameters
ffplt.hist('j_m')
Make a scatter plot from the last uploaded table, with the minimum required parameters
ffplt.scatter('h_m - k_m', 'j_m')
Load a FITS file using astropy.io.fits
import astropy.io.fits as fits
m31_image_fname = astropy.utils.data.download_file(
'http://web.ipac.caltech.edu/staff/roby/demo/2mass-m31-green.fits',
timeout=120, cache=True)
hdu = fits.open(m31_image_fname)
type(hdu)
Upload to the viewer. The return value is the plot_id
.
ffplt.upload_image(hdu)
If the astropy
package is installed, a Numpy array can be uploaded.
data = hdu[0].data
type(data)
Upload to the viewer. The return value is the plot_id
.
ffplt.upload_image(data)
wise_tbl_name = astropy.utils.data.download_file('http://web.ipac.caltech.edu/staff/roby/demo/WiseDemoTable.tbl',
timeout=120, cache=True)
from astropy.table import Table
wise_table = Table.read(wise_tbl_name, format='ipac')
ffplt.upload_table(wise_table, title='WISE Demo Table')