- Timestamp:
- May 26, 2015, 1:03:19 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var_tools.py
r421 r429 10847 10847 return dist 10848 10848 10849 def lonlat2D(lon,lat): 10850 """ Function to return lon, lat 2D matrices from any lon,lat matrix 10851 lon= matrix with longitude values 10852 lat= matrix with latitude values 10853 """ 10854 fname = 'lonlat2D' 10855 10856 if len(lon.shape) != len(lat.shape): 10857 print errormsg 10858 print ' ' + fname + ': longitude values with shape:', lon.shape, \ 10859 'is different that latitude values with shape:', lat.shape, '(dif. size) !!' 10860 quit(-1) 10861 10862 if len(lon.shape) == 3: 10863 lonvv = lon[0,:,:] 10864 latvv = lat[0,:,:] 10865 elif len(lon.shape) == 2: 10866 lonvv = lon[:] 10867 latvv = lat[:] 10868 elif len(lon.shape) == 1: 10869 lonlatv = np.meshgrid(lon[:],lat[:]) 10870 lonvv = lonlatv[0] 10871 latvv = lonlatv[1] 10872 10873 return lonvv, latvv 10874 10849 10875 def compute_tevolboxtraj(values, ncfile, varn): 10850 10876 """ Function to compute tevolboxtraj: temporal evolution at a given point along … … 10878 10904 check_arguments(fname,len(arguments.split(',')),arguments,',',8) 10879 10905 10880 10881 10906 trajfile = values.split(',')[0].split('@')[0] 10882 10907 Tbeg = int(values.split(',')[0].split('@')[1]) … … 10931 10956 varns = [varn] 10932 10957 10933 if len(lonobj.shape) == 3: 10934 lonv = lonobj[0,:,:] 10935 latv = latobj[0,:,:] 10936 elif len(lonobj.shape) == 2: 10937 lonv = lonobj[:] 10938 latv = latobj[:] 10958 lonv, latv = lonlat2D(lonobj[:],latobj[:]) 10939 10959 10940 10960 dimx = lonv.shape[1] … … 10942 10962 10943 10963 timv = timobj[:] 10944 10945 10964 10946 10965 # Selecting accordingly a trajectory … … 11133 11152 newdim = objofile.createDimension('time', None) 11134 11153 11135 st atnames = ['minbox', 'maxbox', 'meanbox', 'mean2box', 'stdevbox']11154 stsn = ['min', 'max', 'mean', 'mean2', 'stdev', 'ac'] 11136 11155 vstlname = ['minimum value within', 'maximum value within', 'mean value within', \ 11137 'squared mean value within', 'standard deviation value within'] 11138 cstatnames = ['mincircle','maxcircle','meancircle','mean2circle','stdevcircle'] 11156 'squared mean value within', 'standard deviation value within', \ 11157 'accumulated value within'] 11158 Nsts = len(stsn) 11159 statnames = [] 11160 cstatnames = [] 11161 for i in range(Nsts): 11162 statnames.append(stsn[i] + 'box') 11163 cstatnames.append(stsn[i] + 'circle') 11139 11164 11140 11165 # Getting values … … 11200 11225 rlatvals = np.ones(tuple([Ttraj,dimz,Nrad*2+1,Nrad*2+1]), dtype=np.float) 11201 11226 11202 statvarvals = np.ones(tuple([Ttraj,dimz, 6]), dtype=np.float)11203 rstatvarvals = np.ones(tuple([Ttraj,dimz, 6]), dtype=np.float)11227 statvarvals = np.ones(tuple([Ttraj,dimz,Nsts]), dtype=np.float) 11228 rstatvarvals = np.ones(tuple([Ttraj,dimz,Nsts]), dtype=np.float) 11204 11229 11205 11230 for it in range(Ttraj): … … 11248 11273 statvarvals[it,iz,5] = np.sqrt(statvarvals[it,iz,4] - \ 11249 11274 statvarvals[it,iz,3]*statvarvals[it,iz,3]) 11275 statvarvals[it,iz,6] = np.sum(varvalst[iz,:,:]) 11276 11250 11277 else: 11251 11278 slicev.append(slice(0,dimz)) … … 11280 11307 statvarvals[it,iz,5] = np.sqrt(statvarvals[it,iz,4] - \ 11281 11308 statvarvals[it,iz,3]*statvarvals[it,iz,3]) 11309 statvarvals[it,iz,6] = np.sum(varvalst[iz,:,:]) 11282 11310 11283 11311 # Circle values … … 11324 11352 rstatvarvals[it,iz,5] = np.sqrt(rstatvarvals[it,iz,4] - \ 11325 11353 rstatvarvals[it,iz,3]*rstatvarvals[it,iz,3]) 11354 rstatvarvals[it,iz,6] = np.sum(varvalst[iz,:,:]) 11326 11355 11327 11356 else: … … 11364 11393 rstatvarvals[it,iz,5] = np.sqrt(rstatvarvals[it,iz,4] - \ 11365 11394 rstatvarvals[it,iz,3]*rstatvarvals[it,iz,3]) 11395 rstatvarvals[it,iz,6] = maskedvals[iz,:,:].sum() 11366 11396 11367 11397 # print 'statistics:',rstatvarvals[it,:] … … 11447 11477 rlatvals = np.ones(tuple([Ttraj,Nrad*2+1,Nrad*2+1]), dtype=np.float) 11448 11478 11449 statvarvals = np.ones(tuple([Ttraj, 6]), dtype=np.float)11450 rstatvarvals = np.ones(tuple([Ttraj, 6]), dtype=np.float)11479 statvarvals = np.ones(tuple([Ttraj,Nsts]), dtype=np.float) 11480 rstatvarvals = np.ones(tuple([Ttraj,Nsts]), dtype=np.float) 11451 11481 11452 11482 for it in range(Ttraj): … … 11489 11519 statvarvals[it,5] = np.sqrt(statvarvals[it,4] - \ 11490 11520 statvarvals[it,3]*statvarvals[it,3]) 11521 statvarvals[it,6] = maskedvals.sum() 11491 11522 11492 11523 varvalst[tuple(slice2D)] = lonv[tuple(slicevnoT)] … … 11523 11554 statvarvals[it,5] = np.sqrt(statvarvals[it,4] - \ 11524 11555 statvarvals[it,3]*statvarvals[it,3]) 11556 statvarvals[it,6] = np.sum(varvalst) 11525 11557 11526 11558 varvalst = lonv[tuple(slicevnoT)] … … 11561 11593 rstatvarvals[it,5] = np.sqrt(rstatvarvals[it,4] - \ 11562 11594 rstatvarvals[it,3]*rstatvarvals[it,3]) 11595 rstatvarvals[it,6] = maskedvals2.sum() 11563 11596 11564 11597 else: … … 11593 11626 rstatvarvals[it,5] = np.sqrt(rstatvarvals[it,4] - \ 11594 11627 rstatvarvals[it,3]*rstatvarvals[it,3]) 11628 rstatvarvals[it,6] = maskedvals.sum() 11595 11629 11596 11630 # print 'statistics:',rstatvarvals[it,:]
Note: See TracChangeset
for help on using the changeset viewer.