Skip to content

Commit 1994104

Browse files
committed
Update tc_tracks tests for new IBTrACS version
1 parent 0bbc123 commit 1994104

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

climada/hazard/test/test_tc_tracks.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,15 @@ def test_penv_rmax_penv_pass(self):
8282
provider="usa", storm_id="1992230N11325"
8383
)
8484
penv_ref = np.ones(97) * 1010
85-
penv_ref[26:36] = [1011, 1012, 1013, 1014, 1015, 1014, 1014, 1014, 1014, 1012]
85+
penv_ref[26:36] = [1011, 1012, 1013, 1014, 1015, 1015, 1014, 1014, 1014, 1012]
86+
rmax_ref = np.zeros(97)
87+
rmax_ref[63:82] = [10., 10., 10.625, 11.25, 11.875, 12.5, 13.125, 13.75, 14.375, 15., 15.625, 16.25, 16.875, 17.5 , 18.125, 18.75, 19.375, 20., 20.]
8688

87-
self.assertTrue(
88-
np.allclose(tc_track.get_track()["environmental_pressure"].values, penv_ref)
89+
np.testing.assert_array_almost_equal(
90+
tc_track.get_track()["environmental_pressure"].values, penv_ref, decimal=4
8991
)
90-
self.assertTrue(
91-
np.allclose(tc_track.get_track()["radius_max_wind"].values, np.zeros(97))
92+
np.testing.assert_array_almost_equal(
93+
tc_track.get_track()["radius_max_wind"].values, rmax_ref, decimal=4
9294
)
9395

9496
def test_ibtracs_raw_pass(self):
@@ -278,7 +280,7 @@ def test_ibtracs_correct_pass(self):
278280
tc_try.data[0]["central_pressure"].values[0], 1013, places=0
279281
)
280282
self.assertAlmostEqual(
281-
tc_try.data[0]["central_pressure"].values[5], 1008, places=0
283+
tc_try.data[0]["central_pressure"].values[5], 1007, places=0
282284
)
283285
self.assertAlmostEqual(
284286
tc_try.data[0]["central_pressure"].values[-1], 1012, places=0
@@ -701,14 +703,16 @@ def test_get_extent(self):
701703
tc_track = tc.TCTracks.from_ibtracs_netcdf(
702704
storm_id=storms, provider=["usa", "bom"]
703705
)
704-
bounds = (153.585022, -23.200001, 258.714996, 17.514986)
705-
bounds_buf = (153.485022, -23.300001, 258.814996, 17.614986)
706-
np.testing.assert_array_almost_equal(tc_track.bounds, bounds)
706+
bounds = (153.6, -23.2, 258.7, 17.5)
707+
bounds_buf = (153.5, -23.3, 258.8, 17.6)
708+
np.testing.assert_array_almost_equal(
709+
tc_track.bounds, bounds, decimal=4
710+
)
707711
np.testing.assert_array_almost_equal(
708-
tc_track.get_bounds(deg_buffer=0.1), bounds_buf
712+
tc_track.get_bounds(deg_buffer=0.1), bounds_buf, decimal=4
709713
)
710714
np.testing.assert_array_almost_equal(
711-
tc_track.extent, u_coord.toggle_extent_bounds(bounds)
715+
tc_track.extent, u_coord.toggle_extent_bounds(bounds), decimal=4
712716
)
713717

714718
def test_generate_centroids(self):
@@ -718,13 +722,13 @@ def test_generate_centroids(self):
718722
storm_id=storms, provider=["usa", "bom"]
719723
)
720724
cen = tc_track.generate_centroids(10, 1)
721-
cen_bounds = (157.585022, -19.200001, 257.585022, 10.799999)
725+
cen_bounds = (157.6, -19.2, 257.6, 10.8)
722726
self.assertEqual(cen.size, 44)
723727
self.assertEqual(np.unique(cen.lat).size, 4)
724728
self.assertEqual(np.unique(cen.lon).size, 11)
725729
np.testing.assert_array_equal(np.diff(np.unique(cen.lat)), 10)
726730
np.testing.assert_array_equal(np.diff(np.unique(cen.lon)), 10)
727-
np.testing.assert_array_almost_equal(cen.total_bounds, cen_bounds)
731+
np.testing.assert_array_almost_equal(cen.total_bounds, cen_bounds, decimal=4)
728732

729733
def test_interp_track_pass(self):
730734
"""Interpolate track to min_time_step. Compare to MATLAB reference."""

0 commit comments

Comments
 (0)