Skip to content

Conversion between projections & coordinate systems does not always preserve the ellipsoid. #4408

@dennissergeev

Description

@dennissergeev

🐛 Bug Report

Conversion between iris and cartopy projections/coordinate systems does not always preserve the ellipsoid.

I noticed this behaviour when I was trying to rotate winds to a rotated pole coordinate system. The crux of the issue is that the original coordinate system attached to the cubes of winds is defined with a non-Earth semi-major axis (I am modelling a different planet). However, when I try to apply iris.analysis.cartography.rotate_winds(), I get this error:

ProjError: Error creating Transformer from CRS.: (Internal Proj Error: proj_create_operations: Source and target ellipsoid do not belong to the same celestial body)

This apparently happens at this step in the rotate_winds() function:

src_crs = x_coord.coord_system.as_cartopy_projection()

because GeogCS.as_cartopy_projection() just calls ccrs.PlateCarree() without passing any information about the globe.

My code that used these operations used to work (~ a 1-2 months ago), so it's likely related to some changes in the recent versions of iris , cartopy or pyproj.

How To Reproduce

Steps to reproduce the behaviour:

from iris.coord_systems import GeogCS

planet_crs = GeogCS(semi_major_axis=123456)
print(planet_crs.as_cartopy_projection().proj4_init)

result:

'+ellps=WGS84 +a=6378137.0 +proj=eqc +lon_0=0.0 +to_meter=111319.4907932736 +vto_meter=1 +no_defs'

Expected behaviour

'+ellps=WGS84 +a=123456.0 +proj=eqc +lon_0=0.0 +to_meter=2154.7136813421193 +vto_meter=1 +no_defs'

I think the conversion between coordinate systems should respect the ellipsoid and not default to Earth (or at least have a warning).

Environment

  • OS & Version: e.g., Ubuntu 20.04 LTS
  • Iris Version: 3.1.0
  • Cartopy Version: 0.20.1
  • Pyproj Version: 3.2.1

Metadata

Metadata

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions