Skip to content

Commit

Permalink
Merge pull request #175 from gmzsebastian/master
Browse files Browse the repository at this point in the history
STIPS 2.2 Pull Request
  • Loading branch information
ojustino authored May 10, 2024
2 parents 06e84d0 + e682982 commit 3170285
Show file tree
Hide file tree
Showing 14 changed files with 197 additions and 102 deletions.
23 changes: 15 additions & 8 deletions .github/workflows/ci_workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,43 @@ jobs:
matrix:
include:

- name: Python 3.8
- name: Python 3.10
os: ubuntu-latest
python: 3.8
python: "3.10"

- name: Python 3.9
- name: Python 3.11
os: ubuntu-latest
python: 3.9
python: 3.11

- name: Python 3.9 Mac
- name: Python 3.11 Mac
os: macos-latest
python: 3.9
python: 3.11

- name: Python Long
os: ubuntu-latest
python: 3.9
python: 3.11

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up environment
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: stips
environment-file: environment.yml
python-version: ${{ matrix.python }}
auto-activate-base: false
miniconda-version: "latest" # Ensure Miniconda is installed if not found

- name: Test with tox
shell: bash -l {0}
if: ${{ matrix.name != 'Python Long' }}
run: |
tox -e test
- name: Test slow tests with pytest
shell: bash -l {0}
if: ${{ matrix.name == 'Python Long' }}
Expand All @@ -57,17 +61,20 @@ jobs:
name: "docs_test"
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up environment
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: stips
environment-file: environment.yml
python-version: 3.9
python-version: 3.11
auto-activate-base: false

- name: Build Docs
shell: bash -l {0}
run: |
Expand Down
8 changes: 8 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ Release Notes
Version History and Change Log
------------------------------

Version 2.2.0
=============
- Added a functionality to allow for faster simulations of extended sources.
- Fixed a bug related to the simulation of extended sources.
- Fixed a bug related to the WCS.
- Updated pandeia to version 3.1 and its corresponding reference files.
- Changed the minimum required Python version to 3.10

Version 2.1.0
=============
- Updated the Flux PHOTFNU values to match Pandeia
Expand Down
13 changes: 6 additions & 7 deletions docs/basic_tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ We will use a single offset with:

* No centering (if an offset is centered, then, for a multi-detector observation, each
detector is centered on the offset co-coordinates individually rather than the instrument
as a whole beinf centered there)
as a whole being centered there)

* No change in RA, DEC, or PA from the center of the observation

Expand Down Expand Up @@ -237,7 +237,7 @@ Observing the Created Scene
In order to observe the scene, we must add the scene catalogues created above to it, add
in error residuals, and finalize the observation. In so doing, we create output catalogues
which are taken from the input catalogues, but only contain the sources visible to the
detectors, and convert source brightness into unites of counts/s for the detectors.
detectors, and convert source brightness into units of counts/s for the detectors.

.. code-block:: python
Expand Down Expand Up @@ -267,16 +267,15 @@ We use ``matplotlib`` to plot the resulting simulated image.
.. code-block:: python
import matplotlib
from matplotlib import style
import matplotlib.pyplot as plt
from astropy.io import fits
matplotlib.rcParams['axes.grid'] = False
matplotlib.rcParams['image.origin'] = 'lower'
import matplotlib.pyplot as plot
from astropy.io import fits
with fits.open(fits_file) as result_file:
result_data = result_file[1].data
fig1 = plot.figure()
im = plot.matshow(result_data)
fig1 = plt.figure()
im = plt.matshow(result_data)
Alternatively, you can open the final ``.fits`` file in your preferred imaging software.
37 changes: 35 additions & 2 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,38 @@ scene with the Roman WFI F129 filter offset by 0.5 degrees in RA and rotated by
fits_file, mosaic_file, params = obm.finalize(mosaic=False)
In this case, the output catalog(s) will show the actual applied count rates. Whether there
is only one output catalog or two depends on the input catalog format.
In this case, the output catalog(s) will show the actual applied count rates.
Whether there is only one output catalog or two depends on the input catalog format.


Fast Extended Sources
----------------------

As of version 2.2, STIPS includes an option to inject extended sources in scenes
using a Sersic-profile approximation. This approximation is ~8 times faster than
the current implementation, but it is also less accurate.

