Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/spacetelescope/jwst into AL…
Browse files Browse the repository at this point in the history
…-837
  • Loading branch information
emolter committed Oct 29, 2024
2 parents e46a0a5 + ed69f20 commit e0501ea
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
name: check that `requirements-sdp.txt` is populated
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- run: grep -v '^ *#' requirements-sdp.txt
build:
needs: [ check ]
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-changelog-entry-needed') }}
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: 3
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- run: pip install .
Expand All @@ -32,7 +32,7 @@ jobs:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'allow-manual-changelog-edit') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: prevent direct changes to `CHANGES.rst`
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: '3.12'
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
Expand Down
1 change: 1 addition & 0 deletions changes/8907.pipeline.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a bug leading to incorrect area extensions, and sometimes crashes, in the coron3 pipeline
1 change: 1 addition & 0 deletions changes/8926.docs.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Mention possible need to provide package name to strun when using aliases.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ has the alias ``calwebb_detector1`` and can be run as

A full list of pipeline aliases can be found in :ref:`Pipeline Stages <pipelines>`.


.. note::

When using an **alias** with strun (for example ``strun resample``) you may
need to provide the ``jwst`` package name if you have other packages installed
that also use the same **alias**. The package name is provided prior to the
**alias** separated by ``::`` (for example ``strun jwst::resample``).

.. _exit_status:

Exit Status
Expand Down
9 changes: 8 additions & 1 deletion jwst/pipeline/calwebb_coron3.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ def to_container(model):
'var_poisson', 'var_rnoise', 'var_flat'
]:
try:
setattr(image, attribute, model.getarray_noinit(attribute)[plane])
arr = model.getarray_noinit(attribute)
if arr.ndim == 3:
setattr(image, attribute, arr[plane])
elif arr.ndim == 2:
setattr(image, attribute, arr)
else:
msg = f"Unexpected array shape for extension {attribute}: {arr.shape}"
raise ValueError(msg)
except AttributeError:
pass
image.update(model)
Expand Down
21 changes: 21 additions & 0 deletions jwst/pipeline/tests/test_calwebb_coron3.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from stdatamodels.jwst.datamodels import CubeModel

from jwst.pipeline.calwebb_coron3 import to_container
import numpy as np


# Generate data
Expand All @@ -22,6 +23,26 @@ def make_container():
]


def test_to_container():
"""Cover bug where IndexError would be raised when area extension of CubeModel
has shape (x,y) instead of (nints,x,y). In this case area extension should
be copied to each ImageModel in the ModelContainer.
"""
shp = (10,5,5)
cube = CubeModel(shp)
extensions_3d = ['data', 'dq', 'err',]
for extension in extensions_3d:
setattr(cube, extension, np.random.rand(*shp))
cube.area = np.random.rand(5,5)

container = to_container(cube)
for i, model in enumerate(container):
for extension in extensions_3d:
assert np.all(getattr(model, extension) == getattr(cube, extension)[i])
assert hasattr(model, 'area')
assert np.all(model.area == cube.area)


@pytest.mark.parametrize('cube, container', [(cube, container)])
def test_container_shape(cube, container):
"""Test container shape"""
Expand Down

0 comments on commit e0501ea

Please sign in to comment.