Skip to content

Commit e6255a8

Browse files
committed
unify the output to a single json file
1 parent 41cad8b commit e6255a8

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

navicat_mikimo/plot_function.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import matplotlib
23
import matplotlib.pyplot as plt
34
import numpy as np
@@ -260,10 +261,15 @@ def plot_evo_save(result_solve_ivp, name, states, x_scale, more_species_mkm):
260261
tail = str(f"_{name}")
261262

262263
fig.savefig(f"mkm{tail}.png", dpi=400)
263-
np.savetxt(f"t{tail}.txt", result_solve_ivp.t)
264-
np.savetxt(f"cat{tail}.txt", result_solve_ivp.y[0, :])
265-
np.savetxt(f"Rs{tail}.txt", result_solve_ivp.y[r_indices])
266-
np.savetxt(f"Ps{tail}.txt", result_solve_ivp.y[p_indices])
264+
output_data = {
265+
"time": result_solve_ivp.t.tolist(),
266+
"catalyst": result_solve_ivp.y[0, :].tolist(),
267+
"reactants": result_solve_ivp.y[r_indices].tolist(),
268+
"products": result_solve_ivp.y[p_indices].tolist(),
269+
}
270+
271+
with open(f"mkm_output{tail}.json", "w") as f:
272+
json.dump(output_data, f, indent=4)
267273

268274

269275
def plot_save_cond(x, Pfs, var, prod_name, verb=1):

0 commit comments

Comments
 (0)