Skip to content

Commit

Permalink
do not error out with negative scales
Browse files Browse the repository at this point in the history
  • Loading branch information
stscieisenhamer committed Dec 4, 2024
1 parent 9fda264 commit a172244
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ dependencies = [
# "rad >=0.19.2",
# "roman_datamodels >=0.19.1",
"rad @ git+https://github.com/spacetelescope/rad.git",
# "roman_datamodels @ git+https://github.com/spacetelescope/roman_datamodels.git",
"roman_datamodels @ git+https://github.com/stscieisenhamer/roman_datamodels.git@rcal-853-velocity",
"roman_datamodels @ git+https://github.com/spacetelescope/roman_datamodels.git",
"gwcs >=0.19.0",
"jsonschema >=4.8",
"numpy >=1.22",
Expand Down
22 changes: 22 additions & 0 deletions romanisim/tests/test_wcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,25 @@ def test_scale_factor():
sky = gwcs.pixel_to_world(grid, grid)

assert all(truth.separation(sky).to(u.arcsec).value < 1e-3)


def test_scale_factor_negative():
"""Test that specifying a scale factor actually calculates a new wcs"""

# Truth aiming for.
cc = SkyCoord(ra=0 * u.deg, dec=0 * u.deg)
scale_factor = -99999
truth = SkyCoord([(0. , 0. ), (0.03055555, 0.03055555),
(0.06111109, 0.06111105), (0.09166659, 0.09166647),
(0.12222204, 0.12222176)],
unit='deg')

# Make a simple grid of pixel coordinates to calculate sky for
grid = range(0, 4096, 1000)

# Create the wcs and generate results
distortion = make_fake_distortion_function()
gwcs = wcs.make_wcs(cc, distortion, scale_factor=scale_factor)
sky = gwcs.pixel_to_world(grid, grid)

assert all(truth.separation(sky).to(u.arcsec).value < 1e-3)
6 changes: 5 additions & 1 deletion romanisim/wcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import romanisim.parameters
import roman_datamodels.maker_utils as maker_utils

from romanisim import log


def fill_in_parameters(parameters, coord, pa_aper=0, boresight=True):
"""Add WCS info to parameters dictionary.
Expand Down Expand Up @@ -574,7 +576,9 @@ def dva_corr_model(va_scale, v2_ref, v3_ref):
return models.Identity(2)

if va_scale <= 0:
raise ValueError("'Velocity aberration scale must be a positive number.")
log.warning("Velocity aberration scale must be a positive number: %s", va_scale)
log.warning("Defaulting to scale of 1.0")
va_scale = 1.0

va_corr = models.Scale(va_scale, name="dva_scale_v2") & models.Scale(
va_scale, name="dva_scale_v3"
Expand Down

0 comments on commit a172244

Please sign in to comment.