Skip to content

Commit 9a1b296

Browse files
author
Chahan Kropf
committed
Add test test resolution
1 parent 70fbde2 commit 9a1b296

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

climada/util/test/test_coordinates.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,6 +1868,21 @@ def test_get_resolution_pass(self):
18681868
self.assertAlmostEqual(res_lat, 0.0833333333333)
18691869
self.assertAlmostEqual(res_lon, 0.0833333333333)
18701870

1871+
def test_get_resolution_large_pass(self):
1872+
"""Test _get_resolution method"""
1873+
centr = Centroids.from_pnt_bounds((-180, -90, 180, 90), 1)
1874+
res_lat, res_lon = u_coord.get_resolution(centr.lat, centr.lon)
1875+
self.assertAlmostEqual(res_lat, 1)
1876+
self.assertAlmostEqual(res_lon, 1)
1877+
1878+
def test_get_resolution_meters_pass(self):
1879+
centr = Centroids.from_pnt_bounds((-180, -90, 180, 90), 1)
1880+
centr.to_crs("EPSG:4087", inplace=True) # meters
1881+
res = u_coord.degree_to_km(1) * 1000
1882+
res_lat, res_lon = u_coord.get_resolution(centr.lat, centr.lon)
1883+
self.assertAlmostEqual(res_lat, res, delta=500) # approx to 500m correct
1884+
self.assertAlmostEqual(res_lon, res, delta=500) # approx to 500m correct
1885+
18711886
def test_vector_to_raster_pass(self):
18721887
"""Test vector_to_raster"""
18731888
xmin, ymin, xmax, ymax = -60, -5, -50, 10 # bounds of points == centers pixels

0 commit comments

Comments
 (0)