{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Intro"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook demonstrates basic usage of the firefly_client API method `show_table` for a file with multiple tables.\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": [
"Call the imports for firefly_client:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from firefly_client import FireflyClient"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this example, we use the IRSA Viewer - a public firefly server. The firefly server can also be run locally, e.g. via a Firefly Docker image obtained from https://hub.docker.com/r/ipac/firefly/tags/. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"url='https://irsa.ipac.caltech.edu/irsaviewer'\n",
"# url=http://127.0.0.1:8080/firefly # if you have firefly server running locally\n",
"\n",
"fc = FireflyClient.make_client(url)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The following example involves 2 files in different formats that contain multiple tables, 1 FITS and 1 VOTable (in XML style). If none are present, try to get a FITS from KOA (https://koa.ipac.caltech.edu/cgi-bin/KOA/nph-KOAlogin) and a XML VOTable through an Extended Name search on the classic version of NED (https://ned.ipac.caltech.edu/classic) and save them to a local computer path. To obtain the files directly, follow the links below:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"FITS: https://koa.ipac.caltech.edu/cgi-bin/getKOA/nph-getKOA?filehand=/koadata40/MOSFIRE/20210502/lev0/MF.20210502.18830.fits\n",
"
\n",
"VOTable: https://ned.ipac.caltech.edu/cgi-bin/objsearch?objname=M31&extend=no&hconst=73&omegam=0.27&omegav=0.73&corr_z=1&out_csys=Equatorial&out_equinox=J2000.0&obj_sort=RA+or+Longitude&of=xml_all&zv_breaker=30000.0&list_limit=5&img_stamp=YES"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Please set `testdata_repo_path` to be the local path where the FITS and VOTable files are located:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"testdata_repo_path = '/hydra/cm' # to be reset to where test files are located on your system"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Load a FITS containing multiple tables"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Upload a file in FITS format that contains multiple tables and display it within the browser (noting that it may likely appear as though only the initial one is visible):"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"localfile = os.path.join(testdata_repo_path, 'MF.20210502.18830.fits')\n",
"filename = fc.upload_file(localfile)\n",
"\n",
"fc.show_table(filename)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Look at another table within the FITS file in the browser (simply the only other one included for the case being looked at):"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fc.show_table(filename, table_index=2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Load a VOTable containing multiple tables"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Upload a file in XML format which functions as a VOTable that contains multiple tables display it within the browser (noting that it may likely appear as though only the initial one is visible):"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"localfile = os.path.join(testdata_repo_path, 'Mr31objsearch.xml')\n",
"filename = fc.upload_file(localfile)\n",
"\n",
"fc.show_table(filename, tbl_id='votable-0')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Look at another table within the VOTable in the broswer (simply the only other one included for the case being looked at):"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fc.show_table(filename, tbl_id='votable-1', table_index=1)"
]
},
{
"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.8.9"
}
},
"nbformat": 4,
"nbformat_minor": 4
}