Skip to content

Expand documentation for now APE14 WCS API - #7962

Merged
eteq merged 18 commits into
astropy:masterfrom
astrofrog:ape-docs
Oct 26, 2018
Merged

eteq merged 18 commits into
astropy:masterfrom
astrofrog:ape-docs

Conversation

@astrofrog

@astrofrog astrofrog commented Oct 24, 2018 •

Copy link
Copy Markdown
Member

This adds some basic usage docs for the new WCS APE 14 API

One important addition - it implements WCS.array_shape which means that we'll finally be able to close e.g. #5461 or #4669 - at least I think.

Hey @drdavella - I really could do with scientific-python/pytest-doctestplus#2 here 😉 (not critical for the PR as I've just put +REMOTE_DATA everywhere, just pointing out a good use case!)

Once the CI runs, there will be a link to preview the docs (from 'giles') in the status checks below.

Direct link to docs preview

@astropy-bot

astropy-bot Bot commented Oct 24, 2018

Copy link
Copy Markdown

Hi there @astrofrog 👋 - thanks for the pull request! I'm just a friendly 🤖 that checks for issues related to the changelog and making sure that this pull request is milestoned and labeled correctly. This is mainly intended for the maintainers, so if you are not a maintainer you can ignore this, and a maintainer will let you know if any action is required on your part 😃.

Everything looks good from my point of view! 👍

If there are any issues with this message, please report them here.

@eteq eteq 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.

A few minor and a few larger suggestions. Note that I'm using this as an excuse to experiment with the new "suggest" thingie, so sorry if this ends up annoying @astrofrog.

Comment thread astropy/wcs/wcsapi/fitswcs.py Resolved
Comment thread docs/wcs/wcsapi.rst Resolved
Comment thread docs/wcs/wcsapi.rst Outdated
the method or property used, and this can normally be determined from the
property or method name. Properties and methods containing ``pixel`` assume
``(x, y)`` ordering, while properties and methods containing ``array`` assume
``(row, column)`` ordering.

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 find this a bit confusing. In my head "x" and "y" are the same thing as "row" and "column". Am I right that what we really mean is "the in-memory representation on the array" vs "the conceptual order of dimensions exposed to the user in the WCS itself"? That's a bit too wordy, but something in that direction? I think it's fine to use "row"/"column" vs "x"/"y", but only once you've defined what that means a bit more.

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.

Would it help to say:

Properties and methods containing ``pixel`` assume
``(x, y)`` or ``Carstesian`` ordering, while properties and methods containing ``array`` assume
``(row, column)`` or ``numpy array`` ordering.

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 guess that doesn't help because as our discussions revealed, I don't really get what "Cartesian ordering" means: to me "Cartesian" means "the metric is s^2 = x^2 + y^2", which is true regardless of the ordering. And "numpy array" also doesn't help because it can be both fortran or C ordered.

If preferred I can write the words on it... once I actually have right in my head which is supposed to be which 😉

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll push some changes soon that are similar to @nden's suggestion.

Comment thread docs/wcs/wcsapi.rst Outdated
===========

Let's take a look at the shared Python interface for WCS by using a spectral
cube (two celestial axes and one spectral axis)::

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 doesn't feel like "Basic" usage - a cube is pretty darn complex. What about starting with a simpler case of just an image and just show how world_to_pixel and pixel_to_world work (along with some of the informational bits you're demonstrating)? Then make this be "Advanced usage" or similar

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

Comment thread docs/wcs/wcsapi.rst Resolved
Comment thread docs/wcs/wcsapi.rst Resolved
@eteq

eteq commented Oct 24, 2018 •

Copy link
Copy Markdown
Member

One quick thing not directly related to the review: @nden - can you confirm the .array_shape as implemented here is compatible with/could be made so with gwcs (due to e.g. #5461 (comment))?

@astrofrog

Copy link
Copy Markdown
Member Author

@eteq - I've expanded the pixel convention section. Does it make sense now? I also added a basic image example.

@nden - I added pixel_shape for consistency. Please feel free to do another PR to deprecate the naxis1/naxis2 access as you mentioned.

@astrofrog

Copy link
Copy Markdown
Member Author

@eteq - I think this is ready for a final review/merge

@nden

nden commented Oct 25, 2018

Copy link
Copy Markdown
Contributor

@eteq In gwcs I have a setter for array_shape because the interface to gwcs.WCS does not currently take a header like astropy.wcs.WCS. In the future, when there's a more user friendly interface this will change but I imagine the implementation will give the same results. The comment you linked to was referring to the equivalent of pixel_bounds. Now that I look at it, astropy.wcs.WCS.pixel_boundsis a property which returns None but is not settable. In gwcs pixel_bounds returns the bounding_box of the model. There's no equivalent attribute in astropy.wcs. So perhaps this property should have a setter in astropy?

@nden

nden commented Oct 25, 2018

Copy link
Copy Markdown
Contributor

Here's a potential issue with not having setters for array_shape and pixel_shape.
There are setters for the private _naxis1 and _naxis2 attributes which we want to replace with the public pixel_shape. I can think of at least one use case where being able to set pixel_shape is useful. When drizzling images a common output WCS is created based on the WCSs of the input images. This output WCS needs to be assigned a pixel_shape value, normally computed using pixel_shape of all input WCSs.

@astrofrog

Copy link
Copy Markdown
Member Author

@nden - we can easily add setters on the FITS WCS mix-in, but I think it would make more sense for you to do it in a separate PR as you know how best to set _naxis

@nden

nden commented Oct 25, 2018

Copy link
Copy Markdown
Contributor

@astrofrog PR with setters

@nden nden mentioned this pull request Oct 25, 2018
@nden

nden commented Oct 26, 2018

Copy link
Copy Markdown
Contributor

@eteq I added pixel_bounds setter.

@astrofrog

Copy link
Copy Markdown
Member Author

Ok so at this point this just needs a suggestion from @eteq on improving wording about the pixel convention stuff - but this can be merged without that change if it comes to it, as that can be clarified after feature freeze.

@eteq

eteq commented Oct 26, 2018

Copy link
Copy Markdown
Member

Yeah, I agree with @astrofrog that it's better to merge this and we can have a follow-on clarifying PR if/when we get to it. Presumably this wording works for some people. (At the very least, people that think like @nden and @astrofrog, so it's definitely better than nothing!)

@eteq
eteq merged commit 4fc9f31 into astropy:master Oct 26, 2018
@astrofrog
astrofrog deleted the ape-docs branch November 14, 2018 15:22
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.

3 participants