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

Fits wcs #246

Merged
merged 30 commits into from
Nov 13, 2024
Merged

Fits wcs #246

merged 30 commits into from
Nov 13, 2024

Conversation

braingram
Copy link
Contributor

@braingram braingram commented Nov 5, 2024

This PR builds off of #235
and works around an astropy issue where SIP coefficients lose precision: astropy/astropy#17334

Copy link

codecov bot commented Nov 5, 2024

Codecov Report

Attention: Patch coverage is 99.38650% with 1 line in your changes missing coverage. Please review.

Project coverage is 99.40%. Comparing base (5a2f7cf) to head (1edecd1).
Report is 32 commits behind head on main.

Files with missing lines Patch % Lines
asdf_astropy/testing/helpers.py 95.65% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #246      +/-   ##
==========================================
- Coverage   99.45%   99.40%   -0.06%     
==========================================
  Files          57       62       +5     
  Lines        2037     2200     +163     
==========================================
+ Hits         2026     2187     +161     
- Misses         11       13       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -6,15 +6,15 @@ description: |-
model classes, which are handled by an implementation of the ASDF
transform extension.
asdf_standard_requirement:
gte: 1.6.0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewers this manifest requires ASDF standard 1.6.0 which has not yet become the stable release. Since this PR adds new features that are compatible with the current stable ASDF standard 1.5.0 I chose to change this manifest (astropy-1.2.0) to instead support the stable version (using all the pre 1.6.0 schemas) and adding the new WCS schemas.

I also added astropy-1.3.0 which support 1.6.0 and also adds the new WCS schemas for that standard version.

So to summarize. Before this PR:

  • astropy-1.2.0 supported ASDF standard 1.6.0 (the unused development version)

After this PR:

  • astropy-1.2.0 supports ASDF standard 1.5.0 and adds the WCS schemas
  • astropy-1.3.0 supports ASDF standard 1.6.0 and adds the WCS schemas

@braingram braingram marked this pull request as ready for review November 5, 2024 20:46
@braingram
Copy link
Contributor Author

@Cadair I can't request you as a reviewer. Would you give this a review?

@braingram
Copy link
Contributor Author

@ViciousEagle03 I put together this PR based on the work you did serializing astropy.wcs.WCS. It turns out one of the hang-ups is a bug in astropy (that was a fun one to track down). If you're available to give this a review that would be great! Thanks again for all your work!

@ViciousEagle03
Copy link
Contributor

@ViciousEagle03 I put together this PR based on the work you did serializing astropy.wcs.WCS. It turns out one of the hang-ups is a bug in astropy (that was a fun one to track down). If you're available to give this a review that would be great! Thanks again for all your work!

This is great! Thanks for cleaning up the code and finding a workaround for the bug. We can finally merge the rest of the PRs dependent on the serialization of astropy.wcs.WCS .

Comment on lines +24 to +25
- type: integer
- type: object
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be simpler if we always stored a slice object with stop = start + 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly. Although I think this should retain the format of the _slices_array. Which can contain all of these values.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair, let's leave it as is.

return wcs


def create_tabular_wcs():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a distortion table, but do we have a test for a -TAB wcs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any suggestions for an example to try?

If I use the one here:
https://github.com/astropy/astropy/blob/0f80be718107ef797a58ba42025e70b21c454c61/astropy/wcs/tests/conftest.py#L11
it doesn't roundtrip through pickle (or to_fits)

import pickle
from astropy.wcs import WCS
from astropy.wcs.tests.helper import SimModelTAB
st = SimModelTAB(nx=150, ny=200)
hdulist = st.hdulist
wcs = WCS(hdulist[0].header, hdulist)
pickle.loads(pickle.dumps(wcs))
KeyError: "Extension ('WCS-TABLE', 1) not found."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file in the astropy package data get_pkg_data_filename("data/tab-time-last-axis.fits", package="astropy.wcs.tests") also fails to round-trip through pickle (or to_fits).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh astropy/astropy#9998 astropy can't produce a -TAB wcs so we can't support it here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I guess we should write a test which errors then 😆

@pllim
Copy link
Member

pllim commented Nov 6, 2024

tl;dr -- Isn't the whole point of ASDF is to be able to use GWCS so you can ditch FITS WCS?

@Cadair
Copy link
Member

Cadair commented Nov 6, 2024

The point of ASDF is to be able to save things, this work is part of a GSOC project for saving NDCube objects to ASDF, if you have backed your NDCube with a gwcs or an astropy WCS it shouldn't matter you should be able to save it to and load it from ASDF.

@braingram
Copy link
Contributor Author

5f34952 adds some tests using the astropy.wcs.tests.data. I wasn't able to find a definitive list of "wcses that should work" and some of the test data is designed to trigger errors. I tried to get most of the files that were not designed to trigger errors.

This did reveal one bug in this PR where setting "pixel_shape" on deserialization resulted in an error for https://github.com/astropy/astropy/blob/7896e82c0b06ea4b3870711e7124569f812df39f/astropy/wcs/tests/data/spectra/orion-velo-1.hdr since the "pixel_shape" is inconsistent with "naxis". I fixed this by removing the "pixel_shape" setting (and looking back I don't see this set anywhere in WCS_unpickle which was the model for this PR).

Copy link
Member

@perrygreenfield perrygreenfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, as much as FITS WCS looks good to me ;-)

@braingram braingram merged commit 0cacd74 into astropy:main Nov 13, 2024
26 of 28 checks passed
@braingram braingram deleted the fits_wcs branch November 13, 2024 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants