#!/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 import json # Imports for firefly_client # In[ ]: from firefly_client import FireflyClient # In[ ]: target='148.892;69.0654;EQ_J2000' fov_deg=0.5 size=0.2 image_basic_req = { 'Service': 'WISE', 'Title': 'Wise', 'SurveyKey': '3a', 'SurveyKeyBand': '2' } hips_basic_req = { 'title': 'A HiPS - 0.2', 'hipsRootUrl': 'http://alasky.u-strasbg.fr/AllWISE/RGB-W4-W2-W1' } # In this example we use the slate.html application for a local server. # In[ ]: url='http://127.0.0.1:8080/firefly' html = 'slate.html' fc = FireflyClient(url, html_file=html) fc.launch_browser() # In[ ]: fc.reinit_viewer() # ## Show HiPS # A HiPS is displayed based on HiPS url # In[ ]: viewer_id = 'hipsDIV1' r = fc.add_cell(0, 0, 4, 2, 'images', viewer_id) if r['success']: hips_url = 'http://alasky.u-strasbg.fr/DSS/DSSColor'; status = fc.show_hips(viewer_id=viewer_id, plot_id='aHipsID1-1', hips_root_url = hips_url, Title='HiPS-DSS', WorldPt=target) # Show another HiPS in the same viewer # In[ ]: if r['success']: hips_url = 'http://alasky.u-strasbg.fr/DSS/DSS2Merged'; status = fc.show_hips(viewer_id=viewer_id, plot_id='aHipsID1-2', hips_root_url = hips_url, Title='HiPS-DSS2', WorldPt=target) # ## Show HiP with hips to image conversion info # In[ ]: hiconversion = { 'imageRequestRoot': dict(hips_basic_req), 'fovDegFallOver': fov_deg } viewer_id = 'hipsDiv2' r = fc.add_cell(0, 4, 2, 2, 'images', viewer_id) if r['success']: hips_url = 'http://alasky.u-strasbg.fr/AllWISE/RGB-W4-W2-W1' status = fc.show_hips(viewer_id=viewer_id, plot_id='aHipsID2', hips_root_url=hips_url, hips_image_conversion=hiconversion) # ## Show Image or HiPS # # Either HiPS or image is displayed per info, such as size or target, defined in image_request, hips_request or allsky_request. # HiPS is displayed => hips_requst: {size:no, target:no}, image_request: {size:no, target:yes} # In[ ]: viewer_id = 'hipsDiv3' r = fc.add_cell(2, 0, 2, 2, 'images', viewer_id) if r['success']: status = fc.show_image_or_hips(viewer_id=viewer_id, image_request=dict(image_basic_req), hips_request=dict(hips_basic_req), fov_deg_fallover=fov_deg) # HiPS is displayed => hips_request: {size:no, target:no}, image_request: {target:yes, size:no} # In[ ]: viewer_id = 'hipsDiv4' r = fc.add_cell(2, 2, 2, 2, 'images', viewer_id) if r['success']: image_r = dict(image_basic_req) image_r.update({'WorldPt': target}) status = fc.show_image_or_hips(viewer_id=viewer_id, image_request=image_r, hips_request=dict(hips_basic_req), fov_deg_fallover=fov_deg) # Regular image is displayed => image_request: {size:yes, target:yes} # In[ ]: viewer_id = 'hipsDiv5' r = fc.add_cell(2, 4, 2, 2, 'images', viewer_id) if r['success']: image_r = dict(image_basic_req) image_r.update({'WorldPt': target, 'SizeInDeg': size}) status=fc.show_image_or_hips(viewer_id=viewer_id, image_request=image_r, hips_request=dict(hips_basic_req), fov_deg_fallover=fov_deg) # All sky is displayed => allsky_request is passed and plot_allsky_first is passed as 'True' # In[ ]: viewer_id = 'hipsDiv6' r = fc.add_cell(4, 0, 4, 2, 'images', viewer_id) if r['success']: status=fc.show_image_or_hips(viewer_id=viewer_id, image_request=dict(image_basic_req), hips_request=dict(hips_basic_req), allsky_request={'Type': 'ALL_SKY'}, fov_deg_fallover=fov_deg, plot_allsky_first=True) # In[ ]: