Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions fc/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ def run_protocol():
def extract_outputs():
"""Extract CSV files of outputs from a single HDF5 file."""
parser = argparse.ArgumentParser(description='Extract CSV files from a protocol output HDF5 file')
parser.add_argument('-o', '--output', help='a specific output name to extract')
parser.add_argument('h5path', help='path to the HDF5 file containing all outputs')
args = parser.parse_args()

with tables.open_file(args.h5path, 'r') as h5file:
output_folder = os.path.dirname(args.h5path)
for output in h5file.root.output._v_leaves.keys():
extract_output(h5file, output, output_folder)
if args.output:
extract_output(h5file, args.output, output_folder)
else:
for output in h5file.root.output._v_leaves.keys():
extract_output(h5file, output, output_folder)


def check_syntax():
Expand Down
14 changes: 12 additions & 2 deletions fc/code_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@
from cellmlmanip.parser import SYMPY_SYMBOL_DELIMITER, Transpiler
from cellmlmanip.printer import Printer

# Tell cellmlmanip to create _exp objects instead of exp objects. This prevents Sympy doing simplification (or
# Tell cellmlmanip to create _exp objects instead of exp objects, etc. This prevents Sympy doing simplification (or
# canonicalisation) resulting in weird errors with exps in some cardiac models.
Transpiler.set_mathml_handler('exp', sympy.Function('_exp'))
Transpiler.set_mathml_handler('abs', sympy.Function('_abs'))
Transpiler.set_mathml_handler('sqrt', sympy.Function('_sqrt'))
Transpiler.set_mathml_handler('sin', sympy.Function('_sin'))
Transpiler.set_mathml_handler('cos', sympy.Function('_cos'))
Transpiler.set_mathml_handler('acos', sympy.Function('_acos'))


# Shared Jinja environment
Expand Down Expand Up @@ -129,8 +134,13 @@ class WebLabPrinter(Printer):
def __init__(self, symbol_function=None, derivative_function=None):
super().__init__(symbol_function, derivative_function)

# Deal with _exp function introduced to avoid simplification
# Deal with functions introduced to avoid simplification
self._function_names['_exp'] = 'math.exp'
self._function_names['_abs'] = 'math.fabs'
self._function_names['_sqrt'] = 'math.sqrt'
self._function_names['_sin'] = 'math.sin'
self._function_names['_cos'] = 'math.cos'
self._function_names['_acos'] = 'math.acos'


def get_unique_names(model):
Expand Down
16 changes: 12 additions & 4 deletions fc/data_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,16 @@ def load(file_path):
f = gzip.GzipFile(real_path, 'rb')
else:
f = open(real_path, 'r')
f.readline() # strip comment line
dims = list(map(int, f.readline().split(',')))[1:]
array = np.loadtxt(f, dtype=float)
# Check for presence of comment line indicating special n-d format
comment = f.readline()
if comment.startswith('#'):
dims = list(map(int, f.readline().strip().split(',')))[1:]
array = np.loadtxt(f, dtype=float)
result = V.Array(array.reshape(tuple(dims)))
else:
# Simple 1d column-oriented data
f.seek(0)
array = np.loadtxt(f, dtype=float)
result = V.Array(array)
f.close()
return V.Array(array.reshape(tuple(dims)))
return result
2 changes: 1 addition & 1 deletion fc/simulations/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def simulate(self, end_point):
for name, expr in self.input_exprs.items():
self.proto.set_input(name, expr.evaluate(self.sim_env))
# self.proto.SetOutputfolder(self.output_path) #TODO
self.proto.run()
self.proto.run(write_out=False)


class TestOdeModel(AbstractOdeModel):
Expand Down
2,003 changes: 1,001 additions & 1,002 deletions test/output/real/aslanidi_Purkinje_model_2009/NCX_block/outputs_detailed_voltage.csv

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# APD90
1,11
113.7025702663205
112.2887184503283
110.8843715004111
109.489444734739
108.1039583517426
106.7280027680522
105.3634125858407
104.0082867478811
102.6624630270142
101.3265499071116
100
1.137024883097638082e+02
1.122889659381754655e+02
1.108847784389487572e+02
1.094895502345863036e+02
1.081041933317954857e+02
1.067280965952242440e+02
1.053635702981335669e+02
1.040084862165954291e+02
1.026628406790865569e+02
1.013265493794613405e+02
1.000000000000000000e+02
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Resting potential
1,11
-99.71737459216668
-99.74588090866968
-99.77434325432121
-99.80273737709383
-99.83108615772576
-99.85937196116815
-99.88760584136625
-99.91579160696091
-99.94392018712578
-99.97198403007278
-100
-9.971737498371513198e+01
-9.974588083467261868e+01
-9.977434409535084114e+01
-9.980273908271838934e+01
-9.983108771753339283e+01
-9.985937258207981415e+01
-9.988760600541388612e+01
-9.991579180449498665e+01
-9.994392106046188928e+01
-9.997198485451123418e+01
-1.000000000000000000e+02
2,003 changes: 1,001 additions & 1,002 deletions test/output/real/aslanidi_atrial_model_2009/GraphState/outputs_state.csv

Large diffs are not rendered by default.

Loading