Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update webbpsf tutorial #28

Merged
merged 3 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/notebooks/pandeia/pandeia.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}
},
"source": [
"# Draft: Pandeia Tutorial"
"# Pandeia Tutorial"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion content/notebooks/stips/stips.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
},
"source": [
"# Draft: STIPS Tutorial"
"# STIPS Tutorial"
]
},
{
Expand Down
141 changes: 109 additions & 32 deletions content/notebooks/webbpsf/webbpsf.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}
},
"source": [
"# Draft: WebbPSF Tutorial"
"# WebbPSF Tutorial"
]
},
{
Expand Down Expand Up @@ -105,17 +105,6 @@
"## Examples"
]
},
{
"cell_type": "markdown",
"id": "28dc1d3a-b44b-4f2b-adae-ea6d85a0329d",
"metadata": {},
"source": [
"* Quick PSF calculation (overview)\n",
"* PSF with default parameters (tutorial)... materially the same as above?)\n",
"* PSF with specified parameters (tutorial)\n",
"* PSF profile and encircled energy (tutorial)"
]
},
{
"cell_type": "markdown",
"id": "cf9456f2-7b1f-4c9d-a425-b5c2d8e46f07",
Expand All @@ -142,16 +131,45 @@
"outputs": [],
"source": [
"wfi = webbpsf.roman.WFI()\n",
"\n",
"default_psf = wfi.calc_psf(display=True)"
]
},
{
"cell_type": "markdown",
"id": "b2cb8df4-e85c-4625-9b96-6ea944b45426",
"metadata": {},
"source": [
"The resulting object contains a list of two FITS extensions, both containing idealized PSF images. `OVERSAMP` splits the detector's original number of pixels by the oversampling factor specified upon creation of the PSFs (by default, 4) while `DET_SAMP` retains the original pixel count.\n",
"\n",
"_Note: Additional extensions that apply distortion to the idealized PSFs are in development for the `WFI` model._"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7cedc980-3dd7-4963-a7bb-0fcfda19f6b5",
"metadata": {},
"outputs": [],
"source": [
"default_psf.info()"
]
},
{
"cell_type": "markdown",
"id": "1d5258f4-7dba-4809-a810-c7af013ad41d",
"metadata": {},
"source": [
"It is also possible to visualize the PSF after creating it."
"The package includes a helper function for visualizing each extension of an existing PSF."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f048132b-ad65-4902-bac8-dff62881aab9",
"metadata": {},
"outputs": [],
"source": [
"webbpsf.display_psf(default_psf, ext='OVERSAMP')"
]
},
{
Expand All @@ -169,7 +187,7 @@
"id": "da4aae41-37f7-4c70-acff-e4fdfb08f3e1",
"metadata": {},
"source": [
"The PSF object has functionality for saving its contents to disk for later use."
"The PSF object itself contains functionality for saving its contents to disk for later use."
]
},
{
Expand All @@ -189,7 +207,17 @@
"source": [
"#### Custom parameters\n",
"\n",
"You can simulate custom PSFs by modifying instrument class attributes like the detector, filter/grism, and many more **LINK**."
"You can simulate custom PSFs by modifying instrument class attributes like the detector, filter, and others. (Find all available attributes in the API documentation for the [Roman `WFI` class](https://webbpsf.readthedocs.io/en/latest/api/webbpsf.WFI.html#webbpsf.WFI) and [its parent `SpaceTelescopeInstrument` class](https://webbpsf.readthedocs.io/en/latest/api/webbpsf.SpaceTelescopeInstrument.html#webbpsf.SpaceTelescopeInstrument).)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d718b95e-6637-4361-840c-e5336bd435b3",
"metadata": {},
"outputs": [],
"source": [
"wfi.filter_list"
]
},
{
Expand All @@ -206,14 +234,6 @@
"custom_psf = wfi.calc_psf(display=True)"
]
},
{
"cell_type": "markdown",
"id": "1656717f-e346-482d-aed8-cf28a8e6c42f",
"metadata": {},
"source": [
"_To generate several individual PSFs from a grid (without having to perform a full calculation at each location), WebbPSF implements the `GriddedPSFModel` class from `photutils`. Learn more about that use case [in the WebbPSF documentation](https://webbpsf.readthedocs.io/en/latest/psf_grids.html)._"
]
},
{
"cell_type": "markdown",
"id": "cbacace1-589d-4a65-98cf-610f040b5276",
Expand Down Expand Up @@ -248,22 +268,80 @@
"metadata": {},
"outputs": [],
"source": [
"plt.figure(figsize=(8,6))\n",
"plt.figure(figsize=(8, 6))\n",
"webbpsf.display_profiles(poly_psf)"
]
},
{
"cell_type": "markdown",
"id": "e0e9bedc-7f2e-49c6-9f08-4ed6683e66a7",
"metadata": {},
"source": [
"### Bulk PSF generation"
]
},
{
"cell_type": "markdown",
"id": "b92bc0dd-87a3-445b-9edc-f43d5e715f33",
"metadata": {},
"source": [
"To generate several individual PSFs in a grid, WebbPSF implements the `GriddedPSFModel` class from `photutils`. (Learn more about this use case [in the WebbPSF documentation](https://webbpsf.readthedocs.io/en/latest/psf_grids.html).)\n",
"\n",
"As a toy example, we generate a 3x3 grid of PSFs for a single WFI detector below."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "55ef3e4e-560d-4146-85ce-6359ad136995",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"wfi.detector = \"SCA07\"\n",
"wfi.filter = \"F158\"\n",
"wfi_grid = wfi.psf_grid(num_psfs=9, all_detectors=False)"
]
},
{
"cell_type": "markdown",
"id": "732f284d-6c57-449c-a206-eab8fb728c9a",
"metadata": {},
"source": [
"Use another WebbPSF helper function to visualize the grid.\n",
"\n",
"The top figure displays PSFs in each detector position specified by the grid. The bottom figure subtracts the mean PSF from each corresponding image from the top to show the effect of detector position on image quality."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c6f28e0c-a9ba-4112-ad70-210447b06d14",
"metadata": {},
"outputs": [],
"source": [
"webbpsf.gridded_library.display_psf_grid(wfi_grid)"
]
},
{
"cell_type": "markdown",
"id": "c50f66b3-8c7f-4227-a27e-ba1e2109cd44",
"metadata": {},
"source": [
"With a PSF grid in hand, you can use a package like `photutils` to estimate PSFs at any given detector position by interpolation without the need to calculate each PSF individually. This is a major time-saver in source-heavy scientific use cases."
]
},
{
"cell_type": "markdown",
"id": "70ca0e4c-f605-40e5-be34-053ff5643297",
"metadata": {},
"source": [
"## Aditional Resources\n",
"While this isn't always necessary, sometimes you want to provide some more resources for the reader who wants to learn something beyond what's in the notebook. Sometimes these don't exist, but if they do, it's good to put them at the end to give the reader somewhere else to go. Usually a list of links using markdown bullet-plus-link format is appropriate:\n",
"\n",
"- [MAST API](https://mast.stsci.edu/api/v0/index.html)\n",
"- [Kepler Archive Page (MAST)](https://archive.stsci.edu/kepler/)\n",
"- [Kepler Archive Manual](https://archive.stsci.edu/kepler/manuals/archive_manual.pdf)\n",
"- [Exo.MAST website](https://exo.mast.stsci.edu/exo/ExoMast/html/exomast.html)"
"- The Roman User Documentation's [\"WebbPSF Overview\"](https://roman-docs.stsci.edu/simulation-tools-handbook-home/webbpsf-for-roman/overview-of-webbpsf) page.\n",
"- The latest version of the [WebbPSF documentation](https://webbpsf.readthedocs.io/en/stable/index.html) on ReadTheDocs, which includes a specific page on the package's [Roman instrument model](https://webbpsf.readthedocs.io/en/stable/roman.html).\n",
"- The [Roman Help Desk](https://roman-docs.stsci.edu/roman-help-desk-at-stsci), an official outlet for user questions about WebbPSF."
]
},
{
Expand All @@ -276,7 +354,6 @@
},
"source": [
"## About this notebook\n",
"Let the world know who the author of this great notebook is! If possible/appropriate, include a contact email address for users who might need support (e.g. [email protected])\n",
"\n",
"**Author:** Justin Otor, Staff Scientist II. \n",
"**Updated In:** 2024-05"
Expand Down Expand Up @@ -316,7 +393,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down
Loading