From 94f68ae28843323baeba7323985b8665da35bec9 Mon Sep 17 00:00:00 2001 From: "Chahan M. Kropf" Date: Wed, 11 Dec 2024 10:48:53 +0100 Subject: [PATCH] Update use of IBtracs file. (#152) * Update use of IBtracs file. * Update changelog * Fix import path from tc_tracks --------- Co-authored-by: Chahan Kropf --- CHANGELOG.md | 1 + climada_petals/hazard/test/test_tc_rainfield.py | 6 +++--- climada_petals/hazard/test/test_tc_surge_bathtub.py | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dc870573..93f36e625 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Added: - Included `boario` in the supplychain module [#81](https://github.com/CLIMADA-project/climada_petals/pull/81/) - Added a Copernicus download function `downloader.py` as part of the `climada.hazard.copernicus_interface` module under construction [#150](https://github.com/CLIMADA-project/climada_petals/pull/150/) +- Update name of IBTrACS file to version 4.1 in tc_rainfield and tc_surge_bathub tests. [#152](https://github.com/CLIMADA-project/climada_petals/pull/152) ### Changed diff --git a/climada_petals/hazard/test/test_tc_rainfield.py b/climada_petals/hazard/test/test_tc_rainfield.py index 82f7bb637..9bdda9348 100644 --- a/climada_petals/hazard/test/test_tc_rainfield.py +++ b/climada_petals/hazard/test/test_tc_rainfield.py @@ -26,9 +26,8 @@ from scipy import sparse import xarray as xr -from climada import CONFIG from climada.hazard import Centroids, TCTracks -import climada.hazard.test as hazard_test +from climada.hazard.tc_tracks import IBTRACS_FILE from climada_petals.hazard.tc_rainfield import ( TCRain, compute_rain, @@ -42,6 +41,7 @@ from climada.util.constants import SYSTEM_DIR + def getTestData(): client = Client() centr_ds = client.get_dataset_info(name='tc_rainfield_test', status='test_dataset') @@ -112,7 +112,7 @@ def test_tcr(self): self.assertAlmostEqual(tc_haz.intensity[0, 100], 123.55255892009247) self.assertAlmostEqual(tc_haz.intensity[0, 260], 15.148539942329757) - @unittest.skipUnless(SYSTEM_DIR.joinpath("IBTrACS.ALL.v04r00.nc").is_file(), + @unittest.skipUnless(SYSTEM_DIR.joinpath(IBTRACS_FILE).is_file(), "IBTrACS file is missing, no download in unitttests") def test_cross_antimeridian(self): # Two locations on the island Taveuni (Fiji), one west and one east of 180° longitude. diff --git a/climada_petals/hazard/test/test_tc_surge_bathtub.py b/climada_petals/hazard/test/test_tc_surge_bathtub.py index ba54e4175..7fc40693e 100644 --- a/climada_petals/hazard/test/test_tc_surge_bathtub.py +++ b/climada_petals/hazard/test/test_tc_surge_bathtub.py @@ -28,6 +28,7 @@ import xarray as xr from climada.hazard import Centroids, TCTracks, TropCyclone +from climada.hazard.tc_tracks import IBTRACS_FILE from climada_petals.hazard.tc_surge_bathtub import _fraction_on_land, TCSurgeBathtub from climada.util.constants import SYSTEM_DIR @@ -95,7 +96,7 @@ def test_fraction_on_land(self): shape = (lat.size, lon.size) lon, lat = [ar.ravel() for ar in np.meshgrid(lon, lat)] centroids = Centroids.from_lat_lon(lat, lon) - + dem_bounds = (bounds[0] - 1, bounds[1] - 1, bounds[2] + 1, bounds[3] + 1) dem_res = 3 / (60 * 60) with tmp_artifical_topo(dem_bounds, dem_res) as topo_path: @@ -176,7 +177,7 @@ def test_surge_from_track(self): self.assertAlmostEqual(inten[9, 31], max(-1.270 + slr, 0), places=2) self.assertAlmostEqual(inten[14, 34] - slr, 2.805, places=2) - @unittest.skipUnless(SYSTEM_DIR.joinpath("IBTrACS.ALL.v04r00.nc").is_file(), + @unittest.skipUnless(SYSTEM_DIR.joinpath(IBTRACS_FILE).is_file(), "IBTrACS file is missing, no download in unitttests") def test_cross_antimeridian(self): # Two locations on the island Taveuni (Fiji), one west and one east of 180° longitude.