{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook demonstrates basic usage of the firefly_client API for Firefly to render tables, images and charts in a grid layout style. \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": [ "\n", "## 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": [ "This example tentatively uses 127.0.0.1:8080 as the server " ] }, { "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": [ "## Dispaly tables, images, XY charts, and Histograms in Window/Grid like layout\n", "\n", "Each rendered unit on Firefly." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Please refer to firefly_slate_demo.py which contains functions to render cells with element tables, images, xy charts or histograms onto Firefly Slate Viewer by using firefly_client API. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import firefly_slate_demo as fs" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Display tables and catalogs" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Open a browser to the firefly server in a new tab. Only works when running the notebook locally." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add some tables into cell 'main' (default grid viewer id for tables)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# first table in cell 'main' \n", "fs.load_moving_table(0,0,4,2, fc)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# add table in cell 'main' for chart and histogram \n", "fs.add_table_for_chart(fc)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# add table in cell 'main'\n", "fs.add_simple_image_table(fc)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# add table in cell 'main'\n", "fs.add_simple_m31_image_table(fc)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "f= '/Users/roby/fits/2mass-m31-2412rows.tbl'\n", "file= fc.upload_file(f);" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fc.show_table(file)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fc.show_table('${cache-dir}/upload_2482826742890803252.fits')\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Add different types of image displays" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# show cell containing the image from the active table with datasource column in cell 'main'\n", "fs.load_image_metadata(2, 0, 4, 2, fc, 'image-meta')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# show cell containing FITS in cell 'wise-cutout'\n", "fs.load_image(0, 4, 2, 2, fc, 'wise-cutout') # load an image" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# show cell with 4 FITS of moving objects in cell 'movingStff'\n", "fs.load_moving(2, 4, 2, 2, fc, 'movingStuff')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Add charts (xy plot and histogram)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# show xy plot in cell 'chart-cell-xy' associated with the table for chart in cell 'main'\n", "fs.load_xy(4, 0, 2, 3, fc, 'chart-cell-xy')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# show histogram associated with the table for chart in cell 'main', the cell id is generated by firefly_client\n", "fs.load_histogram(4, 2, 2, 3, fc)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Add more images" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# show cell containing coverage image associated with the active table in cell 'main'\n", "fs.load_coverage_image(4, 4, 3, 3, fc, 'image-coverage')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# show cell containing image in ranmon location without passing the location and cell id\n", "fs.load_first_image_in_random(fc)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# show second image in random location. This image is located in the same cell as the previous one \n", "fs.load_second_image_in_random(fc)" ] } ], "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 }