"""For the log eq model we should remove edge cultures from the objective fuction. Read in the saved data, add "obj_fun_internals" and resave. """ import numpy as np import json from cans2.cans_funcs import dict_to_json from cans2.process import find_best_fits, remove_edges log_path = "results/log_eq_fit_*.json" # Remove the edge cultures from the obj_fun and resave files. all_fit_paths = np.array(find_best_fits(log_path, num=None, key="obj_fun"))[:, 0] for path in all_fit_paths: with open(path, "r") as f: data = json.load(f) obj_fun_internals = np.sum(remove_edges(data["culture_obj_funs"], data["rows"], data["cols"])) data["obj_fun_internals"] = obj_fun_internals with open(path, "w") as f: json.dump(dict_to_json(data), f, sort_keys=True, indent=4)
with open(error_file, 'a') as f: f.write(error_log) continue t1 = time.time() # Set out dir/files for data and plots. outdir = "results/p15_fits/full_plate/CompModelBC/" datafile = (outdir + "argv_{0}_b_guess_{1}.json").format( sys.argv[1], b_guess) sbmlfile = (outdir + "sbml/argv_{0}_b_guess_{1}.xml").format( sys.argv[1], b_guess) plotfile = (outdir + "plots/argv_{0}_b_guess_{1}.pdf").format( sys.argv[1], b_guess) # Cannot serialize Plate and Model objects as json guess_kwargs = dict_to_json(guess_kwargs) json_guess_kwargs = {} for k, v in guess_kwargs.items(): try: json.dumps(v) except TypeError: pass else: json_guess_kwargs[k] = v data = { 'source_data': 'p15', 'rows': full_plate.rows, 'cols': full_plate.cols, 'c_meas': full_plate.c_meas, 'times': full_plate.times, 'argv': int(sys.argv[1]),
'kn': 0.1, } custom_params['kn'] = 0.2 model = CompModel() times = np.linspace(0, 5, 21) # Generate sets of simulated amounts for i in range(1): plate1 = Plate(rows, cols) plate1.times = times plate1.set_sim_data(model, r_mean=mean, r_var=var, custom_params=custom_params) data = { 'sim_params': plate1.sim_params, 'sim_amounts': plate1.sim_amounts, 'c_meas': plate1.c_meas, 'times': plate1.times, 'r_mean': mean, 'r_var': var, 'rows': plate1.rows, 'cols': plate1.cols, 'model': model.name, 'model_params': model.params, } data = dict_to_json(data) with open(file_name, 'w') as f: json.dump(data, f, sort_keys=True, indent=4)