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

Add WFC3 notebook 'calwf3_with_v1.0_PCTE.ipynb' #100

Merged
merged 18 commits into from
Nov 17, 2023
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
1 change: 0 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ exclude_patterns: [notebooks/DrizzlePac/align_mosaics/align_mosaics.ipynb,
notebooks/DrizzlePac/sky_matching/sky_matching.ipynb,
notebooks/DrizzlePac/use_ds9_regions_in_tweakreg/use_ds9_regions_in_tweakreg.ipynb,
notebooks/WFC3/calwf3_recalibration/calwf3_recal_tvb.ipynb,
notebooks/WFC3/calwf3_v1.0_cte/calwf3_with_v1.0_PCTE.ipynb,
notebooks/WFC3/dash/dash.ipynb,
notebooks/WFC3/exception_report/wfc3_exception_report.ipynb,
notebooks/WFC3/filter_transformations/filter_transformations.ipynb,
Expand Down
2 changes: 1 addition & 1 deletion _toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ parts:
chapters:
- file: notebooks/WFC3/README.md
# - file: notebooks/WFC3/calwf3_recalibration/calwf3_recal_tvb.ipynb
# - file: notebooks/WFC3/calwf3_v1.0_cte/calwf3_with_v1.0_PCTE.ipynb
- file: notebooks/WFC3/calwf3_v1.0_cte/calwf3_with_v1.0_PCTE.ipynb
# - file: notebooks/WFC3/dash/dash.ipynb
# - file: notebooks/WFC3/exception_report/wfc3_exception_report.ipynb
# - file: notebooks/WFC3/filter_transformations/filter_transformations.ipynb
Expand Down
13 changes: 7 additions & 6 deletions notebooks/WFC3/calwf3_v1.0_cte/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
This directory, once cloned from the repository, should contain this
`README.md`, the Jupyter Notebook `calwf3_with_v1.0_PCTE.ipynb`, a file
called `archived_drkcfiles.txt` and a subdirectory `example/`.
called `archived_drkcfiles.txt`, a `requirements.txt` file, and a subdirectory `example/`.

**In order to run this Jupyter Notebook you must have created a virtual
**To run this Jupyter Notebook you must have created a virtual
conda environment that includes `calwf3` v3.5.2.** Version 3.5.2 of `calwf3`
is available in HSTCAL release 2.5.0. To create an environment with
is available in `hstcal` release 2.5.0. To create an environment with
`calwf3` v3.5.2 try this from the terminal:

```
$ conda config --add channels http://ssb.stsci.edu/astroconda

$ conda create -n v1_PCTE hstcal==2.5.0 python=3.7 ginga stsci-hst notebook
$ conda create -n v1_PCTE hstcal==2.5.0 python=3.11
$ conda activate v1_PCTE
$ pip install -r requirements.txt
```

In general, users wanting to use the v1.0 pixel-based CTE correction
In most cases, users wanting to use the v1.0 pixel-based CTE correction
within `calwf3` should use `calwf3` v3.5.2. This version will provide the
most up-to-date calibration procedures such as time-dependent photometric
corrections and zeropoints, while also including the v1.0 correction.
Expand Down
500 changes: 297 additions & 203 deletions notebooks/WFC3/calwf3_v1.0_cte/calwf3_with_v1.0_PCTE.ipynb

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions notebooks/WFC3/calwf3_v1.0_cte/example/background_median.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
See the docstring of aperture_stats_tbl for more info.
"""
import numpy as np

# WAY faster than astropy.stats.sigma_clipped_stats
from scipy.stats import sigmaclip
from astropy.table import Table

def aperture_stats_tbl(data, apertures,
method='exact', sigma_clip=True):

def aperture_stats_tbl(data, apertures, method='exact', sigma_clip=True):

"""Computes mean/median/mode/std in Photutils apertures.
Compute statistics for custom local background methods.
This is primarily intended for estimating backgrounds
Expand Down Expand Up @@ -63,23 +63,24 @@ def aperture_stats_tbl(data, apertures,

aperture_stats = np.array(aperture_stats)


# Place the array of the x y positions alongside the stats
stacked = np.hstack([apertures.positions, aperture_stats])
# Name the columns
names = ['X','Y','aperture_mean','aperture_median','aperture_mode',
'aperture_std', 'aperture_area']
names = ['X', 'Y', 'aperture_mean', 'aperture_median',
'aperture_mode', 'aperture_std', 'aperture_area']
# Make the table
stats_tbl = Table(data=stacked, names=names)


return stats_tbl


def calc_aperture_mmm(data, mask, sigma_clip):

"""Helper function to actually calculate the stats for pixels
falling within some Photutils aperture mask on some array
of data.
"""

cutout = mask.cutout(data, fill_value=np.nan)
if cutout is None:
return (np.nan, np.nan, np.nan, np.nan, np.nan)
Expand All @@ -95,4 +96,5 @@ def calc_aperture_mmm(data, mask, sigma_clip):

mode = 3 * median - 2 * mean
actual_area = (~np.isnan(values)).sum()

return (mean, median, mode, std, actual_area)
1 change: 1 addition & 0 deletions notebooks/WFC3/calwf3_v1.0_cte/pre-requirements.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
conda install --yes -c http://ssb.stsci.edu/astroconda hstcal==2.5.0
9 changes: 9 additions & 0 deletions notebooks/WFC3/calwf3_v1.0_cte/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
astropy
astroquery
crds
jupyter
matplotlib
numpy
photutils
scipy
wfc3tools
Loading