def calc_stats(data,mask=None): """calculate basic statistics, annual means, Wet-day fraction, (99%,other...) should use stat_down.stats in most (all?) datasets, missing values are 1e20, in case they are 9999 in the future use a lower threshold to mask the data """ # data structure to store output in stats=Bunch() # if we weren't supplied a mask calculate it from the current data if mask==None: mask=data[0,...]>9000 # store mean annual precip in a masked array stats.mean=np.ma.array(np.mean(data,axis=0)*365.25,mask=mask) print(data.shape) # stddev takes a while to calculate and we don't care that much, add it later if desired # stdval=np.ma.array(np.std(data,axis=0),mask=mask) # store wet day fraction as a masked array stats.wetfrac=np.ma.array(wet_frac(data),mask=mask) return stats