Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RCAL-853: Apply velocity aberration correction to the WFI WCS #1354

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
16 changes: 15 additions & 1 deletion romancal/assign_wcs/assign_wcs_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,29 @@ def load_wcs(input_model, reference_files=None):
axes_names=("v2", "v3"),
unit=(u.arcsec, u.arcsec),
)
v2v3vacorr = cf.Frame2D(
name="v2v3vacorr",
axes_order=(0, 1),
axes_names=("v2", "v3"),
unit=(u.arcsec, u.arcsec),
)
world = cf.CelestialFrame(reference_frame=coord.ICRS(), name="world")

# Transforms between frames
distortion = wfi_distortion(output_model, reference_files)
tel2sky = pointing.v23tosky(output_model)

# Compute differential velocity aberration (DVA) correction:
va_corr = pointing.dva_corr_model(
va_scale=input_model.meta.velocity_aberration.scale_factor,
v2_ref=input_model.meta.wcsinfo.v2_ref,
v3_ref=input_model.meta.wcsinfo.v3_ref,
)

pipeline = [
Step(detector, distortion),
Step(v2v3, tel2sky),
Step(v2v3, va_corr),
Step(v2v3vacorr, tel2sky),
Step(world, None),
]
wcs = WCS(pipeline)
Expand Down
61 changes: 60 additions & 1 deletion romancal/assign_wcs/pointing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
from astropy.modeling.models import RotationSequence3D, Scale
from astropy.modeling.models import Identity, RotationSequence3D, Scale, Shift
from gwcs.geometry import CartesianToSpherical, SphericalToCartesian


Expand Down Expand Up @@ -45,3 +45,62 @@
)
model.name = "v23tosky"
return model


def dva_corr_model(va_scale, v2_ref, v3_ref):
"""
Create transformation that accounts for differential velocity aberration
(scale).

Parameters
----------
va_scale : float, None
Ratio of the apparent plate scale to the true plate scale. When
``va_scale`` is `None`, it is assumed to be identical to ``1`` and
an ``astropy.modeling.models.Identity`` model will be returned.

v2_ref : float, None
Telescope ``v2`` coordinate of the reference point in ``arcsec``. When
``v2_ref`` is `None`, it is assumed to be identical to ``0``.

v3_ref : float, None
Telescope ``v3`` coordinate of the reference point in ``arcsec``. When
``v3_ref`` is `None`, it is assumed to be identical to ``0``.

Returns
-------
va_corr : astropy.modeling.CompoundModel, astropy.modeling.models.Identity
A 2D compound model that corrects DVA. If ``va_scale`` is `None` or 1
then `astropy.modeling.models.Identity` will be returned.

"""
if va_scale is None or va_scale == 1:
return Identity(2)

Check warning on line 78 in romancal/assign_wcs/pointing.py

View check run for this annotation

Codecov / codecov/patch

romancal/assign_wcs/pointing.py#L78

Added line #L78 was not covered by tests

if va_scale <= 0:
raise ValueError("'Velocity aberration scale must be a positive number.")

va_corr = Scale(va_scale, name="dva_scale_v2") & Scale(

Check warning on line 83 in romancal/assign_wcs/pointing.py

View check run for this annotation

Codecov / codecov/patch

romancal/assign_wcs/pointing.py#L83

Added line #L83 was not covered by tests
va_scale, name="dva_scale_v3"
)

if v2_ref is None:
v2_ref = 0

Check warning on line 88 in romancal/assign_wcs/pointing.py

View check run for this annotation

Codecov / codecov/patch

romancal/assign_wcs/pointing.py#L87-L88

Added lines #L87 - L88 were not covered by tests

if v3_ref is None:
v3_ref = 0

Check warning on line 91 in romancal/assign_wcs/pointing.py

View check run for this annotation

Codecov / codecov/patch

romancal/assign_wcs/pointing.py#L90-L91

Added lines #L90 - L91 were not covered by tests

if v2_ref == 0 and v3_ref == 0:
return va_corr

Check warning on line 94 in romancal/assign_wcs/pointing.py

View check run for this annotation

Codecov / codecov/patch

romancal/assign_wcs/pointing.py#L93-L94

Added lines #L93 - L94 were not covered by tests

# NOTE: it is assumed that v2, v3 angles and va scale are small enough
# so that for expected scale factors the issue of angle wrapping
# (180 degrees) can be neglected.
v2_shift = (1 - va_scale) * v2_ref
v3_shift = (1 - va_scale) * v3_ref

Check warning on line 100 in romancal/assign_wcs/pointing.py

View check run for this annotation

Codecov / codecov/patch

romancal/assign_wcs/pointing.py#L99-L100

Added lines #L99 - L100 were not covered by tests

va_corr |= Shift(v2_shift, name="dva_v2_shift") & Shift(

Check warning on line 102 in romancal/assign_wcs/pointing.py

View check run for this annotation

Codecov / codecov/patch

romancal/assign_wcs/pointing.py#L102

Added line #L102 was not covered by tests
v3_shift, name="dva_v3_shift"
)
va_corr.name = "DVA_Correction"
return va_corr

Check warning on line 106 in romancal/assign_wcs/pointing.py

View check run for this annotation

Codecov / codecov/patch

romancal/assign_wcs/pointing.py#L105-L106

Added lines #L105 - L106 were not covered by tests
Loading