Skip to content

Commit

Permalink
Merge pull request #50 from JarronL/develop
Browse files Browse the repository at this point in the history
Develop v1.0.0
  • Loading branch information
JarronL committed Dec 22, 2021
2 parents 91c5034 + 99c897d commit 70e68a7
Show file tree
Hide file tree
Showing 511 changed files with 1,321,262 additions and 63,342 deletions.
34 changes: 26 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ __pycache__/

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
Expand All @@ -100,9 +100,12 @@ parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
Expand All @@ -117,13 +120,16 @@ pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
Expand All @@ -132,6 +138,8 @@ coverage.xml
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
Expand All @@ -157,13 +165,14 @@ Untitled*.ipynb
# celery beat schedule file
celerybeat-schedule

# dotenv
# Environments
.env

# virtualenv
.venv/
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
Expand All @@ -172,11 +181,20 @@ ENV/
# Rope project settings
.ropeproject

# End of https://www.gitignore.io/api/macos,emacs,python

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# No FITS files
*.fits

# Ignore GO notebooks
notebooks/GO/
*.aptbackup
16 changes: 10 additions & 6 deletions .rtd-environment.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
name: pynrc

dependencies:
- python=3.5
- numpy>=1.13
- matplotlib>=2.0.2
- astropy>=3
- python=3.7
- numpy>=1.19
- matplotlib>=3.3.0
- scipy>=1.5.0
- tqdm>4
- astropy>=4.2
- astroquery>=0.4.3
- Cython
- pip:
- sphinx>=1.5.1
- sphinx>=3.4.1
- sphinx-automodapi
- ipykernel
- nbsphinx
- docutils=0.16
- git+https://github.com/spacetelescope/poppy.git#egg=poppy
- git+https://github.com/spacetelescope/webbpsf.git#egg=webbpsf
- git+https://github.com/spacetelescope/pysynphot.git#egg=pysynphot

- git+https://github.com/JarronL/webbpsf_ext.git#egg=webbpsf_ext
2 changes: 1 addition & 1 deletion .travis_TBI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
language: python

python:
- 3.5
- 3.7

env:
global:
Expand Down
89 changes: 42 additions & 47 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,78 +101,73 @@ Pull Request Guidelines
Before you submit a pull request, check that it meets these guidelines:

1. The pull request should include tests.
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring.
3. The pull request should work for Python 2.7, 3.4, 3.5 and 3.6, and for PyPy.
Check https://travis-ci.org/JarronL/pynrc/pull_requests
and make sure that the tests pass for all supported Python versions.
2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring.
3. The pull request should work for Python 3.7, 3.8, and 3.9 for PyPy. Check https://travis-ci.org/JarronL/pynrc/pull_requests and make sure that the tests pass for all supported Python versions.

Tips
----

To run a subset of tests::
To run a subset of tests:

$ py.test tests.test_pynrc
.. code-block:: sh
$ py.test tests.test_pynrc
Deploying
---------

A reminder for the maintainers on how to deploy.
First, make sure the following packages are installed::
A reminder for the maintainers on how to deploy. First, make sure the following packages are installed:

.. code-block:: sh
$ pip install sphinx_automodapi
$ conda install sphinx_rtd_theme
$ conda install nbsphinx
$ conda install twine
$ pip install sphinx_automodapi
$ conda install sphinx_rtd_theme
$ conda install nbsphinx
$ conda install twine
$ conda install docutils=0.16
1. Update version info in pynrc.version.
Add entries to HISTORY.rst.
Make sure all your changes are committed to git.
2. Generate documentation locally::
1. Update version info in pynrc.version. Add entries to HISTORY.rst. Make sure all your changes are committed to git.
2. Generate documentation locally:

$ make docs
.. code-block:: sh
3. Push all updates to github and make sure readthedocs generates correctly
before actually submitting the release.
4. Package a distribution and test upload the release to TestPyPI::
$ make docs
3. Push all updates to github and make sure readthedocs generates correctly before actually submitting the release.
4. Package a distribution and test upload the release to TestPyPI:

.. code-block:: sh
$ make release-test
$ make release-test
5. If everything works without a hitch, then upload the release to PyPI::
5. If everything works without a hitch, then upload the release to PyPI:

$ make release
.. code-block:: sh
$ make release
This command also tags the release on github. Make sure to have the
command line token handy to enter as the requested password.
Double-check `stable` release of readthedocs.
This command also tags the release on github. Make sure to have the command line token handy to enter as the requested password. Double-check ``stable`` release of readthedocs.