To activate this feature, users must turn on the ``fast_galaxy`` flag. This is how the syntax
looks, starting from the examples listed in the :doc:`STIPS Basic Tutorial <basic_tutorial>`.

.. code-block:: python
observation_parameters = {
'instrument': 'WFI',
'filters': ['F129'],
'detectors': 1,
'distortion': False,
'background': 0.15,
'fast_galaxy': True,
'observations_id': 1,
'exptime': 1000,
'offsets': [offset]
}
.. note::

We caution however that while this method is a useful approximation, the resulting
integrated flux measurements can be off by a factor of ~2. Furthermore, the central
pixel at the core of the galaxy should not be trusted, since this can be off by
multiple orders of magnitude.

25 changes: 12 additions & 13 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,36 @@ Documentation

.. note::

STIPS 2.0 no longer supports HST or JWST. STIPS 1.0.8 is the most recent version to
offer support for those telescopes and instruments.
As of version 2.0, STIPS no longer offers support for HST or JWST.

Overview
--------
STIPS is the Space Telescope Imaging Product Simulator. It is designed to create
simulations of full-detector post-pipeline astronomical scenes for the Nancy Grace Roman
Space Telescope's Wide-Field Instrument (WFI). STIPS has the ability to add
STIPS is the Space Telescope Imaging Product Simulator. It is designed to create
simulations of full-detector post-pipeline astronomical scenes for the Nancy Grace Roman
Space Telescope's Wide-Field Instrument (WFI). STIPS has the ability to add
instrumental distortion (if available) as well as calibration residuals from flatfields,
dark currents, and cosmic rays. It automatically includes Poisson noise and readout noise.
It does not include instrument saturation effects.

Why use STIPS?
--------------
STIPS is intended to produce quick simulations of Level 2 (L2) images, and is provided for
STIPS is intended to produce quick simulations of Level 2 (L2) images, and is provided for
cases where `Pandeia <https://pypi.org/project/pandeia.engine/>`_ does not
provide a large enough simulation area (e.g., full-detector or multiple-detector
observations). STIPS obtains its Roman instrument and filter values from
Pandeia, so it should produce output within 10% of output produced by Pandeia.

STIPS does not start with Level 1 (L1) images and propagate instrumental calibrations
STIPS does not start with Level 1 (L1) images and propagate instrumental calibrations
through the simulations. While it does have the ability to add error residuals (representing
the remaining uncertainty after pipeline calibration), these residuals are not validated
against actual pipeline calibrations of L1 images. STIPS is not the ideal choice if
extremely good instrumental accuracy is needed. Pandeia is the preferred tool for
the remaining uncertainty after pipeline calibration), these residuals are not validated
against actual pipeline calibrations of L1 images. STIPS is not the ideal choice if
extremely good instrumental accuracy is needed. Pandeia is the preferred tool for
high-accuracy observations.

Developed by Brian York (`@york-stsci <https://github.com/york-stsci>`_),
Robel Geda (`@robelgeda <https://github.com/robelgeda>`_),
and O. Justin Otor (`@ojustino <https://github.com/ojustino>`_).
Python ePSF code developed by
Robel Geda (`@robelgeda <https://github.com/robelgeda>`_),
and O. Justin Otor (`@ojustino <https://github.com/ojustino>`_).
Python ePSF code developed by
Sebastian Gomez (`@gmzsebastian <https://github.com/gmzsebastian>`_) based on Fortran code
developed by Andrea Bellini (`@AndreaBellini <https://github.com/AndreaBellini>`_).

Expand Down
10 changes: 5 additions & 5 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ in this section along with instructions.
STIPS Requirements
##################

* ``pandeia>=3.0``: Exposure time calculator.
* ``pandeia>=3.1``: Exposure time calculator.

* ``webbpsf==1.1.1``: Nancy Grace Roman PSF calculator. STIPS also requires that ``poppy``, a
support package used by WebbPSF, have version ``>=1.0.3``.
Expand Down Expand Up @@ -80,9 +80,9 @@ Installing as a User
conda activate stips


* Or, to install to or update an existing and currently active Conda environment::
* Or, to install to or update an existing Conda environment::

conda env update --file environment.yml
conda env update --name EXISTING-ENV --file environment.yml

Installing as a Developer
*************************
Expand Down Expand Up @@ -126,8 +126,8 @@ Testing Installation
To test if all the required files have been installed, please import STIPS in Python::

