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

Cartopy projection from a cube #5219

Closed
rcomer opened this issue Mar 29, 2023 · 5 comments
Closed

Cartopy projection from a cube #5219

rcomer opened this issue Mar 29, 2023 · 5 comments
Labels
Stale A stale issue/pull-request Type: Enhancement

Comments

@rcomer
Copy link
Member

rcomer commented Mar 29, 2023

✨ Feature Request

A convenience function to get an appropriate Cartopy projection from a cube.

Motivation

When plotting a map to the current axes, iris.plot has some logic that figures out the appropriate Cartopy projection and uses it to set up a Cartopy GeoAxes to plot onto (if the current axes isn't already a Cartopy one). This is super convenient and I use it all the time. However, it relies on Matplotlib's implicit API, which is not really how Matplotlib recommends doing things these days.

If this logic could be factored out into its own public function, then users who want to use the recommended explicit API could do so without losing too much convenience.

cartopy_proj = shiny_new_function(cube)
ax = fig.add_subplot(projection=cartopy_proj)
iplt.contourf(cube, axes=ax)

Additional context

I realise there isn't much to this logic, and I could just write my own convenience function for my own use. However, I think it's worth Iris making it as easy as possible for users to follow the recommended practice.

@rcomer
Copy link
Member Author

rcomer commented Mar 29, 2023

I would be happy to either write or review a PR for this.

@pp-mo
Copy link
Member

pp-mo commented Mar 29, 2023

Why can't you use cube.coord_system().as_cartopy_crs() or cube.coord_system().as_cartopy_projection() ??

@rcomer
Copy link
Member Author

rcomer commented Mar 30, 2023

Why can't you use cube.coord_system().as_cartopy_crs() or cube.coord_system().as_cartopy_projection() ??

I think that is illustrated in the logic that iris.plot currently uses: sometimes there isn't a coord system on the cube, in which case we default to PlateCarree(). There are also some extra complications for RotatedGeogCS, though admittedly I've never knowingly used that.

Copy link
Contributor

In order to maintain a backlog of relevant issues, we automatically label them as stale after 500 days of inactivity.

If this issue is still important to you, then please comment on this issue and the stale label will be removed.

Otherwise this issue will be automatically closed in 28 days time.

@github-actions github-actions bot added the Stale A stale issue/pull-request label Aug 12, 2024
Copy link
Contributor

github-actions bot commented Sep 9, 2024

This stale issue has been automatically closed due to a lack of community activity.

If you still care about this issue, then please either:

  • Re-open this issue, if you have sufficient permissions, or
  • Add a comment stating that this is still relevant and someone will re-open it on your behalf.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale A stale issue/pull-request Type: Enhancement
Projects
Status: Done
Development

No branches or pull requests

2 participants