iris icon indicating copy to clipboard operation
iris copied to clipboard

Cartopy projection from a cube

Open rcomer opened this issue 2 years ago • 4 comments

✨ 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 avatar Mar 29 '23 11:03 rcomer

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

rcomer avatar Mar 29 '23 12:03 rcomer

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

pp-mo avatar Mar 29 '23 17:03 pp-mo

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.

rcomer avatar Mar 30 '23 08:03 rcomer

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[bot] avatar Aug 12 '24 00:08 github-actions[bot]

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[bot] avatar Sep 09 '24 00:09 github-actions[bot]