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

filter plots different seasons, filter returns data with missing values now (not squeezed version)

parent 82c4ba1e
Branches
Tags
5 merge requests!319add all changes of dev into release v1.4.0 branch,!318Resolve "release v1.4.0",!317enabled window_lead_time=1,!295Resolve "data handler FIR filter",!259Draft: Resolve "WRF-Datahandler should inherit from SingleStationDatahandler"
Pipeline #67999 passed
......@@ -230,13 +230,16 @@ class ClimateFIRFilter:
# create new time axis
factor = 1 if td_type == "D" else 24
start = coords[time_dim][-1].values.astype("datetime64[%s]" % td_type)
end = coords[time_dim][-1].values.astype("datetime64[%s]" % td_type) + np.timedelta64(extend_range * factor,
end = coords[time_dim][-1].values.astype("datetime64[%s]" % td_type) + np.timedelta64(
extend_range * factor + 1,
td_type)
new_time_axis = np.arange(start, end).astype("datetime64[ns]")
# extract old values to use with new axis
start = coords[time_dim][-1].values.astype("datetime64[%s]" % td_type) - np.timedelta64(
extend_range * factor - 1, td_type)
extend_range * factor, td_type)
# start = coords[time_dim][-1].values.astype("datetime64[%s]" % td_type) - np.timedelta64(
# extend_range * factor, td_type)
end = coords[time_dim][-1].values.astype("datetime64[%s]" % td_type)
new_values = apriori.sel({time_dim: slice(start, end)})
new_values.coords[time_dim] = new_time_axis
......@@ -331,19 +334,24 @@ class ClimateFIRFilter:
# plot
if self.plot_path is not None:
for i, time_pos in enumerate([0.25, 1.5, 2.75, 4]): # [0.25, 1.5, 2.75, 4] x 365 days
try:
pos = 720 * fs
pos = int(time_pos * 365 * fs)
filter_example = filter_input_data.isel({time_dim: pos})
t0 = filter_example.coords[time_dim].values
t_slice = filter_input_data.isel(
{time_dim: slice(pos - int((length - 1) / 2), pos + int((length - 1) / 2) + 1)}).coords[
time_dim].values
self.plot(data, filter_example, var_dim, time_dim, t_slice, t0, plot_index)
self.plot(data, filter_example, var_dim, time_dim, t_slice, t0, f"{plot_index}_{i}")
except IndexError:
pass
# select only values at tmp dimension 0 at each point in time
return filt.sel({new_dim: 0}, drop=True), h, apriori
res = filt.sel({new_dim: 0}, drop=True)
# create result array with same shape like input data, gabs are filled by nans
res_full = xr.ones_like(data) * np.nan
res_full.loc[res.coords] = res
return res_full, h, apriori
@staticmethod
def _create_tmp_dimension(data):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment