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

MNT: Switch to (lon, lat) for all argument and return ordering #2453

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this even put through np.array in the first place if it's split immediately?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷 I was wondering the same thing, but really didn't want to go refactoring more than this PR title suggests.

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