def test_bgc_dep_graph_computation(self): cs = h.bgc_md2_computers() possible_types = all_mvars(cs).difference( {VegetationCarbonInputPartitioningTuple}) #print(TypeSet(possible_types)) for t in possible_types: print(t.__name__) for root in possible_types: before_dg = now() with self.subTest(root=root): gs = list( all_dep_graphs(root_type=root, cs=cs, given=frozenset())) fig = plt.figure() axs = fig.subplots(len(gs), 1) for i, ax in enumerate(axs): g = gs[i] g.draw_matplotlib(ax) fig.savefig("depgraphs_" + root.__name__ + '.pdf') after_dg = now() time = (after_dg - before_dg) #if time >1: if True: print("depgraph time", root, time, len(gs))
def test_bgc_fast_graph_computation(self): cs = h.bgc_md2_computers() possible_types = all_mvars(cs).difference( {VegetationCarbonInputPartitioningTuple}) #print(TypeSet(possible_types)) for t in possible_types: print(t.__name__) for root in possible_types: before_dg = now() with self.subTest(root=root): before_fg = now() fg = fast_graph(cs=cs, root_type=root, given=frozenset()) after_fg = now() time = (after_fg - before_fg) if time > 1: print("fast_graph time", root, time) fig = plt.figure(figsize=(20, 20)) ax1 = fig.add_subplot(1, 1, 1) fg.draw_matplotlib(ax1) fig.savefig(root.__name__ + '.pdf') after_dg = now() time = (after_dg - before_dg) #if time >1: if True: print("fast_graph time", root, time)
### Had to divide Respiration fluxes by state variables because the flux was not presented as a rate*state variable tuple. t = TimeSymbol("t") # parameter_sets: # - "Original dataset of the publication": # values: {k_n: 0.5, omega: 0.8, epsilon_L: 0.35, epsilon_S: 0.1, epsilon_R: 0.55} # desc: Eastern US and Germany, cold broadleaf deciduous # doi: 10.1111/j.1365-2486.2004.00890.x mvs = CMTVS( { BibInfo( # Bibliographical Information name="CTEM", longName="Canadian Terrestrial Ecosystem Model", version="1", entryAuthor="Verónika Ceballos-Núñez", entryAuthorOrcid="0000-0002-0046-1160", entryCreationDate="21/1/2016", doi="10.1111/j.1365-2486.2004.00890.x", sym_dict=sym_dict), A, # the overall compartmental matrix Input, # the overall input t, # time for the complete system x, # state vector of the complete system # VegetationCarbonInputScalar(u), # vegetation carbon partitioning. VegetationCarbonStateVariableTuple((C_L, C_S, C_R)), }, bgc_md2_computers())
# - fig = plt.figure() plot_solutions( fig, times=range(sol_opt.shape[0]), var_names=Observables._fields, tup=(sol_opt, obs), #tup=(sol_opt,), #names=('opt') names=('opt', 'obs')) fig.savefig('solutions.pdf') from ComputabilityGraphs.helpers import all_mvars from ComputabilityGraphs.TypeSet import TypeSet for t in all_mvars(h.bgc_md2_computers()): print(t.__name__) # + #mvs.get_StateVariableTupleTimeDerivative() # + epa_opt = EstimatedParameters._make(C_opt) from model_specific_helpers import ModelParameters, Parameters apa = Parameters.from_EstimatedParametersAndUnEstimatedParameters(epa_opt, cpa) mpa = ModelParameters( **{k: v for k, v in apa._asdict().items() if k in ModelParameters._fields}) # -
def test_duplicated_computers(self): dcd = duplicated_computer_dict(h.bgc_md2_computers()) for key, val in dcd.items(): print(key, len(val)) for f in val: print(f.__name__)