{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook demonstrates basic usage of the firefly_client API.\n", "\n", "Note that it may be necessary to wait for some cells (like those displaying an image) to complete before executing later cells." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setup" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Imports for Python 2/3 compatibility" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from __future__ import print_function, division, absolute_import\n", "import json" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Imports for firefly_client" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from firefly_client import FireflyClient" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "target='148.892;69.0654;EQ_J2000'\n", "fov_deg=0.5\n", "size=0.2\n", "\n", "image_basic_req = {\n", " 'Service': 'WISE',\n", " 'Title': 'Wise',\n", " 'SurveyKey': '3a',\n", " 'SurveyKeyBand': '2'\n", "}\n", "\n", "hips_basic_req = {\n", " 'title': 'A HiPS - 0.2',\n", " 'hipsRootUrl': 'http://alasky.u-strasbg.fr/AllWISE/RGB-W4-W2-W1'\n", "}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this example we use the slate.html application for a local server." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "url='http://127.0.0.1:8080/firefly'\n", "html = 'slate.html'\n", "\n", "fc = FireflyClient(url, html_file=html)\n", "fc.launch_browser()\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fc.reinit_viewer()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Show HiPS " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A HiPS is displayed based on HiPS url" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "viewer_id = 'hipsDIV1'\n", "r = fc.add_cell(0, 0, 4, 2, 'images', viewer_id)\n", "if r['success']:\n", " hips_url = 'http://alasky.u-strasbg.fr/DSS/DSSColor';\n", " status = fc.show_hips(viewer_id=viewer_id, plot_id='aHipsID1-1', hips_root_url = hips_url, \n", " Title='HiPS-DSS', WorldPt=target)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Show another HiPS in the same viewer" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "if r['success']:\n", " hips_url = 'http://alasky.u-strasbg.fr/DSS/DSS2Merged';\n", " status = fc.show_hips(viewer_id=viewer_id, plot_id='aHipsID1-2', hips_root_url = hips_url, \n", " Title='HiPS-DSS2', WorldPt=target)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Show HiP with hips to image conversion info" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "hiconversion = {\n", " 'imageRequestRoot': dict(hips_basic_req),\n", " 'fovDegFallOver': fov_deg\n", "}\n", "\n", "viewer_id = 'hipsDiv2'\n", "r = fc.add_cell(0, 4, 2, 2, 'images', viewer_id)\n", "if r['success']:\n", " hips_url = 'http://alasky.u-strasbg.fr/AllWISE/RGB-W4-W2-W1'\n", " status = fc.show_hips(viewer_id=viewer_id, plot_id='aHipsID2', hips_root_url=hips_url, \n", " hips_image_conversion=hiconversion)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Show Image or HiPS\n", "\n", "Either HiPS or image is displayed per info, such as size or target, defined in image_request, hips_request or allsky_request. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "HiPS is displayed => hips_requst: {size:no, target:no}, image_request: {size:no, target:yes} " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "viewer_id = 'hipsDiv3'\n", "r = fc.add_cell(2, 0, 2, 2, 'images', viewer_id)\n", "if r['success']:\n", " status = fc.show_image_or_hips(viewer_id=viewer_id, image_request=dict(image_basic_req),\n", " hips_request=dict(hips_basic_req), fov_deg_fallover=fov_deg)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "HiPS is displayed => hips_request: {size:no, target:no}, image_request: {target:yes, size:no} " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "viewer_id = 'hipsDiv4'\n", "r = fc.add_cell(2, 2, 2, 2, 'images', viewer_id)\n", "if r['success']:\n", " image_r = dict(image_basic_req)\n", " image_r.update({'WorldPt': target})\n", " status = fc.show_image_or_hips(viewer_id=viewer_id, \n", " image_request=image_r,\n", " hips_request=dict(hips_basic_req), fov_deg_fallover=fov_deg)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Regular image is displayed => image_request: {size:yes, target:yes} " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "viewer_id = 'hipsDiv5'\n", "r = fc.add_cell(2, 4, 2, 2, 'images', viewer_id)\n", "if r['success']:\n", " image_r = dict(image_basic_req)\n", " image_r.update({'WorldPt': target, 'SizeInDeg': size})\n", " status=fc.show_image_or_hips(viewer_id=viewer_id, \n", " image_request=image_r,\n", " hips_request=dict(hips_basic_req), fov_deg_fallover=fov_deg)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "All sky is displayed => allsky_request is passed and plot_allsky_first is passed as 'True'" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "viewer_id = 'hipsDiv6'\n", "r = fc.add_cell(4, 0, 4, 2, 'images', viewer_id)\n", "if r['success']:\n", " status=fc.show_image_or_hips(viewer_id=viewer_id, \n", " image_request=dict(image_basic_req),\n", " hips_request=dict(hips_basic_req), allsky_request={'Type': 'ALL_SKY'}, \n", " fov_deg_fallover=fov_deg, plot_allsky_first=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.2" } }, "nbformat": 4, "nbformat_minor": 1 }