Skip to content
Snippets Groups Projects

Resolve "add offset to Seperation of Scales data handler"

1 file
+ 6
5
Compare changes
  • Side-by-side
  • Inline
@@ -205,9 +205,9 @@ class DataHandlerSeparationOfScalesSingleStation(DataHandlerMixedSamplingWithFil
"""
window = -abs(window)
data = self.input_data
self.history = self.stride(data, dim_name_of_shift, window)
self.history = self.stride(data, dim_name_of_shift, window, offset=self.window_history_offset)
def stride(self, data: xr.DataArray, dim: str, window: int) -> xr.DataArray:
def stride(self, data: xr.DataArray, dim: str, window: int, offset: int = 0) -> xr.DataArray:
# this is just a code snippet to check the results of the kz filter
# import matplotlib
@@ -218,12 +218,13 @@ class DataHandlerSeparationOfScalesSingleStation(DataHandlerMixedSamplingWithFil
time_deltas = np.round(self.time_delta(self.cutoff_period)).astype(int)
start, end = window, 1
res = []
window_array = self.create_index_array(self.window_dim, range(start, end), squeeze_dim=self.target_dim)
_range = list(map(lambda x: x + offset, range(start, end)))
window_array = self.create_index_array(self.window_dim, _range, squeeze_dim=self.target_dim)
for delta, filter_name in zip(np.append(time_deltas, 1), data.coords["filter"]):
res_filter = []
data_filter = data.sel({"filter": filter_name})
for w in range(start, end):
res_filter.append(data_filter.shift({dim: -w * delta}))
for w in _range:
res_filter.append(data_filter.shift({dim: -(w - offset) * delta - offset}))
res_filter = xr.concat(res_filter, dim=window_array).chunk()
res.append(res_filter)
res = xr.concat(res, dim="filter").compute()
Loading