#!/usr/bin/env python # coding: utf-8 # This notebook demonstrates basic usage of the firefly_client API for Firefly 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. # # ## Setup # Imports for firefly_client # In[ ]: from firefly_client import FireflyClient import astropy.utils.data using_lab = False url = 'http://127.0.0.1:8080/firefly' #FireflyClient._debug= True # This example tentatively uses 127.0.0.1:8080 as the server # In[ ]: fc = FireflyClient.make_lab_client() if using_lab else FireflyClient.make_client(url) # ## Dispaly tables, images, XY charts, and Histograms in Window/Grid like layout # # 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. # In[ ]: import firefly_slate_demo as fs # ## Display tables and catalogs # Open a browser to the firefly server in a new tab. Only works when running the notebook locally. # Add some tables into cell 'main' (default grid viewer id for tables) # In[ ]: # first table in cell 'main' fs.load_moving_table(0,0,4,2, fc) # In[ ]: # add table in cell 'main' for chart and histogram fs.add_table_for_chart(fc) # In[ ]: # add table in cell 'main' fs.add_simple_image_table(fc) # In[ ]: # add table in cell 'main' fs.add_simple_m31_image_table(fc) # In[ ]: f= '/Users/roby/fits/2mass-m31-2412rows.tbl' file= fc.upload_file(f); # In[ ]: fc.show_table(file) # In[ ]: fc.show_table('${cache-dir}/upload_2482826742890803252.fits') # ## Add different types of image displays # In[ ]: # 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') # In[ ]: # show cell containing FITS in cell 'wise-cutout' fs.load_image(0, 4, 2, 2, fc, 'wise-cutout') # load an image # In[ ]: # show cell with 4 FITS of moving objects in cell 'movingStff' fs.load_moving(2, 4, 2, 2, fc, 'movingStuff') # ## Add charts (xy plot and histogram) # In[ ]: # 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') # In[ ]: # 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) # ## Add more images # In[ ]: # show cell containing coverage image associated with the active table in cell 'main' fs.load_coverage_image(4, 4, 3, 3, fc, 'image-coverage') # In[ ]: # show cell containing image in ranmon location without passing the location and cell id fs.load_first_image_in_random(fc) # In[ ]: # 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)