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
No related branches found
No related tags found
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: ...@@ -230,13 +230,16 @@ class ClimateFIRFilter:
# create new time axis # create new time axis
factor = 1 if td_type == "D" else 24 factor = 1 if td_type == "D" else 24
start = coords[time_dim][-1].values.astype("datetime64[%s]" % td_type) 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(
td_type) extend_range * factor + 1,
td_type)
new_time_axis = np.arange(start, end).astype("datetime64[ns]") new_time_axis = np.arange(start, end).astype("datetime64[ns]")
# extract old values to use with new axis # extract old values to use with new axis
start = coords[time_dim][-1].values.astype("datetime64[%s]" % td_type) - np.timedelta64( 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) end = coords[time_dim][-1].values.astype("datetime64[%s]" % td_type)
new_values = apriori.sel({time_dim: slice(start, end)}) new_values = apriori.sel({time_dim: slice(start, end)})
new_values.coords[time_dim] = new_time_axis new_values.coords[time_dim] = new_time_axis
...@@ -331,19 +334,24 @@ class ClimateFIRFilter: ...@@ -331,19 +334,24 @@ class ClimateFIRFilter:
# plot # plot
if self.plot_path is not None: if self.plot_path is not None:
try: for i, time_pos in enumerate([0.25, 1.5, 2.75, 4]): # [0.25, 1.5, 2.75, 4] x 365 days
pos = 720 * fs try:
filter_example = filter_input_data.isel({time_dim: pos}) pos = int(time_pos * 365 * fs)
t0 = filter_example.coords[time_dim].values filter_example = filter_input_data.isel({time_dim: pos})
t_slice = filter_input_data.isel( t0 = filter_example.coords[time_dim].values
{time_dim: slice(pos - int((length - 1) / 2), pos + int((length - 1) / 2) + 1)}).coords[ t_slice = filter_input_data.isel(
time_dim].values {time_dim: slice(pos - int((length - 1) / 2), pos + int((length - 1) / 2) + 1)}).coords[
self.plot(data, filter_example, var_dim, time_dim, t_slice, t0, plot_index) time_dim].values
except IndexError: self.plot(data, filter_example, var_dim, time_dim, t_slice, t0, f"{plot_index}_{i}")
pass except IndexError:
pass
# select only values at tmp dimension 0 at each point in time # 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 @staticmethod
def _create_tmp_dimension(data): def _create_tmp_dimension(data):
......
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