{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook demonstrates basic usage of the firefly_client API, overlay_footprints, which overlays the footprint described in image pixel of JSON format on the fits image " ] }, { "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" ] }, { "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": [ "import astropy.utils.data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this example we use the local Firefly server." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "url = 'http://127.0.0.1:8080/firefly'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Instantiate `FireflyClient`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fc = FireflyClient(url)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Download some data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "localbrowser, browser_url = fc.launch_browser()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The data used in this example are taken from http://web.ipac.caltech.edu/staff/shupe/firefly_testdata" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "image_url = 'http://web.ipac.caltech.edu/staff/shupe/firefly_testdata/calexp-subset-HSC-R.fits'\n", "filename = astropy.utils.data.download_file(image_url, cache=True, timeout=120)\n", "imval = fc.upload_file(filename)\n", "plotid = 'footprinttest'" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "status = fc.show_fits(file_on_server=imval, plot_id=plotid, title='footprints HSC R-band')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "table_url = 'http://web.ipac.caltech.edu/staff/shupe/firefly_testdata/footprints-subset-HSC-R.xml'\n", "footprint_table = astropy.utils.data.download_file(table_url, cache=True, timeout=120)\n", "tableval = fc.upload_file(footprint_table)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "status = fc.overlay_footprints(tableval, title='footprints HSC R-band',\n", " footprint_layer_id='footprint_layer_1', \n", " plot_id=plotid, \n", " highlightColor='yellow', \n", " selectColor='cyan', \n", " style='fill', \n", " color='rgba(74,144,226,0.30)')" ] }, { "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.0 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.1" } }, "nbformat": 4, "nbformat_minor": 1 }