#!/usr/bin/env python # coding: utf-8 # This notebook demonstrates basic usage of the firefly_client API. # # 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 Python 2/3 compatibility # In[ ]: from __future__ import print_function, division, absolute_import # Imports for firefly_client # In[ ]: from firefly_client import FireflyClient # In this example we use the irsaviewer application for the server. # In[ ]: url='http://127.0.0.1:8080/firefly' # Instantiate `FireflyClient`. # In[ ]: fc = FireflyClient(url) # ## Download some data # Download a sample image and table. # # We use astropy here for convenience, but firefly_client itself does not depend on astropy. # In[ ]: import astropy.utils.data # Download a cutout of a WISE band 1 image. # In[ ]: image_url = ('http://irsa.ipac.caltech.edu/ibe/data/wise/allsky/4band_p1bm_frm/6a/02206a' + '/149/02206a149-w1-int-1b.fits?center=70,20&size=200pix') filename = astropy.utils.data.download_file(image_url, cache=True, timeout=120) # ## Display tables and catalogs # Open a browser to the firefly server in a new tab. The browser open only works when running the notebook locally, otherwise a link is displayed. # In[ ]: localbrowser, browser_url = fc.launch_browser() # Display the web browser link # In[ ]: fc.display_url() # A local file can be uploaded to the server and then displayed. # In[ ]: imval = fc.upload_file(filename) status = fc.show_fits(file_on_server=imval, plot_id="region test", title='text region test') # Add region data containing text region with 'textangle' property # In[ ]: text_regions= [ 'image;text 100 150 # color=pink text={text angle is 30 deg } edit=0 highlite=0 font="Times 16 bold normal" textangle=30', 'image;text 100 25 # color=pink text={text angle is -20 deg } font="Times 16 bold italic" textangle=-20', 'circle 80.48446937 77.231180603 13.9268922 # text={physical;circle ;; color=cyan } color=cyan', 'image;box 100 150 60 30 30 # color=red text={box on # J2000 with size w=60 & h=30}', 'circle 80.484469p 77.231180p 3.002392 # color=#B8E986 text={This message has both a " and \' in it}'] status = fc.add_region_data(region_data=text_regions, region_layer_id='layerTextRegion', plot_id='region test') # In[ ]: