- Timestamp:
- Jun 18, 2016, 4:14:42 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var_tools.py
r874 r875 8981 8981 newdimvarv, newdimvardimns=operation_alongdims(objvdim,dimvals,dimsoper,operkind) 8982 8982 8983 # Introducing only that dimension variables with any dimension after the operation 8984 if len(newdimvardimns) > 0: 8985 8983 8986 # Old method introducing new dimension if needed 8984 8987 ## dimsvdim = objvdim.dimensions … … 9005 9008 ## dimvdims.append(dimsvdim[idmvd]) 9006 9009 9007 newvar = objnewnc.createVariable(vardims[ivdim], vdimtype,\9008 tuple(newdimvardimns))9009 newvar[:] = newdimvarv9010 dimvattrs = objvdim.ncattrs()9011 for attrn in dimvattrs:9012 attrv = objvdim.getncattr(attrn)9013 newattr = set_attribute(newvar,attrn,attrv)9014 9015 newattr = set_attribute(newvar, 'operation:', operkind +\9016 ' along ' + dimsoperS)9010 newvar = objnewnc.createVariable(vardims[ivdim], vdimtype, \ 9011 tuple(newdimvardimns)) 9012 newvar[:] = newdimvarv 9013 dimvattrs = objvdim.ncattrs() 9014 for attrn in dimvattrs: 9015 attrv = objvdim.getncattr(attrn) 9016 newattr = set_attribute(newvar,attrn,attrv) 9017 9018 newattr = set_attribute(newvar, 'operation:', operkind + \ 9019 ' along ' + dimsoperS) 9017 9020 9018 9021 # new variable 9019 9022 oldvarattr = objvar.ncattrs() 9020 9023 9021 varname = variables_values(vn)[0]9024 varname = gen.variables_values(vn)[0] 9022 9025 if gen.searchInlist(oldvarattr, 'standard_name'): 9023 9026 stdname = objvar.getncattr('standard_name') 9024 9027 else: 9025 stdname = variables_values(vn)[1]9028 stdname = gen.variables_values(vn)[1] 9026 9029 9027 9030 if gen.searchInlist(oldvarattr, 'long_name'): 9028 9031 lname = objvar.getncattr('long_name') 9029 9032 else: 9030 lname = variables_values(vn)[4].replace('|',' ')9033 lname = gen.variables_values(vn)[4].replace('|',' ') 9031 9034 9032 9035 if gen.searchInlist(oldvarattr, 'units'): 9033 9036 uname = objvar.getncattr('units') 9034 9037 else: 9035 uname = variables_values(vn)[5]9038 uname = gen.variables_values(vn)[5] 9036 9039 9037 9040 newvar = objnewnc.createVariable(varname + operkind, 'f4', … … 9042 9045 newvar[:] = newvarv 9043 9046 for idim in range(len(objvar.shape)): 9044 dimn = dimvals.split('|')[idim].split(':')[0] 9047 if dimvals.find('|') != -1: 9048 dimn = dimvals.split('|')[idim].split(':')[0] 9049 else: 9050 dimn = dimvals.split(':')[0] 9045 9051 dimv = '{:d}'.format(len(objnc.dimensions[dimn])) 9046 9052 if idim == 0:
Note: See TracChangeset
for help on using the changeset viewer.