Changeset 281 in lmdz_wrf
- Timestamp:
- Feb 25, 2015, 1:11:11 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var_tools.py
r280 r281 10311 10311 varns = objfile.variables 10312 10312 else: 10313 varns = varn10313 varns = [varn] 10314 10314 10315 10315 if len(lonobj.shape) == 3: … … 10453 10453 10454 10454 # circle values 10455 cslicev.append(gtrajvals[it,0])10456 10455 circdist = radius_dist(dimy, dimx, gtrajvals[it,2], gtrajvals[it,1]) 10457 10456 … … 10497 10496 cxrangeslice2D.append([gtrajvals[it,1]-Nrad, gtrajvals[it,1]+Nrad + 1]) 10498 10497 10499 10500 10498 iline = iline + 1 10501 10499 10502 10500 trajobj.close() 10503 10504 print 'Lluis _________'10505 print yrangeslice10506 10507 quit()10508 10501 10509 10502 # Creation of the netCDF file … … 10526 10519 ## 10527 10520 ivar = 0 10521 print 'Lluis varns:',varns 10522 10528 10523 for vn in varns: 10529 10524 varobj = objfile.variables[vn] 10530 10525 Nvardims = len(varobj.shape) 10526 10527 print ' ' + fname + ": getting '" + vn + "' ... .. ." 10531 10528 10532 10529 slicev = [] … … 10575 10572 10576 10573 for it in range(dimt): 10577 # box values10578 print it,'/',dimt, yrangeslice10579 quit()10580 slicev.append(slice(0,dimz))10581 slicev.append(slice(yrangeslice[it]))10582 slicev.append(slice(xrangeslice[it]))10583 10584 slicevnoT.append(slice(0,dimz))10585 slicevnoT.append(slice(yrangeslice[it]))10586 slicevnoT.append(slice(xrangeslice[it]))10587 10588 slice2D.append(slice(0,dimz))10589 slice2D.append(slice(yrangeslice2D[it]))10590 slice2D.append(slice(xrangeslice2D[it]))10591 10574 10592 10575 if gtrajvals[it,2]-box2 < 0 or gtrajvals[it,2]+box2 + 1 > dimy + 1 \ 10593 10576 or gtrajvals[it,1]-box2 < 0 or gtrajvals[it,1]+box2 + 1 > dimx + 1: 10594 10577 10595 rvarvalst = np.ones((dimz,Nrad*2+1,Nrad*2+1),dtype=np.float)* \10578 varvalst = np.ones((dimz,Nrad*2+1,Nrad*2+1),dtype=np.float)* \ 10596 10579 fillValue 10580 10581 # box values 10582 slicev.append(slice(0,dimz)) 10583 slicev.append(slice(yrangeslice[it])) 10584 slicev.append(slice(xrangeslice[it])) 10585 10586 slicevnoT.append(slice(0,dimz)) 10587 slicevnoT.append(slice(yrangeslice[it])) 10588 slicevnoT.append(slice(xrangeslice[it])) 10589 10590 slice2D.append(slice(0,dimz)) 10591 slice2D.append(slice(yrangeslice2D[it])) 10592 slice2D.append(slice(xrangeslice2D[it])) 10597 10593 10598 10594 varvalst[tuple(slice2D)] = varobj[tuple(slicev)] … … 10622 10618 slice2D.append(slice(gtrajvals[it,1]-box2, gtrajvals[it,1]+box2 +\ 10623 10619 1)) 10624 10620 print 'Lluis',it,'shapes varvalst:',varvals.shape,'varobj:',slicev 10625 10621 varvalst = varobj[tuple(slicev)] 10626 10622 # box values … … 10788 10784 10789 10785 for it in range(dimt): 10790 # box values 10791 slicev.append(slice(yrangeslice[it])) 10792 slicev.append(slice(xrangeslice[it])) 10793 10794 slicevnoT.append(slice(yrangeslice[it])) 10795 slicevnoT.append(slice(xrangeslice[it])) 10796 10797 slice2D.append(slice(yrangeslice2D[it])) 10798 slice2D.append(slice(xrangeslice2D[it])) 10799 10786 slicev = [] 10787 slice2D = [] 10788 slicevnoT = [] 10789 cslicev = [] 10790 cslice2D = [] 10791 cslicevnoT = [] 10792 10793 slicev.append(gtrajvals[it,0]) 10800 10794 if gtrajvals[it,2]-box2 < 0 or gtrajvals[it,2]+box2 + 1 > dimy + 1 \ 10801 10795 or gtrajvals[it,1]-box2 < 0 or gtrajvals[it,1]+box2 + 1 > dimx + 1: 10796 # box values 10797 slicev.append(slice(yrangeslice[0][it],yrangeslice[1][it])) 10798 slicev.append(slice(xrangeslice[0][it],xrangeslice[1][it])) 10799 10800 slicevnoT.append(slice(yrangeslice[0][it],yrangeslice[1][it])) 10801 slicevnoT.append(slice(xrangeslice[0][it],xrangeslice[1][it])) 10802 10803 slice2D.append(slice(yrangeslice2D[0][it],yrangeslice2D[1][it])) 10804 slice2D.append(slice(xrangeslice2D[0][it],xrangeslice2D[1][it])) 10802 10805 10803 10806 rvarvalst = np.ones((Nrad*2+1, Nrad*2+1),dtype=np.float)*fillValue 10804 10807 10808 print it,'Lluis: shapes yrangeslice2D:',yrangeslice2D[it],'xrangeslice:',xrangeslice[it] 10809 print it,'Lluis: shapes slice2D:',slice2D,'slicev:',slicev 10810 print it,'Lluis: shapes varvalst:',varvalst.shape,'varobj:',varobj.shape 10805 10811 varvalst[tuple(slice2D)] = varobj[tuple(slicev)] 10806 10812 varvals[it,:,:] = varvalst … … 10835 10841 1)) 10836 10842 10843 print 'Lluis: shapes obj:',varobj.shape,'slice:',slicev 10837 10844 varvalst = varobj[tuple(slicev)] 10838 10845 # box values … … 10857 10864 10858 10865 # Circle values 10859 cslicev.append(slice(cyrangeslice[it])) 10860 cslicev.append(slice(cxrangeslice[it])) 10861 10862 cslicevnoT.append(slice(cyrangeslice[it])) 10863 cslicevnoT.append(slice(cxrangeslice[it])) 10864 10865 cslice2D.append(slice(cyrangeslice2D[it])) 10866 cslice2D.append(slice(cxrangeslice2D[it])) 10866 cslicev.append(gtrajvals[it,0]) 10867 10867 if gtrajvals[it,2]-Nrad < 0 or gtrajvals[it,2]+Nrad + 1 > dimy + 1 \ 10868 10868 or gtrajvals[it,1]-Nrad < 0 or gtrajvals[it,1]+Nrad + 1 > dimx + 1: 10869 cslicev.append(slice(cyrangeslice[it])) 10870 cslicev.append(slice(cxrangeslice[it])) 10871 10872 cslicevnoT.append(slice(cyrangeslice[it])) 10873 cslicevnoT.append(slice(cxrangeslice[it])) 10874 10875 cslice2D.append(slice(cyrangeslice2D[it])) 10876 cslice2D.append(slice(cxrangeslice2D[it])) 10869 10877 10870 10878 rvarvalst = np.ones((Nrad*2+1,Nrad*2+1),dtype=np.float)*fillValue … … 10887 10895 10888 10896 else: 10889 slicev.append(slice(gtrajvals[it,2]-Nrad,gtrajvals[it,2]+Nrad+1))10890 slicev.append(slice(gtrajvals[it,1]-Nrad,gtrajvals[it,1]+Nrad+1))10891 slicevnoT.append(slice(gtrajvals[it,2]-Nrad, gtrajvals[it,2]+ \10897 cslicev.append(slice(gtrajvals[it,2]-Nrad,gtrajvals[it,2]+Nrad+1)) 10898 cslicev.append(slice(gtrajvals[it,1]-Nrad,gtrajvals[it,1]+Nrad+1)) 10899 cslicevnoT.append(slice(gtrajvals[it,2]-Nrad, gtrajvals[it,2]+ \ 10892 10900 Nrad+1)) 10893 slicevnoT.append(slice(gtrajvals[it,1]-Nrad, gtrajvals[it,1]+ \10901 cslicevnoT.append(slice(gtrajvals[it,1]-Nrad, gtrajvals[it,1]+ \ 10894 10902 Nrad+1)) 10895 10903 10896 slice2D.append(slice(gtrajvals[it,2]-Nrad,gtrajvals[it,2]+Nrad+1))10897 slice2D.append(slice(gtrajvals[it,1]-Nrad,gtrajvals[it,1]+Nrad+1))10904 cslice2D.append(slice(gtrajvals[it,2]-Nrad,gtrajvals[it,2]+Nrad+1)) 10905 cslice2D.append(slice(gtrajvals[it,1]-Nrad,gtrajvals[it,1]+Nrad+1)) 10898 10906 10899 10907 rvarvalst = varobj[tuple(cslicev)] … … 10902 10910 rvarvalst = np.where(cdist > np.float(Nrad),fillValue,rvarvalst) 10903 10911 10912 10913 print 'Lluis shapes: rvarvals:',rvarvals[it,:,:].shape,'rvarvalst:',rvarvalst.shape 10904 10914 rvarvals[it,:,:] = rvarvalst 10905 10915 … … 11044 11054 # 'control/wss.nc', 'wss') 11045 11055 # in camelot, /bdd/PCER/workspace/lfita/etudes/FF/50sims 11046 compute_tevolboxtraj('001/trajectory.dat@0,XLONG,XLAT,ZNU,Times,wrf,3,3', \11047 '001/full_concatenated.nc', 'PSFC')11056 #compute_tevolboxtraj('001/trajectory.dat@0,XLONG,XLAT,ZNU,Times,wrf,3,3', \ 11057 # '001/full_concatenated.nc', 'PSFC') 11048 11058 11049 11059 def numVector_String(vec,char):
Note: See TracChangeset
for help on using the changeset viewer.