diff --git a/notebook/RomanDESCForwardModelLightcurves.ipynb b/notebook/RomanDESCForwardModelLightcurves.ipynb index adadab5..80191bf 100644 --- a/notebook/RomanDESCForwardModelLightcurves.ipynb +++ b/notebook/RomanDESCForwardModelLightcurves.ipynb @@ -34,13 +34,20 @@ "This Notebook was developed and tested within a conda environment. You can create this environment with:\n", "\n", "```\n", - "conda create --name astrophot -c conda-forge python astropy cudatoolkit h5py ipykernel jupyter matplotlib numpy pandas pyyaml pyarrow scipy requests tqdm webbpsf\n", + "conda create --name astrophot -c conda-forge python astropy cudatoolkit h5py ipykernel jupyter matplotlib numpy pandas pyyaml pyarrow scipy requests tqdm \n", "conda activate astrophot\n", - "pip install astrophot pyro-ppl torch\n", + "pip install astrophot pyro-ppl torch webbpsf\n", "ipython kernel install --user --name=astrophot\n", "```\n", "\n", "And then download the `webbpsf` extra data files.\n", + "https://webbpsf.readthedocs.io/en/latest/installation.html#installing-the-required-data-files\n", + "\n", + "and set the `WEBBPSF_PATH` in the conda environment, e.g.,\n", + "\n", + "```\n", + "conda env config vars set WEBBPSF_PATH=/pscratch/sd/w/wmwv/RomanDESC/webbpsf-data\n", + "```\n", "\n", "This requires astrophot >= v0.15.2" ] @@ -57,7 +64,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "DATASET = \"RomanDESC\"\n", @@ -67,7 +76,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "import os\n", @@ -87,6 +98,18 @@ "import webbpsf\n" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# Make sure we have WEBBPSF_PATH set to load the Roman WFI PSF model\n", + "print(os.environ[\"WEBBPSF_PATH\"])" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -97,7 +120,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "image_file_format = (\n", @@ -122,7 +147,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# 5 transient IDs of interest\n", @@ -231,7 +258,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# Persist the above in CSV files.\n", @@ -248,7 +277,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "def get_visit_band_sca_for_object_id(object_id):\n", @@ -326,7 +357,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# transient_id = 30328322\n", @@ -342,7 +375,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "transient_info = transient_info_table.loc[transient_id]\n", @@ -368,7 +403,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "image_files = [os.path.join(DATADIR, bn) for bn in image_file_basenames]\n", @@ -378,7 +415,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "def get_truth_table(truth_files, visits, transient_id):\n", @@ -414,7 +453,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "scrolled": false + "tags": [] }, "outputs": [], "source": [ @@ -424,7 +463,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "print(lightcurve_truth)" @@ -445,7 +486,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "def get_roman_psf(band, sca, x, y):\n", @@ -490,7 +533,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# These are 4k x 4k images\n", @@ -518,7 +563,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "### Bad pixel mask values\n", @@ -549,7 +596,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "zp_AB_to_nJy = 8.90 + 2.5 * 9" @@ -567,7 +616,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "DEFAULT_ZP = 22.5 # Appropriate if the image was calibrated and scaled to nanomaggies\n", @@ -664,7 +715,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "scrolled": false + "tags": [] }, "outputs": [], "source": [ @@ -674,7 +725,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "for i, target in enumerate(targets):\n", @@ -691,7 +744,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "npix = 75\n", @@ -724,9 +779,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "scrolled": false - }, + "metadata": {}, "outputs": [], "source": [ "n = len(targets.image_list)\n", @@ -1051,9 +1104,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "scrolled": false - }, + "metadata": {}, "outputs": [], "source": [ "model_host_sn.initialize()" @@ -1108,9 +1159,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "scrolled": false - }, + "metadata": {}, "outputs": [], "source": [ "model_filename = f\"Transient_{transient_id}_AstroPhot_model.yaml\"\n", @@ -1228,9 +1277,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "scrolled": false - }, + "metadata": {}, "outputs": [], "source": [ "lightcurve_obs[\"mag\"] = lightcurve_obs[\"inst_mag\"] + lightcurve_obs[\"zp\"] \n", @@ -1281,9 +1328,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "scrolled": false - }, + "metadata": {}, "outputs": [], "source": [ "lightcurve_truth" @@ -1292,9 +1337,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "scrolled": false - }, + "metadata": {}, "outputs": [], "source": [ "from astropy.table import join\n", @@ -1332,9 +1375,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "scrolled": false - }, + "metadata": {}, "outputs": [], "source": [ "lightcurve" @@ -1451,9 +1492,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "scrolled": false - }, + "metadata": {}, "outputs": [], "source": [ "plot_target_model(\n", @@ -1474,9 +1513,9 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "astrophot", "language": "python", - "name": "python3" + "name": "astrophot" }, "language_info": { "codemirror_mode": { @@ -1488,7 +1527,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.6" + "version": "3.11.9" } }, "nbformat": 4,