bash-3.2$ python
Python 3.7.3 | packaged by conda-forge | (default, Dec 6 2019, 08:36:57)
[Clang 9.0.0 (tags/RELEASE_900/final)] :: Anaconda, Inc. on darwin
Python 3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:45:13)
[Clang 16.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> import stips
Expand Down
18 changes: 9 additions & 9 deletions docs/using_stips/psf_grid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ The STIPS PSF Grid
Overview
--------

Starting with STIPS 2.0.0, STIPS uses WebbPSF PSF grids to implement an ePSF. The ePSF
uses a 3x3 grid of PSFs to handle PSF variation across the detector, and an oversample of
As of version 2.0.0, STIPS uses WebbPSF PSF grids to implement an ePSF. The ePSF
uses a 3x3 grid of PSFs to handle PSF variation across the detector, and an oversample of
4x4 to handle sub-pixel positioning. Each point source has its PSF calculated individually
as it is added to the detector.

Internal Image Size
-------------------

The size of the STIPS pre-convolution image is set by the size of the detector. In
addition, the image is padded by half of the PSF size on each side in order to include
The size of the STIPS pre-convolution image is set by the size of the detector. In
addition, the image is padded by half of the PSF size on each side in order to include
sources that fall off the detector, but whose PSF may land on the detector.

PSF Image Size
--------------

The size of the STIPS generated PSF image depends on the source brightness. For most
sources, a 45x45-pixel PSF is created via an ePSF oversampled to a factor of 4. For bright
sources (magnitude < the bright limit, default 14), a 91x91-pixel PSF is created to
provide flux from the extended wings. For extra-bright sources
(magnitude < the extra-bright limit, default 3), a 181x181-pixel PSF is created to provide
The size of the STIPS generated PSF image depends on the source brightness. For most
sources, a 45x45-pixel PSF is created via an ePSF oversampled to a factor of 4. For bright
sources (magnitude < the bright limit, default 14), a 91x91-pixel PSF is created to
provide flux from the extended wings. For extra-bright sources
(magnitude < the extra-bright limit, default 3), a 181x181-pixel PSF is created to provide
even more wing flux to the model.
6 changes: 3 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file describes a conda environment that can be to install STIPS
# This file describes a conda environment that can be used to install STIPS
#
# Run the following command to set up this environment:
# $ conda env create -f environment.yml
Expand All @@ -25,7 +25,7 @@ channels:
dependencies:
# Base dependencies
- pip
- python>=3.8
- python>=3.10
- jupyter
- Cython
- esutil # installed from conda because you need the pre-compiled binaries.
Expand All @@ -36,7 +36,7 @@ dependencies:

# Core Modules
- webbpsf==1.1.1
- pandeia.engine==3.0
- pandeia.engine==3.1
- synphot==1.1.1
- stsynphot==1.1.0
- soc_roman_tools
Expand Down
8 changes: 4 additions & 4 deletions environment_dev.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file describes a conda environment that can be to install STIPS for development and
# testing purposes. Note that this environment set-up installs the STIPS module in
# This file describes a conda environment that can be used to install STIPS for development and
# testing purposes. Note that this environment setup installs the STIPS module in
# editable mode, so any changes you make to the STIPS source will be reflected the next
# time you run python.
#
Expand Down Expand Up @@ -28,7 +28,7 @@ channels:
dependencies:
# Base dependencies
- pip
- python>=3.8
- python>=3.10
- jupyter
- Cython
- esutil # installed from conda because you need the pre-compiled binaries.
Expand All @@ -45,7 +45,7 @@ dependencies:

# Core Modules
- webbpsf==1.1.1
- pandeia.engine==3.0
- pandeia.engine==3.1
- synphot==1.1.1
- stsynphot==1.1.0
- soc_roman_tools
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[metadata]
name = stips
# version should be PEP440 compatible (https://www.python.org/dev/peps/pep-0440/)
version = 2.1.0
version = 2.2.0
author = Space Telescope Science Institute
author_email = [email protected]
description = STIPS is the Space Telescope Imaging Product Simulator.
Expand All @@ -24,7 +24,7 @@ install_requires =
synphot==1.1.1
stsynphot==1.1.0
webbpsf==1.1.1
pandeia.engine==3.0
pandeia.engine==3.1
montage-wrapper
pyyaml
soc_roman_tools
Expand Down
Loading

0 comments on commit 3170285

Please sign in to comment.