cartopy
cartopy copied to clipboard
Discontinuous RotatedPole parameters produce inverted coordinate system
Description
From the beginning, the implementation of Nightshade
has included
if lat > 0:
pole_lat = -90 + lat
central_lon = 180
else:
pole_lat = 90 + lat
central_lon = 0
I have code that depends on that routine and the resulting RotatedPole
to do a series of ecliptic calculations. Unfortunately, I've had to copy-and-modify, because the original code - due to the if
above - produces discontinuous behaviour when lat
(i.e. solar declination) crosses zero. In one half of the annual domain, the behaviour is correct; and in the other half the following happen:
- I believe the boundary of behaviour is at the September equinox
-
delta_sun
changes sign, which in itself is not a problem -
lat
becomes positive; also not a problem - the
if
expression above abruptly starts evaluating toTrue
- the entire coordinate system abruptly becomes inverted.
I have found that only the second case is correct (i.e. negative latitude). Copying the implementation and removing the conditional, preserving only the second case, produces correct, continuous behaviour.
I suspect that the reason this hasn't been noticed is that the nightshade curve is symmetric and so inversion is "invisible"; but anyone using the CRS owned by Nightshade
for asymmetric curves is going to get a nasty surprise.
Code to reproduce
Compare behaviour before and after 3b77fe0, before and after an equinox.
Operating system
All
Cartopy version
0.22, but theoretically all versions
pip list
pip freeze
Cartopy==0.22.0
certifi==2024.2.2
charset-normalizer==3.3.2
contourpy==1.2.0
cycler==0.12.1
fonttools==4.49.0
idna==3.6
kiwisolver==1.4.5
matplotlib==3.8.3
mypy==1.8.0
mypy-extensions==1.0.0
numpy==1.26.4
packaging==23.2
pillow==10.2.0
pyparsing==3.1.1
pyproj==3.6.1
pyshp==2.3.1
python-dateutil==2.8.2
pytz==2024.1
requests==2.31.0
scipy==1.12.0
shapely==2.0.3
six==1.16.0
tomli==2.0.1
types-requests==2.31.0.20240311
typing_extensions==4.9.0
tzdata==2024.1
urllib3==2.2.1