Changeset 1746 in lmdz_wrf
- Timestamp:
- Dec 17, 2017, 4:07:39 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/ORforcing_reconstruct.py
r1745 r1746 25 25 Xmin=-90.25 26 26 #Xmin='all' 27 Xmax=- 5.2527 Xmax=-33.25 28 28 Ymin=-67.25 29 29 Ymax=15.25 … … 31 31 # Variables to reconstruct 32 32 #variable = 'all' 33 variable = ' LWdown'33 variable = 'time,LWdown,Qair,PSurf,SWdown,Tair,Wind_E,Wind_N,Snowf,Rainf' 34 34 35 35 # Resolution … … 86 86 veclat = np.zeros((len(indv)), dtype=np.float) 87 87 88 # Construct veclon, veclat (Fortran like, First 1)88 # Construct veclon, veclat 89 89 for iid in range(len(indv)): 90 90 iy = int((indv[iid]-1)/dimx) … … 107 107 for vn in varns: 108 108 if not gen.searchInlist(ncvars, vn): 109 print errormsg109 print gen.errormsg 110 110 print ' ' + fname + ": file '" + ncfile + "' does not have " + \ 111 111 " variable '" + vn + "' !!" … … 138 138 139 139 matind = matindt.transpose() 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() 140 # Fortran like, First 1 141 matind = np.where(matind != -1, matind - 1, matind) 149 142 150 143 # Creation of file … … 166 159 167 160 # Variable indices 168 newvar = onewnc.createVariable(' lonlat_matind', 'i', ('y', 'x'), fill_value=-1)161 newvar = onewnc.createVariable('vec1D_matind', 'i', ('y', 'x'), fill_value=-1) 169 162 newvar[:] = matind 170 ncvar.basicvardef(newvar, 'lonlat_matind', 'matrix with the equivalencies from ' + \ 171 '2D lon, lat matrices', '-') 163 ncvar.basicvardef(newvar, 'vec1D_matind', 'matrix with the equivalencies from 1D ' + \ 164 'vector indices', '-') 165 ncvar.set_attribute(newvar, 'coordinates', 'lon lat') 172 166 173 167 # Looking for equivalencies in the 1D vector 174 lind = list(indv) 175 vec1Dind = matind 168 matlonlat = matind.copy() 176 169 for j in range(dimy): 177 170 for i in range(dimx): 178 171 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() 172 matlonlat[j,i] = indv[matind[j,i]] 173 174 newvar = onewnc.createVariable('lonlat_matind', 'i', ('y', 'x'), fill_value=-1) 175 newvar[:] = matlonlat 176 ncvar.basicvardef(newvar, 'lonlat_matind', 'matrix with the equivalencies from ' + \ 177 '2D lon, lat matrices', '-') 178 ncvar.set_attribute(newvar, 'coordinates', 'lon lat') 179 onewnc.sync() 190 180 191 181 # Getting variables … … 245 235 iix = vardims.index('x') 246 236 iiy = vardims.index('y') 237 iislc = 0 238 Nslices = len(slices) 247 239 for slc in slices: 240 gen.percendone(iislc,Nslices,0.25,vn + ' reconstructed:') 248 241 ival = slc[iix] 249 242 jval = slc[iiy] … … 257 250 oldvarslice.append(slc[iid]) 258 251 259 print vn, 'Slice new:', slc, 'old:', oldvarslice, 'shape:', newvar.shape, 'oldshape:', ovar.shape260 252 newvar[tuple(slc)] = ovar[tuple(oldvarslice)] 261 253 else:
Note: See TracChangeset
for help on using the changeset viewer.