Changeset 2271 in lmdz_wrf for trunk/tools/nc_var_tools.py
- Timestamp:
- Dec 27, 2018, 8:46:52 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var_tools.py
r2270 r2271 28 28 # addVar: Operation to add a new variable in a file using exisintg dimensions 29 29 # addvals: Function to add values to a given variable at a given dimension 30 # area_weighted: Function to provide an area weighted statistics within two different values 31 # of matrices assuming regular lon/lat projections without taking into account Earth's curvature 30 32 # attrinvar: Check existence of an attribute in a netCDF variable object 31 33 # basicvardef: Function to give the basic attributes to a variable (std_name, long_name, units) … … 27222 27224 quit() 27223 27225 27224 statsavail = ['mean', 'min', 'max', 'mean2', 'stddev' ]27226 statsavail = ['mean', 'min', 'max', 'mean2', 'stddev', 'count'] 27225 27227 # Characteristics of the statistics 27226 27228 statnschars = {'mean': ['spcmean', 'spatial mean', 1], \ … … 27238 27240 27239 27241 for stn in statns: 27240 if not gen.searchInlist(stat savail, stn):27242 if not gen.searchInlist(statnschars.keys(), stn): 27241 27243 print errormsg 27242 27244 print ' ' + fname + ": statistics '" + stn + "' not ready !!" 27243 print ' available ones:', stat nschar.keys()27245 print ' available ones:', statsavail 27244 27246 quit(-1) 27245 27247 … … 27574 27576 varns.append(vn) 27575 27577 27578 varrm = [refvarxn, refvaryn, refvarxbndsn, refvarybndsn, getvarxn, getvaryn, \ 27579 getvarxbndsn, getvarybndsn] 27580 for vn in varrm: 27581 if gen.searchInlist(varns, vn): varns.remove(vn) 27582 27576 27583 for vn in varns: 27577 27584 print ' ' + fname + ": using '" + vn + "' ..." … … 27587 27594 27588 27595 if stn == 'count': 27589 svals = np.unique(var in)27596 svals = np.unique(varvals) 27590 27597 statchar[2] = len(svals) 27591 27598 27592 varout = fsci.module_scientific.spaceweightstats(varin=varvalst,\27599 varoutt = fsci.module_scientific.spaceweightstats(varin=varvalst, \ 27593 27600 ngridsin=Ngridsint, gridsin=gridsint, percentages=percenst, \ 27594 27601 stats=stn, dxa=refdx, dya=refdy, dxb=getdx, dyb=getdy, \ 27595 27602 maxngridsin=Ngridsinmax, lstats=statchar[2]) 27596 27603 27597 varout = varout .transpose()27604 varout = varoutt.transpose() 27598 27605 if statchar[2] == 1: 27599 27606 newvar = onewnc.createVariable(vn + statchar[0], 'f', ('lat','lon')) … … 27601 27608 else: 27602 27609 if stn == 'count': 27603 if not gen.searchInlist(onewnc.dimensions, 'count'):27604 newdim = onewnc.createDimension( 'count', statchar[2])27605 newvar = onewnc.createVariable(vn + 'count', 'f', ('count'))27610 if not gen.searchInlist(onewnc.dimensions, vn+'count'): 27611 newdim = onewnc.createDimension(vn+'count', statchar[2]) 27612 newvar = onewnc.createVariable(vn+'count', 'f', (vn+'count')) 27606 27613 newvar[:] = svals 27607 27614 basicvardef(newvar, vn+'count', 'unique .get. values of ' + \ 27608 27615 vn, ovar.units) 27609 27616 27610 newvar = onewnc.createVariable(vn + statchar[0], 'f', ('count',\27617 newvar = onewnc.createVariable(vn+statchar[0], 'f', (vn+'count', \ 27611 27618 'lat','lon')) 27612 27619 newvar[:] = varout[:] … … 27627 27634 return 27628 27635 27629 fvals= 'reference_data.nc:lon;lon;lon_bnds;-1;lat;lat;lat_bnds;-1,get_data.nc:lon;lon;lon_bnds;-1;lat;lat;lat_bnds;-1'27630 area_weighted('yes:min,max,mean,stddev',fvals,'ct_values')27636 #fvals= 'reference_data.nc:lon;lon;lon_bnds;-1;lat;lat;lat_bnds;-1,get_data.nc:lon;lon;lon_bnds;-1;lat;lat;lat_bnds;-1' 27637 #area_weighted('yes:min,max,mean,stddev',fvals,'ct_values') 27631 27638 27632 27639
Note: See TracChangeset
for help on using the changeset viewer.