-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Convert WCS wrappers to FITS WCS. #649
Conversation
@Cadair @jmason86 Thoughts on this approach? |
ndcube/wcs/wcs_tools.py
Outdated
return fitswcs | ||
|
||
|
||
def slice_fitswcs(fitswcs, slice_items): |
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 might find the slice
and sub
methods on WCS
useful: https://docs.astropy.org/en/stable/api/astropy.wcs.WCS.html#astropy.wcs.WCS.slice
ndcube/wcs/wcs_tools.py
Outdated
return low_level_wrapper | ||
# Determine chain of wrappers down to the FITS-WCS. | ||
wrapper_chain = [type(low_level_wrapper)] | ||
while hasattr(low_level_wrapper, "_wcs"): |
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.
Well this is horrifying. I think checking if it's an instance of https://docs.astropy.org/en/stable/api/astropy.wcs.wcsapi.BaseWCSWrapper.html#astropy.wcs.wcsapi.BaseWCSWrapper would be slightly better.
a6a1329
to
6ad941d
Compare
Thanks @Cadair. Here's a 2nd draft. Sticking with the approach for now of not dropping any axes from WCS but letting users know where length-1 dummy axes are needed in the data array for it to be made consistent with the FITS WCS. It saves a lot of logic or error catching about whether Thoughts on this draft/approach, @Cadair @jmason86? |
862260a
to
4530963
Compare
4530963
to
7b3b5e0
Compare
I took a look (the test in particular was helpful... thanks for writing it so closely to my use case!) and I think this would do the trick! |
pre-commit.ci autofix |
@jmason86 I've released this PR from draft form. So it would be great to get an official review/approval from you. @Cadair, would you like to review this also now that it's an official proposed PR? |
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.
Tested out the code and it indeed appears to operate just as promised!
Thanks @jmason86. Can you take a quick look at this line and confirm I have my WCS algebra right? It gives the right answer in the case I've tested. But I have a nagging doubt that it might be a specific solution, rather than a truly general one. |
@Cadair would you still like to give a review on this? Or can we merge it to get it to @jmason86 ? |
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.
Looks good to me, does this need documenting somewhere? Is this even being picked up by our API docs?
0678433
to
5242895
Compare
I don't know. The doc test is failing for some reason. @nabobalis do know why that is? Looks like something is aiohttp is deprecated... |
It is running on Python/3.12 for some reason. You will want to fix that. |
pre-commit.ci autofix |
Might pass now? |
Or not: |
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.
Needs a new API page entry. I don't see how it would be pulled in by modapi.
In docs/reference/wcs.rst, I think adding a section for tools should be enough.
Unless the plan is to collapse the namespace?
Also fixed some bugs in unwrap_wcs_to_fitswcs found in testing.
for more information, see https://pre-commit.ci
…clude axis lengths.
Co-authored-by: Stuart Mumford <[email protected]>
for more information, see https://pre-commit.ci
9973f61
to
b4edd34
Compare
Hopefully the CI is passing. |
PR Description
This PR is a draft of a feature to convert a chain of WCS wrapper classes to a FITS-WCS, provided the base-level WCS is a FITS-WCS and only supported wrapper types are involved. See Issue #648