Changeset 1745 in lmdz_wrf
- Timestamp:
- Dec 17, 2017, 2:14:25 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/ORforcing_reconstruct.py
r1744 r1745 74 74 Ydimn = olon.dimensions[0] 75 75 76 # Fortran indices, first 1 76 77 indv = oind[:] 77 78 lonv = olon[:] 78 79 latv = olat[:] 80 indv = indv - 1 79 81 80 82 dimx = lonv.shape[1] … … 84 86 veclat = np.zeros((len(indv)), dtype=np.float) 85 87 86 # Const uct veclon, veclat88 # Construct veclon, veclat (Fortran like, First 1) 87 89 for 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 90 92 veclon[iid] = lonv[iy,ix] 91 93 veclat[iid] = latv[iy,ix] … … 137 139 matind = matindt.transpose() 138 140 141 print 'Lluis veclon:', veclon[0:10] 142 print 'Lluis matind: ___' 143 for i in range(3): 144 print matind[50+i,50:55] 145 146 print 'matind n:', np.min(matind), 'x:', np.max(matind), 'L1Dvec:', veclon.shape[0], 'vecind: n', np.min(indv), 'x:', np.max(indv) 147 print 'vecind[matind]:', indv[matind[50:53,0]] 148 quit() 149 139 150 # Creation of file 140 151 onewnc = NetCDFFile(ofilen, 'w') … … 153 164 ncvar.basicvardef(newvar, 'lat', 'Latitude', 'degrees_north') 154 165 onewnc.sync() 166 167 # Variable indices 168 newvar = onewnc.createVariable('lonlat_matind', 'i', ('y', 'x'), fill_value=-1) 169 newvar[:] = matind 170 ncvar.basicvardef(newvar, 'lonlat_matind', 'matrix with the equivalencies from ' + \ 171 '2D lon, lat matrices', '-') 172 173 # Looking for equivalencies in the 1D vector 174 lind = list(indv) 175 vec1Dind = matind 176 for 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 181 newvar = onewnc.createVariable('vec1D_matind', 'i', ('y', 'x'), fill_value=-1) 182 newvar[:] = vec1Dind 183 ncvar.basicvardef(newvar, 'vec1D_matind', 'matrix with the equivalencies from 1D ' + \ 184 'vector indices', '-') 185 186 onewnc.sync() 187 onc.clsoe() 188 onewnc.close() 189 quit() 155 190 156 191 # Getting variables
Note: See TracChangeset
for help on using the changeset viewer.