Skip to content
Snippets Groups Projects
Commit b333c7d2 authored by lukas leufen's avatar lukas leufen
Browse files

Merge branch 'lukas_issue305_feat_offset-seperation-of-scales-data-handler' into 'develop'

Resolve "add offset to Seperation of Scales data handler"

See merge request !294
parents 28ef8cbe e67e16c3
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",!299Draft: Merge default data handler and preprocessing support parameter use_multiprocessing....,!294Resolve "add offset to Seperation of Scales data handler",!259Draft: Resolve "WRF-Datahandler should inherit from SingleStationDatahandler"
Pipeline #66392 passed with warnings
......@@ -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()
......
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