Skip to content

Commit

Permalink
tutorial as is
Browse files Browse the repository at this point in the history
  • Loading branch information
jtmyles committed Sep 6, 2018
1 parent bab9de7 commit 79d561e
Show file tree
Hide file tree
Showing 4 changed files with 764 additions and 114 deletions.
7 changes: 7 additions & 0 deletions Basics/DataInventory.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
"## Set-up"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
207 changes: 189 additions & 18 deletions ImageProcessing/Re-RunHSC.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"# HSC Re-Run: Making Forced Photometry Light Curves from Scratch\n",
"\n",
"<br>Owner: **Justin Myles** ([@jtmyles](https://github.com/LSSTScienceCollaborations/StackClub/issues/new?body=@jtmyles))\n",
"<br>Last Verified to Run: **N/A -- in development**\n",
"<br>Last Verified to Run: **2018-08-10**\n",
"<br>Verified Stack Release: **16.0**\n",
"\n",
"This project addresses issue [#63: HSC Re-run](https://github.com/LSSTScienceCollaborations/StackClub/issues/63)\n",
"\n",
Expand All @@ -32,12 +33,15 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"os.system(\"eups list lsst_distrib\") #todo\n",
"import sys\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline\n",
"import eups.setupcmd"
]
},
Expand All @@ -63,14 +67,15 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"!eups list lsst_distrib\n",
"datarepo = \"/home/jmyles/repositories/ci_hsc/\"\n",
"datadir = \"/home/jmyles/DATA/\"\n",
"os.system(\"mkdir -p {}\".format(datadir))"
"USER = \"jmyles\"\n",
"# todo: $USER\n",
"datarepo = \"/home/{}/repositories/ci_hsc/\".format(USER)\n",
"datadir = \"/home/{}/DATA/\".format(USER)\n",
"os.system(\"mkdir -p {}\".format(datadir));"
]
},
{
Expand Down Expand Up @@ -110,6 +115,7 @@
"outputs": [],
"source": [
"# ingest script\n",
"# todo: $USER ()\n",
"!ingestImages.py /home/jmyles/DATA /home/jmyles/repositories/ci_hsc/raw/*.fits --mode=link"
]
},
Expand Down Expand Up @@ -171,12 +177,10 @@
"outputs": [],
"source": [
"\"\"\"\n",
"# review what data will be processed\n",
"!processCcd.py DATA --rerun processCcdOutputs --id --show data\n",
"# id allows you to select data by data ID\n",
"# unspecified id selects all raw data\n",
"# example IDs: raw, filter, visit, ccd, field\n",
"# show data turns on dry-run mode\n",
"!processCcd.py DATA --rerun processCcdOutputs --id\n",
"# all cl tasks write output datasets to a Butler repo\n",
"# --rerun configured to write to processCcdOutputs\n",
"# other option is --output\n",
"\"\"\""
]
},
Expand All @@ -186,7 +190,52 @@
"metadata": {},
"outputs": [],
"source": [
"#!which processCcd.py"
"!which processCcd.py\n",
"\"\"\"\n",
"processCcd.py\n",
"from lsst.pipe.tasks.processCcd import ProcessCcdTask\n",
"\n",
"ProcessCcdTask.parseAndRun()\n",
"\"\"\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# show source of lsst.pipe.tasks.processCcd\n",
"# emacs /opt/lsst/software/stack/stack/miniconda3-4.3.21-10a4fa6/Linux64/pipe_tasks/16.0+1/python/lsst/pipe/tasks/processCcd.py\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from lsst.pipe.tasks.processCcd import ProcessCcdTask, ProcessCcdConfig\n",
"processCcdTaskInstance = ProcessCcdTask(butler=butler)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from stackclub import where_is\n",
"where_is(processCcdTaskInstance, in_the=\"source\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"processCcdConfig = ProcessCcdConfig()"
]
},
{
Expand All @@ -196,13 +245,24 @@
"outputs": [],
"source": [
"\"\"\"\n",
"!processCcd.py DATA --rerun processCcdOutputs --id\n",
"# all cl tasks write output datasets to a Butler repo\n",
"# --rerun configured to write to processCcdOutputs\n",
"# other option is --output\n",
"# review what data will be processed\n",
"!processCcd.py DATA --rerun processCcdOutputs --id --show data\n",
"# id allows you to select data by data ID\n",
"# unspecified id selects all raw data\n",
"# example IDs: raw, filter, visit, ccd, field\n",
"# show data turns on dry-run mode\n",
"\"\"\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#!which processCcd.py"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -245,6 +305,117 @@
"# - TAN: tangent-plane projection\n",
"\"\"\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Part 6: Multi-band catalog analysis\n",
"https://pipelines.lsst.io/getting-started/multiband-analysis.html"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import lsst.daf.persistence as dafPersist\n",
"datadir = \"/home/{}/DATA/\".format(os.environ['USER'])\n",
"butler = dafPersist.Butler(inputs=datadir + 'rerun/coaddForcedPhot/')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Access the sources identified from the coadd images"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"rSources = butler.get('deepCoadd_forced_src', {'filter': 'HSC-R', 'tract': 0, 'patch': '1,1'})\n",
"iSources = butler.get('deepCoadd_forced_src', {'filter': 'HSC-I', 'tract': 0, 'patch': '1,1'})"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Throw out negative fluxes, and convert fluxes to magnitudes."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"rCoaddCalib = butler.get('deepCoadd_calexp_calib', {'filter': 'HSC-R', 'tract': 0, 'patch': '1,1'})\n",
"iCoaddCalib = butler.get('deepCoadd_calexp_calib', {'filter': 'HSC-I', 'tract': 0, 'patch': '1,1'})\n",
"\n",
"rCoaddCalib.setThrowOnNegativeFlux(False)\n",
"iCoaddCalib.setThrowOnNegativeFlux(False)\n",
"\n",
"rMags = rCoaddCalib.getMagnitude(rSources['base_PsfFlux_flux'])\n",
"iMags = iCoaddCalib.getMagnitude(iSources['base_PsfFlux_flux'])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Select stars from catalog"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"deblended = rSources['deblend_nChild'] == 0\n",
"\n",
"refTable = butler.get('deepCoadd_ref', {'filter': 'HSC-R^HSC-I', 'tract': 0, 'patch': '1,1'})\n",
"inInnerRegions = refTable['detect_isPatchInner'] & refTable['detect_isTractInner'] # define inner regions\n",
"isSkyObject = refTable['merge_peak_sky'] # reject sky objects\n",
"isPrimary = refTable['detect_isPrimary']\n",
"\n",
"isStellar = iSources['base_ClassificationExtendedness_value'] < 1.\n",
"isGoodFlux = ~iSources['base_PsfFlux_flag']\n",
"selected = isPrimary & isStellar & isGoodFlux"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Make color-magnitude diagram."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.style.use('seaborn-notebook')\n",
"plt.figure(1, figsize=(4, 4), dpi=140)\n",
"plt.scatter(rMags[selected] - iMags[selected],\n",
" iMags[selected],\n",
" edgecolors='None', s=2, c='k')\n",
"plt.xlim(-0.5, 3)\n",
"plt.ylim(25, 14)\n",
"plt.xlabel('$r-i$')\n",
"plt.ylabel('$i$')\n",
"plt.subplots_adjust(left=0.125, bottom=0.1)\n",
"plt.show()"
]
}
],
"metadata": {
Expand Down
Loading

0 comments on commit 79d561e

Please sign in to comment.