Changeset 1750 in lmdz_wrf
- Timestamp:
- Dec 18, 2017, 3:02:22 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/ORforcing_reconstruct.py
r1749 r1750 15 15 16 16 parser = OptionParser() 17 parser.add_option("-f", "--fileHEader", dest="fh", help="header of files", \ 18 metavar="VALUE") 19 parser.add_option("-L", "--latitude", dest="latn", help="name of the variable latitiude", \ 20 metavar="VALUE") 21 parser.add_option("-l", "--longitude", dest="lonn", help="name of the variable longitiude", \ 22 metavar="VALUE") 23 parser.add_option("-v", "--Variables", dest="varns", help="',' separated list of variables", \ 24 metavar="VALUE") 17 25 parser.add_option("-y", "--year", dest="year", help="year to process", \ 18 26 metavar="VALUE") … … 22 30 ####### ###### ##### #### ### ## # 23 31 24 filen = 'cruncep_halfdeg_'+ opts.year + '.nc'32 filen = opts.fh + opts.year + '.nc' 25 33 26 34 # Variable whcih provides the indices of a 1D vector from the dimy, dimx space … … 28 36 29 37 # 2D longitude, latitude matrices 30 lonvar = 'nav_lon'31 latvar = 'nav_lat'38 lonvar = opts.lonn 39 latvar = opts.latn 32 40 33 41 # Range to retrieve … … 40 48 # Variables to reconstruct 41 49 #variable = 'all' 42 variable = 'time,LWdown,Qair,PSurf,SWdown,Tair,Wind_E,Wind_N,Snowf,Rainf'50 variable = opts.varns 43 51 44 52 # Resolution … … 79 87 olat = onc.variables[latvar] 80 88 81 vecdimn = oind.dimensions[0]82 Xdimn = olon.dimensions[1]83 Ydimn = olon.dimensions[0]84 85 # Fortran indices, first 186 89 indv = oind[:] 87 90 lonv = olon[:] 88 91 latv = olat[:] 92 93 vecdimn = oind.dimensions[0] 94 if len(olon.dimensions) == 2: 95 Xdimn = olon.dimensions[1] 96 Ydimn = olon.dimensions[0] 97 dimx = lonv.shape[1] 98 dimy = lonv.shape[0] 99 elif len(olon.dimensions) == 1: 100 Xdimn = olon.dimensions[0] 101 Ydimn = olat.dimensions[0] 102 dimx = lonv.shape[0] 103 dimy = latv.shape[0] 104 lonv, latv = np.meshgrid(lonv, latv) 105 106 # Fortran indices, first 1 89 107 indv = indv - 1 90 91 dimx = lonv.shape[1]92 dimy = lonv.shape[0]93 108 94 109 veclon = np.zeros((len(indv)), dtype=np.float) … … 98 113 for iid in range(len(indv)): 99 114 iy = int((indv[iid]-1)/dimx) 100 ix = in dv[iid] - iy*dimx - 1115 ix = int(indv[iid] - iy*dimx - 1) 101 116 veclon[iid] = lonv[iy,ix] 102 117 veclat[iid] = latv[iy,ix] … … 117 132 if not gen.searchInlist(ncvars, vn): 118 133 print gen.errormsg 119 print ' ' + fname + ": file '" + ncfile + "' does not have " +\134 print ' ' + fname + ": file '" + filen + "' does not have " + \ 120 135 " variable '" + vn + "' !!" 121 136 print ' available ones:', ncvars
Note: See TracChangeset
for help on using the changeset viewer.