Changeset 713 in lmdz_wrf


Ignore:
Timestamp:
Apr 25, 2016, 6:37:18 PM (9 years ago)
Author:
lfita
Message:

Adding percentage of subdomains for the coarse search

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var_tools.py

    r712 r713  
    1877018770def Partialmap_Entiremap(values, filen, varn):
    1877118771    """ Function to transform from a partial global map (e.g.: only land points) to an entire one
    18772       values= [lonmame],[latname],[fillVal],[resolution],[kind],[lonlatProjfile]
     18772      Coincidence of points is done throughout a first guess from fractions of the total domain of search
     18773      values= [lonmame],[latname],[fillVal],[resolution],[kind],[lonlatProjfile],[fracd]
    1877318774        [lonname]: name of the longitude variable
    1877418775        [latname]: name of the latitude variable
     
    1878518786         'Goode': Goode projection
    1878618787        [lonlatProjfile]: file with the lon,lat of the desired projection. 'None' to be computed and written on fly
     18788        [fracd]: Percentage of the fractions within perform the first guess search
    1878718789      filen= name of the netCDF file
    1878818790      varn= name of the variable
     
    1879818800        quit()
    1879918801
    18800     arguments = '[lonmame],[latname],[fillVal],[resolution],[kind],[lonlatProjfile]'
     18802    arguments = '[lonmame],[latname],[fillVal],[resolution],[kind],' +               \
     18803      '[lonlatProjfile],[fracd]'
    1880118804    check_arguments(fname, values, arguments, ',')
    1880218805
     
    1881618819    kind = values.split(',')[4]
    1881718820    Projfile = values.split(',')[5]
     18821    fracd = np.float(values.split(',')[6])
     18822
    1881818823    if Projfile == 'None':
    1881918824        lonlatProjfile = None
     
    1897418979        else:
    1897518980            newvar = newnc.createVariable('lon','f8',('lon'))
    18976         basicvardef(newvar, 'lon', 'Longitudes','degrees East')
     18981        basicvardef(newvar, 'lon', 'Longitudes','degrees_East')
    1897718982        newvar[:] = lonmap
    1897818983        newvar.setncattr('axis', 'X')
     
    1898318988        else:
    1898418989            newvar = newnc.createVariable('lat','f8',('lat'))
    18985         basicvardef(newvar, 'lat', 'Latitudes','degrees North')
     18990        basicvardef(newvar, 'lat', 'Latitudes','degrees_North')
    1898618991        newvar[:] = latmap
    1898718992        newvar.setncattr('axis', 'Y')
     
    1903319038#    print fraclat
    1903419039
     19040# Reducing the searching points
     19041    newvarinvals = newvarinpt[:]
     19042    maskpt = np.where(newvarinvals.mask == True, False, True)
     19043    points = np.arange(Ninpts)
     19044    mapoints = ma.array(points, mask=maskpt)
     19045    ptsf = mapoints.compressed()
     19046
     19047    Nptsf = len(ptsf)
     19048    print Ninpts,'Npoints to find:', len(ptsf), ptsf[0:10], newvarindiff[ptsf[0:10]]
    1903519049# Error at 150024, 150025, 151709, 153421
    19036     print '  ' + fname + ': re-locating:',Ninpts,'points...'
     19050    print '  ' + fname + ': from:', Ninpts,'re-locating:',Nptsf,'points...'
    1903719051    if kind == 'Goode':
    19038         for iv in range(150024,Ninpts):
     19052        for iv0 in range(Nptsf):
     19053            iv = mapoints[ptsf[iv0]]
    1903919054            if newvarinpt[iv] == 0:
    1904019055
     
    1904219057#                mindiffLl = np.min(difflonlat)
    1904319058#                ilatlon = index_mat(difflonlat, mindiffLl)
    19044                 ilatlon, mindiffLl = CoarselonlatFind(projlon,projlat,lonvs[iv],latvs[iv],.1)
     19059                ilatlon, mindiffLl = CoarselonlatFind(projlon,projlat,lonvs[iv],latvs[iv],fracd)
    1904519060
    1904619061#                if ilatlon[0] != ilatlon2[0] or ilatlon[1] != ilatlon2[1]:
     
    1909519110                        quit(-1)
    1909619111
    19097                 if np.mod(iv,100) == 0:
     19112                if np.mod(iv,1000) == 0:
    1909819113                    newnc.sync()
    1909919114#                    print '  ' + fname + 'values localized:', newvar[:].compressed()
Note: See TracChangeset for help on using the changeset viewer.