Skip to content

Commit

Permalink
Set vel_pert_method=None
Browse files Browse the repository at this point in the history
Turns out that vel_pert_method='bps' would return all NaNs with a zero motion field (python=3.8)
  • Loading branch information
dnerini committed Jan 9, 2021
1 parent 56ad50e commit ef6288f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions pysteps/tests/test_nowcasts_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_steps_callback(tmp_path):
motion_field = np.zeros((2, *field_shape))

exporter = io.initialize_forecast_exporter_netcdf(
outpath=tmp_path,
outpath=tmp_path.as_posix(),
outfnprefix="test_steps",
startdate=startdate,
timestep=timestep,
Expand All @@ -125,7 +125,7 @@ def test_steps_callback(tmp_path):
def callback(array):
return io.export_forecast_dataset(array, exporter)

out = nowcasts.get_method("steps")(
precip_output = nowcasts.get_method("steps")(
precip_input,
motion_field,
timesteps=n_timesteps,
Expand All @@ -134,6 +134,7 @@ def callback(array):
timestep=timestep,
seed=42,
n_ens_members=n_ens_members,
vel_pert_method=None,
callback=callback,
return_output=True,
)
Expand All @@ -144,16 +145,16 @@ def callback(array):
assert os.path.exists(tmp_file) and os.path.getsize(tmp_file) > 0

# assert that the file can be read by the nowcast importer
out_netcdf, metadata_netcdf = io.import_netcdf_pysteps(tmp_file)
precip_netcdf, metadata_netcdf = io.import_netcdf_pysteps(tmp_file, dtype="float64")

# assert that the dimensionality of the array is as expected
assert out_netcdf.ndim == 4, "Wrong number of dimensions"
assert out_netcdf.shape[0] == n_ens_members, "Wrong ensemble size"
assert out_netcdf.shape[1] == n_timesteps, "Wrong number of lead times"
assert out_netcdf.shape[2:] == field_shape, "Wrong field shape"
assert precip_netcdf.ndim == 4, "Wrong number of dimensions"
assert precip_netcdf.shape[0] == n_ens_members, "Wrong ensemble size"
assert precip_netcdf.shape[1] == n_timesteps, "Wrong number of lead times"
assert precip_netcdf.shape[2:] == field_shape, "Wrong field shape"

# assert that the saved output is the same as the original output
assert out == pytest.approx(out_netcdf), "Wrong output values"
assert np.allclose(precip_netcdf, precip_output, equal_nan=True), "Wrong output values"

# assert that leadtimes and timestamps are as expected
td = timedelta(minutes=timestep)
Expand Down

0 comments on commit ef6288f

Please sign in to comment.