.. todo::

6. Release code to conda-forge
If you already have a conda-forge feedstock forked to your own GitHub account, first
edit `recipe/meta.yaml` to update the version, hash, etc. To calculate the sha256
hash, run:
6. Release code to ``conda-forge``. If you already have a conda-forge feedstock forked to your own GitHub account, first edit ``recipe/meta.yaml`` to update the version, hash, etc. To calculate the sha256 hash, run:

```shell
openssl dgst -sha256 path/to/package_name-0.1.1.tar.gz
```
.. code-block:: sh
openssl dgst -sha256 path/to/package_name-0.1.1.tar.gz
Then, commit and push the yaml file to GitHub:
Then, commit and push the yaml file to GitHub:

```shell
git pull upstream master
git add --all
git commit -m 'version bump to v0.1.1'
git push -u origin master
```
.. code-block:: sh
git pull upstream master
git add --all
git commit -m 'version bump to v0.1.1'
git push -u origin master
Finally, issue a pull request to conda-forge.
Finally, issue a pull request to conda-forge.

7. At end of all this, double-check the build environments at
https://readthedocs.org/projects/pynrc/builds/. For whatever reason,
it is common for there to be an OSError and the build to fail.
Resetting the environment at https://readthedocs.org/projects/pynrc/versions/
tends to fix this issue. Build times take about 5 minutes.
7. At end of all this, double-check the build environments at https://readthedocs.org/projects/pynrc/builds/. For whatever reason, it is common for there to be an OSError and the build to fail. Resetting the environment at https://readthedocs.org/projects/pynrc/versions/ tends to fix this issue. Build times take about 5 minutes.

.. Travis will then deploy to PyPI if tests pass.
39 changes: 30 additions & 9 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
Revision History
================

v0.8.0beta (ongoing)
-----------------
v1.0.1 (Dec 14, 2021)
---------------------

- Default OPD JWST_OTE_OPD_RevAA_prelaunch_predicted.fits

v1.0.0 (Nov 22, 2021)
---------------------

