Changeset 1390 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Dec 15, 2016, 4:26:53 PM (8 years ago)
Author:
lfita
Message:

Adding 'shortmon': list of the 12 months with 3-characters length

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/generic_tools.py

    r1388 r1390  
    3030fillValueF64 = 1.e20
    3131fillValueI32 = -99999
     32
     33# 12 Months
     34shortmon = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    3235
    3336# For variables_values
     
    1082710830    return linearwgt
    1082810831
    10829 def linearint_3x3weights(xvals, yvals, intval):
     10832def linearint_3x3weights(xvals, yvals, intval0):
    1083010833    """ Function to provide the weights for a linear interpolation of a value inside a 3x3 matrix of values as a weighted distance mean
    1083110834      xvals: 3x3 matrix of x-values
     
    1085710860    fname = 'linear_wegiths'
    1085810861
     10862    intval = np.array(intval0, dtype=np.float)
     10863    print 'type xvals:',  xvals.dtype
     10864
    1085910865    # Assuming that values come from `vals_around' function (None, when outside matrix size)
    1086010866    xvalsma = ma.masked_equal(xvals,None)
     
    1088010886        quit(-1)
    1088110887
    10882     dist = np.sqrt( (xvalsma-intval[1])**2 + (yvalsma-intval[0])**2)
     10888    print 'Lluis intval:', intval
     10889    print '  ' + fname + ' Lluis xvalsma ____'
     10890    print xvalsma
     10891
     10892    print '  ' + fname + ' Lluis yvalsma ____'
     10893    print yvalsma
     10894
     10895    dist = np.sqrt( (xvals-intval[1])**2 + (yvals-intval[0])**2)
    1088310896    inc = np.sum(dist)
    1088410897    print 'inc:', inc, 'intval', intval
     
    1090910922            iijj = iijj + 1
    1091010923
    10911     # Normalizing values (onlyl the first 4)
     10924    # Normalizing values (only the first 4)
    1091210925    if iijj >= 3:
    1091310926        inc = np.sum(sortdist[0:4])
     
    1094310956      yvals= 2D matrix of y-coordinate values
    1094410957      RETURNS:
    10945         curvloc = [2,Npts] matrix with the closest i,j grid point in the 2D space of the field positions
    10946         curvweights = [3,3,Npts] 3x3 matrix weights around the curve position
     10958        curvloc= [2,Npts] matrix with the closest i,j grid point in the 2D space of the field positions
     10959        curvweights= [Npts,3,3] 3x3 matrix weights around the curve position
     10960        Nwgt= Number of weights
     10961        ijaorund3x3= [2,9] distance (in xval, yval units) to the curve position
    1094710962    """
    1094810963    fname = 'curvelocalize_2D'
     
    1095910974        mindist = np.min(dist)
    1096010975        ijloc = index_mat(dist,mindist)
    10961         iloc[icv] = ijloc[1]
    10962         jloc[icv] = ijloc[0]
     10976
     10977        curvloc[0,icv] = ijloc[0]
     10978        curvloc[1,icv] = ijloc[1]
    1096310979
    1096410980        # Values around the nearest 2D-point to the curve point
    1096510981        xaroundvls = vals_around(xvals,ijloc)
    1096610982        yaroundvls = vals_around(yvals,ijloc)
    10967 
    10968         curveweights[icv,:,:], Npts, ijaorund3x3= linearint_3x3weights(xvals, yvals, \
    10969           intval)
     10983        print 'Lluis type xaroundvls:', type(xaroundvls)
     10984
     10985        curveweights[icv,:,:], Nwgt, ijaorund3x3= linearint_3x3weights(xaroundvls,   \
     10986          yaroundvls, curve[:,icv])
    1097010987       
    10971  
    10972     return
    10973 
    10974 
     10988    return curvloc, curveweights, Nwgt, ijaround3x3
     10989
     10990#lon1d = np.arange(10)
     10991#lat1d = np.arange(-5,5)
     10992#dx = lon1d.shape[0]
     10993#dy = lat1d.shape[0]
     10994
     10995#lons = np.zeros((dy,dx), dtype=np.float)
     10996#lats = np.zeros((dy,dx), dtype=np.float)
     10997
     10998#for iy in range(dy):
     10999#    lons[iy,:] = lon1d
     11000#for ix in range(dx):
     11001#    lats[:,ix] = lat1d
     11002
     11003#Ncurve = 12
     11004#iicurve = 0
     11005#eicurve = dx-1
     11006#ijcurve = 1
     11007#ejcurve = dy-3
     11008#iloncurve = lon1d[iicurve]
     11009#eloncurve = lon1d[eicurve]
     11010#ilatcurve = lat1d[ijcurve]
     11011#elatcurve = lat1d[ejcurve]
     11012#Dxcurve = (eloncurve-iloncurve)/(Ncurve-1.)
     11013#Dycurve = (elatcurve-ilatcurve)/(Ncurve-1.)
     11014
     11015#curve = np.zeros((2,Ncurve), dtype=np.float)
     11016#for icv in range(Ncurve):
     11017#    curve[0,icv] = ilatcurve + Dycurve*icv
     11018#    curve[1,icv] = iloncurve + Dxcurve*icv
     11019
     11020#print 'Curve origin:', ilatcurve, ',', iloncurve
     11021#print 'Curve ending:', elatcurve, ',', eloncurve
     11022
     11023#print curve
     11024
     11025#loccurve, wgts, Nwgts, loc3x3 = curvelocalize_2D(curve,lons,lats)
     11026#print loccurve
    1097511027#quit()
Note: See TracChangeset for help on using the changeset viewer.