Skip to content

Commit

Permalink
add HSC Footprints notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
stargaser committed Jul 3, 2019
1 parent b7db17a commit 12189e3
Showing 1 changed file with 273 additions and 0 deletions.
273 changes: 273 additions & 0 deletions firefly_features/HSC-Footprints.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Browsing HSC Footprints"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Last verified to run:** 2019-03-29\n",
"\n",
"**Verified science platform release or release candidate:** 17.0.1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook tests new functionality in `lsst.display.firefly` for browsing catalogs, footprints and images."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from lsst.daf.persistence import Butler\n",
"import lsst.afw.geom as afwGeom"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import lsst.afw.display as afwDisplay"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This example uses HSC-reprocessed data from `/datasets/hsc/repo/rerun/RC/w_2018_38/DM-15690/deepCoadd-results`"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"butler = Butler('/datasets/hsc/repo/rerun/RC/w_2018_38/DM-15690/')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Define an ID for retrieving data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dataId = dict(filter='HSC-R', tract=9813, patch='4,4')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Define a bounding boxes for a region of interest, one for the catalog and a larger one for the image."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"footprintsBbox = afwGeom.Box2I(corner=afwGeom.Point2I(16900, 18700),\n",
" dimensions=afwGeom.Extent2I(600,600))\n",
"imageBbox = afwGeom.Box2I(corner=afwGeom.Point2I(16800, 18600),\n",
" dimensions=afwGeom.Extent2I(800,800))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Retrieve a cutout for the corresponding exposure / coadd"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"calexp = butler.get('deepCoadd_calexp_sub', dataId=dataId, bbox=imageBbox)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Retrieve a catalog for the entire region"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"measCat = butler.get('deepCoadd_meas', dataId=dataId)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Select only those records with pixel locations inside the footprints bounding box"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"catSelect = np.array([footprintsBbox.contains(afwGeom.Point2I(r.getX(), r.getY()))\n",
" for r in measCat])\n",
"catalogSubset = measCat.subset(catSelect)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Set up the Firefly display"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"display1 = afwDisplay.Display(frame=1, backend='firefly')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"display1.setMaskTransparency(80)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"display1.scale('asinh', 10, 80, unit='percent', Q=6)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The `resetLayout` method sets up the image for upper left and table below, with space for plots at upper right"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"display1.resetLayout()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Display the image"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"display1.mtv(calexp)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Overlay the footprints and accompanying table.\n",
"\n",
"Colors can be specified as a name like `'cyan'` or `afwDisplay.RED`; as an rgb value such as `'rgb(80,100,220)'`; or as rgb plus alpha (opacity) such as `'rgba('74,144,226,0.60)'`.\n",
"\n",
"The `layerString` and `titleString` are concatenated with the frame, to make the footprint drawing layer name and the table title, respectively. If multiple footprint layers are desired, be sure to use different values of `layerString`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"display1.overlayFootprints(catalogSubset, color='rgba(74,144,226,0.50)',\n",
" highlightColor='yellow', selectColor='orange',\n",
" style='outline', layerString='detection footprints ',\n",
" titleString='catalog footprints ')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "LSST",
"language": "python",
"name": "lsst"
},
"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.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 12189e3

Please sign in to comment.