[25834] | 1 | Index: ../trunk-jpl/src/m/contrib/defleurian/netCDF/export_netCDF.py
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- ../trunk-jpl/src/m/contrib/defleurian/netCDF/export_netCDF.py (revision 25062)
|
---|
| 4 | +++ ../trunk-jpl/src/m/contrib/defleurian/netCDF/export_netCDF.py (revision 25063)
|
---|
| 5 | @@ -6,7 +6,6 @@
|
---|
| 6 |
|
---|
| 7 |
|
---|
| 8 | def export_netCDF(md, filename): # {{{
|
---|
| 9 | - res_time = time.time()
|
---|
| 10 | debug = False
|
---|
| 11 | if path.exists(filename):
|
---|
| 12 | print('File {} allready exist'.format(filename))
|
---|
| 13 | @@ -86,32 +85,6 @@
|
---|
| 14 | except AttributeError:
|
---|
| 15 | subfields = dict.keys(md.__dict__[group].__dict__[field].__getitem__(0))
|
---|
| 16 |
|
---|
| 17 | - # for subfield in subfields:
|
---|
| 18 | - # if subfield not in['errlog', 'outlog']:
|
---|
| 19 | - # #first create the variable
|
---|
| 20 | - # try:
|
---|
| 21 | - # Var = md.__dict__[group].__dict__[field].__getitem__(0).__dict__[subfield]
|
---|
| 22 | - # except AttributeError:
|
---|
| 23 | - # Var = md.__dict__[group].__dict__[field].__getitem__(0)[subfield]
|
---|
| 24 | - # Var = SqueezeVar(Var)
|
---|
| 25 | - # #If first time we create a nc variable
|
---|
| 26 | - # if Listsize == len(TimeDim):
|
---|
| 27 | - # ExtraDim = 'Time'
|
---|
| 28 | - # else:
|
---|
| 29 | - # ExtraDim = 'Unlim'
|
---|
| 30 | - # if debug:
|
---|
| 31 | - # print("=$$=creating var for {}.{}.{}".format(group, field, subfield))
|
---|
| 32 | - # DimDict, ncvar = CreateVar(NCData, Var, subfield, Subgroup, DimDict, ExtraDim)
|
---|
| 33 | -
|
---|
| 34 | - # for listindex in range(0, Listsize):
|
---|
| 35 | - # try:
|
---|
| 36 | - # Var = md.__dict__[group].__dict__[field].__getitem__(listindex).__dict__[subfield]
|
---|
| 37 | - # except AttributeError:
|
---|
| 38 | - # Var = md.__dict__[group].__dict__[field].__getitem__(listindex)[subfield]
|
---|
| 39 | - # Var = SqueezeVar(Var)
|
---|
| 40 | - # #and fill it up
|
---|
| 41 | - # FillVar(ncvar, Var, listindex)
|
---|
| 42 | -
|
---|
| 43 | for subfield in subfields:
|
---|
| 44 | if subfield not in['errlog', 'outlog']:
|
---|
| 45 | try:
|
---|
| 46 | @@ -125,6 +98,9 @@
|
---|
| 47 | Var = md.__dict__[group].__dict__[field].__getitem__(listindex).__dict__[subfield]
|
---|
| 48 | except AttributeError:
|
---|
| 49 | Var = md.__dict__[group].__dict__[field].__getitem__(listindex)[subfield]
|
---|
| 50 | + except KeyError:
|
---|
| 51 | + #Some fields only exist for the first step
|
---|
| 52 | + continue
|
---|
| 53 | Var = SqueezeVar(Var)
|
---|
| 54 | StackedVar = np.vstack((StackedVar, Var))
|
---|
| 55 | if debug:
|
---|
| 56 | @@ -173,7 +149,6 @@
|
---|
| 57 | if ncvar is not None:
|
---|
| 58 | FillVar(ncvar, Var)
|
---|
| 59 | NCData.close()
|
---|
| 60 | - print("export time is {}".format(time.time() - res_time))
|
---|
| 61 |
|
---|
| 62 | # }}}
|
---|
| 63 |
|
---|
| 64 | Index: ../trunk-jpl/src/m/io/loadvars.py
|
---|
| 65 | ===================================================================
|
---|
| 66 | --- ../trunk-jpl/src/m/io/loadvars.py (revision 25062)
|
---|
| 67 | +++ ../trunk-jpl/src/m/io/loadvars.py (revision 25063)
|
---|
| 68 | @@ -123,7 +123,8 @@
|
---|
| 69 | keylist = [key for key in curclass.variables]
|
---|
| 70 | dimlist = [curclass.variables[key].dimensions for key in keylist]
|
---|
| 71 | indexlist = np.arange(0, len(NCFile.dimensions['Time']))
|
---|
| 72 | - if 'Time' in np.all(dimlist):
|
---|
| 73 | + AllHaveTime = np.all(['Time' in dimtuple for dimtuple in dimlist])
|
---|
| 74 | + if AllHaveTime:
|
---|
| 75 | #Time dimension is in all the variables so we take that as stepnumber for the results
|
---|
| 76 | listtype = curclass.classtype
|
---|
| 77 | nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = [getattr(__import__(listtype), listtype)() for i in range(max(1, len(NCFile.dimensions['Time'])))]
|
---|