6 fail, 711 pass in 8m 50s
Annotations
Check warning on line 0 in climada.hazard.test.test_tc_tracks.TestIO
github-actions / Core / Unit Test Results (3.11)
test_from_fast (climada.hazard.test.test_tc_tracks.TestIO) failed
tests_xml/tests.xml [took 0s]
Raw output
NameError: name 'tc_tracks' is not defined
self = <climada.hazard.test.test_tc_tracks.TestIO testMethod=test_from_fast>
def test_from_fast(self):
"""test the correct import of netcdf files from fast model and the conversion to a
different xr.array structure compatible with CLIMADA."""
> tc_track = tc.TCTracks.from_fast(TEST_TRACK_FAST)
climada/hazard/test/test_tc_tracks.py:651:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'climada.hazard.tc_tracks.TCTracks'>
folder_name = PosixPath('/home/runner/work/climada_python/climada_python/climada/hazard/test/data/FAST_test_tracks.nc')
@classmethod
def from_fast(cls, folder_name: str):
"""Create a new TCTracks object from NetCDF files generated by the FAST model, modifying
the xr.array structure to ensure compatibility with CLIMADA, and calculating the central
pressure and radius of maximum wind.
Model GitHub Repository: https://github.com/linjonathan/tropical_cyclone_risk?
tab=readme-ov-file
Model Publication: https://agupubs.onlinelibrary.wiley.com/doi/epdf/10.1029/2023MS003686
Parameters:
----------
folder_name : str
Folder name from where to read files.
storm_id : int
Number of the simulated storm
Returns:
-------
tracks : TCTracks
TCTracks object with tracks data from the given directory of NetCDF files.
"""
file_tr = get_file_names(folder_name)
LOGGER.info("Reading %s files.", len(file_tr))
data = []
for file in file_tr:
if Path(file).suffix != ".nc":
continue
with xr.open_dataset(file) as ds:
for i in ds.n_trk:
# Select track
track = ds.sel(n_trk=i)
# Define coordinates
lat = track.lat_trks.data
lon = track.lon_trks.data
time = track.time.data
# Convert time to pandas Datetime "yyyy.mm.dd"
reference_time = (
f"{track.tc_years.item()}-{int(track.tc_month.item())}-01"
)
time = pd.to_datetime(time, unit="s", origin=reference_time).astype(
"datetime64[s]"
)
# Define variables
time_step_vector = np.full(time.shape[0], track.time.data[1])
max_sustained_wind_ms = track.v_trks.data
max_sustained_wind_knots = max_sustained_wind_ms * 1.943844
basin_vector = np.full(time.shape[0], track.tc_basins.data.item())
env_pressure = BASIN_ENV_PRESSURE[track.tc_basins.data.item()]
env_pressure_vect = np.full(time.shape[0], env_pressure)
cen_pres_missing = np.full(lat.shape, np.nan)
rmw_missing = np.full(lat.shape, np.nan)
> cen_pres = tc_tracks._estimate_pressure(
cen_pres_missing, lat, lon, max_sustained_wind_knots
)
E NameError: name 'tc_tracks' is not defined
climada/hazard/tc_tracks.py:1716: NameError
Check warning on line 0 in climada.hazard.test.test_tc_tracks_synth.TestSynth
github-actions / Core / Unit Test Results (3.11)
test_random_no_landfall_pass (climada.hazard.test.test_tc_tracks_synth.TestSynth) failed
tests_xml/tests.xml [took 0s]
Raw output
NameError: name 'climada' is not defined
self = <climada.hazard.test.test_tc_tracks_synth.TestSynth testMethod=test_random_no_landfall_pass>
def test_random_no_landfall_pass(self):
"""Test calc_perturbed_trajectories with decay and no historical tracks with landfall"""
tc_track = tc.TCTracks.from_processed_ibtracs_csv(TEST_TRACK_SHORT)
expected_warning = "only %s historical tracks were provided. " % len(
tc_track.data
)
with self.assertLogs("climada.hazard.tc_tracks_synth", level="INFO") as cm:
> tc_track.calc_perturbed_trajectories(use_global_decay_params=False)
climada/hazard/test/test_tc_tracks_synth.py:633:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <climada.hazard.tc_tracks.TCTracks object at 0x7fe4ee4e6790>
kwargs = {'use_global_decay_params': False}
def calc_perturbed_trajectories(self, **kwargs):
"""See function in `climada.hazard.tc_tracks_synth`."""
> climada.hazard.tc_tracks_synth.calc_perturbed_trajectories(self, **kwargs)
E NameError: name 'climada' is not defined
climada/hazard/tc_tracks.py:1396: NameError
Check warning on line 0 in climada.hazard.test.test_tc_tracks_synth.TestSynth
github-actions / Core / Unit Test Results (3.11)
test_random_walk_decay_pass (climada.hazard.test.test_tc_tracks_synth.TestSynth) failed
tests_xml/tests.xml [took 0s]
Raw output
NameError: name 'climada' is not defined
self = <climada.hazard.test.test_tc_tracks_synth.TestSynth testMethod=test_random_walk_decay_pass>
def test_random_walk_decay_pass(self):
"""Test land decay is called from calc_perturbed_trajectories."""
assert TC_ANDREW_FL.is_file()
tc_track = tc.TCTracks.from_processed_ibtracs_csv(TC_ANDREW_FL)
nb_synth_tracks = 2
# should work if using global parameters
with self.assertLogs("climada.hazard.tc_tracks_synth", level="DEBUG") as cm0:
> tc_track.calc_perturbed_trajectories(
nb_synth_tracks=nb_synth_tracks,
seed=25,
decay=True,
use_global_decay_params=True,
)
climada/hazard/test/test_tc_tracks_synth.py:684:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <climada.hazard.tc_tracks.TCTracks object at 0x7fe4b4f80b10>
kwargs = {'decay': True, 'nb_synth_tracks': 2, 'seed': 25, 'use_global_decay_params': True}
def calc_perturbed_trajectories(self, **kwargs):
"""See function in `climada.hazard.tc_tracks_synth`."""
> climada.hazard.tc_tracks_synth.calc_perturbed_trajectories(self, **kwargs)
E NameError: name 'climada' is not defined
climada/hazard/tc_tracks.py:1396: NameError
Check warning on line 0 in climada.hazard.test.test_tc_tracks_synth.TestSynth
github-actions / Core / Unit Test Results (3.11)
test_random_walk_identical_pass (climada.hazard.test.test_tc_tracks_synth.TestSynth) failed
tests_xml/tests.xml [took 0s]
Raw output
NameError: name 'climada' is not defined
self = <climada.hazard.test.test_tc_tracks_synth.TestSynth testMethod=test_random_walk_identical_pass>
def test_random_walk_identical_pass(self):
"""Test 0 perturbation leads to identical tracks."""
tc_track = tc.TCTracks.from_processed_ibtracs_csv(TC_ANDREW_FL)
nb_synth_tracks = 2
> tc_track.calc_perturbed_trajectories(
nb_synth_tracks=nb_synth_tracks,
max_shift_ini=0,
max_dspeed_rel=0,
max_ddirection=0,
decay=False,
)
climada/hazard/test/test_tc_tracks_synth.py:730:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <climada.hazard.tc_tracks.TCTracks object at 0x7fe4edb7c7d0>
kwargs = {'decay': False, 'max_ddirection': 0, 'max_dspeed_rel': 0, 'max_shift_ini': 0, ...}
def calc_perturbed_trajectories(self, **kwargs):
"""See function in `climada.hazard.tc_tracks_synth`."""
> climada.hazard.tc_tracks_synth.calc_perturbed_trajectories(self, **kwargs)
E NameError: name 'climada' is not defined
climada/hazard/tc_tracks.py:1396: NameError
Check warning on line 0 in climada.hazard.test.test_tc_tracks_synth.TestSynth
github-actions / Core / Unit Test Results (3.11)
test_random_walk_ref_pass (climada.hazard.test.test_tc_tracks_synth.TestSynth) failed
tests_xml/tests.xml [took 0s]
Raw output
NameError: name 'climada' is not defined
self = <climada.hazard.test.test_tc_tracks_synth.TestSynth testMethod=test_random_walk_ref_pass>
def test_random_walk_ref_pass(self):
"""Test against MATLAB reference."""
tc_track = tc.TCTracks.from_processed_ibtracs_csv(TEST_TRACK_SHORT)
nb_synth_tracks = 2
> tc_track.calc_perturbed_trajectories(
nb_synth_tracks=nb_synth_tracks, seed=25, decay=False
)
climada/hazard/test/test_tc_tracks_synth.py:641:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <climada.hazard.tc_tracks.TCTracks object at 0x7fe4ee1641d0>
kwargs = {'decay': False, 'nb_synth_tracks': 2, 'seed': 25}
def calc_perturbed_trajectories(self, **kwargs):
"""See function in `climada.hazard.tc_tracks_synth`."""
> climada.hazard.tc_tracks_synth.calc_perturbed_trajectories(self, **kwargs)
E NameError: name 'climada' is not defined
climada/hazard/tc_tracks.py:1396: NameError
Check warning on line 0 in climada.hazard.test.test_tc_tracks_synth.TestSynth
github-actions / Core / Unit Test Results (3.11)
test_random_walk_single_point (climada.hazard.test.test_tc_tracks_synth.TestSynth) failed
tests_xml/tests.xml [took 1s]
Raw output
NameError: name 'climada' is not defined
self = <climada.hazard.test.test_tc_tracks_synth.TestSynth testMethod=test_random_walk_single_point>
def test_random_walk_single_point(self):
found = False
for year in range(1951, 1981):
tc_track = tc.TCTracks.from_ibtracs_netcdf(
provider="usa", year_range=(year, year), discard_single_points=False
)
singlept = np.where([x["time"].size == 1 for x in tc_track.data])[0]
found = len(singlept) > 0
if found:
# found a case with a single-point track, keep max three tracks for efficiency
tc_track.data = tc_track.data[max(0, singlept[0] - 1) : singlept[0] + 2]
n_tr = tc_track.size
tc_track.equal_timestep()
> tc_track.calc_perturbed_trajectories(nb_synth_tracks=2)
climada/hazard/test/test_tc_tracks_synth.py:770:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <climada.hazard.tc_tracks.TCTracks object at 0x7fe4ed984390>
kwargs = {'nb_synth_tracks': 2}
def calc_perturbed_trajectories(self, **kwargs):
"""See function in `climada.hazard.tc_tracks_synth`."""
> climada.hazard.tc_tracks_synth.calc_perturbed_trajectories(self, **kwargs)
E NameError: name 'climada' is not defined
climada/hazard/tc_tracks.py:1396: NameError