-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from LSSTDESC/tqz/golden_spike_fixes
Fix GoldenSpike notebook with new base classes, collect new notebooks
- Loading branch information
Showing
2 changed files
with
346 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,277 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "2610a0f0-0c71-4401-896f-734442bcd66d", | ||
"metadata": {}, | ||
"source": [ | ||
"## Photometric error stage demo\n", | ||
"\n", | ||
"author: Tianqing Zhang, John-Franklin Crenshaw\n", | ||
"\n", | ||
"This notebook demonstrate the use of `rail.creation.degradation.photometric_errors`, which adds column for the photometric noise to the catalog based on the package PhotErr developed by John-Franklin Crenshaw. The RAIL stage PhotoErrorModel inherit from the Noisifier base classes, and the LSST, Roman, Euclid child classes inherit from the PhotoErrorModel" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "f7a6adc3-68e8-4a1d-842f-bfb0960a1c4a", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"\n", | ||
"from rail.creation.degradation.photometric_errors import LSSTErrorModel\n", | ||
"from rail.creation.degradation.photometric_errors import RomanErrorModel\n", | ||
"from rail.creation.degradation.photometric_errors import EuclidErrorModel\n", | ||
"\n", | ||
"from rail.core.data import PqHandle\n", | ||
"from rail.core.stage import RailStage\n", | ||
"\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"import pandas as pd\n", | ||
"import numpy as np\n", | ||
"\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "6912a740-31ea-4987-b06d-81ff17cd895a", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"DS = RailStage.data_store\n", | ||
"DS.__class__.allow_overwrite = True\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "a282c2ed-141b-4507-8254-dc8fbc9864dc", | ||
"metadata": {}, | ||
"source": [ | ||
"### Create a random catalog with ugrizy+YJHF bands as the the true input" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "1078bc2a-fc54-41c3-bd30-6c447bb971d4", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"data = np.random.normal(23, 3, size = (1000,10))\n", | ||
"\n", | ||
"data_df = pd.DataFrame(data=data, # values\n", | ||
" columns=['u', 'g', 'r', 'i', 'z', 'y', 'Y', 'J', 'H', 'F'])\n", | ||
"data_truth = PqHandle('input')\n", | ||
"data_truth.set_data(data_df)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "a11f3db8-9b2d-405c-a1c5-832a6ffec0d0", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"data_df" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "1da27deb-d167-4f38-8c59-f270184d6ab3", | ||
"metadata": {}, | ||
"source": [ | ||
"### The LSST error model adds noise to the optical bands" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e5f4862a-0621-46d4-8901-7e84b461c424", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"errorModel_lsst = LSSTErrorModel.make_stage(name=\"error_model\")\n", | ||
"\n", | ||
"samples_w_errs = errorModel_lsst(data_truth)\n", | ||
"samples_w_errs()\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "6282c42e-1a6f-480a-aa2b-817bd30d372f", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"fig, ax = plt.subplots(figsize=(5, 4), dpi=100)\n", | ||
"\n", | ||
"for band in \"ugrizy\":\n", | ||
" # pull out the magnitudes and errors\n", | ||
" mags = samples_w_errs.data[band].to_numpy()\n", | ||
" errs = samples_w_errs.data[band + \"_err\"].to_numpy()\n", | ||
"\n", | ||
" # sort them by magnitude\n", | ||
" mags, errs = mags[mags.argsort()], errs[mags.argsort()]\n", | ||
"\n", | ||
" # plot errs vs mags\n", | ||
" ax.plot(mags, errs, label=band)\n", | ||
"\n", | ||
"ax.legend()\n", | ||
"ax.set(xlabel=\"Magnitude (AB)\", ylabel=\"Error (mags)\")\n", | ||
"plt.show()\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "50927ccb-4492-4bdd-a29b-0907704b2c59", | ||
"metadata": {}, | ||
"source": [ | ||
"### The Roman error model adds noise to the infrared bands" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "d484a34b-cf10-45bd-8571-b78dc1818180", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"errorModel_Roman = RomanErrorModel.make_stage(name=\"error_model\", )\n", | ||
"\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "25dcd9de-8612-4a98-a05b-07a1c9a66e36", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"errorModel_Roman.config['m5']['Y'] = 27.0" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "9ab2ef86-01a0-426a-a8ad-08d4e4079421", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"errorModel_Roman.config['theta']['Y'] = 27.0" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "c199c365-6d09-45ca-a1ea-bcf8c709c559", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"samples_w_errs_roman = errorModel_Roman(data_truth)\n", | ||
"samples_w_errs_roman()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "a12362dc-0689-43f3-b990-edff734010bb", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"fig, ax = plt.subplots(figsize=(5, 4), dpi=100)\n", | ||
"\n", | ||
"for band in \"YJHF\":\n", | ||
" # pull out the magnitudes and errors\n", | ||
" mags = samples_w_errs_roman.data[band].to_numpy()\n", | ||
" errs = samples_w_errs_roman.data[band + \"_err\"].to_numpy()\n", | ||
"\n", | ||
" # sort them by magnitude\n", | ||
" mags, errs = mags[mags.argsort()], errs[mags.argsort()]\n", | ||
"\n", | ||
" # plot errs vs mags\n", | ||
" ax.plot(mags, errs, label=band)\n", | ||
"\n", | ||
"ax.legend()\n", | ||
"ax.set(xlabel=\"Magnitude (AB)\", ylabel=\"Error (mags)\")\n", | ||
"plt.show()\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "359de4ad-a47c-4dc5-8c81-53aeb92bdf42", | ||
"metadata": {}, | ||
"source": [ | ||
"### The Euclid error model adds noise to YJH bands" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "775d0a23-7435-4b01-83db-2234c3d24f57", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"errorModel_Euclid = EuclidErrorModel.make_stage(name=\"error_model\")\n", | ||
"\n", | ||
"samples_w_errs_Euclid = errorModel_Euclid(data_truth)\n", | ||
"samples_w_errs_Euclid()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "7fcfe07a-5571-4dd3-8ad0-358964c1d493", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"fig, ax = plt.subplots(figsize=(5, 4), dpi=100)\n", | ||
"\n", | ||
"for band in \"YJH\":\n", | ||
" # pull out the magnitudes and errors\n", | ||
" mags = samples_w_errs_Euclid.data[band].to_numpy()\n", | ||
" errs = samples_w_errs_Euclid.data[band + \"_err\"].to_numpy()\n", | ||
"\n", | ||
" # sort them by magnitude\n", | ||
" mags, errs = mags[mags.argsort()], errs[mags.argsort()]\n", | ||
"\n", | ||
" # plot errs vs mags\n", | ||
" ax.plot(mags, errs, label=band)\n", | ||
"\n", | ||
"ax.legend()\n", | ||
"ax.set(xlabel=\"Magnitude (AB)\", ylabel=\"Error (mags)\")\n", | ||
"plt.show()\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "268b3d37-b7fd-4ac1-8457-2104a87c9e6d", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "rail_env", | ||
"language": "python", | ||
"name": "rail_env" | ||
}, | ||
"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.11.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.