metno/gridpp

Implement time window methods

Closed this issue · 0 comments

Function:
vec2 window(const vec2& array, int length, gridpp::Statistic statistic, bool before=false, bool keep_missing=false, bool missing_edges=true)

Parameters:
array: dimensions (case, time)
length: window length
statistic: what statistic to apply to window
before: if false, centre the window on each timestep, if true, make the window end at the timestep
keep_missing: if true, set window value to missing if one or more values in window is missing
missing_edges: if true, set the window value to missing, if the window goes outside the edges

Existing code:
https://github.com/metno/gridpp/blob/master/src/client/Calibrator/Window.cpp

Useful functions:
gridpp::calc_statistic to compute the statistic for a subarray

Python example:

array = np.expand_dims([0, 1, 5, 6, 7], 0)
gridpp.window(array, 3, gridpp.Mean, before=True, keep_missing=False, missing_edges=True)
expected = [np.nan, np.nan, 2, 4, 6]