Skip to content

Commit 9f75759

Browse files
Merge branch 'develop'
# Conflicts: # climada_petals/_version.py # setup.py
2 parents 1833579 + 0cb3655 commit 9f75759

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,26 @@
44

55
Release date: 2023-09-01
66

7+
### Description
8+
9+
### Dependency Changes
10+
11+
### Added
12+
13+
### Changed
14+
15+
### Fixed
16+
17+
- `TCForecast` now skips "untrackable" TCs when reading multi-message `.bufr` files [#91](https://github.com/CLIMADA-project/climada_petals/pull/91)
18+
19+
### Deprecated
20+
21+
### Removed
22+
23+
## 4.0.0
24+
25+
Release date: 2023-09-01
26+
727
### Dependency Changes
828

929
Upgraded:

climada_petals/hazard/tc_tracks_forecast.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def read_one_bufr_tc(self, file, id_no=None):
277277
n_timestep = ec.codes_get_size(bufr, 'timePeriod') + 1
278278
except ec.CodesInternalError:
279279
LOGGER.warning("Track %s has no defined timePeriod. Track is discarded.", sid)
280-
return None
280+
continue
281281

282282
# get number of ensemble members
283283
ens_no = ec.codes_get_array(bufr, "ensembleMemberNumber")
68 KB
Binary file not shown.

climada_petals/hazard/test/test_tc_tracks_forecast.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
https://confluence.ecmwf.int/display/FCST/New+Tropical+Cyclone+Wind+Radii+product
3939
"""
4040

41+
TEST_BUFR_FILE_MULTIMESSAGE_MISSING_TIMEPERIOD = DATA_DIR.joinpath('test202308220000.bufr')
42+
"""TC tracks in four BUFR formats as provided by ECMWF. Sourced from
43+
https://confluence.ecmwf.int/display/FCST/New+Tropical+Cyclone+Wind+Radii+product
44+
"""
45+
4146
TEST_CXML_FILE = DATA_DIR.joinpath("cxml_sample_track.xml")
4247
"""A sample CXML file holding forecast data, subset from the ECMWF archive at
4348
https://confluence.ecmwf.int/display/TIGGE/Tools#Tools-ECMWFTropicalCycloneTrackData(XMLformat)
@@ -80,7 +85,6 @@ def test_fetch_ecmwf(self):
8085
np.datetime64('2020-03-19T12:00:00.000000'))
8186
self.assertEqual(forecast.data[1].is_ensemble, True)
8287

83-
8488
def test_ecmwf_multimessage(self):
8589
"""Test ECMWF reader in multimessage format"""
8690
forecast = TCForecast()
@@ -100,6 +104,22 @@ def test_ecmwf_multimessage(self):
100104
np.array(['70E', '70W', '71E', '71W', '72W'], dtype=str)
101105
)
102106

107+
def test_ecmwf_multimessage_missing_timeperiod(self):
108+
"""Test ECMWF reader should continue reading messages if one track misses timePeriod"""
109+
with self.assertLogs('climada_petals.hazard.tc_tracks_forecast', level='INFO') as cm:
110+
forecast = TCForecast()
111+
forecast.fetch_ecmwf(files=TEST_BUFR_FILE_MULTIMESSAGE_MISSING_TIMEPERIOD)
112+
self.assertIn(
113+
"Track 07L has no defined timePeriod. Track is discarded.", cm.output[0]
114+
)
115+
self.assertEqual(forecast.size, 125)
116+
np.testing.assert_array_equal(
117+
np.unique(
118+
[forecast.data[ind_i].name
119+
for ind_i in np.arange(122)]
120+
),
121+
np.array(['09L', 'FRANKLIN', 'GERT'], dtype=str)
122+
)
103123

104124
def test_equal_timestep(self):
105125
"""Test equal timestep"""

0 commit comments

Comments
 (0)