- Updates to work with WebbPSF v1 release candidate
- Move PSF generation to new ``webbpsf_ext`` package (https://github.com/JarronL/webbpsf_ext)
- Create DMS-like level1b FITS files using pipeline data models for imaging and coronagraphy
- PSF coefficients now use Legendre polynomials by default
- Create calibration files for each SCA (darks, IPC, noise, flats, linearity, etc)
- Background roll-off at grism edges
- SIAF-aware locations

v0.9.0beta (no release)
-----------------------

- Release to work with WebbPSF 0.8.0.
- Updates to work with WebbPSF 0.9.0.
- Start working on commissioning and DMS-like data
- Add more advanced time-dependent detector effects
- BEX model isochrones for low-mass companions from Linder et al (2019)
- There was a pandemic...

v0.8.0beta (no release)
-----------------------

- Updates to work with WebbPSF 0.8.0.
- Phasing out support for Python 2
- Add info on saturation limits in terms of surface brightness
- Include option to create grism 2nd order
Expand Down Expand Up @@ -36,8 +61,7 @@ v0.6.4 (Mar 2018)

- Off-axis PSFs now get drifted in the same way as their on-axis
counterparts.
- Created an intermediate :mod:`~pynrc.nrc_hci` class to enable
offsets of WFE drifted PSFs.
- Created an intermediate ``nrc_hci`` class to enable offsets of WFE drifted PSFs.


v0.6.3 (Mar 2018)
Expand All @@ -51,7 +75,7 @@ v0.6.2 (Mar 2018)
-----------------

- Implemented coronagraphic wedges, including arbitrary offsets along bar
- Renamed ``obs_coronagraphy`` to :mod:`~pynrc.obs_hci`
- Renamed ``obs_coronagraphy`` to ``~pynrc.obs_hci``

- Faster modeling of off-axis PSFs
- Include coronagraphic features (e.g.: ND squares) in slope images
Expand Down Expand Up @@ -102,6 +126,3 @@ v0.1.0 (Aug 2016)
- Rewrite of ``SimNRC`` and rename ``pynrc``
- Object oriented ``multiaccum``, ``DetectorOps``, and ``NIRCam`` classes
- Create separate detector instances in ``NIRCam`` class


-----------------------
50 changes: 29 additions & 21 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,46 +1,54 @@
=====
pyNRC
=====
========
Overview
========

A JWST NIRCam ETC and Simulator
===============================

.. image:: https://img.shields.io/pypi/v/pynrc.svg
:target: https://pypi.python.org/pypi/pynrc
:alt: Badge showing current released PyPI version

.. image:: https://readthedocs.org/projects/pynrc/badge/?version=latest
:target: https://pynrc.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

*Authors:* Jarron Leisenring (UA)
*Authors:* `Jarron Leisenring <https://github.com/JarronL>`_
(U. of Arizona, Steward Observatory)

*Contributors:* Everett Schlawin (UA), Jonathan Fraine (STScI)
*Contributors:* `Everett Schlawin <https://github.com/eas342>`_,
`Jonathan Fraine <https://github.com/exowanderer>`_,
`Jonathan Aguilar <https://github.com/aggle>`_

**!!Under Development!!**
pyNRC is a set of Python-based tools for planning observations with JWST NIRCam, such as an ETC, a simple slope image simulator, and an enhanced data simulator compatible with the JWST pipeline.

pyNRC is a set of Python-based tools for planning observations with JWST NIRCam,
such as an ETC, a simple slope image simulator, and an enhanced data simulator.

While special attention has been placed on NIRCam coronagraphic modes,
this package also works for a variety of NIRCam observing modes including:
While special attention has been placed on NIRCam coronagraphic modes, this package also works for a variety of NIRCam observing modes including:

- direct imaging
- coronagraphic imaging
- weak lens imaging
- slitless grism spectroscopy
- DHS observations (TBI)

All PSFs are generated via WebbPSF (https://webbpsf.readthedocs.io) to reproduce
realistic JWST images and spectra.
All PSFs are generated by `WebbPSF <https://webbpsf.readthedocs.io>`_ as implemented by the `WebbPSF Extensions <https://github.com/JarronL/webbpsf_ext>`_ package to reproduce realistic JWST images and spectra.

Documentation can be found at https://pynrc.readthedocs.io.

**Note:** pyNRC enables more modes than are officially allowed by the Observatory,
(ie., filter + coronagraphic combinations, subarray sizes, etc.).
Just because you can do something with pyNRC does not mean it will be supported.
Check out https://jwst-docs.stsci.edu/display/JTI/NIRCam+Observing+Modes for more information.
Similar to some of its dependencies, pyNRC requires input data files in order to generate simulations. Due to the size of these files, they are not included with this source distribution. Please see the documentation for instructions on how to to download the required data files.

.. warning::

pyNRC enables more modes than are officially allowed by the Observatory, (ie., filter + coronagraphic combinations, subarray sizes, etc.). Just because you can do something with pyNRC does not mean it will be supported in flight. Check out `JDocs`_ for more information.


.. _JDocs: https://jwst-docs.stsci.edu/jwst-near-infrared-camera/nircam-observing-modes


Simulating PSFs
===============

Simulating PSFs with WebbPSF can become computationally expensive if generating new ones on the fly, especially considering JWST PSFs vary with respect to wavelength, field position, and time-dependent wavefront error drift. In an effort to speed up this process, pyNRC uses WebbPSF to generate a series of monochromatic PSF simulations, then produces polynomial fits to each oversampled pixel. Storing the coefficients rather than a library of PSFS allows for quick creation (via matrix multiplication) of PSF images for an arbitrary number of wavelengths (subject to hardware memory limitations, of course). The applications range from quickly creating PSFs for many different stellar types over wide bandpasses to generating a large number of monochromatic PSFs for spectral dispersion.

In addition, each science instrument PSF is dependent on the detector position due to field-dependent wavefront errors. Such changes are tracked in WebbPSF, but it becomes burdensome to generate new PSFs from scratch at each location, especially for large starfields. Instead, these changes can be stored by the fitting the residuals of the PSF coefficients across an instrument's field of view, then interpolating for an arbitrary location. A similar scheme can be achieved for coronagraphic occulters, where the PSF changes as the source position moves with respect to the mask.

Similar to some of its dependencies, pyNRC requires a host of input data files in
order to generate simulations. Due to the size of these files, they are not included
with this source distribution. Please see the documentation for instructions on how to
to download the required data files.
JWST's thermal evolution (e.g., changing the angle of the sunshield after slewing to a new target) causes small but significant distortions to the telescope backplane. WebbPSF has tools to modify OPDs, but high-fidelity simulations take time to calculate. Since the change to the PSF coefficients varies smoothly with respect to WFE drift components, it's simple to parameterize the coefficient residuals in a fashion similar to the field-dependence.

0 comments on commit 70e68a7

Please sign in to comment.