{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook demonstrates basic usage of the firefly_client API for Firefly Slate Viewer to render tables, images and charts in a grid layout style. This notebook shows the same layout content as what ffapi-api-slate.html renders in Firefly.\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 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": "markdown", "metadata": {}, "source": [ "This example uses http://127.0.0.1:8080/firefly as the server.\n", "\n", "'slate.html' is a template made for grid view " ] }, { "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)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Display tables, images, XY charts, and Histograms in Window/Grid like layout\n", "\n", "Each rendered unit on Firefly Slate Viewer is called a'cell'. To render a cell and its content, the cell location (row, column, width, height), element type and cell ID are needed. (row, column) and (width, height) represent the position and size of the cell in terms of the grid blocks on Firefly Slate Viewer. Element types include types of 'tables', images', 'xyPlots', 'tableImageMeta' and 'coverageImage'.\n" ] }, { "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. The browser open only works when running the notebook locally, otherwise the browser url will be displayed." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "localbrowser, browser_url = fc.launch_browser()" ] }, { "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": "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)" ] }, { "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 }