Sum A Daily Time Series Into A Monthly Time Series With A Nan Value Threshold
I have a 3D time series data matrix from January 1st, 1979 to December 31st, 2005. The matrix is currently 9862x360x720 (daily rainfall x 0.5° latitude x 0.5° longitude). I want
Solution 1:
I believe this does what you want:
NaN = float("nan") # Make a constant for NaN
def sum_nan_threshold(iterable, *, nan_threshold=10):
if sum(x == NaN for x in iterable) >= nan_threshold: # Are there more NaNs then threshold?
return NaN
else:
return sum(x for x in iterable if x != NaN) # Else sum up if not equal to NaN
Post a Comment for "Sum A Daily Time Series Into A Monthly Time Series With A Nan Value Threshold"