Skip to content
Snippets Groups Projects
Commit b4c6f8fb authored by Christoph.Knote's avatar Christoph.Knote
Browse files

Stupid data fix

parent 9d1dec7c
Branches
Tags
No related merge requests found
...@@ -108,7 +108,7 @@ class InputFile17: ...@@ -108,7 +108,7 @@ class InputFile17:
self.timeVar = hdr[0] self.timeVar = hdr[0]
self.time = [ x[0] for x in dmp ] self.time = [ x[0] for x in dmp ]
ntime = 1 ntime = 1
self.anc = { hdr[i]: [ x[i] for x in dmp ] for i in range(ntime, ntime+nanc) } self.anc = { hdr[i]: [ x[i] for x in dmp ] for i in range(ntime, ntime+nanc) }
self._data = { hdr[i]: [ x[i] for x in dmp ] for i in range(ntime+nanc, len(dmp[0])) } self._data = { hdr[i]: [ x[i] for x in dmp ] for i in range(ntime+nanc, len(dmp[0])) }
def __str__(self): def __str__(self):
...@@ -140,7 +140,12 @@ class InputFile17: ...@@ -140,7 +140,12 @@ class InputFile17:
line = [ xtime ] + [ self.anc[key][itime] for key in anc_names ] + [ self._data[key][itime] for key in data_names ] line = [ xtime ] + [ self.anc[key][itime] for key in anc_names ] + [ self._data[key][itime] for key in data_names ]
f.write(' '.join('{0:e}'.format(x) for x in line) + '\n') f.write(' '.join('{0:e}'.format(x) for x in line) + '\n')
else: else:
data_line = ' '.join( '{0:e}'.format(float(self.anc[x])) for x in self.anc.keys() ) + ' ' + ' '.join( '{0:e}'.format(float(self._data[x])) for x in self.keys() ) + '\n' def _data_fix(key):
if isinstance(self._data[x], list):
return self._data[x][0]
else:
return self._data[x]
data_line = ' '.join( '{0:e}'.format( float(self.anc[x])) for x in self.anc.keys() ) + ' ' + ' '.join( '{0:e}'.format( float(_data_fix(x))) for x in self.keys() ) + '\n'
if not self.time is None: if not self.time is None:
data_line = '{0:e}'.format(float(self.time)) + ' ' + data_line data_line = '{0:e}'.format(float(self.time)) + ' ' + data_line
f.write(data_line) f.write(data_line)
...@@ -227,7 +232,12 @@ class InputFileOrig: ...@@ -227,7 +232,12 @@ class InputFileOrig:
f.write(' '.join('{0:e}'.format(x) for x in line) + '\n') f.write(' '.join('{0:e}'.format(x) for x in line) + '\n')
else: else:
f.write('{0:s}' .format(' '.join( column_names)) +'\n') f.write('{0:s}' .format(' '.join( column_names)) +'\n')
f.write(' '.join( '{0:e}'.format(float(self._data[x])) for x in self.keys() ) + '\n') def _data_fix(key):
if isinstance(self._data[x], list):
return self._data[x][0]
else:
return self._data[x]
f.write(' '.join( '{0:e}'.format(float(_data_fix(x))) for x in self.keys() ) + '\n')
def __init__(self, fpath=None): def __init__(self, fpath=None):
#: Time format (0: constant, 1: seconds since start, 2: hour of diurnal cycle) #: Time format (0: constant, 1: seconds since start, 2: hour of diurnal cycle)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment