Changeset 1558 in lmdz_wrf for trunk/tools/generic_tools.py
- Timestamp:
- May 9, 2017, 3:48:14 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/generic_tools.py
r1552 r1558 19 19 main = 'nc_var_tools.py' 20 20 21 errormsg='ERROR -- error -- ERROR -- error' 22 warnmsg='WARNING -- warning -- WARNING -- warning' 21 errormsg = 'ERROR -- error -- ERROR -- error' 22 warnmsg = 'WARNING -- warning -- WARNING -- warning' 23 infmsg = 'INFORMATION -- information -- INFORMATION -- information' 23 24 24 25 fillValue = 1.e20 … … 3688 3689 return pearsonr 3689 3690 3690 def mask_quantiles(maskmat, Nquants ):3691 def mask_quantiles(maskmat, Nquants, Notenough=True): 3691 3692 """ Function to provide the quantiles of a masked array 20 for %5 bins (21 in total) 3692 3693 """ 3693 3694 import numpy.ma as ma 3694 3695 fillValue = 1.e20 3696 3695 fname = 'mask_quantiles' 3696 3697 if type(maskmat) != type(mamat): 3698 maskvals = np.zeros((maskmat.shape), dtype=bool) 3699 else: 3700 maskvals = maskmat.mask 3697 3701 sortmat = maskmat.flatten().copy() 3698 3702 sortmat.sort() 3699 3703 quants = np.zeros(Nquants+1, dtype=type(maskmat[0])) 3700 3704 Nv = ma.size(maskmat) 3701 NoMask= maskmat.count()3705 NoMask=np.sum(~maskvals) 3702 3706 3703 3707 if NoMask < Nquants: 3704 quants[:] = fillValue 3708 if Notenough: 3709 print errormsg 3710 print ' ' + fname + ': Not enough data=', NoMask, 'to compute', Nquants,\ 3711 'quantiles !!' 3712 quit(-1) 3713 else: 3714 quants = gen.fillValueF 3705 3715 else: 3706 3716 for iq in range(Nquants):
Note: See TracChangeset
for help on using the changeset viewer.