{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Intro" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook demonstrates basic usage of the firefly_client API method `overlay_footprints` which overlays the footprint described in image pixel of JSON format on a FITS image.\n", "\n", "Note that it may be necessary to wait for some cells (like those displaying an table) to complete before executing later cells." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setup" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Imports for firefly_client: " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from firefly_client import FireflyClient\n", "import astropy.utils.data\n", "using_lab = False\n", "url = 'http://127.0.0.1:8080/firefly'\n", "#FireflyClient._debug= True" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this example, we use local firefly server (you can also use public server - irsaviewer instead):" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Instantiate `FireflyClient` using the url above." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fc = FireflyClient.make_lab_client() if using_lab else FireflyClient.make_client(url)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Start with Image Data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The data used in this example are taken from http://web.ipac.caltech.edu/staff/shupe/firefly_testdata and can be downloaded. Download a file using the image URL below and upload it to the server:" ] }, { "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)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Set the `plot_id` for the image and display it through the opened browser:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plotid = 'footprinttest'\n", "status = fc.show_fits(file_on_server=imval, plot_id=plotid, title='footprints HSC R-band')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Add Data for Footprints" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Upload a table with footprint data using the foloowing url from where it can be downloaded:" ] }, { "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": "markdown", "metadata": {}, "source": [ "Overlay a footprint layer (while comparing a highlighted section to the overall footprint) onto the plot using the above 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)')" ] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.10.12" } }, "nbformat": 4, "nbformat_minor": 4 }