-
Notifications
You must be signed in to change notification settings - Fork 171
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
JP-1762: Add VA correction to WCS #5602
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5602 +/- ##
==========================================
+ Coverage 75.40% 75.64% +0.23%
==========================================
Files 406 406
Lines 36486 37214 +728
==========================================
+ Hits 27513 28150 +637
- Misses 8973 9064 +91
*This pull request uses carry forward flags. Click here to find out more.
Continue to review full report at Codecov.
|
jwst/assign_wcs/nirspec.py
Outdated
@@ -142,6 +147,7 @@ def imaging(input_model, reference_files): | |||
(sca, det2gwa), | |||
(gwa, gwa2msa), | |||
(msa_frame, None)] | |||
# TODO: Add DVA correction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to add VA correction here since this pipeline does not go to sky but stops at the MSA.
jwst/assign_wcs/nirspec.py
Outdated
@@ -231,12 +237,13 @@ def ifu(input_model, reference_files, slit_y_range=[-.55, .55]): | |||
(slit_frame, slit2slicer), | |||
('slicer', slicer2msa), | |||
(msa_frame, None)] | |||
# TODO: Add DVA correction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for VA correction here, ti stops at the MSA.
jwst/assign_wcs/nirspec.py
Outdated
@@ -345,14 +352,15 @@ def slitlets_wcs(input_model, reference_files, open_slits_id): | |||
(gwa, gwa2slit), | |||
(slit_frame, slit2msa), | |||
(msa_frame, None)] | |||
# TODO: Add DVA correction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here, no va correction
Thanks @nden! I removed |
a076f38
to
4107925
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good!
Just a couple minor comments below. Not sure why we're seeing small changes in the computed coordinates, mostly in S_REGION.
https://plwishmaster.stsci.edu:8081/job/RT/job/jdavies-dev/220/testReport/
name='v2v3vacorr_spatial', | ||
axes_order=(0, 1), | ||
unit=(u.arcsec, u.arcsec), | ||
axes_names=('v2', 'v3') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to have axes_names
here but not for the MIRI imaging mode (or the other instrument imaging modes)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not know... I just copied the frame that was already used in the assign_wcs
for a given instrument. I simply appended vacorr
to the frame name. No other changes. I also noticed sometimes frames are called v2
and sometimes V3
- see #5746 point #4
. Maybe this should be noted there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Maybe for a future "consistency and cleanup" PR then. Agree to keep it as for this PR.
@@ -74,6 +74,7 @@ def imaging(input_model, reference_files): | |||
""" | |||
detector = cf.Frame2D(name='detector', axes_order=(0, 1), unit=(u.pix, u.pix)) | |||
v2v3 = cf.Frame2D(name='v2v3', axes_order=(0, 1), unit=(u.arcsec, u.arcsec)) | |||
v2v3vacorr = cf.Frame2D(name='v2v3vacorr', axes_order=(0, 1), unit=(u.arcsec, u.arcsec)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, no axes_names
here. Maybe it would be good to have consistency between these imaging modes and the spectral modes?
jwst/assign_wcs/pointing.py
Outdated
va_scale = float(datamodel.meta.velocity_aberration.scale_factor) | ||
v2_ref = float(datamodel.meta.wcsinfo.v2_ref) | ||
v3_ref = float(datamodel.meta.wcsinfo.v3_ref) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Casting these to float is probably not needed, as they are already floats by definition from the schemas. Or they are not populated and return None
, which of course will return a TypeError
when cast to float
. AttributeError
should never be returned.
You could just put the equation in the try
block and if any of the items are None
, you're going to get a TypeError
.
I wonder the casting of values could be causing the slightly differences in the regtests for S_REGION? One is type <class 'numpy.float32'>
, the other <class 'float'>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could just put the equation in the try block and if any of the items are None, you're going to get a TypeError.
Isn't what I am already doing? I did not know that meta.velocity_aberration.scale_factor
and wcsinfo.v2_ref
and meta.wcsinfo.v3_ref
are always guaranteed to exist. If that is the case, I'll be happy to remove attribute error from being caught.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, they are always guaranteed to exist because they're in the schema and in meta
.
jwst/assign_wcs/pointing.py
Outdated
# rot.inverse | c2s | unit_conv.inverse | ||
# ) | ||
|
||
va_corr.name = 'VA_Correction' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name should be descriptive, and bits are free. "Spacecraft Velocity Aberration Correction" would be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nden What do you think? I personally think that VA_Correction
should be OK but if you think a longer string is more desirable - it is easy to change this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Models can be referenced by name so I'd say shorter is better and not having spaces in the name is preferable.
def create_imaging_datamodel(v2_ref, v3_ref, va_scale): | ||
hdul = create_hdul() | ||
datamodel = ImageModel(hdul) | ||
datamodel.meta.velocity_aberration.scale_factor = va_scale | ||
datamodel.meta.wcsinfo.v2_ref = v2_ref | ||
datamodel.meta.wcsinfo.v3_ref = v3_ref | ||
return datamodel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be a Pytest fixture, and it would be much clearer that the tests depend on it.
I investigated this and it looks that For example, for
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Mihai. Yeah, it looks like some of our test data, probably from OTB or SDP processing, already has VA_SCALE set, so nice to see it exercised in your code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM other than the code style issue
Needs a change log. |
This PR adds support for velocity aberration correction in WCS. It needs thorough review.
It was decided, after a couple of iterations, that DVA correction will be applied as a separate transformation from the
v2v3
frame to a new, VA-corrected,v2v3
frame that will be called'v2v3vacorr'
in WCS pipeline.The code applies a constant scale DVA correction in the (almost-)tangent plane
v2-v3
at Colin Cox suggestion. However, for when non-linear effects may become important, this PR also includes commented out full set of transformations from the sphericalv2,v3
coordinates to a tangent plane and then applying constant scale transformation in that plane and then backward transformation to the (DVA-corrected) spherical coordinatesv2,v3
.Resolves JP-1762 and #5434