changes in docstrings, gsmt output as dict, percentiles as string #90
13 fail, 636 pass in 6m 52s
Annotations
Check warning on line 0 in climada.hazard.test.test_tc_cc.TestKnutson
github-actions / Unit Test Results Python 3.10
test_get_gmst_pass (climada.hazard.test.test_tc_cc.TestKnutson) failed
tests_xml/tests.xml [took 0s]
Raw output
TypeError: 'dict' object is not callable
self = <climada.hazard.test.test_tc_cc.TestKnutson testMethod=test_get_gmst_pass>
def test_get_gmst_pass(self):
"""Test get_gmst_info function."""
> gmst_data, gmst_start_year, gmst_end_year, rcps = tc_cc.get_gmst_info()
climada/hazard/test/test_tc_cc.py:46:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def get_gmst_info():
"""
Get Global Mean Surface Temperature (GMST) data from 1880 to 2100 for
RCPs 2.6, 4.5, 6.0 and 8.5.
Returns
-------
gmst_info : dict
dictionary with keys:
- rcps: list of strings referring to RCPs 2.6, 4.5, 6.0 and 8.5
- gmst_start_year: integer with the GMST data starting year, 1880
- gmst_start_year: integer with the GMST data ending year, 2100
- gmst_data: array with GMST data across RCPs (first dim) and years (second dim)
"""
gmst_info = {}
gmst_info.update({'rcps' : ['2.6', '4.5', '6.0', '8.5']})
> gmst_info({'gmst_start_year' : 1880})
E TypeError: 'dict' object is not callable
climada/hazard/tc_clim_change.py:193: TypeError
Check warning on line 0 in climada.hazard.test.test_tc_cc.TestKnutson
github-actions / Unit Test Results Python 3.10
test_get_knutson_scaling_pass (climada.hazard.test.test_tc_cc.TestKnutson) failed
tests_xml/tests.xml [took 0s]
Raw output
TypeError: 'dict' object is not callable
self = <climada.hazard.test.test_tc_cc.TestKnutson testMethod=test_get_knutson_scaling_pass>
def test_get_knutson_scaling_pass(self):
"""Test get_knutson_criterion function."""
> criterion = tc_cc.get_knutson_scaling_factor()
climada/hazard/test/test_tc_cc.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
climada/hazard/tc_clim_change.py:99: in get_knutson_scaling_factor
gmst_info = get_gmst_info()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def get_gmst_info():
"""
Get Global Mean Surface Temperature (GMST) data from 1880 to 2100 for
RCPs 2.6, 4.5, 6.0 and 8.5.
Returns
-------
gmst_info : dict
dictionary with keys:
- rcps: list of strings referring to RCPs 2.6, 4.5, 6.0 and 8.5
- gmst_start_year: integer with the GMST data starting year, 1880
- gmst_start_year: integer with the GMST data ending year, 2100
- gmst_data: array with GMST data across RCPs (first dim) and years (second dim)
"""
gmst_info = {}
gmst_info.update({'rcps' : ['2.6', '4.5', '6.0', '8.5']})
> gmst_info({'gmst_start_year' : 1880})
E TypeError: 'dict' object is not callable
climada/hazard/tc_clim_change.py:193: TypeError
Check warning on line 0 in climada.hazard.test.test_trop_cyclone.TestReader
github-actions / Unit Test Results Python 3.10
test_memory_limit (climada.hazard.test.test_trop_cyclone.TestReader) failed
tests_xml/tests.xml [took 0s]
Raw output
NameError: name '_compute_windfields_sparse' is not defined
self = <climada.hazard.test.test_trop_cyclone.TestReader testMethod=test_memory_limit>
def test_memory_limit(self):
"""Test from_tracks when memory is (very) limited"""
tc_track = TCTracks.from_processed_ibtracs_csv(TEST_TRACK)
tc_track.equal_timestep()
tc_track.data = tc_track.data[:1]
# A very low memory constraint forces the algorithm to split the track into chunks.
# This should not affect the results. In practice, chunking is not applied due to limited
# memory, but due to very high spatial/temporal resolution of the centroids/tracks. We
# simulate this situation by artificially reducing the available memory.
> tc_haz = TropCyclone.from_tracks(tc_track, centroids=CENTR_TEST_BRB, max_memory_gb=0.001)
climada/hazard/test/test_trop_cyclone.py:60:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
climada/hazard/trop_cyclone.py:321: in from_tracks
cls.from_single_track(track, centroids, coastal_idx,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'climada.hazard.trop_cyclone.TropCyclone'>
track = <xarray.Dataset>
Dimensions: (time: 223)
Coordinates:
* time (time) datetime64[ns...
data_provider: hurdat_atl
id_no: 1951239012334.0
category: 1
centroids = <climada.hazard.centroids.centr.Centroids object at 0x7fc2ac66f8e0>
coastal_idx = array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20,..., 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285,
286, 287, 288, 289, 290, 291, 292, 293, 294, 295])
model = 'H08', store_windfields = False, metric = 'equirect'
intensity_thres = 17.5, max_dist_eye_km = 300, max_memory_gb = 0.001
@classmethod
def from_single_track(
cls,
track: xr.Dataset,
centroids: Centroids,
coastal_idx: np.ndarray,
model: str = 'H08',
store_windfields: bool = False,
metric: str = "equirect",
intensity_thres: float = DEF_INTENSITY_THRES,
max_dist_eye_km: float = DEF_MAX_DIST_EYE_KM,
max_memory_gb: float = DEF_MAX_MEMORY_GB,
):
"""
Generate windfield hazard from a single track dataset
Parameters
----------
track : xr.Dataset
Single tropical cyclone track.
centroids : Centroids
Centroids instance.
coastal_idx : np.ndarray
Indices of centroids close to coast.
model : str, optional
Parametric wind field model, one of "H1980" (the prominent Holland 1980 model),
"H08" (Holland 1980 with b-value from Holland 2008), "H10" (Holland et al. 2010), or
"ER11" (Emanuel and Rotunno 2011).
Default: "H08".
store_windfields : boolean, optional
If True, store windfields. Default: False.
metric : str, optional
Specify an approximation method to use for earth distances: "equirect" (faster) or
"geosphere" (more accurate). See `dist_approx` function in `climada.util.coordinates`.
Default: "equirect".
intensity_thres : float, optional
Wind speeds (in m/s) below this threshold are stored as 0. Default: 17.5
max_dist_eye_km : float, optional
No wind speed calculation is done for centroids with a distance (in km) to the TC
center ("eye") larger than this parameter. Default: 300
max_memory_gb : float, optional
To avoid memory issues, the computation is done for chunks of the track sequentially.
The chunk size is determined depending on the available memory (in GB). Default: 8
Raises
------
ValueError, KeyError
Returns
-------
haz : TropCyclone
"""
> intensity_sparse, windfields_sparse = _compute_windfields_sparse(
track=track,
centroids=centroids,
coastal_idx=coastal_idx,
model=model,
store_windfields=store_windfields,
metric=metric,
intensity_thres=intensity_thres,
max_dist_eye_km=max_dist_eye_km,
max_memory_gb=max_memory_gb,
)
E NameError: name '_compute_windfields_sparse' is not defined
climada/hazard/trop_cyclone.py:602: NameError
Check warning on line 0 in climada.hazard.test.test_trop_cyclone.TestReader
github-actions / Unit Test Results Python 3.10
test_set_one_file_pass (climada.hazard.test.test_trop_cyclone.TestReader) failed
tests_xml/tests.xml [took 0s]
Raw output
NameError: name '_compute_windfields_sparse' is not defined
self = <climada.hazard.test.test_trop_cyclone.TestReader testMethod=test_set_one_file_pass>
def test_set_one_file_pass(self):
"""Test from_tracks with one input."""
tc_track = TCTracks.from_processed_ibtracs_csv(TEST_TRACK_SHORT)
> tc_haz = TropCyclone.from_tracks(tc_track, centroids=CENTR_TEST_BRB)
climada/hazard/test/test_trop_cyclone.py:201:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
climada/hazard/trop_cyclone.py:321: in from_tracks
cls.from_single_track(track, centroids, coastal_idx,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'climada.hazard.trop_cyclone.TropCyclone'>
track = <xarray.Dataset>
Dimensions: (time: 9)
Coordinates:
* time (time) datetime64[ns] ... data_provider: hurdat_atl
id_no: 1951239012334.0
category: -1
centroids = <climada.hazard.centroids.centr.Centroids object at 0x7fc2ac66f8e0>
coastal_idx = array([], dtype=int64), model = 'H08', store_windfields = False
metric = 'equirect', intensity_thres = 17.5, max_dist_eye_km = 300
max_memory_gb = 8
@classmethod
def from_single_track(
cls,
track: xr.Dataset,
centroids: Centroids,
coastal_idx: np.ndarray,
model: str = 'H08',
store_windfields: bool = False,
metric: str = "equirect",
intensity_thres: float = DEF_INTENSITY_THRES,
max_dist_eye_km: float = DEF_MAX_DIST_EYE_KM,
max_memory_gb: float = DEF_MAX_MEMORY_GB,
):
"""
Generate windfield hazard from a single track dataset
Parameters
----------
track : xr.Dataset
Single tropical cyclone track.
centroids : Centroids
Centroids instance.
coastal_idx : np.ndarray
Indices of centroids close to coast.
model : str, optional
Parametric wind field model, one of "H1980" (the prominent Holland 1980 model),
"H08" (Holland 1980 with b-value from Holland 2008), "H10" (Holland et al. 2010), or
"ER11" (Emanuel and Rotunno 2011).
Default: "H08".
store_windfields : boolean, optional
If True, store windfields. Default: False.
metric : str, optional
Specify an approximation method to use for earth distances: "equirect" (faster) or
"geosphere" (more accurate). See `dist_approx` function in `climada.util.coordinates`.
Default: "equirect".
intensity_thres : float, optional
Wind speeds (in m/s) below this threshold are stored as 0. Default: 17.5
max_dist_eye_km : float, optional
No wind speed calculation is done for centroids with a distance (in km) to the TC
center ("eye") larger than this parameter. Default: 300
max_memory_gb : float, optional
To avoid memory issues, the computation is done for chunks of the track sequentially.
The chunk size is determined depending on the available memory (in GB). Default: 8
Raises
------
ValueError, KeyError
Returns
-------
haz : TropCyclone
"""
> intensity_sparse, windfields_sparse = _compute_windfields_sparse(
track=track,
centroids=centroids,
coastal_idx=coastal_idx,
model=model,
store_windfields=store_windfields,
metric=metric,
intensity_thres=intensity_thres,
max_dist_eye_km=max_dist_eye_km,
max_memory_gb=max_memory_gb,
)
E NameError: name '_compute_windfields_sparse' is not defined
climada/hazard/trop_cyclone.py:602: NameError
Check warning on line 0 in climada.hazard.test.test_trop_cyclone.TestReader
github-actions / Unit Test Results Python 3.10
test_set_one_pass (climada.hazard.test.test_trop_cyclone.TestReader) failed
tests_xml/tests.xml [took 0s]
Raw output
NameError: name '_compute_windfields_sparse' is not defined
self = <climada.hazard.test.test_trop_cyclone.TestReader testMethod=test_set_one_pass>
def test_set_one_pass(self):
"""Test _tc_from_track function."""
intensity_idx = [0, 1, 2, 3, 80, 100, 120, 200, 220, 250, 260, 295]
intensity_values = {
"geosphere": [25.60794285, 26.90906280, 28.26649026, 25.54076797, 31.21986961,
36.17171808, 21.11408573, 28.01457948, 32.65349378, 31.34027741, 0,
40.27362679],
"equirect": [25.60778909, 26.90887264, 28.26624642, 25.54092386, 31.21941738,
36.16596567, 21.11399856, 28.01452136, 32.65076804, 31.33884098, 0,
40.27002104]
}
# the values for the two metrics should agree up to first digit at least
for i, val in enumerate(intensity_values["geosphere"]):
self.assertAlmostEqual(intensity_values["equirect"][i], val, 1)
tc_track = TCTracks.from_processed_ibtracs_csv(TEST_TRACK)
tc_track.equal_timestep()
tc_track.data = tc_track.data[:1]
for metric in ["equirect", "geosphere"]:
> tc_haz = TropCyclone.from_tracks(tc_track, centroids=CENTR_TEST_BRB, model='H08',
store_windfields=True, metric=metric)
climada/hazard/test/test_trop_cyclone.py:91:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
climada/hazard/trop_cyclone.py:321: in from_tracks
cls.from_single_track(track, centroids, coastal_idx,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'climada.hazard.trop_cyclone.TropCyclone'>
track = <xarray.Dataset>
Dimensions: (time: 223)
Coordinates:
* time (time) datetime64[ns...
data_provider: hurdat_atl
id_no: 1951239012334.0
category: 1
centroids = <climada.hazard.centroids.centr.Centroids object at 0x7fc2ac66f8e0>
coastal_idx = array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20,..., 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285,
286, 287, 288, 289, 290, 291, 292, 293, 294, 295])
model = 'H08', store_windfields = True, metric = 'equirect'
intensity_thres = 17.5, max_dist_eye_km = 300, max_memory_gb = 8
@classmethod
def from_single_track(
cls,
track: xr.Dataset,
centroids: Centroids,
coastal_idx: np.ndarray,
model: str = 'H08',
store_windfields: bool = False,
metric: str = "equirect",
intensity_thres: float = DEF_INTENSITY_THRES,
max_dist_eye_km: float = DEF_MAX_DIST_EYE_KM,
max_memory_gb: float = DEF_MAX_MEMORY_GB,
):
"""
Generate windfield hazard from a single track dataset
Parameters
----------
track : xr.Dataset
Single tropical cyclone track.
centroids : Centroids
Centroids instance.
coastal_idx : np.ndarray
Indices of centroids close to coast.
model : str, optional
Parametric wind field model, one of "H1980" (the prominent Holland 1980 model),
"H08" (Holland 1980 with b-value from Holland 2008), "H10" (Holland et al. 2010), or
"ER11" (Emanuel and Rotunno 2011).
Default: "H08".
store_windfields : boolean, optional
If True, store windfields. Default: False.
metric : str, optional
Specify an approximation method to use for earth distances: "equirect" (faster) or
"geosphere" (more accurate). See `dist_approx` function in `climada.util.coordinates`.
Default: "equirect".
intensity_thres : float, optional
Wind speeds (in m/s) below this threshold are stored as 0. Default: 17.5
max_dist_eye_km : float, optional
No wind speed calculation is done for centroids with a distance (in km) to the TC
center ("eye") larger than this parameter. Default: 300
max_memory_gb : float, optional
To avoid memory issues, the computation is done for chunks of the track sequentially.
The chunk size is determined depending on the available memory (in GB). Default: 8
Raises
------
ValueError, KeyError
Returns
-------
haz : TropCyclone
"""
> intensity_sparse, windfields_sparse = _compute_windfields_sparse(
track=track,
centroids=centroids,
coastal_idx=coastal_idx,
model=model,
store_windfields=store_windfields,
metric=metric,
intensity_thres=intensity_thres,
max_dist_eye_km=max_dist_eye_km,
max_memory_gb=max_memory_gb,
)
E NameError: name '_compute_windfields_sparse' is not defined
climada/hazard/trop_cyclone.py:602: NameError
Check warning on line 0 in climada.hazard.test.test_trop_cyclone.TestReader
github-actions / Unit Test Results Python 3.10
test_two_files_pass (climada.hazard.test.test_trop_cyclone.TestReader) failed
tests_xml/tests.xml [took 0s]
Raw output
NameError: name '_compute_windfields_sparse' is not defined
self = <climada.hazard.test.test_trop_cyclone.TestReader testMethod=test_two_files_pass>
def test_two_files_pass(self):
"""Test from_tracks with two ibtracs."""
tc_track = TCTracks.from_processed_ibtracs_csv([TEST_TRACK_SHORT, TEST_TRACK_SHORT])
> tc_haz = TropCyclone.from_tracks(tc_track, centroids=CENTR_TEST_BRB)
climada/hazard/test/test_trop_cyclone.py:226:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
climada/hazard/trop_cyclone.py:321: in from_tracks
cls.from_single_track(track, centroids, coastal_idx,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'climada.hazard.trop_cyclone.TropCyclone'>
track = <xarray.Dataset>
Dimensions: (time: 9)
Coordinates:
* time (time) datetime64[ns] ... data_provider: hurdat_atl
id_no: 1951239012334.0
category: -1
centroids = <climada.hazard.centroids.centr.Centroids object at 0x7fc2ac66f8e0>
coastal_idx = array([], dtype=int64), model = 'H08', store_windfields = False
metric = 'equirect', intensity_thres = 17.5, max_dist_eye_km = 300
max_memory_gb = 8
@classmethod
def from_single_track(
cls,
track: xr.Dataset,
centroids: Centroids,
coastal_idx: np.ndarray,
model: str = 'H08',
store_windfields: bool = False,
metric: str = "equirect",
intensity_thres: float = DEF_INTENSITY_THRES,
max_dist_eye_km: float = DEF_MAX_DIST_EYE_KM,
max_memory_gb: float = DEF_MAX_MEMORY_GB,
):
"""
Generate windfield hazard from a single track dataset
Parameters
----------
track : xr.Dataset
Single tropical cyclone track.
centroids : Centroids
Centroids instance.
coastal_idx : np.ndarray
Indices of centroids close to coast.
model : str, optional
Parametric wind field model, one of "H1980" (the prominent Holland 1980 model),
"H08" (Holland 1980 with b-value from Holland 2008), "H10" (Holland et al. 2010), or
"ER11" (Emanuel and Rotunno 2011).
Default: "H08".
store_windfields : boolean, optional
If True, store windfields. Default: False.
metric : str, optional
Specify an approximation method to use for earth distances: "equirect" (faster) or
"geosphere" (more accurate). See `dist_approx` function in `climada.util.coordinates`.
Default: "equirect".
intensity_thres : float, optional
Wind speeds (in m/s) below this threshold are stored as 0. Default: 17.5
max_dist_eye_km : float, optional
No wind speed calculation is done for centroids with a distance (in km) to the TC
center ("eye") larger than this parameter. Default: 300
max_memory_gb : float, optional
To avoid memory issues, the computation is done for chunks of the track sequentially.
The chunk size is determined depending on the available memory (in GB). Default: 8
Raises
------
ValueError, KeyError
Returns
-------
haz : TropCyclone
"""
> intensity_sparse, windfields_sparse = _compute_windfields_sparse(
track=track,
centroids=centroids,
coastal_idx=coastal_idx,
model=model,
store_windfields=store_windfields,
metric=metric,
intensity_thres=intensity_thres,
max_dist_eye_km=max_dist_eye_km,
max_memory_gb=max_memory_gb,
)
E NameError: name '_compute_windfields_sparse' is not defined
climada/hazard/trop_cyclone.py:602: NameError
Check warning on line 0 in climada.hazard.test.test_trop_cyclone.TestReader
github-actions / Unit Test Results Python 3.10
test_windfield_models (climada.hazard.test.test_trop_cyclone.TestReader) failed
tests_xml/tests.xml [took 0s]
Raw output
NameError: name '_compute_windfields_sparse' is not defined
self = <climada.hazard.test.test_trop_cyclone.TestReader testMethod=test_windfield_models>
def test_windfield_models(self):
"""Test _tc_from_track function with different wind field models."""
intensity_idx = [0, 1, 2, 3, 80, 100, 120, 200, 220, 250, 260, 295]
intensity_values = {
"H08": [25.60778909, 26.90887264, 28.26624642, 25.54092386, 31.21941738, 36.16596567,
21.11399856, 28.01452136, 32.65076804, 31.33884098, 0, 40.27002104],
"H10": [27.604317, 28.720708, 29.894993, 27.52234 , 32.512395, 37.114355,
23.848917, 29.614752, 33.775593, 32.545347, 19.957627, 41.014578],
# Holland 1980 and Emanuel & Rotunno 2011 use recorded wind speeds, while the above use
# pressure values only. That's why the results are so different:
"H1980": [21.376807, 21.957217, 22.569568, 21.284351, 24.254226, 26.971303,
19.220149, 21.984516, 24.196388, 23.449116, 0, 31.550207],
"ER11": [23.565332, 24.931413, 26.360758, 23.490333, 29.601171, 34.522795,
18.996389, 26.102109, 30.780737, 29.498453, 0, 38.368805],
}
tc_track = TCTracks.from_processed_ibtracs_csv(TEST_TRACK)
tc_track.equal_timestep()
tc_track.data = tc_track.data[:1]
for model in ["H08", "H10", "H1980", "ER11"]:
> tc_haz = TropCyclone.from_tracks(tc_track, centroids=CENTR_TEST_BRB, model=model)
climada/hazard/test/test_trop_cyclone.py:147:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
climada/hazard/trop_cyclone.py:321: in from_tracks
cls.from_single_track(track, centroids, coastal_idx,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'climada.hazard.trop_cyclone.TropCyclone'>
track = <xarray.Dataset>
Dimensions: (time: 223)
Coordinates:
* time (time) datetime64[ns...
data_provider: hurdat_atl
id_no: 1951239012334.0
category: 1
centroids = <climada.hazard.centroids.centr.Centroids object at 0x7fc2ac66f8e0>
coastal_idx = array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20,..., 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285,
286, 287, 288, 289, 290, 291, 292, 293, 294, 295])
model = 'H08', store_windfields = False, metric = 'equirect'
intensity_thres = 17.5, max_dist_eye_km = 300, max_memory_gb = 8
@classmethod
def from_single_track(
cls,
track: xr.Dataset,
centroids: Centroids,
coastal_idx: np.ndarray,
model: str = 'H08',
store_windfields: bool = False,
metric: str = "equirect",
intensity_thres: float = DEF_INTENSITY_THRES,
max_dist_eye_km: float = DEF_MAX_DIST_EYE_KM,
max_memory_gb: float = DEF_MAX_MEMORY_GB,
):
"""
Generate windfield hazard from a single track dataset
Parameters
----------
track : xr.Dataset
Single tropical cyclone track.
centroids : Centroids
Centroids instance.
coastal_idx : np.ndarray
Indices of centroids close to coast.
model : str, optional
Parametric wind field model, one of "H1980" (the prominent Holland 1980 model),
"H08" (Holland 1980 with b-value from Holland 2008), "H10" (Holland et al. 2010), or
"ER11" (Emanuel and Rotunno 2011).
Default: "H08".
store_windfields : boolean, optional
If True, store windfields. Default: False.
metric : str, optional
Specify an approximation method to use for earth distances: "equirect" (faster) or
"geosphere" (more accurate). See `dist_approx` function in `climada.util.coordinates`.
Default: "equirect".
intensity_thres : float, optional
Wind speeds (in m/s) below this threshold are stored as 0. Default: 17.5
max_dist_eye_km : float, optional
No wind speed calculation is done for centroids with a distance (in km) to the TC
center ("eye") larger than this parameter. Default: 300
max_memory_gb : float, optional
To avoid memory issues, the computation is done for chunks of the track sequentially.
The chunk size is determined depending on the available memory (in GB). Default: 8
Raises
------
ValueError, KeyError
Returns
-------
haz : TropCyclone
"""
> intensity_sparse, windfields_sparse = _compute_windfields_sparse(
track=track,
centroids=centroids,
coastal_idx=coastal_idx,
model=model,
store_windfields=store_windfields,
metric=metric,
intensity_thres=intensity_thres,
max_dist_eye_km=max_dist_eye_km,
max_memory_gb=max_memory_gb,
)
E NameError: name '_compute_windfields_sparse' is not defined
climada/hazard/trop_cyclone.py:602: NameError
Check warning on line 0 in climada.hazard.test.test_trop_cyclone.TestReader
github-actions / Unit Test Results Python 3.10
test_windfield_models_different_windunits (climada.hazard.test.test_trop_cyclone.TestReader) failed
tests_xml/tests.xml [took 0s]
Raw output
NameError: name '_compute_windfields_sparse' is not defined
self = <climada.hazard.test.test_trop_cyclone.TestReader testMethod=test_windfield_models_different_windunits>
def test_windfield_models_different_windunits(self):
"""
Test _tc_from_track function should calculate the same results or raise ValueError
with different windspeed units.
"""
intensity_idx = [0, 1, 2, 3, 80, 100, 120, 200, 220, 250, 260, 295]
intensity_values = {
# Holland 1980 and Emanuel & Rotunno 2011 use recorded wind speeds, that is why checking them for different
# windspeed units is so important:
"H1980": [21.376807, 21.957217, 22.569568, 21.284351, 24.254226, 26.971303,
19.220149, 21.984516, 24.196388, 23.449116, 0, 31.550207],
"ER11": [23.565332, 24.931413, 26.360758, 23.490333, 29.601171, 34.522795,
18.996389, 26.102109, 30.780737, 29.498453, 0, 38.368805],
}
tc_track = TCTracks.from_processed_ibtracs_csv(TEST_TRACK)
tc_track.equal_timestep()
tc_track.data = tc_track.data[:1]
tc_track_kmph = TCTracks(data=[ds.copy(deep=True) for ds in tc_track.data])
tc_track_kmph.data[0]['max_sustained_wind'] *= (
(1.0 * ureg.knot).to(ureg.km / ureg.hour).magnitude
)
tc_track_kmph.data[0].attrs['max_sustained_wind_unit'] = 'km/h'
tc_track_mps = TCTracks(data=[ds.copy(deep=True) for ds in tc_track.data])
tc_track_mps.data[0]['max_sustained_wind'] *= (
(1.0 * ureg.knot).to(ureg.meter / ureg.second).magnitude
)
tc_track_mps.data[0].attrs['max_sustained_wind_unit'] = 'm/s'
for model in ["H1980", "ER11"]:
for tc_track_i in [tc_track_kmph, tc_track_mps]:
> tc_haz = TropCyclone.from_tracks(tc_track_i, centroids=CENTR_TEST_BRB, model=model)
climada/hazard/test/test_trop_cyclone.py:187:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
climada/hazard/trop_cyclone.py:321: in from_tracks
cls.from_single_track(track, centroids, coastal_idx,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'climada.hazard.trop_cyclone.TropCyclone'>
track = <xarray.Dataset>
Dimensions: (time: 223)
Coordinates:
* time (time) datetime64[ns...
data_provider: hurdat_atl
id_no: 1951239012334.0
category: 1
centroids = <climada.hazard.centroids.centr.Centroids object at 0x7fc2ac66f8e0>
coastal_idx = array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20,..., 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285,
286, 287, 288, 289, 290, 291, 292, 293, 294, 295])
model = 'H1980', store_windfields = False, metric = 'equirect'
intensity_thres = 17.5, max_dist_eye_km = 300, max_memory_gb = 8
@classmethod
def from_single_track(
cls,
track: xr.Dataset,
centroids: Centroids,
coastal_idx: np.ndarray,
model: str = 'H08',
store_windfields: bool = False,
metric: str = "equirect",
intensity_thres: float = DEF_INTENSITY_THRES,
max_dist_eye_km: float = DEF_MAX_DIST_EYE_KM,
max_memory_gb: float = DEF_MAX_MEMORY_GB,
):
"""
Generate windfield hazard from a single track dataset
Parameters
----------
track : xr.Dataset
Single tropical cyclone track.
centroids : Centroids
Centroids instance.
coastal_idx : np.ndarray
Indices of centroids close to coast.
model : str, optional
Parametric wind field model, one of "H1980" (the prominent Holland 1980 model),
"H08" (Holland 1980 with b-value from Holland 2008), "H10" (Holland et al. 2010), or
"ER11" (Emanuel and Rotunno 2011).
Default: "H08".
store_windfields : boolean, optional
If True, store windfields. Default: False.
metric : str, optional
Specify an approximation method to use for earth distances: "equirect" (faster) or
"geosphere" (more accurate). See `dist_approx` function in `climada.util.coordinates`.
Default: "equirect".
intensity_thres : float, optional
Wind speeds (in m/s) below this threshold are stored as 0. Default: 17.5
max_dist_eye_km : float, optional
No wind speed calculation is done for centroids with a distance (in km) to the TC
center ("eye") larger than this parameter. Default: 300
max_memory_gb : float, optional
To avoid memory issues, the computation is done for chunks of the track sequentially.
The chunk size is determined depending on the available memory (in GB). Default: 8
Raises
------
ValueError, KeyError
Returns
-------
haz : TropCyclone
"""
> intensity_sparse, windfields_sparse = _compute_windfields_sparse(
track=track,
centroids=centroids,
coastal_idx=coastal_idx,
model=model,
store_windfields=store_windfields,
metric=metric,
intensity_thres=intensity_thres,
max_dist_eye_km=max_dist_eye_km,
max_memory_gb=max_memory_gb,
)
E NameError: name '_compute_windfields_sparse' is not defined
climada/hazard/trop_cyclone.py:602: NameError
Check warning on line 0 in climada.hazard.test.test_trop_cyclone.TestClimateSce
github-actions / Unit Test Results Python 3.10
test_apply_climate_scenario_track (climada.hazard.test.test_trop_cyclone.TestClimateSce) failed
tests_xml/tests.xml [took 0s]
Raw output
TypeError: 'dict' object is not callable
self = <climada.hazard.test.test_trop_cyclone.TestClimateSce testMethod=test_apply_climate_scenario_track>
def test_apply_climate_scenario_track(self):
"""Test _apply_criterion function."""
intensity = np.zeros((4, 10))
intensity[0, :] = np.arange(10)
intensity[1, 5] = 10
intensity[2, :] = np.arange(10, 20)
intensity[3, 3] = 3
tc = TropCyclone(
intensity=sparse.csr_matrix(intensity),
basin=['NA', 'NA', 'NA', 'NO'],
category=np.array([2, 0, 4, 1]),
event_id=np.arange(4),
frequency=np.ones(4) * 0.5,
)
> tc_cc = tc.apply_climate_scenario_knu(ref_year=2050, rcp_scenario=45)
climada/hazard/test/test_trop_cyclone.py:422:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
climada/hazard/trop_cyclone.py:396: in apply_climate_scenario_knu
scale_year_rcp_05, scale_year_rcp_45 = [
climada/hazard/trop_cyclone.py:397: in <listcomp>
get_knutson_scaling_factor(
climada/hazard/tc_clim_change.py:99: in get_knutson_scaling_factor
gmst_info = get_gmst_info()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def get_gmst_info():
"""
Get Global Mean Surface Temperature (GMST) data from 1880 to 2100 for
RCPs 2.6, 4.5, 6.0 and 8.5.
Returns
-------
gmst_info : dict
dictionary with keys:
- rcps: list of strings referring to RCPs 2.6, 4.5, 6.0 and 8.5
- gmst_start_year: integer with the GMST data starting year, 1880
- gmst_start_year: integer with the GMST data ending year, 2100
- gmst_data: array with GMST data across RCPs (first dim) and years (second dim)
"""
gmst_info = {}
gmst_info.update({'rcps' : ['2.6', '4.5', '6.0', '8.5']})
> gmst_info({'gmst_start_year' : 1880})
E TypeError: 'dict' object is not callable
climada/hazard/tc_clim_change.py:193: TypeError
Check warning on line 0 in climada.hazard.test.test_trop_cyclone.TestClimateSce
github-actions / Unit Test Results Python 3.10
test_apply_criterion_track (climada.hazard.test.test_trop_cyclone.TestClimateSce) failed
tests_xml/tests.xml [took 0s]
Raw output
TypeError: 'dict' object is not callable
self = <climada.hazard.test.test_trop_cyclone.TestClimateSce testMethod=test_apply_criterion_track>
def test_apply_criterion_track(self):
"""Test _apply_criterion function."""
criterion = [
{'basin': 'NA', 'category': [1, 2, 3, 4, 5],
'year': 2100, 'change': 1.045}
]
scale = 0.75
# artificially increase the size of
# the hazard by repeating (tiling) the data:
ntiles = 8
intensity = np.zeros((4, 10))
intensity[0, :] = np.arange(10)
intensity[1, 5] = 10
intensity[2, :] = np.arange(10, 20)
intensity[3, 3] = 3
intensity = np.tile(intensity, (ntiles, 1))
tc = TropCyclone(
intensity=sparse.csr_matrix(intensity),
basin=ntiles * ['NA', 'NA', 'NA', 'WP'],
frequency=np.repeat(1/(4*ntiles), 4*ntiles),
category=np.array(ntiles * [2, 0, 4, 1]),
event_id=np.arange(intensity.shape[0]),
)
> tc_cc = tc.apply_climate_scenario_knu()
climada/hazard/test/test_trop_cyclone.py:462:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
climada/hazard/trop_cyclone.py:396: in apply_climate_scenario_knu
scale_year_rcp_05, scale_year_rcp_45 = [
climada/hazard/trop_cyclone.py:397: in <listcomp>
get_knutson_scaling_factor(
climada/hazard/tc_clim_change.py:99: in get_knutson_scaling_factor
gmst_info = get_gmst_info()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def get_gmst_info():
"""
Get Global Mean Surface Temperature (GMST) data from 1880 to 2100 for
RCPs 2.6, 4.5, 6.0 and 8.5.
Returns
-------
gmst_info : dict
dictionary with keys:
- rcps: list of strings referring to RCPs 2.6, 4.5, 6.0 and 8.5
- gmst_start_year: integer with the GMST data starting year, 1880
- gmst_start_year: integer with the GMST data ending year, 2100
- gmst_data: array with GMST data across RCPs (first dim) and years (second dim)
"""
gmst_info = {}
gmst_info.update({'rcps' : ['2.6', '4.5', '6.0', '8.5']})
> gmst_info({'gmst_start_year' : 1880})
E TypeError: 'dict' object is not callable
climada/hazard/tc_clim_change.py:193: TypeError
Check warning on line 0 in climada.hazard.test.test_trop_cyclone.TestClimateSce
github-actions / Unit Test Results Python 3.10
test_no_negative_freq (climada.hazard.test.test_trop_cyclone.TestClimateSce) failed
tests_xml/tests.xml [took 0s]
Raw output
TypeError: 'dict' object is not callable
self = <climada.hazard.test.test_trop_cyclone.TestClimateSce testMethod=test_no_negative_freq>
def test_no_negative_freq(self):
"""Test apply_climate_scenario_knu with too high changes and check
that no negative frequencies are returned."""
criterion = [{'basin': 'SP', 'category': [0, 1],
'year': 2100, 'change': 0.5}
]
tc = TropCyclone(
frequency=np.ones(2),
basin=['SP', 'SP'],
category=np.array([0, 1]),
)
> tc_cc = tc.apply_climate_scenario_knu(criterion, 3)
climada/hazard/test/test_trop_cyclone.py:533:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
climada/hazard/trop_cyclone.py:396: in apply_climate_scenario_knu
scale_year_rcp_05, scale_year_rcp_45 = [
climada/hazard/trop_cyclone.py:397: in <listcomp>
get_knutson_scaling_factor(
climada/hazard/tc_clim_change.py:99: in get_knutson_scaling_factor
gmst_info = get_gmst_info()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def get_gmst_info():
"""
Get Global Mean Surface Temperature (GMST) data from 1880 to 2100 for
RCPs 2.6, 4.5, 6.0 and 8.5.
Returns
-------
gmst_info : dict
dictionary with keys:
- rcps: list of strings referring to RCPs 2.6, 4.5, 6.0 and 8.5
- gmst_start_year: integer with the GMST data starting year, 1880
- gmst_start_year: integer with the GMST data ending year, 2100
- gmst_data: array with GMST data across RCPs (first dim) and years (second dim)
"""
gmst_info = {}
gmst_info.update({'rcps' : ['2.6', '4.5', '6.0', '8.5']})
> gmst_info({'gmst_start_year' : 1880})
E TypeError: 'dict' object is not callable
climada/hazard/tc_clim_change.py:193: TypeError
Check warning on line 0 in climada.hazard.test.test_trop_cyclone.TestClimateSce
github-actions / Unit Test Results Python 3.10
test_two_criterion_track (climada.hazard.test.test_trop_cyclone.TestClimateSce) failed
tests_xml/tests.xml [took 0s]
Raw output
TypeError: 'dict' object is not callable
self = <climada.hazard.test.test_trop_cyclone.TestClimateSce testMethod=test_two_criterion_track>
def test_two_criterion_track(self):
"""Test apply_climate_scenario_knu function with two criteria"""
criterion = [
{'basin': 'WP', 'category': [1, 2, 3, 4, 5],
'year': 2100, 'change': 1.025},
{'basin': 'NA', 'category': [0, 1, 2, 3, 4, 5],
'year': 2100, 'change': 0.7},
{'basin': 'NA', 'category': [1, 2, 3, 4, 5],
'year': 2100, 'change': 1},
{'basin': 'NA', 'category': [3, 4, 5],
'year': 2100, 'change': 1},
{'basin': 'NA', 'category': [4, 5],
'year': 2100, 'change': 2}
]
scale = 0.75
intensity = np.zeros((4, 10))
intensity[0, :] = np.arange(10)
intensity[1, 5] = 10
intensity[2, :] = np.arange(10, 20)
intensity[3, 3] = 3
tc = TropCyclone(
intensity=sparse.csr_matrix(intensity),
frequency=np.ones(4) * 0.5,
basin=['NA', 'NA', 'NA', 'WP'],
category=np.array([2, 0, 4, 1]),
event_id=np.arange(4),
)
> tc_cc = tc.apply_climate_scenario_knu(criterion, scale)
climada/hazard/test/test_trop_cyclone.py:512:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
climada/hazard/trop_cyclone.py:396: in apply_climate_scenario_knu
scale_year_rcp_05, scale_year_rcp_45 = [
climada/hazard/trop_cyclone.py:397: in <listcomp>
get_knutson_scaling_factor(
climada/hazard/tc_clim_change.py:99: in get_knutson_scaling_factor
gmst_info = get_gmst_info()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def get_gmst_info():
"""
Get Global Mean Surface Temperature (GMST) data from 1880 to 2100 for
RCPs 2.6, 4.5, 6.0 and 8.5.
Returns
-------
gmst_info : dict
dictionary with keys:
- rcps: list of strings referring to RCPs 2.6, 4.5, 6.0 and 8.5
- gmst_start_year: integer with the GMST data starting year, 1880
- gmst_start_year: integer with the GMST data ending year, 2100
- gmst_data: array with GMST data across RCPs (first dim) and years (second dim)
"""
gmst_info = {}
gmst_info.update({'rcps' : ['2.6', '4.5', '6.0', '8.5']})
> gmst_info({'gmst_start_year' : 1880})
E TypeError: 'dict' object is not callable
climada/hazard/tc_clim_change.py:193: TypeError
Check warning on line 0 in climada.hazard.test.test_trop_cyclone.TestDumpReloadCycle
github-actions / Unit Test Results Python 3.10
test_dump_reload_hdf5 (climada.hazard.test.test_trop_cyclone.TestDumpReloadCycle) failed
tests_xml/tests.xml [took 0s]
Raw output
NameError: name '_compute_windfields_sparse' is not defined
self = <climada.hazard.test.test_trop_cyclone.TestDumpReloadCycle testMethod=test_dump_reload_hdf5>
def setUp(self):
"""Create a TropCyclone object and a temporary directory"""
self.tempdir = TemporaryDirectory()
tc_track = TCTracks.from_processed_ibtracs_csv(TEST_TRACK_SHORT)
> self.tc_hazard = TropCyclone.from_tracks(tc_track, centroids=CENTR_TEST_BRB)
climada/hazard/test/test_trop_cyclone.py:541:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
climada/hazard/trop_cyclone.py:321: in from_tracks
cls.from_single_track(track, centroids, coastal_idx,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'climada.hazard.trop_cyclone.TropCyclone'>
track = <xarray.Dataset>
Dimensions: (time: 9)
Coordinates:
* time (time) datetime64[ns] ... data_provider: hurdat_atl
id_no: 1951239012334.0
category: -1
centroids = <climada.hazard.centroids.centr.Centroids object at 0x7fc2ac66f8e0>
coastal_idx = array([], dtype=int64), model = 'H08', store_windfields = False
metric = 'equirect', intensity_thres = 17.5, max_dist_eye_km = 300
max_memory_gb = 8
@classmethod
def from_single_track(
cls,
track: xr.Dataset,
centroids: Centroids,
coastal_idx: np.ndarray,
model: str = 'H08',
store_windfields: bool = False,
metric: str = "equirect",
intensity_thres: float = DEF_INTENSITY_THRES,
max_dist_eye_km: float = DEF_MAX_DIST_EYE_KM,
max_memory_gb: float = DEF_MAX_MEMORY_GB,
):
"""
Generate windfield hazard from a single track dataset
Parameters
----------
track : xr.Dataset
Single tropical cyclone track.
centroids : Centroids
Centroids instance.
coastal_idx : np.ndarray
Indices of centroids close to coast.
model : str, optional
Parametric wind field model, one of "H1980" (the prominent Holland 1980 model),
"H08" (Holland 1980 with b-value from Holland 2008), "H10" (Holland et al. 2010), or
"ER11" (Emanuel and Rotunno 2011).
Default: "H08".
store_windfields : boolean, optional
If True, store windfields. Default: False.
metric : str, optional
Specify an approximation method to use for earth distances: "equirect" (faster) or
"geosphere" (more accurate). See `dist_approx` function in `climada.util.coordinates`.
Default: "equirect".
intensity_thres : float, optional
Wind speeds (in m/s) below this threshold are stored as 0. Default: 17.5
max_dist_eye_km : float, optional
No wind speed calculation is done for centroids with a distance (in km) to the TC
center ("eye") larger than this parameter. Default: 300
max_memory_gb : float, optional
To avoid memory issues, the computation is done for chunks of the track sequentially.
The chunk size is determined depending on the available memory (in GB). Default: 8
Raises
------
ValueError, KeyError
Returns
-------
haz : TropCyclone
"""
> intensity_sparse, windfields_sparse = _compute_windfields_sparse(
track=track,
centroids=centroids,
coastal_idx=coastal_idx,
model=model,
store_windfields=store_windfields,
metric=metric,
intensity_thres=intensity_thres,
max_dist_eye_km=max_dist_eye_km,
max_memory_gb=max_memory_gb,
)
E NameError: name '_compute_windfields_sparse' is not defined
climada/hazard/trop_cyclone.py:602: NameError