Skip to content

Commit

Permalink
Move Notebook doc webbpsf from conda to pip install.
Browse files Browse the repository at this point in the history
  • Loading branch information
wmwv committed Jul 9, 2024
1 parent 82d96b2 commit 240e141
Showing 1 changed file with 88 additions and 49 deletions.
137 changes: 88 additions & 49 deletions notebook/RomanDESCForwardModelLightcurves.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
Expand All @@ -57,7 +64,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"DATASET = \"RomanDESC\"\n",
Expand All @@ -67,7 +76,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import os\n",
Expand All @@ -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": {},
Expand All @@ -97,7 +120,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"image_file_format = (\n",
Expand All @@ -122,7 +147,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# 5 transient IDs of interest\n",
Expand Down Expand Up @@ -231,7 +258,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# Persist the above in CSV files.\n",
Expand All @@ -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",
Expand Down Expand Up @@ -326,7 +357,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# transient_id = 30328322\n",
Expand All @@ -342,7 +375,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"transient_info = transient_info_table.loc[transient_id]\n",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -414,7 +453,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
"tags": []
},
"outputs": [],
"source": [
Expand All @@ -424,7 +463,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"print(lightcurve_truth)"
Expand All @@ -445,7 +486,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"def get_roman_psf(band, sca, x, y):\n",
Expand Down Expand Up @@ -490,7 +533,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# These are 4k x 4k images\n",
Expand Down Expand Up @@ -518,7 +563,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"### Bad pixel mask values\n",
Expand Down Expand Up @@ -549,7 +596,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"zp_AB_to_nJy = 8.90 + 2.5 * 9"
Expand All @@ -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",
Expand Down Expand Up @@ -664,7 +715,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
"tags": []
},
"outputs": [],
"source": [
Expand All @@ -674,7 +725,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"for i, target in enumerate(targets):\n",
Expand All @@ -691,7 +744,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"npix = 75\n",
Expand Down Expand Up @@ -724,9 +779,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"n = len(targets.image_list)\n",
Expand Down Expand Up @@ -1051,9 +1104,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"model_host_sn.initialize()"
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -1281,9 +1328,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"lightcurve_truth"
Expand All @@ -1292,9 +1337,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"from astropy.table import join\n",
Expand Down Expand Up @@ -1332,9 +1375,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"lightcurve"
Expand Down Expand Up @@ -1451,9 +1492,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"plot_target_model(\n",
Expand All @@ -1474,9 +1513,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "astrophot",
"language": "python",
"name": "python3"
"name": "astrophot"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -1488,7 +1527,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 240e141

Please sign in to comment.