Skip to content
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
5 changes: 1 addition & 4 deletions jwst/ami/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
import stdatamodels.jwst.datamodels as dm

from jwst.ami.bp_fix import calc_pupil_support, filthp_d
from jwst.ami.tests.helpers import PXSC_RAD
from jwst.stpipe import Step

PXSC_DEG = 65.6 / (60.0 * 60.0 * 1000)
PXSC_RAD = PXSC_DEG * np.pi / (180)
PXSC_MAS = PXSC_DEG * 3600 * 1000


@pytest.fixture(scope="package")
def example_model():
Expand Down
9 changes: 9 additions & 0 deletions jwst/ami/tests/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Useful constants and functions for AMI tests."""

import numpy as np

PXSC_DEG = 65.6 / (60.0 * 60.0 * 1000)
PXSC_RAD = PXSC_DEG * np.pi / (180)
PXSC_MAS = PXSC_DEG * 3600 * 1000

__all__ = [] # type: ignore[var-annotated]
2 changes: 1 addition & 1 deletion jwst/ami/tests/test_ami_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import stdatamodels.jwst.datamodels as dm

from jwst.ami import AmiNormalizeStep
from jwst.ami.tests.conftest import PXSC_MAS
from jwst.ami.tests.helpers import PXSC_MAS
from jwst.ami.utils import get_cw_beta

RAW_AMP = 3
Expand Down
2 changes: 1 addition & 1 deletion jwst/ami/tests/test_bp_fix.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from numpy.testing import assert_allclose

from jwst.ami import bp_fix
from jwst.ami.tests.conftest import PXSC_MAS, PXSC_RAD
from jwst.ami.tests.helpers import PXSC_MAS, PXSC_RAD


@pytest.mark.parametrize("filt", bp_fix.filts)
Expand Down
2 changes: 1 addition & 1 deletion jwst/ami/tests/test_find_affine2d_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np

from jwst.ami import find_affine2d_parameters, utils
from jwst.ami.tests.conftest import PXSC_DEG
from jwst.ami.tests.helpers import PXSC_DEG


def test_create_afflist_rot():
Expand Down
2 changes: 1 addition & 1 deletion jwst/ami/tests/test_hextransformee.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from jwst.ami import hextransformee
from jwst.ami.bp_fix import filtwl_d
from jwst.ami.tests.conftest import PXSC_RAD
from jwst.ami.tests.helpers import PXSC_RAD
from jwst.ami.utils import Affine2d


Expand Down
2 changes: 1 addition & 1 deletion jwst/ami/tests/test_lg_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest

from jwst.ami import lg_model
from jwst.ami.tests.conftest import PXSC_RAD
from jwst.ami.tests.helpers import PXSC_RAD

PSF_FOV = 21

Expand Down
4 changes: 2 additions & 2 deletions jwst/exp_to_source/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
import stdatamodels.jwst.datamodels as dm

from jwst.extract_1d.tests.conftest import mock_nirspec_fs_one_slit_function
from jwst.extract_1d.tests.helpers import mock_nirspec_fs_one_slit_func


@pytest.fixture
Expand All @@ -14,7 +14,7 @@ def mock_nirspec_fs_one_slit():
SlitModel
The mock model.
"""
model = mock_nirspec_fs_one_slit_function()
model = mock_nirspec_fs_one_slit_func()
# mock WCS was originally a function which is not serializable
model.meta.wcs = None
yield model
Expand Down
40 changes: 9 additions & 31 deletions jwst/extract_1d/soss_extract/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@

from jwst.extract_1d.soss_extract import atoca
from jwst.extract_1d.soss_extract import atoca_utils as au

PWCPOS = 245.85932900002442
DATA_SHAPE = (25, 200)
WAVE_BNDS_O1 = [2.8, 0.8]
WAVE_BNDS_O2 = [1.4, 0.5]
WAVE_BNDS_GRID = [0.7, 2.7]
ORDER1_SCALING = 20.0
ORDER2_SCALING = 2.0
TRACE_END_IDX = [DATA_SHAPE[1], 180]
SPECTRAL_SLOPE = 2
from jwst.extract_1d.soss_extract.tests.helpers import (
DATA_SHAPE,
PWCPOS,
TRACE_END_IDX,
WAVE_BNDS_GRID,
WAVE_BNDS_O1,
WAVE_BNDS_O2,
f_lam,
)


@pytest.fixture(scope="package")
Expand Down Expand Up @@ -313,27 +312,6 @@ def engine(
)


def f_lam(wl, m=SPECTRAL_SLOPE, b=0):
"""
Return a linear model of flux as function of wavelength.

Parameters
----------
wl : array[float]
Wavelength
m : float
Slope of linear model
b : float
Intercept of linear model

Returns
-------
array[float]
Flux
"""
return m * wl + b


@pytest.fixture(scope="package")
def imagemodel(engine, detector_mask):
"""
Expand Down
34 changes: 34 additions & 0 deletions jwst/extract_1d/soss_extract/tests/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Test data and functions useful for testing."""

PWCPOS = 245.85932900002442
DATA_SHAPE = (25, 200)
WAVE_BNDS_O1 = [2.8, 0.8]
WAVE_BNDS_O2 = [1.4, 0.5]
WAVE_BNDS_GRID = [0.7, 2.7]
ORDER1_SCALING = 20.0
ORDER2_SCALING = 2.0
TRACE_END_IDX = [DATA_SHAPE[1], 180]
SPECTRAL_SLOPE = 2

__all__ = ["f_lam"]


def f_lam(wl, m=SPECTRAL_SLOPE, b=0):
"""
Return a linear model of flux as function of wavelength.

Parameters
----------
wl : array[float]
Wavelength
m : float
Slope of linear model
b : float
Intercept of linear model

Returns
-------
array[float]
Flux
"""
return m * wl + b
2 changes: 1 addition & 1 deletion jwst/extract_1d/soss_extract/tests/test_atoca.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from scipy.sparse import csr_matrix

from jwst.extract_1d.soss_extract import atoca
from jwst.extract_1d.soss_extract.tests.conftest import (
from jwst.extract_1d.soss_extract.tests.helpers import (
DATA_SHAPE,
SPECTRAL_SLOPE,
WAVE_BNDS_O1,
Expand Down
2 changes: 1 addition & 1 deletion jwst/extract_1d/soss_extract/tests/test_pastasoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
get_soss_traces,
get_soss_wavemaps,
)
from jwst.extract_1d.soss_extract.tests.conftest import (
from jwst.extract_1d.soss_extract.tests.helpers import (
PWCPOS,
TRACE_END_IDX,
WAVE_BNDS_O1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
estim_error_nearest_data,
get_box_weights,
)
from jwst.extract_1d.soss_extract.tests.conftest import DATA_SHAPE
from jwst.extract_1d.soss_extract.tests.helpers import DATA_SHAPE

WIDTH = 5.1

Expand Down
2 changes: 1 addition & 1 deletion jwst/extract_1d/soss_extract/tests/test_soss_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
_compute_box_weights,
_model_image,
)
from jwst.extract_1d.soss_extract.tests.conftest import DATA_SHAPE
from jwst.extract_1d.soss_extract.tests.helpers import DATA_SHAPE


@pytest.fixture
Expand Down
Loading
Loading