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

Updated ConcentrationOutput reading routine (faster). Exposing

InputFileOrig, InputFile17 for documentation.
parent 843a9471
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@ except:
import _installation
from data import InputFile, Output, ConcentrationOutput, RatesOutput, AdjointOutput, JacobianOutput, HessianOutput
from data import InputFile, InputFileOrig, InputFile17, Output, ConcentrationOutput, RatesOutput, AdjointOutput, JacobianOutput, HessianOutput
from fluxes import FluxParser
work_path = _installation.validate()
......
......@@ -43,6 +43,11 @@ def _mygenfromtxt(f):
return np.array(dat, dtype=[(_, float) for _ in hdr])
def InputFile(fpath=None, version=1.7):
'''
Returns an instance of a BOXMOX input file class, either old format if
version < 1.7 (class InputFileOrig), or the current file format
(class InputFile17).
'''
if not fpath is None:
# file format discovery: 3 lines with numbers ==> 1.7
with open(fpath, 'rb') as f:
......@@ -324,7 +329,13 @@ class ConcentrationOutput(Output):
def __init__(self, fpath, vars=None):
self.fpath = fpath
with open(fpath, 'rb') as f:
self.data = _mygenfromtxt(f)
# not using mygenfromtxt as we know the file format and this is way faster...
spamreader = csv.reader(f, skipinitialspace = True, delimiter=" ")
hdr = spamreader.next()
dat = []
for row in spamreader:
dat.append( tuple(map(float, row)) )
self.data = np.array(dat, dtype=[(_, float) for _ in hdr])
self.times = self.data['time']
if not vars is None:
self.data = self.data[vars]
......
......@@ -129,7 +129,9 @@ Experiment
Input/Output
^^^^^^^^^^^^
.. autoclass:: InputFile
.. autofunction:: InputFile
.. autoclass:: InputFile17
.. autoclass:: InputFileOrig
.. autoclass:: ConcentrationOutput
:inherited-members:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment