Changeset 1745 in lmdz_wrf


Ignore:
Timestamp:
Dec 17, 2017, 2:14:25 PM (8 years ago)
Author:
lfita
Message:

Working on make it fine

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/ORforcing_reconstruct.py

    r1744 r1745  
    7474Ydimn = olon.dimensions[0]
    7575
     76# Fortran indices, first 1
    7677indv = oind[:]
    7778lonv = olon[:]
    7879latv = olat[:]
     80indv = indv - 1
    7981
    8082dimx = lonv.shape[1]
     
    8486veclat = np.zeros((len(indv)), dtype=np.float)
    8587
    86 # Constuct veclon, veclat
     88# Construct veclon, veclat  (Fortran like, First 1)
    8789for iid in range(len(indv)):
    88     iy = int(indv[iid]/dimx)
    89     ix = indv[iid] - iy*dimx
     90    iy = int((indv[iid]-1)/dimx)
     91    ix = indv[iid] - iy*dimx - 1
    9092    veclon[iid] = lonv[iy,ix]
    9193    veclat[iid] = latv[iy,ix]
     
    137139matind = matindt.transpose()
    138140
     141print 'Lluis veclon:', veclon[0:10]
     142print 'Lluis matind: ___'
     143for i in range(3):
     144    print matind[50+i,50:55]
     145
     146print 'matind n:', np.min(matind), 'x:', np.max(matind), 'L1Dvec:', veclon.shape[0], 'vecind: n', np.min(indv), 'x:', np.max(indv)
     147print 'vecind[matind]:', indv[matind[50:53,0]]
     148quit()
     149
    139150# Creation of file
    140151onewnc = NetCDFFile(ofilen, 'w')
     
    153164ncvar.basicvardef(newvar, 'lat', 'Latitude', 'degrees_north')   
    154165onewnc.sync()
     166
     167# Variable indices
     168newvar = onewnc.createVariable('lonlat_matind', 'i', ('y', 'x'), fill_value=-1)
     169newvar[:] = matind
     170ncvar.basicvardef(newvar, 'lonlat_matind', 'matrix with the equivalencies from ' +   \
     171  '2D lon, lat matrices', '-')
     172
     173# Looking for equivalencies in the 1D vector
     174lind = list(indv)
     175vec1Dind = matind
     176for j in range(dimy):
     177    for i in range(dimx):
     178        if matind[j,i] != -1:
     179            vec1Dind[j,i] = lind.index(matind[j,i])
     180
     181newvar = onewnc.createVariable('vec1D_matind', 'i', ('y', 'x'), fill_value=-1)
     182newvar[:] = vec1Dind
     183ncvar.basicvardef(newvar, 'vec1D_matind', 'matrix with the equivalencies from 1D ' + \
     184  'vector indices', '-')
     185
     186onewnc.sync()
     187onc.clsoe()
     188onewnc.close()
     189quit()
    155190
    156191# Getting variables
Note: See TracChangeset for help on using the changeset viewer.