- Timestamp:
- Dec 27, 2018, 8:46:52 PM (6 years ago)
- Location:
- trunk/tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/module_scientific.f90
r2270 r2271 5025 5025 INTEGER :: ix, iy, iu, minvalv 5026 5026 LOGICAL :: single 5027 REAL(r_k), ALLOCATABLE, DIMENSION(:) :: uniques 5028 5027 5029 5028 5030 !!!!!!! Variables … … 5054 5056 END DO 5055 5057 END DO 5056 5057 CALL sortR_K(unique, Nunique) 5058 IF (ALLOCATED(uniques)) DEALLOCATE(uniques) 5059 ALLOCATE(uniques(Nunique)) 5060 uniques(1:Nunique) = unique(1:Nunique) 5061 5062 CALL sortR_K(uniques(1:Nunique), Nunique) 5063 unique(1:Nunique) = uniques(1:Nunique) 5058 5064 5059 5065 END SUBROUTINE unique_matrixRK2D … … 5165 5171 END DO 5166 5172 CASE('count') 5167 CALL unique_matrixRK2D(dx A, dyA, dxA*dyA, varin, Ncounts, icounts)5173 CALL unique_matrixRK2D(dxB, dyB, dxB*dyB, varin, Ncounts, icounts) 5168 5174 IF (Lstats /= Ncounts) THEN 5175 PRINT *,' ' // TRIM(fname) // 'provided:', Lstats 5176 PRINT *,' ' // TRIM(fname) // 'found:', Ncounts, ' :', icounts 5169 5177 WRITE(val1S,'(I3)')Lstats 5170 5178 WRITE(val2S,'(I3)')Ncounts -
trunk/tools/nc_var.py
r2247 r2271 67 67 ## e.g. # nc_var.py -o compute_slices_stats -S 'XLONG,-74.,-36.,4.;XLAT,-62.,18.,2.;HGT,500.,7000.,500.@Time|Times:west_east|XLONG:south_north|XLAT@Time' -f wrfout_d01_1995-01-01_00:00:00 -v T2,Q2 68 68 ## e.g. # nc_var.py -o dimrename -f /media/lluis/ExtDiskC_ext3/DATA/estudios/FPS_Alps/additional/IOP/select/out_irene/simcdx_vars_cape_120lev_cdxwrf2.nc -S Time -v time0 69 ## e.g. # nc_var.py -o area_weighted -f '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' -S 'yes:min,max,mean,stddev,count' -v ct_values,xband_values,box_values,mosaic_values 69 70 70 71 from optparse import OptionParser … … 80 81 # addVar: Operation to add a new variable in a file using exisintg dimensions 81 82 # addvals: Function to add values to a given variable at a given dimension 83 # area_weighted: Function to provide an area weighted statistics within two different values 84 # of matrices assuming regular lon/lat projections without taking into account Earth's curvature 82 85 # CDO_toCF: Function to pass a CDO output file to CF-conventions 83 86 # CFmorzization: Function to provide a CF-compilation version of a variable within a file … … 209 212 # WRF_to_newCF: Function to pass a WRF original file to new CF-conventions file 210 213 211 operations=['addDim', 'addVar', 'addvals', ' CDO_toCF', 'CFmorzization', \212 ' chdimname', 'changevartype',\214 operations=['addDim', 'addVar', 'addvals', 'area_weighted', 'CDO_toCF', \ 215 'CFmorzization', 'chdimname', 'changevartype', \ 213 216 'checkallvars', 'checkAllValues', 'checkNaNs', \ 214 217 'chgtimestep', 'chvarname', 'cleaning_varsfile', 'compute_deaccum', \ … … 291 294 292 295 # Operations which file name is not a real file 293 NotCheckingFile = ['DatesFiles', 'compute_opersvarsfiles', 'file_creation', \ 296 NotCheckingFile = ['area_weighted', 'DatesFiles', 'compute_opersvarsfiles', \ 297 'file_creation', \ 294 298 'join_singlestation_obsfiles', 'join_sounding_obsfiles', 'list_operations', \ 295 299 'merge_files', \ … … 327 331 elif oper == 'addvals': 328 332 ncvar.addvals(opts.values, opts.ncfile, opts.varname) 333 elif oper == 'area_weighted': 334 ncvar.area_weighted(opts.values, opts.ncfile, opts.varname) 329 335 elif oper == 'CDO_toCF': 330 336 ncvar.CDO_toCF(opts.ncfile) -
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.