Repository navigation
Add support for custom coordinate frames in WCSAxes specifically in transform_coord_meta_from_wcs - #16347
Conversation
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
There was a problem hiding this comment.
Welcome to Astropy 👋 and congratulations on your first pull request! 🎉
A project member will respond to you as soon as possible; in the meantime, please have a look over the Checklist for Contributed Code and make sure you've addressed as many of the questions there as possible.
If you feel that this pull request has not been responded to in a timely manner, please send a message directly to the development mailing list. If the issue is urgent or sensitive in nature (e.g., a security vulnerability) please send an e-mail directly to the private e-mail [email protected].
|
👋 Thank you for your draft pull request! Do you know that you can use |
neutrinoceros
left a comment
There was a problem hiding this comment.
Thank you for your contribution ! I'll leave it to wcsaxes maintainers to discuss whether this approach is acceptable or not, but here's a quick technical review.
Even though the code might be covered already, I believe a test would also be needed to demonstrate the new feature (and to make sure we don't break it in the future).
You'll also need to provide a change log entry (see docs/changes/README.md). Thanks !
c28b372 to
e326827
Compare
astrofrog
left a comment
There was a problem hiding this comment.
This is looking good! Just one comment below.
|
|
||
| astropy.visualization.wcsaxes.wcsapi.CUSTOM_UCD_COORD_META_MAPPING.update( | ||
| myframe_mapping | ||
| ) |
There was a problem hiding this comment.
I think we should avoid having this be the API to register custom mappings, and instead write a context manager similar to custom_ctype_to_ucd_mapping to make sure the changes are temporary and cleaned up after use.
There was a problem hiding this comment.
This would also have the benefit of allowing this functionality to be documented via the API docs even if we don't add something to the main narrative docs.
There was a problem hiding this comment.
Great thanks for the feedback, I've taken a first crack at adding a context manager similar custom_ctype_to_ucd_mapping.
There was a problem hiding this comment.
Thanks! I don't think we should keep the test of modifying the dictionary, we should just be testing the context manager.
There was a problem hiding this comment.
Given there's no way to stop someone editing the dictionary shouldn't we keep a test for it?
There was a problem hiding this comment.
I'd vote against it; we shouldn't be testing for implementation details.
There was a problem hiding this comment.
If the dictionary isn't meant to be accessed directly maybe we should make it private to make it explicit?
There was a problem hiding this comment.
I removed it, I don't think we need to make it private
There was a problem hiding this comment.
I do think there is utility in people directly accessing the dict if packages like sunpy write their own coordinate frames they could add to the dict without the context manager to improve the plotting of those frames.
astrofrog
left a comment
There was a problem hiding this comment.
Looking good! Just a few small comments.
|
|
||
| astropy.visualization.wcsaxes.wcsapi.CUSTOM_UCD_COORD_META_MAPPING.update( | ||
| myframe_mapping | ||
| ) |
There was a problem hiding this comment.
Thanks! I don't think we should keep the test of modifying the dictionary, we should just be testing the context manager.
| self.mapping = {} | ||
| for k, v in mapping.items(): | ||
| if k in CUSTOM_UCD_COORD_META_MAPPING: | ||
| raise ValueError(f"UCD metadata mapping {k} already exists.") |
There was a problem hiding this comment.
Ideally we might want to allow existing entries to be overriden, but if this is too much work we could always keep as-is for now and consider it a future improvement to allow overriding.
There was a problem hiding this comment.
Patched in opt-in support for overwriting (with a kwarg)
| ax.coords | ||
| assert ax.coords["eggs"].coord_type == "longitude" | ||
| assert ax.coords["eggs"].coord_wrap == 360 * u.deg | ||
| assert ax.coords["eggs"].get_format_unit() == u.arcsec |
There was a problem hiding this comment.
It would be good if possible to add a test of two nested custom_ucd_wcscoord_mapping calls to make sure both apply at the same time.
|
Hi humans 👋 - this pull request hasn't had any new commits for approximately 4 months. I plan to close this in 30 days if the pull request doesn't have any new commits by then. In lieu of a stalled pull request, please consider closing this and open an issue instead if a reminder is needed to revisit in the future. Maintainers may also choose to add keep-open label to keep this PR open but it is discouraged unless absolutely necessary. If this PR still needs to be reviewed, as an author, you can rebase it to reset the clock. If you believe I commented on this pull request incorrectly, please report this here. |
Co-authored-by: Clément Robert <[email protected]>
1fc34ce to
410c7b8
Compare
|
|
||
| astropy.visualization.wcsaxes.wcsapi.CUSTOM_UCD_COORD_META_MAPPING.update( | ||
| myframe_mapping | ||
| ) |
There was a problem hiding this comment.
I'd vote against it; we shouldn't be testing for implementation details.
astrofrog
left a comment
There was a problem hiding this comment.
This seems good overall but just a small note on the changelog entry - and in addition I though wcscoord in the context manager name was a bit strange, what about using custom_ucd_coord_meta_mapping as the context manager name?
|
@Cadair - I pushed the changes I suggested in case you agree with them |
|
Lgtm thanks |
Description
This pull request adds support for externally created customs coordinate frames to WCSAxes by altering how
transform_coord_meta_from_wcsoperates.CUSTOM_UCD_COORD_META_MAPPINGwhich could be extended by external packages.If this approach is ok then the custom sunpy frame could be moved into the sunpy repo.
I didn't add a new test as while there is new code the current tests cover it I think.In an external package I could register new CTYPE to UCD and UCD to coord meta data mappings.
Fixes #16339