Skip to content

Commit 67a6a66

Browse files
Merge branch 'develop' into feature/from_netcdf_fast
2 parents f157b92 + 595b31f commit 67a6a66

File tree

8 files changed

+54
-30
lines changed

8 files changed

+54
-30
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ jobs:
7474
needs: build-and-test
7575
with:
7676
core_branch: ${{ github.ref }}
77-
petals_branch: feature/exposures_crs
77+
petals_branch: develop
7878
permissions:
7979
checks: write

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ Code freeze date: YYYY-MM-DD
3737
- latitude and longitude column are no longer present there (the according arrays can be retrieved as properties of the Exposures object: `exp.latitude` instead of `exp.gdf.latitude.values`).
3838
- `Exposures.gdf` has been renamed to `Exposures.data` (it still works though, as it is a property now pointing to the latter)
3939
- the `check` method does not add a default "IMPF_" column to the GeoDataFrame anymore
40+
- Updated IBTrACS version from v4.0 to v4.1 ([#976](https://github.com/CLIMADA-project/climada_python/pull/976)
41+
- Fix xarray future warning in TCTracks for .dims to .sizes
42+
- Fix hazard.concatenate type test for pathos pools
4043

4144
### Fixed
4245

climada/engine/impact.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ def __init__(
107107
crs=DEF_CRS,
108108
eai_exp=None,
109109
at_event=None,
110-
tot_value=0,
111-
aai_agg=0,
110+
tot_value=0.,
111+
aai_agg=0.,
112112
unit="",
113113
imp_mat=None,
114114
haz_type="",

climada/hazard/base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,8 +936,7 @@ def append(self, *others):
936936
"The hazards are incompatible and cannot be concatenated."
937937
)
938938
self.haz_type = haz_types.pop()
939-
940-
haz_classes = {type(haz) for haz in haz_list}
939+
haz_classes = {haz.__class__.__name__ for haz in haz_list}
941940
if len(haz_classes) > 1:
942941
raise TypeError(
943942
f"The given hazards are of different classes: {haz_classes}. "

climada/hazard/tc_tracks.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@
8484
IBTRACS_URL = (
8585
"https://www.ncei.noaa.gov/data/"
8686
"international-best-track-archive-for-climate-stewardship-ibtracs/"
87-
"v04r00/access/netcdf"
87+
"v04r01/access/netcdf"
8888
)
8989
"""Site of IBTrACS netcdf file containing all tracks v4.0,
9090
s. https://www.ncdc.noaa.gov/ibtracs/index.php?name=ib-v4-access"""
9191

92-
IBTRACS_FILE = "IBTrACS.ALL.v04r00.nc"
93-
"""IBTrACS v4.0 file all"""
92+
IBTRACS_FILE = "IBTrACS.ALL.v04r01.nc"
93+
"""IBTrACS v4.1 file all"""
9494

9595
IBTRACS_AGENCIES = [
9696
"usa",
@@ -377,7 +377,7 @@ def from_ibtracs_netcdf(
377377
correct_pres=False,
378378
discard_single_points=True,
379379
additional_variables=None,
380-
file_name="IBTrACS.ALL.v04r00.nc",
380+
file_name=IBTRACS_FILE,
381381
):
382382
"""Create new TCTracks object from IBTrACS databse.
383383
@@ -486,7 +486,7 @@ def from_ibtracs_netcdf(
486486
compatiblity with other functions such as `equal_timesteps`. Default: True.
487487
file_name : str, optional
488488
Name of NetCDF file to be dowloaded or located at climada/data/system.
489-
Default: 'IBTrACS.ALL.v04r00.nc'
489+
Default: 'IBTrACS.ALL.v04r01.nc'
490490
additional_variables : list of str, optional
491491
If specified, additional IBTrACS data variables are extracted, such as "nature" or
492492
"storm_speed". Only variables that are not agency-specific are supported.
@@ -732,7 +732,7 @@ def from_ibtracs_netcdf(
732732
)
733733
ibtracs_ds = ibtracs_ds.sel(storm=valid_storms_mask)
734734

735-
if ibtracs_ds.dims["storm"] == 0:
735+
if ibtracs_ds.sizes["storm"] == 0:
736736
LOGGER.info(
737737
"After discarding IBTrACS events without valid values by the selected "
738738
"reporting agencies, there are no tracks left that match the specified "
@@ -2699,7 +2699,7 @@ def ibtracs_fit_param(explained, explanatory, year_range=(1980, 2019), order=1):
26992699
raise KeyError("Unknown ibtracs variable: %s" % var)
27002700

27012701
# load ibtracs dataset
2702-
fn_nc = SYSTEM_DIR.joinpath("IBTrACS.ALL.v04r00.nc")
2702+
fn_nc = SYSTEM_DIR.joinpath(IBTRACS_FILE)
27032703
with xr.open_dataset(fn_nc) as ibtracs_ds:
27042704
# choose specified year range
27052705
years = ibtracs_ds.sid.str.slice(0, 4).astype(int)

climada/hazard/test/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929

3030
def download_ibtracs():
31-
"""This makes sure a IBTrACS.ALL.v04r00.nc file is present in SYSTEM_DIR
31+
"""This makes sure a IBTrACS.ALL.v04r01.nc file is present in SYSTEM_DIR
3232
First, downloading from the original sources is attempted. If that fails an old version
3333
is downloaded from the CLIMADA Data API
3434
"""
@@ -44,9 +44,9 @@ def download_ibtracs():
4444
): # plan b: download an old version of that file from the climada api
4545
client = Client()
4646
dsinfo = client.get_dataset_info(
47-
name="IBTrACS", version="v04r00", status="external"
47+
name="IBTrACS", version="v04r01", status="external"
4848
)
4949
[fileinfo] = [
50-
fi for fi in dsinfo.files if fi.file_name == "IBTrACS.ALL.v04r00.nc"
50+
fi for fi in dsinfo.files if fi.file_name == "IBTrACS.ALL.v04r01.nc"
5151
]
5252
client._download_file(local_path=SYSTEM_DIR, fileinfo=fileinfo)

climada/hazard/test/test_tc_tracks.py

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,35 @@ def test_penv_rmax_penv_pass(self):
114114
provider="usa", storm_id="1992230N11325"
115115
)
116116
penv_ref = np.ones(97) * 1010
117-
penv_ref[26:36] = [1011, 1012, 1013, 1014, 1015, 1014, 1014, 1014, 1014, 1012]
117+
penv_ref[26:36] = [1011, 1012, 1013, 1014, 1015, 1015, 1014, 1014, 1014, 1012]
118+
rmax_ref = np.zeros(97)
119+
rmax_ref[63:82] = [
120+
10.0,
121+
10.0,
122+
10.625,
123+
11.25,
124+
11.875,
125+
12.5,
126+
13.125,
127+
13.75,
128+
14.375,
129+
15.0,
130+
15.625,
131+
16.25,
132+
16.875,
133+
17.5,
134+
18.125,
135+
18.75,
136+
19.375,
137+
20.0,
138+
20.0,
139+
]
118140

119-
self.assertTrue(
120-
np.allclose(tc_track.get_track()["environmental_pressure"].values, penv_ref)
141+
np.testing.assert_array_almost_equal(
142+
tc_track.get_track()["environmental_pressure"].values, penv_ref, decimal=4
121143
)
122-
self.assertTrue(
123-
np.allclose(tc_track.get_track()["radius_max_wind"].values, np.zeros(97))
144+
np.testing.assert_array_almost_equal(
145+
tc_track.get_track()["radius_max_wind"].values, rmax_ref, decimal=4
124146
)
125147

126148
def test_ibtracs_raw_pass(self):
@@ -310,7 +332,7 @@ def test_ibtracs_correct_pass(self):
310332
tc_try.data[0]["central_pressure"].values[0], 1013, places=0
311333
)
312334
self.assertAlmostEqual(
313-
tc_try.data[0]["central_pressure"].values[5], 1008, places=0
335+
tc_try.data[0]["central_pressure"].values[5], 1007, places=0
314336
)
315337
self.assertAlmostEqual(
316338
tc_try.data[0]["central_pressure"].values[-1], 1012, places=0
@@ -771,14 +793,14 @@ def test_get_extent(self):
771793
tc_track = tc.TCTracks.from_ibtracs_netcdf(
772794
storm_id=storms, provider=["usa", "bom"]
773795
)
774-
bounds = (153.585022, -23.200001, 258.714996, 17.514986)
775-
bounds_buf = (153.485022, -23.300001, 258.814996, 17.614986)
776-
np.testing.assert_array_almost_equal(tc_track.bounds, bounds)
796+
bounds = (153.6, -23.2, 258.7, 17.5)
797+
bounds_buf = (153.5, -23.3, 258.8, 17.6)
798+
np.testing.assert_array_almost_equal(tc_track.bounds, bounds, decimal=4)
777799
np.testing.assert_array_almost_equal(
778-
tc_track.get_bounds(deg_buffer=0.1), bounds_buf
800+
tc_track.get_bounds(deg_buffer=0.1), bounds_buf, decimal=4
779801
)
780802
np.testing.assert_array_almost_equal(
781-
tc_track.extent, u_coord.toggle_extent_bounds(bounds)
803+
tc_track.extent, u_coord.toggle_extent_bounds(bounds), decimal=4
782804
)
783805

784806
def test_generate_centroids(self):
@@ -788,13 +810,13 @@ def test_generate_centroids(self):
788810
storm_id=storms, provider=["usa", "bom"]
789811
)
790812
cen = tc_track.generate_centroids(10, 1)
791-
cen_bounds = (157.585022, -19.200001, 257.585022, 10.799999)
813+
cen_bounds = (157.6, -19.2, 257.6, 10.8)
792814
self.assertEqual(cen.size, 44)
793815
self.assertEqual(np.unique(cen.lat).size, 4)
794816
self.assertEqual(np.unique(cen.lon).size, 11)
795817
np.testing.assert_array_equal(np.diff(np.unique(cen.lat)), 10)
796818
np.testing.assert_array_equal(np.diff(np.unique(cen.lon)), 10)
797-
np.testing.assert_array_almost_equal(cen.total_bounds, cen_bounds)
819+
np.testing.assert_array_almost_equal(cen.total_bounds, cen_bounds, decimal=4)
798820

799821
def test_interp_track_pass(self):
800822
"""Interpolate track to min_time_step. Compare to MATLAB reference."""

doc/tutorial/climada_hazard_TropCyclone.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@
6464
"<a id='Part1.a'></a> \n",
6565
"### a) Load TC tracks from historical records\n",
6666
"\n",
67-
"The best-track historical data from the International Best Track Archive for Climate Stewardship ([IBTrACS](https://www.ncdc.noaa.gov/ibtracs/)) can easily be loaded into CLIMADA to study the historical records of TC events. The constructor `from_ibtracs_netcdf()` generates the `Datasets` for tracks selected by [IBTrACS](https://www.ncdc.noaa.gov/ibtracs/) id, or by basin and year range. To achieve this, it downloads the first time the [IBTrACS data v4 in netcdf format](https://www.ncei.noaa.gov/data/international-best-track-archive-for-climate-stewardship-ibtracs/v04r00/access/netcdf/) and stores it in `~/climada/data/`. The tracks can be accessed later either using the attribute `data` or using `get_track()`, which allows to select tracks by its name or id. Use the method `append()` to extend the `data` list.\n",
67+
"The best-track historical data from the International Best Track Archive for Climate Stewardship ([IBTrACS](https://www.ncdc.noaa.gov/ibtracs/)) can easily be loaded into CLIMADA to study the historical records of TC events. The constructor `from_ibtracs_netcdf()` generates the `Datasets` for tracks selected by [IBTrACS](https://www.ncdc.noaa.gov/ibtracs/) id, or by basin and year range. To achieve this, it downloads the first time the [IBTrACS data v4 in netcdf format](https://www.ncei.noaa.gov/data/international-best-track-archive-for-climate-stewardship-ibtracs/v04r01/access/netcdf/) and stores it in `~/climada/data/`. The tracks can be accessed later either using the attribute `data` or using `get_track()`, which allows to select tracks by its name or id. Use the method `append()` to extend the `data` list.\n",
6868
"\n",
69-
"If you get an error downloading the IBTrACS data, try to manually access [https://www.ncei.noaa.gov/data/international-best-track-archive-for-climate-stewardship-ibtracs/v04r00/access/netcdf/](https://www.ncei.noaa.gov/data/international-best-track-archive-for-climate-stewardship-ibtracs/v04r00/access/netcdf/), click on the file `IBTrACS.ALL.v04r00.nc` and copy it to `~/climada/data/`.\n",
69+
"If you get an error downloading the IBTrACS data, try to manually access [https://www.ncei.noaa.gov/data/international-best-track-archive-for-climate-stewardship-ibtracs/v04r01/access/netcdf/](https://www.ncei.noaa.gov/data/international-best-track-archive-for-climate-stewardship-ibtracs/v04r01/access/netcdf/), click on the file `IBTrACS.ALL.v04r01.nc` and copy it to `~/climada/data/`.\n",
7070
"\n",
7171
"To visualize the tracks use `plot()`.\n"
7272
]

0 commit comments

Comments
 (0)