Changeset 729 in lmdz_wrf


Ignore:
Timestamp:
Apr 26, 2016, 6:52:24 PM (9 years ago)
Author:
lfita
Message:

Fixing issue on the right values for the coarse lon/lat

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/module_ForInterpolate.F90

    r728 r729  
    197197END SUBROUTINE CoarselonlatFind
    198198
    199 SUBROUTINE CoarseInterpolate(projlon, projlat, lonvs, latvs, percen, mindiff, ivar, newvar, newvarin, &
    200   newvarinpt, newvarindiff, dimx, dimy, Ninpts)
     199SUBROUTINE CoarseInterpolate(inpts, projlon, projlat, lonvs, latvs, percen, mindiff, ivar, newvar,    &
     200  newvarin, newvarinpt, newvarindiff, dimx, dimy, Ninpts)
    201201! Subroutine which finds the closest grid point within a projection throughout a first guest
    202202!   approche from percentages of the whole domain
     
    210210  REAL(r_k), DIMENSION(dimx,dimy), INTENT(in)            :: projlon, projlat
    211211  INTEGER, INTENT(in)                                    :: Ninpts
     212  INTEGER, DIMENSION(Ninpts), INTENT(in)                 :: inpts
    212213  REAL(r_k), DIMENSION(Ninpts), INTENT(in)               :: ivar, lonvs, latvs
    213214  REAL(r_k)                                              :: mindiff, percen
     
    229230
    230231!!!!!!! Variables
     232! inpts: relative position of the values to interpolate
    231233! dimx, dimy: dimension length of the target interpolation
    232234! proj[lon/lat]: longitudes and latitudes of the target interpolation
     
    248250  extremelat = (/ MINVAL(projlat), MAXVAL(projlat) /)
    249251
    250   PRINT *,'  ' // TRIM(fname) //' fraction:', dimx, ' ,', dimy, ' %', percen
    251 
    252   dfracdx = INT(1./percen)
    253   dfracdy = INT(1./percen)
     252  PRINT *,'  ' // TRIM(fname) //' total space:', dimx, ', ', dimy, ' %', percen
     253
     254  dfracdx = INT(1./percen+1)
     255  dfracdy = INT(1./percen+1)
    254256  fracdx = INT(dimx*percen)
    255257  fracdy = INT(dimy*percen)
     258  PRINT *,'  ' // TRIM(fname) //' fraction:', dfracdx, ', ', dfracdy, ' freq:', fracdx,', ',fracdy
    256259
    257260  IF (ALLOCATED(fractionlon)) DEALLOCATE(fractionlon)
     
    272275  DO i=1,dfracdx
    273276    DO j=1,dfracdy
    274       fractionlon(i,j) = projlon(fracdx*(i-1),fracdy*(j-1))
    275       fractionlat(i,j) = projlat(fracdx*(i-1),fracdy*(j-1))
     277      fractionlon(i,j) = projlon(fracdx*(i-1)+1,fracdy*(j-1)+1)
     278      fractionlat(i,j) = projlat(fracdx*(i-1)+1,fracdy*(j-1)+1)
     279!      PRINT *,'i,j:',i,', ',j,' frac ij:',fracdx*(i-1),', ',fracdy*(j-1),' lonlat:', fractionlon(i,j),&
     280!        ', ',fractionlat(i,j)
    276281    END DO
    277282  END DO
    278283
    279284  PRINT *,'  ' // TRIM(fname) // ' fractions of:'
    280   PRINT *,' lon _______'
    281   PRINT *,fractionlon
     285  PRINT *,' lon _______ (',dfracdx,', ',dfracdy,')'
     286  DO i=1,dfracdx
     287    PRINT *,fractionlon(i,:)
     288  END DO
    282289  PRINT *,' lat_______'
    283   PRINT *,fractionlat
     290  DO i=1,dfracdx
     291    PRINT *,fractionlat(i,:)
     292  END DO
    284293
    285294  DO iv=1,Ninpts
     
    292301
    293302        IF (ilonlat(1) >= 0 .AND. ilonlat(1) >= 0) THEN
    294           newvar(ilonlat(1),ilonlat(2)) = ivar(iv)
    295           newvarin(ilonlat(1),ilonlat(2)) = iv
    296           newvarinpt(iv) = 1
    297           newvarindiff(iv) = mindiffLl
     303          newvar(ilonlat(1),ilonlat(2)) = ivar(inpts(iv))
     304          newvarin(ilonlat(1),ilonlat(2)) = inpts(iv)
     305          newvarinpt(inpts(iv)) = 1
     306          newvarindiff(inpts(iv)) = mindiffLl
    298307!          PRINT *,'Lluis iv:', newvarin(ilonlat(1),ilonlat(2)), ' localized:', newvarinpt(iv),        &
    299308!            ' values:', newvar(ilonlat(1),ilonlat(2)), ' invalues:', ivar(iv), ' mindist:',           &
  • trunk/tools/nc_var_tools.py

    r727 r729  
    1944319443      foudre: f2py -m module_ForInterpolate --f90exec=/usr/bin/gfortran-4.7 -c module_ForInterpolate.F90 module_generic.F90 >& run_f2py.log
    1944419444      ciclad: f2py --f90flags="-fPIC" -L/opt/canopy-1.3.0/Canopy_64bit/System/lib/ -L/usr/lib64/ -L/opt/canopy-1.3.0/Canopy_64bit/System/lib/ -m module_ForInterpolate -c module_ForInterpolate.F90 module_generic.F90
    19445       values= [lonmame],[latname],[fillVal],[resolution],[kind],[lonlatProjfile],[fracd],[fracs]
     19445      values= [lonmame],[latname],[fillVal],[resolution],[kind],[lonlatProjfile],[ipoint],[fracd],[fracs]
    1944619446        [lonname]: name of the longitude variable
    1944719447        [latname]: name of the latitude variable
     
    1945819458         'Goode': Goode projection
    1945919459        [lonlatProjfile]: file with the lon,lat of the desired projection. 'None' to be computed and written on fly
     19460        [ipoint]: initial point to use for the interpolation (0, the first)
    1946019461        [fracd]: Percentage of the fractions within perform the first guess search
    1946119462        [fracs]: Number of grid points to perform the syncronization with the file and the computed values
     
    1947519476
    1947619477    arguments = '[lonmame],[latname],[fillVal],[resolution],[kind],' +               \
    19477       '[lonlatProjfile],[fracd],[fracs]'
     19478      '[lonlatProjfile],[ipoint],[fracd],[fracs]'
    1947819479    check_arguments(fname, values, arguments, ',')
    1947919480
     
    1949319494    kind = values.split(',')[4]
    1949419495    Projfile = values.split(',')[5]
    19495     fracd = np.float(values.split(',')[6])
    19496     fracs = int(values.split(',')[7])
     19496    ipoint = int(values.split(',')[6])
     19497    fracd = np.float(values.split(',')[7])
     19498    fracs = int(values.split(',')[8])
    1949719499
    1949819500    if Projfile == 'None':
     
    1972419726# Error at 150024, 150025, 151709, 153421
    1972519727    print '  ' + fname + ': from:', Ninpts,'re-locating:',Nptsf,'points...'
    19726 #    fracs = 100000
    1972719728    if kind == 'Goode':
    1972819729#        newvar,newvarin,newvarinpt,newvarindiff =                                    \
    1972919730#          fin.module_forinterpolate.coarseinterpolate(projlon, projlat, lonvs,       \
    1973019731#          latvs, percen, mindiff, ivar, dimx, dimy, ninpts)
    19731         for ir in range(0,Ninpts,fracs):
     19732        for ir in range(ipoint,Ninpts,fracs):
    1973219733            iri = ir
    1973319734            ire = ir + fracs + 1
    1973419735            print iri,',',ire
    1973519736#            percendone(iri,Ninpts,0.5,'done:')
     19737            pts = np.arange(iri,ire,1, dtype='int32')
    1973619738            lonvss = lonvs[iri:ire].astype('float64')
    1973719739            latvss = latvs[iri:ire].astype('float64')
     
    1973919741
    1974019742            newvar,newvarin,newvarinpt,newvarindiff =                                \
    19741               fin.module_forinterpolate.coarseinterpolate(projlon, projlat,          \
     19743              fin.module_forinterpolate.coarseinterpolate(pts, projlon, projlat,     \
    1974219744              lonvss, latvss, np.float64(fracd), np.float64(mindiff), ovars)
    1974319745            newnc.sync()
Note: See TracChangeset for help on using the changeset viewer.