Changeset 742 in lmdz_wrf
- Timestamp:
- May 3, 2016, 12:17:51 PM (9 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/module_ForInterpolate.F90
r740 r742 216 216 REAL(r_k), INTENT(out) :: mindiffLl 217 217 ! Local 218 INTEGER :: i ,j218 INTEGER :: i 219 219 REAL(r_k), DIMENSION(Nperx,Npery) :: difffraclonlat 220 220 REAL(r_k) :: mindifffracLl … … 634 634 INTEGER :: ierr 635 635 INTEGER, DIMENSION(2) :: ilonlat 636 REAL(r_k), DIMENSION(dimx,dimy) :: difflonlat637 636 REAL(r_k) :: mindiffLl 638 637 INTEGER :: Ninpts1 … … 743 742 END SUBROUTINE CoarseInterpolateExact 744 743 745 SUBROUTINE Interpolate(projlon, projlat, lonvs, latvs, mindiff, i var, newvarinpt,&746 newvarindiff, ilonlat, dimx, dimy,Ninpts)744 SUBROUTINE Interpolate(projlon, projlat, lonvs, latvs, mindiff, inpt, diffs, ilonlat, dimx, dimy, & 745 Ninpts) 747 746 ! Subroutine which finds the closest grid point within a projection 748 747 … … 755 754 REAL(r_k), DIMENSION(dimx,dimy), INTENT(in) :: projlon, projlat 756 755 INTEGER, INTENT(in) :: Ninpts 757 REAL(r_k), DIMENSION(Ninpts), INTENT(in) :: ivar,lonvs, latvs756 REAL(r_k), DIMENSION(Ninpts), INTENT(in) :: lonvs, latvs 758 757 REAL(r_k), INTENT(in) :: mindiff 759 INTEGER, DIMENSION(Ninpts), INTENT( out) :: newvarinpt760 REAL(r_k), DIMENSION(Ninpts), INTENT(out) :: newvarindiff758 INTEGER, DIMENSION(Ninpts), INTENT(inout) :: inpt 759 REAL(r_k), DIMENSION(Ninpts), INTENT(out) :: diffs 761 760 INTEGER, DIMENSION(Ninpts,2), INTENT(out) :: ilonlat 762 761 763 762 ! Local 764 INTEGER :: iv,i,j 765 INTEGER :: ierr 763 INTEGER :: iv 766 764 REAL(r_k) :: mindiffLl 767 765 INTEGER :: Ninpts1 … … 776 774 ! [lon/lat]vs: longitudes and latitudes of the points to interpolate 777 775 ! mindiff: minimal accepted distance to the target point 778 ! ivar: values to localize in the target projection 779 ! newvar: localisation of the [lon/lat]vs point in the target projection 780 ! newvarin: number of point from the input data 781 ! newvarinpt: integer value indicating if the value has been already located (0: no, 1: yes) 782 ! newvarindiff: distance of point from the input data to the closest target point 776 ! inpt: whether the point has already been localized 777 ! diffs: distance of point from the input data to the closest target point 783 778 ! ilonlat: longitude and latitude of the point 784 779 ! ncid: netCDF output file id … … 791 786 792 787 DO iv=1,Ninpts 793 IF ( newvarinpt(iv) == 0) THEN788 IF (inpt(iv) <= 0) THEN 794 789 ! Not using the subroutine, not efficient! 795 790 ! CALL lonlatFind(dimx, dimy, projlon, projlat, extremelon, extremelat, lonvs(iv), latvs(iv), & … … 818 813 819 814 IF (ilonlat(iv,1) >= 0 .AND. ilonlat(iv,2) >= 0) THEN 820 newvarinpt(iv) = 1821 newvarindiff(iv) = mindiffLl815 diffs(iv) = mindiffLl 816 inpt(iv) = 1 822 817 ! PRINT *,'Lluis iv:', newvarin(ilonlat(1),ilonlat(2)), ' localized:', newvarinpt(iv), & 823 818 ! ' values:', newvar(ilonlat(1),ilonlat(2)), ' invalues:', ivar(iv), ' mindist:', & … … 841 836 STOP 842 837 END IF 843 ELSE844 PRINT *,TRIM(ErrWarnMsg('err'))845 PRINT *,' ' // TRIM(fname) // ': for point #', iv,' lon,lat in incomplet map:', lonvs(iv), &846 ' ,', latvs(iv), ' there is not a set of lon,lat in the completed map closer than: ', &847 mindiff, ' !!'848 PRINT *,' found minimum difference:', mindiffLl849 STOP850 838 END IF 851 839 END DO -
trunk/tools/nc_var_tools.py
r741 r742 10501 10501 elif vtype == type(np.int32(1)): 10502 10502 typeinf = np.iinfo(np.int32) 10503 if ( abs(np.float64(val)) > typeinf.max):10503 if (np.abs(np.float64(val)) > typeinf.max): 10504 10504 print warnmsg 10505 10505 print ' ' + fname + ': value to transform ', val,' overpasses type:', \ … … 10508 10508 newval = abs(np.float64(val))/np.float64(val) * np.int32(typeinf.max) 10509 10509 else: 10510 newval = np.int32( val)10510 newval = np.int32(np.float64(val)) 10511 10511 elif vtype == type(np.int64(1)): 10512 10512 newval = np.int64(val) … … 20436 20436 for ir in range(ptsf[0],Ninpts,fracs): 20437 20437 iri = ir 20438 ire = ir + fracs + 120438 ire = ir + fracs 20439 20439 print iri,',',ire 20440 20440 # percendone(iri,Ninpts,0.5,'done:') 20441 pts = np.arange(iri,ire,1, dtype='int32') 20442 lonvss = lonvs[iri:ire].astype('float64') 20443 latvss = latvs[iri:ire].astype('float64') 20444 ovars = ovar[iri:ire].astype('float64') 20441 lonvss = lonvs[iri:ire+1].astype('float64') 20442 latvss = latvs[iri:ire+1].astype('float64') 20443 inptss = newvarinpt[iri:ire+1].astype('int32') 20445 20444 20446 20445 # newvar,newvarin,newvarinpt[pts],newvarindiff[pts] = \ … … 20448 20447 # lonvss, latvss, fracd, mindiff, ovars) 20449 20448 # Slow way 20450 newvarinpt[pts],newvarindiff[pts],ilonlatv = \ 20451 fin.module_forinterpolate.interpolate(projlon, projlat, \ 20452 lonvss, latvss, np.float64(mindiff), ovars) 20449 idiff, ilonlatv = fin.module_forinterpolate.interpolate(projlon, projlat,\ 20450 lonvss, latvss, np.float64(mindiff), inptss) 20453 20451 for i in range(fracs): 20454 # print 'Lluis: ilonlatv:', ilonlatv[i,:] 20455 newvar[ilonlatv[i,1],ilonlatv[i,0]] = ovars[i] 20456 newvarin[ilonlatv[i,1],ilonlatv[i,0]] = i 20452 newvar[ilonlatv[i,0],ilonlatv[i,1]] = ovar[iri + i] 20453 newvarin[ilonlatv[i,0],ilonlatv[i,1]] = iri + i 20454 newvarinpt[iri+i] = 1 20455 newvarindiff[iri+i] = idiff[i] 20456 20457 20457 newnc.sync() 20458 # newnc.close() 20459 # quit() 20458 20460 20459 20461 elif kind == 'lonlat':
Note: See TracChangeset
for help on using the changeset viewer.