Skip to content

Commit

Permalink
Merge pull request #2453 from greglucas/lon-lat-consistency
Browse files Browse the repository at this point in the history
MNT: Switch to (lon, lat) for all argument and return ordering
  • Loading branch information
greglucas authored Oct 23, 2024
2 parents eff1bab + fe44201 commit 894ff37
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions lib/cartopy/feature/nightshade.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, date=None, delta=0.1, refraction=-0.83,

# Returns the Greenwich hour angle,
# need longitude (opposite direction)
lat, lon = _solar_position(date)
lon, lat = _solar_position(date)
pole_lon = lon
if lat > 0:
pole_lat = -90 + lat
Expand Down Expand Up @@ -149,7 +149,7 @@ def _solar_position(date):
Returns
-------
(latitude, longitude) in degrees
(longitude, latitude) in degrees
Note
----
Expand Down Expand Up @@ -203,4 +203,4 @@ def _solar_position(date):
if lon < -180:
lon += 360

return (delta_sun, lon)
return (lon, delta_sun)
2 changes: 1 addition & 1 deletion lib/cartopy/tests/crs/test_gnomonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_eccentric_globe():

@pytest.mark.parametrize('lat', [-10, 0, 10])
@pytest.mark.parametrize('lon', [-10, 0, 10])
def test_central_params(lat, lon):
def test_central_params(lon, lat):
gnom = ccrs.Gnomonic(central_latitude=lat, central_longitude=lon)
other_args = {f'lat_0={lat}', f'lon_0={lon}',
'a=6378137.0'}
Expand Down
2 changes: 1 addition & 1 deletion lib/cartopy/tests/crs/test_orthographic.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_eccentric_globe():

@pytest.mark.parametrize('lat', [-10, 0, 10])
@pytest.mark.parametrize('lon', [-10, 0, 10])
def test_central_params(lat, lon):
def test_central_params(lon, lat):
ortho = ccrs.Orthographic(central_latitude=lat, central_longitude=lon)
other_args = {f'lat_0={lat}', f'lon_0={lon}',
'a=6378137.0'}
Expand Down
2 changes: 1 addition & 1 deletion lib/cartopy/tests/feature/test_nightshade.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_julian_day():
(datetime(2030, 6, 21, 0, 0), (23 + 26 / 60), -(179 + 34 / 60))
])
def test_solar_position(dt, true_lat, true_lon):
lat, lon = _solar_position(dt)
lon, lat = _solar_position(dt)
assert pytest.approx(true_lat, 0.1) == lat
assert pytest.approx(true_lon, 0.1) == lon

Expand Down
8 changes: 4 additions & 4 deletions lib/cartopy/tests/test_crs.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_osni(self, approx):
ll = ccrs.Geodetic()

# results obtained by nearby.org.uk.
lat, lon = np.array([54.5622169298669, -5.54159863617957],
lon, lat = np.array([-5.54159863617957, 54.5622169298669],
dtype=np.double)
east, north = np.array([359000, 371000], dtype=np.double)

Expand Down Expand Up @@ -65,7 +65,7 @@ def _check_osgb(self, osgb):
ll = ccrs.Geodetic()

# results obtained by streetmap.co.uk.
lat, lon = np.array([50.462023, -3.478831], dtype=np.double)
lon, lat = np.array([-3.478831, 50.462023], dtype=np.double)
east, north = np.array([295132.1, 63512.6], dtype=np.double)

# note the handling of precision here...
Expand Down Expand Up @@ -233,7 +233,7 @@ def test_project_point(self):
def test_utm(self):
utm30n = ccrs.UTM(30)
ll = ccrs.Geodetic()
lat, lon = np.array([51.5, -3.0], dtype=np.double)
lon, lat = np.array([-3.0, 51.5], dtype=np.double)
east, north = np.array([500000, 5705429.2], dtype=np.double)
assert_arr_almost_eq(utm30n.transform_point(lon, lat, ll),
[east, north],
Expand All @@ -242,7 +242,7 @@ def test_utm(self):
[lon, lat],
decimal=1)
utm38s = ccrs.UTM(38, southern_hemisphere=True)
lat, lon = np.array([-18.92, 47.5], dtype=np.double)
lon, lat = np.array([47.5, -18.92], dtype=np.double)
east, north = np.array([763316.7, 7906160.8], dtype=np.double)
assert_arr_almost_eq(utm38s.transform_point(lon, lat, ll),
[east, north],
Expand Down

0 comments on commit 894ff37

Please sign in to comment.