Skip to content

Add several convenience APE 14 WCS wrappers - #9736

Closed
astrofrog wants to merge 15 commits into
astropy:masterfrom
astrofrog:low-level-wcs-wrappers
Closed

astrofrog wants to merge 15 commits into
astropy:masterfrom
astrofrog:low-level-wcs-wrappers

Conversation

@astrofrog

@astrofrog astrofrog commented Dec 8, 2019 •

Copy link
Copy Markdown
Member

These APE 14 wrapper classes came out of discussions with @keflavich and @Cadair:

  • A class to reorder pixel and world dimensions in an APE 14-compliant WCS
  • A class to scale/resample pixel dimensions in an APE 14-compliant WCS
  • A class to combine multiple APE 14-compliant WCSes, for example two spatial dimensions from a FITS WCS with a spectral dimension from a GWCS

One unrelated but significant change here is changing array_index_to_world_values and world_to_array_index_values to have a default implementation, since there's really no reason those need to be defined every time (we end up copy/pasting a lot of code) and instead can just always use the equivalent 'pixel' methods as a starting point.

We still need add a way for these classes to call out to implementation-specific alternatives (i.e. FITS WCS can implement these as pure FITS WCS modifications).

@Cadair

Cadair commented Dec 8, 2019

Copy link
Copy Markdown
Member

ping @DanRyanIrish you might also end up interested in some of these 😀

@astrofrog
astrofrog force-pushed the low-level-wcs-wrappers branch from dd14ba1 to 379cba8 Compare December 14, 2019 14:51
@astrofrog
astrofrog force-pushed the low-level-wcs-wrappers branch from 379cba8 to 5392b5f Compare January 28, 2020 19:25
@astrofrog astrofrog added this to the v4.1 milestone Jan 28, 2020
@astrofrog
astrofrog requested a review from Cadair January 28, 2020 19:26
@astrofrog

Copy link
Copy Markdown
Member Author

The first phase of this is ready - that is the classes and associated tests. For now there is no dispatch to specific types, but I wonder if we want to do this first, merge it once reviewed, then do a separate PR to figure out the dispatch? So I'm marking this as ready for review.

@astrofrog
astrofrog requested review from eteq, keflavich and nden January 28, 2020 19:27
@astrofrog

astrofrog commented Jan 28, 2020 •

Copy link
Copy Markdown
Member Author

I'm also tagging @eteq and @keflavich for review as original co-authors of APE 14

keflavich
keflavich previously approved these changes Feb 1, 2020

@keflavich keflavich left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was only able to do a shallow review, but I don't see anything obviously wrong. A real review would entail trying these out somewhere, but I don't have use cases readily in hand.

@Cadair Cadair left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is good and really want to see it in 4.1.

There is a bunch of commonality between these wrapper classes. For instance not all of them need to modify all the methods and properties, and all the __str__ and __repr__ are the same. Could we define a BaseWrapper ABC which just copies all the API from the _wcs object and then we can override it where needed?

Also I would like to see the __repr__'s changed to object.__repr__(self) + "\n" + str(self) so that they are different from the str and more importantly show what type they are, otherwise there is no way to tell the difference between all these classes sharing the same __str__ implementation.

Parameters
----------
*wcs : `~astropy.wcs.wcsapi.BaseLowLevelWCS`
The WCSes to combine

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This probably could do with a little more detail on ordering? I assume it's really pixel axes that we are in strict order here? Although obviously the world axes are not crossing the wcs lines at this point.


@property
def world_axis_object_classes(self):
# TODO: deal with name conflicts

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we at least detect this in the __init__ and throw a warning if we aren't going to fix it in the first release?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Having played with this, is this comment even valid anymore?

@bsipocz

bsipocz commented Apr 22, 2020

Copy link
Copy Markdown
Member

Docs failures are related, but the rest might not, so please rebase during the next iteration.

@Cadair
Cadair force-pushed the low-level-wcs-wrappers branch from a0343e4 to 5836ec3 Compare April 22, 2020 08:46
@bsipocz

bsipocz commented Apr 23, 2020

Copy link
Copy Markdown
Member

This needs new reviews as a lot has happened since the approval was given.

@pep8speaks

Copy link
Copy Markdown

Hello @astrofrog 👋! It looks like you've made some changes in your pull request, so I've checked the code again for style.

Line 179:1: W391 blank line at end of file

@keflavich keflavich left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we add these to a document somewhere? I did try to go through and review, but I don't have the clearest idea of where and when I'm likely to want to use these wrappers. They're all meant to be low-level, but that means I'm probably the target audience as a user of the wrappers... should I be incorporating this into 1d spectra in SpectralCube (which should be inheriting from specutils anyway)?

I just don't remember what use case we raised this for. I should be able to figure this out.

@Cadair

Cadair commented Apr 28, 2020

Copy link
Copy Markdown
Member

We need to make the old import for sliced_low_level_wcs still work

@Cadair Cadair modified the milestones: v4.1, v4.2 Apr 29, 2020
Cadair added a commit to Cadair/ndcube that referenced this pull request May 7, 2020
@astrofrog
astrofrog dismissed keflavich’s stale review May 11, 2020 10:54

This PR needs more work following discussions with @nden and @perrygreenfield

@astrofrog

Copy link
Copy Markdown
Member Author

To prevent PR clutter, I'm going to close this as it's going to require more work and discussions with @nden and @perrygreenfield

@astrofrog astrofrog closed this May 11, 2020
Cadair added a commit to Cadair/ndcube that referenced this pull request Sep 23, 2020
Cadair added a commit to Cadair/ndcube that referenced this pull request Nov 11, 2020
Cadair added a commit to Cadair/ndcube that referenced this pull request Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants