- Timestamp:
- Jan 31, 2019, 3:38:37 PM (6 years ago)
- Location:
- trunk/tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/module_scientific.f90
r2304 r2308 5719 5719 END DO 5720 5720 5721 IF (s1 == ss1 .AND. s2 == ss2 .AND. s3 == ss3) THEN5722 PRINT *, ' Lluis FOR Nin:', Nin5723 PRINT *, ' Lluis FOR values:', vin(:,ii3)5724 DO iv=1, Nin5725 PRINT *,' c:', iv, ':', gin(iv,:), ' p:', pin(iv)5726 END DO5727 END IF5728 5729 5721 ! Computing along d3 5730 5722 DO i3=1, di3 -
trunk/tools/nc_var.py
r2287 r2308 69 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 70 70 ## e.g. # nc_var.py -o area_weighted -f '/media/lluis/ExtDiskC_ext4/bkup/llamp/estudios/dominios/SA150k/geo_em.d01.nc:west_east;XLONG_M;WRFxbnds;-1;south_north;XLAT_M;WRFybnds;-1,/media/lluis/ExtDiskC_ext4/bkup/llamp/estudios/dominios/SA50k/geo_em.d01.nc:west_east;XLONG_M;WRFxbnds;-1;south_north;XLAT_M;WRFybnds;-1' -S 'no:mean' -v HGT_M 71 ## e.g. # nc_var.py -o compute_slices_stats_areaweighted -S 'XLONG,-74.,-36.4,4.;XLAT,-63.,19.,4.;HGT,500.,7000.,500.@Time|WRFtime:west_east|XLONG:south_north|XLAT@Time@ south_north|lat_bnds,west_east|lon_bnds@Time' -f /home/lluis/PY/wrfout_d01_1995-01-01_00:00:00 -V T271 ## e.g. # nc_var.py -o compute_slices_stats_areaweighted -S 'XLONG,-74.,-36.4,4.;XLAT,-63.,19.,4.;HGT,500.,7000.,500.@Time|WRFtime:west_east|XLONG:south_north|XLAT@Time@west_east|lon_bnds,south_north|lat_bnds@XLONG|lat_bnds;lon_bnds,XLAT|lat_bnds;lon_bnds@Time' -f /home/lluis/estudios/Andes/space_weighted/wrfout_bnds.nc -v T2,U10,V10,Q2 72 72 73 73 from optparse import OptionParser -
trunk/tools/nc_var_tools.py
r2305 r2308 26476 26476 for islc in range(Nslices1): 26477 26477 vvslc = slcvar1[islc,] 26478 slcv[islc,] = np.where(vvslc, 1, 0) 26479 newvar = onewnc.createVariable(varn1+'sliced', 'i', tuple(slcdims)) 26478 slcv[islc,] = np.where(vvslc, 1, gen.fillValueI) 26479 newvar = onewnc.createVariable(varn1+'sliced', 'i', tuple(slcdims), \ 26480 fill_value=gen.fillValueI) 26480 26481 newvar[:] = slcv[:] 26481 26482 basicvardef(newvar, varn1+'sliced', 'sliced variable ' + varn1, v1u) … … 26499 26500 for islc in range(Nslices2): 26500 26501 vvslc = slcvar2[islc,] 26501 slcv[islc,] = np.where(vvslc, 1, 0) 26502 newvar = onewnc.createVariable(varn2+'sliced', 'i', tuple(slcdims)) 26502 slcv[islc,] = np.where(vvslc, 1, gen.fillValueI) 26503 newvar = onewnc.createVariable(varn2+'sliced', 'i', tuple(slcdims), \ 26504 fill_value=gen.fillValueI) 26503 26505 newvar[:] = slcv[:] 26504 26506 basicvardef(newvar, varn2+'sliced', 'sliced variable ' + varn2, v2u) … … 27769 27771 if values == 'h': 27770 27772 print fname + '_____________________________________________________________' 27771 print compute_slices_stats .__doc__27773 print compute_slices_stats_areaweighted.__doc__ 27772 27774 quit() 27773 27775 … … 27953 27955 for islc in range(Nslices): 27954 27956 vvslc =~slcvar[islc,] 27955 slcv[islc,] = np.where(vvslc, 1, 0) 27956 newvar = onewnc.createVariable(varn+'sliced', 'i', tuple(slcdims)) 27957 slcv[islc,] = np.where(vvslc, 1, gen.fillValueI) 27958 newvar = onewnc.createVariable(varn+'sliced', 'i', tuple(slcdims), \ 27959 fill_value=gen.fillValueI) 27957 27960 newvar[:] = slcv[:] 27958 27961 basicvardef(newvar, varn+'sliced', 'sliced variable ' + varn, vu) … … 28228 28231 nbvertexmax=dvget) 28229 28232 28233 # Comming from Fortran (dx, dy) !!! 28230 28234 Ngridsin = Ngridsint.transpose() 28231 gridsin = gridsint.transpose() 28235 gridsin0 = gridsint.transpose() 28236 gridsin = np.zeros(gridsin0.shape, dtype=int) 28237 gridsin[0,...] = gridsin0[1,...] 28238 gridsin[1,...] = gridsin0[0,...] 28239 gridsin = gridsin - 1 28240 28232 28241 areas = areast.transpose() 28233 28242 percens = percenst.transpose() 28234 28243 28235 28244 # Remember we are in C-like! 28236 gridsin = gridsin - 128237 28245 28238 28246 Ngridsinmax = np.max(Ngridsin) … … 28335 28343 28336 28344 if Nt > 0: 28345 # Results come from Fortran... (dx, dy) 28337 28346 gridsin[1,0:Nt,0,islc] = ainds[0:Nt,0] 28338 28347 gridsin[0,0:Nt,0,islc] = ainds[0:Nt,1] … … 28486 28495 28487 28496 onewnc.sync() 28497 28488 28498 # Getting full slice 28489 28499 # NOTE: for simplicity let's assume that there is only one slice with bounds !! … … 28587 28597 pnewvar.setncattr('coordinates',' '.join(Spgrid[::-1])) 28588 28598 28599 jjA = 10 28600 iiA = 2 28601 jjB = 0 28602 iiB = 4 28589 28603 for jA in range(dyA): 28590 28604 for iA in range(dxA): … … 28612 28626 28613 28627 onewnc.sync() 28628 #onewnc.close() 28629 #quit() 28614 28630 28615 28631 for islc in range(2,Nnewslcs): … … 28758 28774 # Let's check 28759 28775 psum = np.sum(sgpa[0:Nin,jA,iA,jB,iB]) 28760 if psum != 1.: 28761 print warnmsg 28762 print ' ' + fname + 'at slide:', jA,iA,jB,iB, \ 28763 'percentages do NOT add one !!' 28764 print ' Ngrids:', Nin, 'slice area:', \ 28765 aanewvar[jA,iA,jB,iB], 'total sum:', psum 28766 #for iv in range(Nin): 28767 # print iv, sgpa[iv,jA,iA,jB,iB] 28776 if not np.isnan(psum): 28777 if not gen.almost_zero(psum, 1., 4): 28778 print warnmsg 28779 print ' ' + fname + 'at slide:', jA,iA,jB,iB, \ 28780 'percentages do NOT add one down to 0.0001 !!' 28781 print ' Ngrids:', Nin, 'slice area:', \ 28782 aanewvar[jA,iA,jB,iB], 'total sum:', psum 28783 else: 28784 print errormsg 28785 print ' ' + fname + ': grid Nan slice area for final '+ \ 28786 ' slice:', jA, iA, jB, iB, 'N grids:', Nin,' !!' 28787 print ' slice total area:', aanewvar[jA,iA,jB,iB] 28788 print ' #grid grid_area grid_percen _______' 28789 for iv in range(Nin): 28790 print iv, anewvar[iv,jA,iA,jB,iB], sgpa[iv,jA,iA,jB,iB] 28791 quit(-1) 28768 28792 onewnc.sync() 28769 28793 … … 28785 28809 #sint = sin.transpose() 28786 28810 sint0 = sin.transpose() 28787 ## We are in Fortran thus (dx,dy) and 1st:1 !!!!28811 ## We are going to use them in Fortran thus (dx,dy) and 1st:1 !!!! 28788 28812 sint = np.ones((sint0.shape), dtype=np.float)*gen.fillValueF 28789 28813 sint[...,0] = sint0[...,1] 28790 28814 sint[...,1] = sint0[...,0] 28815 sint = sint + 1 28791 28816 spt = sgpa.transpose() 28792 28817 … … 28798 28823 it = 1 28799 28824 slicesvals = [] 28800 print 'Lluis Ndims:', Ndims28801 28825 idd = 0 28802 28826 for dnn in Ndims: 28803 28827 scvv = slicesinf[dnn.split('_')[1]] 28804 28828 sccvvv = scvv[3] 28805 print 'sccvvv:', sccvvv28806 print 'Lluis dnn:', dnn, sccvvv[chijk[idd]]28807 28829 slicesvals.append(sccvvv[chijk[idd]]) 28808 28830 idd = idd + 1 … … 28856 28878 newvardims = vardims + dimsslice 28857 28879 newvarshape = varshape + shapeslice 28858 print 'Lluis newvardims:', newvardims, 'newvarshape:', newvarshape, 'varv:', varv.shape28859 print 'Lluis shapes sint:', sint.shape28860 28880 28861 28881 # newvarslice = [] … … 28884 28904 varvt = None 28885 28905 varvt = varv.transpose() 28886 print 'vs:', varvt[7, 69, :]28887 28906 if len(vshape) == 3 and len(sN.shape) == 4: 28888 28907 voutt = fsci.module_scientific.multi_spaceweightstats_in3drk3_slc3v4( \ … … 28906 28925 quit(-1) 28907 28926 28908 print "Lluis Let's check !!", vout.shape28909 print 'i j k it:', i, j, k ,it, 'N:', sN[i,j,k], '<>', slicesvals28910 for iv in range(sN[i,j,k]):28911 print iv, 'c:', sin[:,iv,i,j,k], 'p:', sgpa[iv,i,j,k], 'v:', \28912 varv[it,sin[0,iv,i,j,k],sin[1,iv,i,j,k]]28913 print 'min max mean mean2 std median count _______'28914 print vout[:,it,i,j,k]28927 #print "Lluis Let's check !!", vout.shape 28928 #print 'i j k it:', i, j, k ,it, 'N:', sN[i,j,k], '<>', slicesvals 28929 #for iv in range(sN[i,j,k]): 28930 # print iv, 'c:', sin[:,iv,i,j,k], 'p:', sgpa[iv,i,j,k], 'v:', \ 28931 # varv[it,sin[0,iv,i,j,k],sin[1,iv,i,j,k]] 28932 #print 'min max mean mean2 std median count _______' 28933 #print vout[:,it,i,j,k] 28915 28934 28916 28935 ist = 0 28917 28936 for statn in statns: 28918 28937 newvar = onewvars[statn] 28919 print 'Lluis stn:', statn, 'shape:', newvar.shape28920 28938 rightvals = np.where(vout[6] == 0, gen.fillValueF, vout[ist]) 28921 28939 newvar[:] = rightvals
Note: See TracChangeset
for help on using the changeset viewer.