Skip to content

Commit

Permalink
Merge pull request #166 from LSSTDESC/issues/165
Browse files Browse the repository at this point in the history
Updated dm_butler_lensing_cuts notebook
  • Loading branch information
fjaviersanchez authored Mar 1, 2024
2 parents 1653685 + 8391bb1 commit 33a3a9c
Showing 1 changed file with 66 additions and 13 deletions.
79 changes: 66 additions & 13 deletions tutorials/dm_butler_lensing_cuts.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"# Accessing the Coadd data using the Data Butler\n",
"<br>Owner: **Jim Chiang** ([@jchiang87](https://github.com/LSSTDESC/DC2-analysis/issues/new?body=@jchiang87))\n",
"<br>Last Verified to Run: **2018-10-26** (by @yymao)\n",
"<br>Last Verified to Run: **2024-03-01** (by @fjaviersanchez)\n",
"\n",
"This notebook shows how to read in the coadd catalog data for an entire tract using the LSST Data Management (DM) data butler, and construct a Pandas dataframe with the columns needed to apply the weak lensing cuts used in recent analysis of data from Hyper Suprime Cam [Mandelbaum et al (2018)](https://arxiv.org/abs/1705.06745) using cuts given by [Francois in Slack](https://lsstc.slack.com/archives/C77DDKZHR/p1525197444000687).\n",
"\n",
Expand All @@ -24,7 +24,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import numpy as np\n",
Expand All @@ -49,7 +51,46 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"REPOS"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"tract = skymap[4851]\n",
"filter = 'i'\n",
"for patch in tract:\n",
" patchId = '%d,%d' % patch.getIndex()\n",
" dataId = dict(filter=filter_, tract=tract.getId(), patch=patchId)\n",
"\n",
" # Patches for which there is no data will raise a `NoResults` exception when requested\n",
" # from the butler. We catch those exceptions, note the missing data, and \n",
" # continue looping over the patches.\n",
" try:\n",
" forced = butler.get('deepCoadd_forced_src', dataId)\n",
" calib = butler.get('deepCoadd_calexp_photoCalib', dataId)\n",
" merged = butler.get('deepCoadd_ref', dataId)\n",
" except dp.NoResults as eobj:\n",
" print(eobj)\n",
" continue"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"def read_tract(butler, tract, filter_='i', num_patches=None):\n",
Expand Down Expand Up @@ -108,8 +149,10 @@
" data[filter_ + '_modelfit_CModel_instFluxErr'] = forced['modelfit_CModel_instFluxErr']\n",
"\n",
" # The calib object applies the zero point to get calibrated magnitudes.\n",
" data[filter_ + '_mag_CModel'] = calib.getMagnitude(forced['modelfit_CModel_instFlux'])\n",
" data[filter_ + '_mag_err_CModel'] = calib.getMagnitude(forced['modelfit_CModel_instFluxErr'])\n",
" \n",
" _aux = calib.instFluxToMagnitude(forced, 'modelfit_CModel')\n",
" data[filter_ + '_mag_CModel'] = _aux[:, 0]\n",
" data[filter_ + '_mag_err_CModel'] = _aux[:, 1]\n",
" data[filter_ + '_modelfit_CModel_SNR'] \\\n",
" = forced['modelfit_CModel_instFlux']/forced['modelfit_CModel_instFluxErr']\n",
" data['ext_shapeHSM_HsmShapeRegauss_abs_e'] \\\n",
Expand Down Expand Up @@ -137,10 +180,12 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"butler = dp.Butler(REPOS['1.2i'])"
"butler = dp.Butler(REPOS['2.2i_dr6'])"
]
},
{
Expand All @@ -153,7 +198,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"skymap = butler.get('deepCoadd_skyMap')\n",
Expand All @@ -176,7 +223,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"base_mask = ~(np.isnan(data['i_modelfit_CModel_instFlux'])\n",
Expand All @@ -196,7 +245,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"mask = data['detect_isPrimary']\n",
Expand All @@ -216,7 +267,7 @@
"mask &= data['ext_shapeHSM_HsmShapeRegauss_abs_e'] < 2\n",
"mask &= data['ext_shapeHSM_HsmShapeRegauss_sigma'] <= 0.4\n",
"mask &= data['i_mag_CModel'] < 24.5 # !!! Doesnt have exinction correction\n",
"mask &= data['base_Blendedness_abs_instFlux'] < 10**(-0.375)"
"mask &= data['base_Blendedness_abs'] < 10**(-0.375)"
]
},
{
Expand All @@ -229,7 +280,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"fig = plt.figure(figsize=(10, 10))\n",
Expand Down Expand Up @@ -282,5 +335,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}

0 comments on commit 33a3a9c

Please sign in to comment.