Skip to content
Snippets Groups Projects
Commit 04b75e20 authored by leufen1's avatar leufen1
Browse files

update filter tests

parent c8080c7d
No related branches found
No related tags found
3 merge requests!522filter can now combine obs, forecast, and apriori for first iteration. Further...,!521Resolve "release v2.4.0",!517Resolve "load ifs data"
Pipeline #142576 failed
......@@ -852,7 +852,6 @@ class ClimateFIRFilter(FIRFilter):
filt_input_coll.append(trimmed)
# visualization
plot_dates = [filt.coords[time_dim][49].values]
plot_data.extend(self.create_visualization(filt, d, filter_input_data, plot_dates, time_dim, new_dim,
sampling, extend_length_history, extend_length_future,
minimum_length, h, var, extend_opts, extend_end, offset, f))
......
......@@ -294,13 +294,13 @@ class TestClimateFIRFilter:
def test_trim_data_to_minimum_length(self, xr_array, time_dim):
obj = object.__new__(ClimateFIRFilter)
xr_array = obj._shift_data(xr_array, range(-20, 1), time_dim, new_dim="window")
res = obj._trim_data_to_minimum_length(xr_array, 5, "window")
res = obj._trim_data_to_minimum_length(xr_array, -5, "window")
assert xr_array.shape == (21, 100, 1)
assert res.shape == (6, 100, 1)
res = obj._trim_data_to_minimum_length(xr_array, 30, "window")
res = obj._trim_data_to_minimum_length(xr_array, -30, "window")
assert res.shape == (21, 100, 1)
xr_array = obj._shift_data(xr_array.sel(window=0), range(-20, 5), time_dim, new_dim="window")
res = obj._trim_data_to_minimum_length(xr_array, 5, "window", extend_length_future=2)
res = obj._trim_data_to_minimum_length(xr_array, -5, "window", extend_length_future=2)
assert res.shape == (8, 100, 1)
def test_create_full_filter_result_array(self, xr_array, time_dim):
......@@ -321,7 +321,7 @@ class TestClimateFIRFilter:
assert len(res) == 5
# check filter data properties
assert res[0].shape == (*xr_array_long_with_var.shape, int(filter_order+1)/2 + 24 + 2)
assert res[0].shape == (*xr_array_long_with_var.shape, 24 + 2)
assert res[0].dims == (*xr_array_long_with_var.dims, "window")
# check filter properties
......@@ -351,7 +351,7 @@ class TestClimateFIRFilter:
var_dim=var_dim, new_dim="total_new_dim", window=("kaiser", 5), minimum_length=1000,
apriori=apriori, plot_dates=plot_dates)
assert res[0].shape == (*xr_array_long_with_var.shape, int(10 * 24 + 1 + 1) / 2 + 1000 + 2)
assert res[0].shape == (*xr_array_long_with_var.shape, 1000 + 2)
assert res[0].dims == (*xr_array_long_with_var.dims, "total_new_dim")
assert np.testing.assert_almost_equal(
res[2], obj._calculate_filter_coefficients(("kaiser", 5), filter_order, 0.05, 24)) is None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment