diff --git a/boxmox/experiment.py b/boxmox/experiment.py index 8213d95fe2e4ff08b1f1865c0e44834cbb28be1a..17fe76c235ae9a5c31d62e9b941f1edee9bea4b1 100644 --- a/boxmox/experiment.py +++ b/boxmox/experiment.py @@ -31,10 +31,14 @@ class ExampleData: else: raise Exception("Input file {:s} does not exist.".format(name)) def __init__(self, path): - self.path = path + self.path = path self.files = { x.replace(".csv", ""): os.path.join(self.path, x) for x in os.listdir(self.path) if '.csv' in x } - -examples = { x: ExampleData(os.path.join(examplesPath, x)) for x in os.listdir(examplesPath) if os.path.isdir( os.path.join(examplesPath, x) ) } + self.mech = 'unknown' + try: + with open( os.path.join( self.path, 'mech_used' ) ) as f: + self.mech = f.readline() + except: + pass compiledMechsPath=os.path.join(os.environ['KPP_HOME'], "boxmox", "compiled_mechs") @@ -44,6 +48,9 @@ try: except: print("No compile_mechs directory found") +_examples = { x: ExampleData(os.path.join(examplesPath, x)) for x in os.listdir(examplesPath) if os.path.isdir( os.path.join(examplesPath, x) ) } +examples = { x: _examples[x] for x in _examples if _examples[x].mech in compiledMechs } + class Namelist: ''' A BOXMOX (Fortran 90) namelist. Getting and setting of values