Skip to content

Dm 11476 Make demo sample to create charts with plot.ly #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 11, 2017
154 changes: 104 additions & 50 deletions examples/slate-demo-explicit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
"collapsed": false
},
"outputs": [],
"source": [
Expand All @@ -81,7 +81,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Dispaly tables, images, XY charts, and Histograms in Window/Grid like layout\n",
"## 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'. "
]
Expand Down Expand Up @@ -126,15 +126,34 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"## Display tables and catalogs\n"
"re-init Firefly completely and clean the viewer. You may restart the viewer instead of launching a new browser to repeat rendering cells. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be helpful to insert a Markdown cell above this one, explaining what reinit_viewer() does. It seems to be different than reloading the browser window (clearing everything).

"outputs": [],
"source": [
"fc.reinit_viewer()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Add some tables into cell 'main' (default cell id for tables)"
"\n",
"## Display tables and catalogs\n",
"\n",
"\n",
"Add some tables into cell 'main' (default cell id for tables)\n",
"\n",
"\n",
"- add first table in cell 'main':\n",
"- 'main' is the cell id currently supported by Firefly for element type 'tables'\n",
"- this cell is shown at row = 0, col = 0 with width = 4, height = 2"
]
},
{
Expand All @@ -145,10 +164,6 @@
},
"outputs": [],
"source": [
"# first table in cell 'main'. \n",
"# 'main' is the cell id currently supported by Firefly for element type 'tables'\n",
"# this cell is shown at row = 0, col = 0 with width = 4, height = 2\n",
"\n",
"r = fc.add_cell(0, 0, 4, 2, 'tables', 'main')\n",
"\n",
"if r['success']:\n",
Expand All @@ -160,6 +175,13 @@
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- add 2nd table in cell 'main' for chart and histogram "
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -168,11 +190,16 @@
},
"outputs": [],
"source": [
"# add 2nd table in cell 'main' for chart and histogram \n",
"\n",
"tbl_name = astropy.utils.data.download_file('http://web.ipac.caltech.edu/staff/roby/demo/WiseDemoTable.tbl',\n",
" timeout=120, cache=True)\n",
"fc.show_table(fc.upload_file(tbl_name), tbl_id='tbl_chart', title='table for xyplot and histogram', page_size=15)\n"
"fc.show_table(fc.upload_file(tbl_name), tbl_id='tbl_chart', title='table for xyplot and histogram', page_size=15)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- add 3rd table in cell 'main'"
]
},
{
Expand All @@ -183,12 +210,17 @@
},
"outputs": [],
"source": [
"# add 3rd table in cell 'main'\n",
"\n",
"tbl_name = astropy.utils.data.download_file(\"http://web.ipac.caltech.edu/staff/roby/demo/test-table4.tbl\", \n",
" timeout=120, cache=True)\n",
"meta_info = {'datasource': 'FITS'}\n",
"fc.show_table(fc.upload_file(tbl_name), title='A table of simple images', page_size=15, meta=meta_info)\n"
"fc.show_table(fc.upload_file(tbl_name), title='A table of simple images', page_size=15, meta=meta_info)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- add 4th table in cell 'main'"
]
},
{
Expand All @@ -199,20 +231,21 @@
},
"outputs": [],
"source": [
"# add 4th table in cell 'main'\n",
"\n",
"tbl_name = astropy.utils.data.download_file(\"http://web.ipac.caltech.edu/staff/roby/demo/test-table-m31.tbl\", \n",
" timeout=120, cache=True)\n",
"\n",
"meta_info = {'positionCoordColumns': 'ra_obj;dec_obj;EQ_J2000', 'datasource': 'FITS'}\n",
"fc.show_table(fc.upload_file(tbl_name), title='A table of m31 images', page_size=15, meta=meta_info)\n"
"fc.show_table(fc.upload_file(tbl_name), title='A table of m31 images', page_size=15, meta=meta_info)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Add different types of image displays"
"## Add different types of image displays\n",
"\n",
"- show cell with id 'image-meta' continaing image from the active table containing datasource column in cell 'main'\n",
"- the cell is shown at row = 2, col = 0 with width = 4, height = 2 "
]
},
{
Expand All @@ -223,15 +256,19 @@
},
"outputs": [],
"source": [
"# show cell with id 'image-meta' continaing image from the active table containing datasource column in cell 'main'\n",
"# the cell is shown at row = 2, col = 0 with width = 4, height = 2 \n",
"\n",
"r = fc.add_cell(2, 0, 4, 2, 'tableImageMeta', 'image-meta')\n",
"if r['success']:\n",
" fc.show_image_metadata(viewer_id=r['cell_id'])\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- show cell 'wise-content' containing fits at row = 0, col = 4 with width = 2, height = 2"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -240,8 +277,6 @@
},
"outputs": [],
"source": [
"# show cell 'wise-content' containing fits at row = 0, col = 4 with width = 2, height = 2\n",
"\n",
"r = fc.add_cell(0, 4, 2, 2, 'images', 'wise-cutout')\n",
"if r['success']:\n",
" image_name = astropy.utils.data.download_file('http://irsa.ipac.caltech.edu/ibe/data/wise/allsky/4band_p1bm_frm/6a/02206a' +\n",
Expand All @@ -250,6 +285,13 @@
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- show 4 fits of moving objects in cell 'movingStff' at row = 2, col = 4 with width = 2, height = 2"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -258,8 +300,6 @@
},
"outputs": [],
"source": [
"# show 4 fits of moving objects in cell 'movingStff' at row = 2, col = 4 with width = 2, height = 2\n",
"\n",
"r = fc.add_cell(2, 4, 2, 2, 'images', 'movingStuff')\n",
"if r['success']:\n",
" v_id = r['cell_id']\n",
Expand All @@ -282,7 +322,10 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Add charts (xy plot and histogram)"
"## Add charts (xy plot and histogram)\n",
"\n",
"- show the cell 'chart-cell-xy' with xy plot related to the table with id 'tbl_chart' in cell 'main'\n",
"- this cell is shown at row = 4, col = 0 with width = 2, height = 3"
]
},
{
Expand All @@ -293,15 +336,21 @@
},
"outputs": [],
"source": [
"# show the cell 'chart-cell-xy' with xy plot related to the table with id 'tbl_chart' in cell 'main'\n",
"# this cell is shown at row = 4, col = 0 with width = 2, height = 3\n",
"\n",
"r = fc.add_cell(4, 0, 2, 3, 'xyPlots', 'chart-cell-xy')\n",
"if r['success']:\n",
" fc.show_xyplot('tbl_chart', group_id=r['cell_id'], xCol='ra1', yCol='dec1')\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- show the cell with histogram related to the table with id 'tbl_chart' in cell 'main', \n",
"- this cell is shown at row = 4, col = 2, with width = 2, height = 3 \n",
"- the cell id is automatically created by FireflyClient in case it is not specified externally. "
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -310,21 +359,19 @@
},
"outputs": [],
"source": [
"# show the cell with histogram related to the table with id 'tbl_chart' in cell 'main', \n",
"# this cell is shown at row = 4, col = 2, with width = 2, height = 3 \n",
"# the cell id is automatically created by FireflyClient in case it is not specified externally. \n",
"\n",
"r = fc.add_cell(4, 2, 2, 3, 'xyPlots')\n",
"if r['success']:\n",
" fc.show_histogram('tbl_chart', group_id=r['cell_id'], col='modeint', xOptions='log')\n",
"\n"
" fc.show_histogram('tbl_chart', group_id=r['cell_id'], col='modeint', xOptions='log')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Add more images"
"## Add more images\n",
"\n",
"- show coverage image associated with the active table in cell 'main'\n",
"- ths cell is shown at row = 4, col = 4 with width = 2, height = 3"
]
},
{
Expand All @@ -335,12 +382,18 @@
},
"outputs": [],
"source": [
"# show coverage image associated with the active table in cell 'main'\n",
"# ths cell is shown at row = 4, col = 4 with width = 3, height = 3\n",
"\n",
"r = fc.add_cell(4, 4, 3, 3, 'coverageImage', 'image-coverage')\n",
"r = fc.add_cell(4, 4, 2, 3, 'coverageImage', 'image-coverage')\n",
"if r['success']:\n",
" fc.show_coverage(viewer_id=r['cell_id'])\n"
" fc.show_coverage(viewer_id=r['cell_id'])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- show image in random location without passing cell location and cell id (i.e. without calling add_cell)\n",
"- the image is shown in the cell with id 'DEFAULT_FITS_VIEWER_ID' in default, \n",
"- and the cell is automatically located by Firefly"
]
},
{
Expand All @@ -351,13 +404,16 @@
},
"outputs": [],
"source": [
"# show image in random location without passing cell location and cell id (i.e. without calling add_cell)\n",
"# the image is shown in the cell with id 'DEFAULT_FITS_VIEWER_ID' in default, \n",
"# and the cell is automatically located by Firefly\n",
"\n",
"img_name = astropy.utils.data.download_file('http://web.ipac.caltech.edu/staff/roby/demo/wise-m51-band2.fits', \n",
" timeout=120, cache=True)\n",
"fc.show_fits(file_on_server=fc.upload_file(img_name))\n"
"fc.show_fits(file_on_server=fc.upload_file(img_name))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- show second image in random. it is shown in the same cell as the previous one "
]
},
{
Expand All @@ -368,11 +424,9 @@
},
"outputs": [],
"source": [
"# show second image in random. it is shown in the same cell as the previous one \n",
"\n",
"fc.show_fits(plot_id='xxq', Service='TWOMASS', Title='2mass from service', ZoomType='LEVEL',\n",
" initZoomLevel=2, SurveyKey='k', WorldPt='10.68479;41.26906;EQ_J2000',\n",
" RangeValues='92,-1,92,2,1,0,1,2,44,120', SizeInDeg='.12')\n"
" RangeValues='92,-1,92,2,1,0,1,2,44,120', SizeInDeg='.12')"
]
},
{
Expand Down
Loading