source:
issm/oecreview/Archive/24684-25833/ISSM-25062-25063.diff@
25834
Last change on this file since 25834 was 25834, checked in by , 4 years ago | |
---|---|
File size: 4.3 KB |
-
../trunk-jpl/src/m/contrib/defleurian/netCDF/export_netCDF.py
6 6 7 7 8 8 def export_netCDF(md, filename): # {{{ 9 res_time = time.time()10 9 debug = False 11 10 if path.exists(filename): 12 11 print('File {} allready exist'.format(filename)) … … 86 85 except AttributeError: 87 86 subfields = dict.keys(md.__dict__[group].__dict__[field].__getitem__(0)) 88 87 89 # for subfield in subfields:90 # if subfield not in['errlog', 'outlog']:91 # #first create the variable92 # try:93 # Var = md.__dict__[group].__dict__[field].__getitem__(0).__dict__[subfield]94 # except AttributeError:95 # Var = md.__dict__[group].__dict__[field].__getitem__(0)[subfield]96 # Var = SqueezeVar(Var)97 # #If first time we create a nc variable98 # if Listsize == len(TimeDim):99 # ExtraDim = 'Time'100 # else:101 # ExtraDim = 'Unlim'102 # if debug:103 # print("=$$=creating var for {}.{}.{}".format(group, field, subfield))104 # DimDict, ncvar = CreateVar(NCData, Var, subfield, Subgroup, DimDict, ExtraDim)105 106 # for listindex in range(0, Listsize):107 # try:108 # Var = md.__dict__[group].__dict__[field].__getitem__(listindex).__dict__[subfield]109 # except AttributeError:110 # Var = md.__dict__[group].__dict__[field].__getitem__(listindex)[subfield]111 # Var = SqueezeVar(Var)112 # #and fill it up113 # FillVar(ncvar, Var, listindex)114 115 88 for subfield in subfields: 116 89 if subfield not in['errlog', 'outlog']: 117 90 try: … … 125 98 Var = md.__dict__[group].__dict__[field].__getitem__(listindex).__dict__[subfield] 126 99 except AttributeError: 127 100 Var = md.__dict__[group].__dict__[field].__getitem__(listindex)[subfield] 101 except KeyError: 102 #Some fields only exist for the first step 103 continue 128 104 Var = SqueezeVar(Var) 129 105 StackedVar = np.vstack((StackedVar, Var)) 130 106 if debug: … … 173 149 if ncvar is not None: 174 150 FillVar(ncvar, Var) 175 151 NCData.close() 176 print("export time is {}".format(time.time() - res_time))177 152 178 153 # }}} 179 154 -
../trunk-jpl/src/m/io/loadvars.py
123 123 keylist = [key for key in curclass.variables] 124 124 dimlist = [curclass.variables[key].dimensions for key in keylist] 125 125 indexlist = np.arange(0, len(NCFile.dimensions['Time'])) 126 if 'Time' in np.all(dimlist): 126 AllHaveTime = np.all(['Time' in dimtuple for dimtuple in dimlist]) 127 if AllHaveTime: 127 128 #Time dimension is in all the variables so we take that as stepnumber for the results 128 129 listtype = curclass.classtype 129 130 nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = [getattr(__import__(listtype), listtype)() for i in range(max(1, len(NCFile.dimensions['Time'])))]
Note:
See TracBrowser
for help on using the repository browser.