This notebook demonstrates basic usage of the firefly_client API for Firefly Slate Viewer to render tables, images and charts in a grid layout style.
Note that it may be necessary to wait for some cells (like those displaying an image) to complete before executing later cells.
Imports for firefly_client
from firefly_client import FireflyClient
using_lab = False
url = 'http://127.0.0.1:8080/firefly'
#FireflyClient._debug= True
This example uses http://127.0.0.1:8080/firefly as the server.
Both of these are passed by default if there are no corresponding environment variables set, but we're still passing them explicitly for clarity.
fc = FireflyClient.make_lab_client() if using_lab else FireflyClient.make_client(url)
Each rendered unit on Firefly.
Please refer to firefly_slate_demo.py which contains functions to render cells with element tables, images, xy charts or histograms onto Firefly Slate Viewer by using firefly_client API.
import firefly_slate_demo as fs
Instantiating FireflyClient should open a browser to the firefly server in a new tab. You can also achieve this using the following method. The browser open only works when running the notebook locally, otherwise a link is displayed.
# localbrowser, browser_url = fc.launch_browser()
Add some tables into cell 'main' (default grid viewer id for tables)
# first table in cell 'main'
fs.load_moving_table(0,0,4,2, fc)
# add table in cell 'main' for chart and histogram
fs.add_table_for_chart(fc)
# add table in cell 'main'
fs.add_simple_image_table(fc)
# add table in cell 'main'
fs.add_simple_m31_image_table(fc)
# show cell containing the image from the active table with datasource column in cell 'main'
fs.load_image_metadata(2, 0, 4, 2, fc, 'image-meta')
# show cell containing FITS in cell 'wise-cutout'
fs.load_image(0, 4, 2, 2, fc, 'wise-cutout') # load an image
# show cell with 4 FITS of moving objects in cell 'movingStff'
fs.load_moving(2, 4, 2, 2, fc, 'movingStuff')
# show xy plot in cell 'chart-cell-xy' associated with the table for chart in cell 'main'
fs.load_xy(4, 0, 2, 3, fc, 'chart-cell-xy')
# show histogram associated with the table for chart in cell 'main', the cell id is generated by firefly_client
fs.load_histogram(4, 2, 2, 3, fc)
# show cell containing coverage image associated with the active table in cell 'main'
fs.load_coverage_image(4, 4, 3, 3, fc, 'image-coverage')
# show cell containing image in ranmon location without passing the location and cell id
fs.load_first_image_in_random(fc)
# show second image in random location. This image is located in the same cell as the previous one
fs.load_second_image_in_random(fc)