I have a 1-d numpy array which I would like to downsample. Any of the following methods are acceptable if the downsampling raster doesn\'t perfectly fit the data:
If array size is not divisible by downsampling factor (R), reshaping (splitting) of array can be done using np.linspace followed by mean of each subarray.
input_arr = np.arange(531)
R = 150 (number of split)
split_arr = np.linspace(0, len(input_arr), num=R+1, dtype=int)
dwnsmpl_subarr = np.split(input_arr, split_arr[1:])
dwnsmpl_arr = np.array( list( np.mean(item) for item in dwnsmpl_subarr[:-1] ) )