Reference guide#
This manual details, for each module of openalea.cnwgrass.integration,
the functions and objects included in openalea.cnwgrass.integration,
describing what they are and what they do.
openalea.cnwgrass.integration package#
openalea.cnwgrass.integration.caribu_facade module#
- openalea.cnwgrass.integration.caribu_facade.CARIBU_OUTPUTS = ['PARa', 'Erel', 'PARa_prim', 'Erel_prim']#
the outputs of Caribu
- class openalea.cnwgrass.integration.caribu_facade.CaribuFacade(shared_mtg, shared_elements_inputs_outputs_df, geometrical_model, update_shared_df=True)[source]#
Bases:
objectThe CaribuFacade class permits to initialize, run the model Caribu from a
MTG, and update the MTG and the dataframes shared between all models.Use
run()to run the model.- run(run_caribu, sun_sky_option='mix', energy=1, DOY=1, hourTU=12, latitude=48.85, diffuse_model='soc', azimuths=4, zeniths=5, heterogeneous_canopy=False, plant_density=250.0, inter_row=0.15, update_shared_df=None, prim_scale=False)[source]#
Run the model and update the MTG and the dataframes shared between all models.
- Parameters:
run_caribu (bool) – If ‘True’, run the CARIBU model to calculate light distribution inside the 3D canopy.
sun_sky_option (str) – The irradiance model, should be one of ‘mix’ or ‘sun’ or ‘sky’
energy (float) – The incident PAR above the canopy (µmol m-2 s-1)
DOY (int) – Day Of the Year to be used for solar sources
hourTU (int) – Hour to be used for solar sources (Universal Time)
latitude (float) – latitude to be used for solar sources (°)
diffuse_model (string) – The kind of diffuse model, either ‘soc’ or ‘uoc’.
azimuths (int) – The number of azimuthal positions.
zeniths (int) – The number of zenithal positions.
heterogeneous_canopy (bool) – Whether to create a duplicated heterogeneous canopy from the initial mtg.
plant_density (float) – Number of plant per m2 in the stand (plant m-2).
inter_row (float) – Inter-row spacing in the stand (m).
update_shared_df (bool) – if ‘True’, update the shared dataframes at this time step.
prim_scale (bool) – If True, light distribution output at primitive scale, if not at organ scale
Update the MTG shared between all models from the population of Caribu. :param dict aggregated_outputs: {‘param1’: { vid1: , vid2, …}, ‘param2’: { vid1: , vid2, …}}
Update the dataframes shared between all models from the inputs dataframes or the outputs dataframes of the model. :param dict aggregated_outputs: {‘param1’: { vid1: , vid2, …}, ‘param2’: { vid1: , vid2, …}}
- openalea.cnwgrass.integration.caribu_facade.SHARED_ELEMENTS_INPUTS_OUTPUTS_INDEXES = ['plant', 'axis', 'metamer', 'organ', 'element']#
the columns which define the topology in the elements scale dataframe shared between all models
openalea.cnwgrass.integration.cnmetabolism_facade module#
- openalea.cnwgrass.integration.cnmetabolism_facade.CNMETABOLISM_ATTRIBUTES_MAPPING = {<class 'openalea.cnwgrass.cnmetabolism.model.Chaff'>: 'chaff', <class 'openalea.cnwgrass.cnmetabolism.model.Endosperm'>: 'endosperm', <class 'openalea.cnwgrass.cnmetabolism.model.Grains'>: 'grains', <class 'openalea.cnwgrass.cnmetabolism.model.HiddenZone'>: 'hiddenzone', <class 'openalea.cnwgrass.cnmetabolism.model.Internode'>: 'internode', <class 'openalea.cnwgrass.cnmetabolism.model.Lamina'>: 'lamina', <class 'openalea.cnwgrass.cnmetabolism.model.Peduncle'>: 'peduncle', <class 'openalea.cnwgrass.cnmetabolism.model.Phloem'>: 'phloem', <class 'openalea.cnwgrass.cnmetabolism.model.Roots'>: 'roots', <class 'openalea.cnwgrass.cnmetabolism.model.Sheath'>: 'sheath'}#
the mapping of CN-Metabolism organ classes to the attributes in axis and phytomer which represent an organ
- class openalea.cnwgrass.integration.cnmetabolism_facade.CNMetabolismFacade(shared_mtg, delta_t, culm_density, update_parameters, model_axes_inputs_df, model_organs_inputs_df, model_hiddenzones_inputs_df, model_elements_inputs_df, model_soils_inputs_df, shared_axes_inputs_outputs_df, shared_organs_inputs_outputs_df, shared_hiddenzones_inputs_outputs_df, shared_elements_inputs_outputs_df, shared_soils_inputs_outputs_df, tillers_replications=None, external_soil_model=False, update_shared_df=True)[source]#
Bases:
objectThe CNMetabolismFacade class permits to initialize, run the model CN-Metabolism from a
MTG, and update the MTG and the dataframes shared between all models.Use
run()to run the model.- static graphs(axes_postprocessing_df, hiddenzones_postprocessing_df, organs_postprocessing_df, elements_postprocessing_df, soils_postprocessing_df, meteo_data=None, graphs_dirpath='.')[source]#
Generate the graphs and save them into graphs_dirpath.
- Parameters:
axes_postprocessing_df (pandas.DataFrame) – CN-Metabolism outputs at axis scale
hiddenzones_postprocessing_df (pandas.DataFrame) – CN-Metabolism outputs at hidden zone scale
organs_postprocessing_df (pandas.DataFrame) – CN-Metabolism outputs at organ scale
elements_postprocessing_df (pandas.DataFrame) – CN-Metabolism outputs at element scale
soils_postprocessing_df (pandas.DataFrame) – CN-Metabolism outputs at soil scale
meteo_data (pandas.DataFrame) – the meteo dataframe having the mapping between t (hours) and calendar dates
graphs_dirpath (str) – the path of the directory to save the generated graphs
- static postprocessing(axes_outputs_df, organs_outputs_df, hiddenzone_outputs_df, elements_outputs_df, soils_outputs_df, delta_t)[source]#
Run the postprocessing.
- param pandas.DataFrame axes_outputs_df:
the outputs of the model at axis scale.
- param pandas.DataFrame organs_outputs_df:
the outputs of the model at organ scale.
- param pandas.DataFrame hiddenzone_outputs_df:
the outputs of the model at hiddenzone scale.
- param pandas.DataFrame elements_outputs_df:
the outputs of the model at element scale.
- param pandas.DataFrame soils_outputs_df:
the outputs of the model at element scale.
- param int delta_t:
The delta between two runs, in seconds.
- Returns:
- post-processing for each scale:
plant (see
PLANTS_RUN_POSTPROCESSING_VARIABLES)axis (see
AXES_RUN_POSTPROCESSING_VARIABLES)metamer (see
PHYTOMERS_RUN_POSTPROCESSING_VARIABLES)organ (see
ORGANS_RUN_POSTPROCESSING_VARIABLES)hidden zone (see
HIDDENZONE_RUN_POSTPROCESSING_VARIABLES)element (see
ELEMENTS_RUN_POSTPROCESSING_VARIABLES)and soil (see
SOILS_RUN_POSTPROCESSING_VARIABLES)
depending on the dataframes given as argument. For example, if user passes only dataframes plants_df, axes_df and metamers_df, then only post-processing dataframes of plants, axes and metamers are returned.
- Return type:
dict [‘scale’ : pandas.DataFrame]
- openalea.cnwgrass.integration.cnmetabolism_facade.MTG_RUN_VARIABLES = {'Ag', 'Amino_Acids_import', 'C_exudation', 'Conc_Nitrates_Soil', 'D_Fructan', 'D_Proteins', 'D_Starch', 'D_cytokinins', 'D_proteins', 'D_starch', 'Export_Amino_Acids', 'Export_Nitrates', 'Export_cytokinins', 'HATS_LATS', 'Loading_Amino_Acids', 'Loading_Sucrose', 'N_exudation', 'Nitrates_import', 'Nstruct', 'Photosynthesis', 'R_Nnit_red', 'R_Nnit_upt', 'R_grain_growth_starch', 'R_grain_growth_struct', 'R_phloem_loading', 'R_residual', 'Regul_S_Fructan', 'Respi_growth', 'SAM_temperature', 'SRWC', 'S_Amino_Acids', 'S_Fructan', 'S_Proteins', 'S_Starch', 'S_Sucrose', 'S_cytokinins', 'S_grain_starch', 'S_grain_structure', 'Total_Organic_Nitrogen', 'Total_Transpiration', 'Tr', 'Transpiration', 'Ts', 'Tsoil', 'Unloading_Amino_Acids', 'Unloading_Sucrose', 'Uptake_Nitrates', 'age_from_flowering', 'amino_acids', 'cytokinins', 'cytokinins_import', 'fructan', 'green_area', 'is_growing', 'is_over', 'mineralisation', 'moistening', 'mstruct', 'nb_leaves', 'nb_replications', 'nitrates', 'proteins', 'ratio_DZ', 'regul_transpiration', 'senesced_mstruct', 'starch', 'status', 'structure', 'sucrose', 'sum_respi', 'triosesP', 'volume'}#
all the variables to be stored in the MTG
- openalea.cnwgrass.integration.cnmetabolism_facade.MTG_TO_CNMETABOLISM_AXES_ORGANS_MAPPING = {'endosperm': <class 'openalea.cnwgrass.cnmetabolism.model.Endosperm'>, 'grains': <class 'openalea.cnwgrass.cnmetabolism.model.Grains'>, 'phloem': <class 'openalea.cnwgrass.cnmetabolism.model.Phloem'>, 'roots': <class 'openalea.cnwgrass.cnmetabolism.model.Roots'>}#
the mapping of organs (which belong to an axis) labels in MTG to organ classes in CN-Metabolism
- openalea.cnwgrass.integration.cnmetabolism_facade.MTG_TO_CNMETABOLISM_PHYTOMERS_ORGANS_MAPPING = {'blade': <class 'openalea.cnwgrass.cnmetabolism.model.Lamina'>, 'ear': <class 'openalea.cnwgrass.cnmetabolism.model.Chaff'>, 'hiddenzone': <class 'openalea.cnwgrass.cnmetabolism.model.HiddenZone'>, 'internode': <class 'openalea.cnwgrass.cnmetabolism.model.Internode'>, 'peduncle': <class 'openalea.cnwgrass.cnmetabolism.model.Peduncle'>, 'sheath': <class 'openalea.cnwgrass.cnmetabolism.model.Sheath'>}#
the mapping of organs (which belong to a phytomer) labels in MTG to organ classes in CN-Metabolism
- openalea.cnwgrass.integration.cnmetabolism_facade.POPULATION_RUN_VARIABLES = {'Ag', 'Amino_Acids_import', 'C_exudation', 'D_Fructan', 'D_Proteins', 'D_Starch', 'D_cytokinins', 'D_proteins', 'D_starch', 'Export_Amino_Acids', 'Export_Nitrates', 'Export_cytokinins', 'HATS_LATS', 'Loading_Amino_Acids', 'Loading_Sucrose', 'N_exudation', 'Nitrates_import', 'Nstruct', 'Photosynthesis', 'R_Nnit_red', 'R_Nnit_upt', 'R_grain_growth_starch', 'R_grain_growth_struct', 'R_phloem_loading', 'R_residual', 'Regul_S_Fructan', 'Respi_growth', 'SAM_temperature', 'S_Amino_Acids', 'S_Fructan', 'S_Proteins', 'S_Starch', 'S_Sucrose', 'S_cytokinins', 'S_grain_starch', 'S_grain_structure', 'Total_Organic_Nitrogen', 'Total_Transpiration', 'Tr', 'Transpiration', 'Ts', 'Unloading_Amino_Acids', 'Unloading_Sucrose', 'Uptake_Nitrates', 'age_from_flowering', 'amino_acids', 'cytokinins', 'cytokinins_import', 'fructan', 'green_area', 'is_growing', 'is_over', 'moistening', 'mstruct', 'nb_leaves', 'nb_replications', 'nitrates', 'proteins', 'ratio_DZ', 'regul_transpiration', 'senesced_mstruct', 'starch', 'status', 'structure', 'sucrose', 'sum_respi', 'triosesP'}#
all the variables of a CN-Metabolism population computed during a run step of the simulation
- openalea.cnwgrass.integration.cnmetabolism_facade.POPULATION_STATE_VARIABLE = {'Ag', 'Nstruct', 'SAM_temperature', 'Tr', 'Ts', 'age_from_flowering', 'amino_acids', 'cytokinins', 'fructan', 'green_area', 'is_growing', 'is_over', 'moistening', 'mstruct', 'nb_leaves', 'nitrates', 'proteins', 'ratio_DZ', 'senesced_mstruct', 'starch', 'status', 'structure', 'sucrose', 'triosesP'}#
the parameters and variables which define the state of a CN-Metabolism population
openalea.cnwgrass.integration.morphogenesis_facade module#
- class openalea.cnwgrass.integration.morphogenesis_facade.MorphogenesisFacade(shared_mtg, delta_t, model_axes_inputs_df, model_hiddenzones_inputs_df, model_elements_inputs_df, shared_axes_inputs_outputs_df, shared_hiddenzones_inputs_outputs_df, shared_elements_inputs_outputs_df, geometrical_model, phytoT=None, hydraulics=False, optimal_growth_option=False, option_static=False, update_parameters=None, update_shared_df=True)[source]#
Bases:
objectThe MorphogenesisFacade class permits to initialize, run the model Morphogenesis from a
MTG, and update the MTG and the dataframes shared between all models.Use
run()to run the model.- geometrical_model#
the model which deals with geometry
openalea.cnwgrass.integration.gasexchange_facade module#
- openalea.cnwgrass.integration.gasexchange_facade.GASEXCHANGE_ELEMENTS_INPUTS = ['HiddenElement', 'StemElement', 'LeafElement1']#
names of the elements
- openalea.cnwgrass.integration.gasexchange_facade.GASEXCHANGE_ORGANS_NAMES = {'blade', 'ear', 'internode', 'peduncle', 'sheath'}#
the name of the organs modelled by Gas-Exchange
- class openalea.cnwgrass.integration.gasexchange_facade.GasExchangeFacade(shared_mtg, model_elements_inputs_df, model_axes_inputs_df, shared_elements_inputs_outputs_df, stomatal_model_name='BWB', hydraulics=False, update_parameters=None, update_shared_df=True)[source]#
Bases:
objectThe GasExchangeFacade class permits to initialize, run the model Gas-Exchange from a
MTG, and update the MTG and the dataframes shared between all models.Use
run()to run the model.- run(Ta, ambient_CO2, RH, Ur, update_shared_df=None)[source]#
Run the model and update the MTG and the dataframes shared between all models.
- Parameters:
Ta (float) – air temperature at t (degree Celsius)
ambient_CO2 (float) – air CO2 at t (µmol mol-1)
RH (float) – relative humidity at t (decimal fraction)
Ur (float) – wind speed at the top of the canopy at t (m s-1)
update_shared_df (bool) – if ‘True’, update the shared dataframes at this time step.
- openalea.cnwgrass.integration.gasexchange_facade.SHARED_ELEMENTS_INPUTS_OUTPUTS_INDEXES = ['plant', 'axis', 'metamer', 'organ', 'element']#
the columns which define the topology in the elements scale dataframe shared between all models
openalea.cnwgrass.integration.build_outputs module#
- openalea.cnwgrass.integration.build_outputs.AXES_TOPOLOGY_COLUMNS = ['plant', 'axis']#
columns which define the topology in the input/output dataframe
- openalea.cnwgrass.integration.build_outputs.AXES_VARIABLES = {'SAM_temperature', 'Total_Transpiration', 'delta_teq', 'delta_teq_roots', 'mstruct', 'nb_leaves', 'status', 'sum_TT'}#
variables in each input/output dataframe
openalea.cnwgrass.integration.runner module#
- openalea.cnwgrass.integration.runner.get_management_value(df, variable_name)[source]#
Extracts management variables from the input file.
- Parameters:
df (pandas.DataFrame) – the dataframe with all management variables
variable_name (str) – name of the current management variable
return management_input :rtype float or dict
- openalea.cnwgrass.integration.runner.run(simulation_length, forced_start_time=0, run_simu=True, run_postprocessing=True, generate_graphs=True, run_from_outputs=False, stored_times=None, show_3Dplant=False, hydraulics=False, stomatal_model_name='BWB', drought_trigger=None, rehydration_scenario=None, optimal_growth_option=False, option_static=False, external_soil_model=False, tillers_replications=None, heterogeneous_canopy=True, update_parameters_all_models=None, step_callback=None, INPUTS_DIRPATH='inputs', METEO_FILENAME='meteo.csv', MANAGEMENT_FILENAME='management.csv', OUTPUTS_DIRPATH='outputs', POSTPROCESSING_DIRPATH='postprocessing', GRAPHS_DIRPATH='graphs')[source]#
Run a simulation of integration with coupling to several models
- Parameters:
simulation_length (int) – length of the simulation (hours)
forced_start_time (int) – desired start time (hour)
run_simu (bool) – whether to run the simulation
run_postprocessing (bool) – whether to run the postprocessing
generate_graphs (bool) – whether to run generate graphs
run_from_outputs (bool) – whether to start a simulation from a specific time and initial states as found in previous outputs
stored_times (str or list) – Time steps when are stored the model outputs. Can be either ‘all’, a list or an empty list. Default to ‘all’
show_3Dplant (bool) – whether to plot the scene in pgl viewer
hydraulics (bool) – if True the model will assume the coupling to the turgor-driven growth model
stomatal_model_name (str) – the model of stomatal conductance. Should be one of ‘BWB’, ‘Leuning’, ‘Tuzet’ or ‘hydraulics’. ‘Tuzet’ and ‘hydraulics’ requires hydraulics to be True
drought_trigger (dict or None) – a dict for external drought control scenario. {‘trigger_variable’: value}. For now, only implemented for ‘green_area’ variable (value = green area above which the drought will be triggered).
rehydration_scenario (dict or None) – a dict to specify the rehydration scenario. {‘stop_drought_SRWC’: SRWC at which the drought event stops (%), ‘SRWC_target’: Target SRWC for rehydration (%), ‘rehydration_duration’: duration of the rehydration period (days)}
optimal_growth_option (bool) – if True the model will assume optimal growth conditions
option_static (bool) – Whether the model should be run for a static plant architecture
external_soil_model (bool) – whether an external soil model is coupled to cnmetabolism. If True, cnmetabolism will skip calculations made in soil and uptake N by roots
tillers_replications (dict [str, float]) – a dictionary with tiller id as key, and weight of replication as value.
heterogeneous_canopy (bool) – Whether to create a duplicated heterogeneous canopy from the initial mtg.
update_parameters_all_models (dict) –
a dict to update model parameters {‘cnmetabolism’: {‘organ1’: {‘param1’: ‘val1’, ‘param2’: ‘val2’},
’organ2’: {‘param1’: ‘val1’, ‘param2’: ‘val2’}
},
’morphogenesis’: {‘param1’: ‘val1’, ‘param2’: ‘val2’}
}
step_callback (dict or None) – a dict of functions used to force some external inputs that are natively computed by the model {‘function_name’ : function , …}
INPUTS_DIRPATH (str) – the path directory of inputs # The directory at path ‘adel’ must contain files ‘adel_pars.RData’, ‘adel0000.pckl’ and ‘scene0000.bgeom’ for ADELWHEAT
METEO_FILENAME (str) – the name of the file with meteo data
MANAGEMENT_FILENAME (str) – the name of the file with managment data
OUTPUTS_DIRPATH (str) – the path to save outputs
POSTPROCESSING_DIRPATH (str) – the path to save postprocessings
GRAPHS_DIRPATH (str) – the path to save graphs
openalea.cnwgrass.integration.growth_facade module#
- class openalea.cnwgrass.integration.growth_facade.GrowthFacade(shared_mtg, delta_t, model_hiddenzones_inputs_df, model_elements_inputs_df, model_roots_inputs_df, model_axes_inputs_df, shared_organs_inputs_outputs_df, shared_hiddenzones_inputs_outputs_df, shared_elements_inputs_outputs_df, shared_axes_inputs_outputs_df, hydraulics=False, update_parameters=None, update_shared_df=True)[source]#
Bases:
objectThe GrowthFacade class permits to initialize, run the model Growth from a
MTG, and update the MTG and the dataframes shared between all models.Use
run()to run the model.- Parameters:
- run(postflowering_stages=False, update_shared_df=None)[source]#
Run the model and update the MTG and the dataframes shared between all models. :param bool postflowering_stages: if True the model will calculate root growth with the parameters calibrated for post flowering stages :param bool update_shared_df: if ‘True’, update the shared dataframes at this time step.
openalea.cnwgrass.integration.senescence_facade module#
- openalea.cnwgrass.integration.senescence_facade.PHOTOSYNTHETIC_ORGANS_NAMES = {'blade', 'ear', 'internode', 'peduncle', 'sheath'}#
the name of the photosynthetic organs modeled by Senescence
- class openalea.cnwgrass.integration.senescence_facade.SENESCENCEFacade(shared_mtg, delta_t, model_roots_inputs_df, model_axes_inputs_df, model_elements_inputs_df, shared_organs_inputs_outputs_df, shared_axes_inputs_outputs_df, shared_elements_inputs_outputs_df, update_parameters=None, update_shared_df=True)[source]#
Bases:
objectThe SENESCENCEFacade class permits to initialize, run the model Senescence from a
MTG, and update the MTG and the dataframes shared between all models. Userun()to run the model.
- openalea.cnwgrass.integration.senescence_facade.SHARED_AXES_INPUTS_OUTPUTS_INDEXES = ['plant', 'axis']#
the columns which define the topology in the organs scale dataframe shared between all models
- openalea.cnwgrass.integration.senescence_facade.SHARED_ELEMENTS_INPUTS_OUTPUTS_INDEXES = ['plant', 'axis', 'metamer', 'organ', 'element']#
the columns which define the topology in the elements scale dataframe shared between all models
- openalea.cnwgrass.integration.senescence_facade.SHARED_ORGANS_INPUTS_OUTPUTS_INDEXES = ['plant', 'axis', 'organ']#
the columns which define the topology in the organs scale dataframe shared between all models
openalea.cnwgrass.integration.tools module#
- openalea.cnwgrass.integration.tools.OUTPUTS_INDEXES = ['t', 'plant', 'axis', 'metamer', 'organ', 'element']#
All the possible indexes
- openalea.cnwgrass.integration.tools.additional_graphs(axes_outputs, hz_outputs, elements_outputs, axes_postprocessing, hz_postprocessing, elements_postprocessing, organs_postprocessing, plant_density, RER_max_param, GRAPHS_DIRPATH, data_obs)[source]#
- Parameters:
axes_outputs (pandas.DataFrame)
hz_outputs (pandas)
elements_outputs (pandas.DataFrame)
axes_postprocessing (pandas.DataFrame)
hz_postprocessing (pandas.DataFrame)
elements_postprocessing (pandas.DataFrame)
organs_postprocessing (pandas.DataFrame)
plant_density (int)
RER_max_param (dict)
GRAPHS_DIRPATH (str)
data_obs (pandas.DataFrame)
- openalea.cnwgrass.integration.tools.combine_dataframes_inplace(model_dataframe, shared_column_indexes, shared_dataframe_to_update)[source]#
Combine model_dataframe and shared_dataframe_to_update in-place:
re-index model_dataframe and shared_dataframe_to_update by shared_column_indexes,
use method pd.DataFrame.combine_first(),
reset to the right types in shared_dataframe_to_update,
reorder the columns: first columns in shared_column_indexes, then others columns alphabetically,
and reset the index in shared_dataframe_to_update.
- Parameters:
model_dataframe (pandas.DataFrame) – dataframe to use for updating shared_dataframe_to_update.
shared_column_indexes (list) – The indexes to re-index model_dataframe and shared_dataframe_to_update before combining them.
shared_dataframe_to_update (pandas.DataFrame) – The dataframe to update.
note:: shared_dataframe_to_update is updated in-place. Thus, shared_dataframe_to_update keeps the same object’s memory address.
- openalea.cnwgrass.integration.tools.compare_actual_to_desired(data_dirpath, actual_data_df, desired_data_filename, actual_data_filename=None, precision=4, overwrite_desired_data=False)[source]#
Compare
difference = actual_data_df - desired_data_df
to
tolerance = 10**-precision * (1 + abs(desired_data_df))
where
desired_data_df = pd.read_csv(os.path.join(data_dirpath, desired_data_filename))
If difference > tolerance, then raise an AssertionError.
- Parameters:
data_dirpath (str) – The path of the directory where to find the data to compare.
actual_data_df (pandas.DataFrame) – The computed data.
desired_data_filename (str) – The file name of the expected data.
actual_data_filename (str) – If not None, save the computed data to actual_data_filename, in directory data_dirpath. Default is None.
precision (int) – The precision to use for the comparison. Default is 4.
overwrite_desired_data (bool) – If True the comparison between actual and desired data is not run. Instead, the desired data will be overwritten using actual data. To be used with caution.
- openalea.cnwgrass.integration.tools.plot_outputs(outputs, x_name, y_name, x_label='', y_label='', x_lim=None, title=None, meteo_data=None, filters={}, plot_filepath=None, colors=[], linestyles=[], explicit_label=True, kwargs={})[source]#
Plot outputs, with x=`x_name` and y=`y_name`.
The general algorithm is:
find the scale of outputs and keep only the needed columns,
apply filters to outputs and make groups according to the scale,
plot each group as a new line,
save or display the plot.
- Parameters:
outputs (pandas.DataFrame) – The outputs of CN-Metabolism.
x_name (str) – x-axis of the plot.
y_name (str) – y-axis of the plot.
x_label (str) – The x label of the plot. Default is ‘’.
y_label (str or unicode) – The y label of the plot. Default is ‘’.
x_lim (float) – the x-axis limit.
title (str) – the title of the plot. If None (default), create a title which is the concatenation of y_name and each scales which cardinality is one.
meteo_data (pandas.DataFrame) – the meteo dataframe having the mapping between t (hours) and calendar dates
filters (dict) – A dictionary whose keys are the columns of outputs for which we want to apply a specific filter. These columns can be one or more element of
OUTPUTS_INDEXES. The value associated to each key is a criteria that the rows of outputs must satisfy to be plotted. The values can be either one value or a list of values. If no value is given for any column, then all rows are plotted (default).colors (list) – The colors for lines. If empty, let matplotlib default line colors.
linestyles (list) – The styles for lines. If empty, let matplotlib default line styles.
plot_filepath (str) – The file path to save the plot. If None, do not save the plot but display it.
explicit_label (bool) – True: makes the line label from concatenation of each scale id (default). - False: makes the line label from concatenation of scales containing several distinct elements.
kwargs (dict) – key arguments to be passed to matplolib
Examples:
import pandas as pd cnmetabolism_output_df = pd.read_csv('cnmetabolism_output.csv') # in this example, 'cnmetabolism_output.csv' must contain at least the columns 't' and 'Conc_Sucrose'. plot(cnmetabolism_output_df, x_name = 't', y_name = 'Conc_Sucrose', x_label='Time (Hour)', y_label=u'[Sucrose] (µmol g$^{-1}$ mstruct)', title='{} = f({})'.format('Conc_Sucrose', 't'), filters={'plant': 1, 'axis': 'MS', 'organ': 'Lamina', 'element': 1})
openalea.cnwgrass.integration.hydraulics_facade module#
- openalea.cnwgrass.integration.hydraulics_facade.MTG_RUN_VARIABLES = {'Growth', 'SAM_temperature', 'SRWC', 'Total_Transpiration_turgor', 'Tr', 'Ts', 'Tsoil', 'WC_mstruct', 'Wmax', 'age', 'amino_acids', 'delta_hiddenzone_dimensions_plastic', 'delta_leaf_L', 'delta_weq', 'epsilon_volume', 'fructan', 'green_area', 'hiddenzone_age', 'is_growing', 'lamina_Lmax', 'leaf_L', 'leaf_Lmax', 'leaf_Wmax', 'leaf_enclosed_mstruct', 'leaf_pseudo_age', 'leaf_pseudostem_length', 'length', 'length_hz_En', 'mstruct', 'omega', 'organ_volume', 'osmotic_water_potential', 'phi_length', 'phi_thickness', 'phi_volume', 'phi_width', 'plant_water_content', 'proteins', 'resistance', 'sucrose', 'thickness', 'total_water_influx', 'turgor_water_potential', 'volume', 'water_content', 'water_influx', 'water_outflow', 'water_potential', 'width'}#
all the variables to be stored in the MTG
- openalea.cnwgrass.integration.hydraulics_facade.MTG_TO_hydraulics_AXES_ORGANS_MAPPING = {'roots': <class 'openalea.cnwgrass.hydraulics.model.Roots'>, 'xylem': <class 'openalea.cnwgrass.hydraulics.model.Xylem'>}#
the mapping of organs (which belong to an axis) labels in MTG to organ classes in Hydraulics
- openalea.cnwgrass.integration.hydraulics_facade.MTG_TO_hydraulics_PHYTOMERS_ORGANS_MAPPING = {'blade': <class 'openalea.cnwgrass.hydraulics.model.Lamina'>, 'hiddenzone': <class 'openalea.cnwgrass.hydraulics.model.HiddenZone'>, 'internode': <class 'openalea.cnwgrass.hydraulics.model.Internode'>, 'sheath': <class 'openalea.cnwgrass.hydraulics.model.Sheath'>}#
the mapping of organs (which belong to a phytomer) labels in MTG to organ classes in Hydraulics
- openalea.cnwgrass.integration.hydraulics_facade.POPULATION_RUN_VARIABLES = {'Growth', 'SAM_temperature', 'SRWC', 'Total_Transpiration_turgor', 'Tr', 'Ts', 'Tsoil', 'WC_mstruct', 'Wmax', 'age', 'amino_acids', 'delta_hiddenzone_dimensions_plastic', 'delta_leaf_L', 'delta_weq', 'epsilon_volume', 'fructan', 'green_area', 'hiddenzone_age', 'is_growing', 'lamina_Lmax', 'leaf_L', 'leaf_Lmax', 'leaf_Wmax', 'leaf_enclosed_mstruct', 'leaf_pseudo_age', 'leaf_pseudostem_length', 'length', 'length_hz_En', 'mstruct', 'omega', 'organ_volume', 'osmotic_water_potential', 'phi_length', 'phi_thickness', 'phi_volume', 'phi_width', 'plant_water_content', 'proteins', 'resistance', 'sucrose', 'thickness', 'total_water_influx', 'turgor_water_potential', 'volume', 'water_content', 'water_influx', 'water_outflow', 'water_potential', 'width'}#
all the variables of a Hydraulics population computed during a run step of the simulation
- openalea.cnwgrass.integration.hydraulics_facade.POPULATION_STATE_VARIABLE = {'SAM_temperature', 'SRWC', 'Tr', 'Ts', 'Tsoil', 'Wmax', 'age', 'amino_acids', 'fructan', 'green_area', 'hiddenzone_age', 'is_growing', 'lamina_Lmax', 'leaf_L', 'leaf_Wmax', 'leaf_enclosed_mstruct', 'leaf_pseudo_age', 'leaf_pseudostem_length', 'length', 'length_hz_En', 'mstruct', 'proteins', 'sucrose', 'thickness', 'turgor_water_potential', 'water_content', 'width'}#
the parameters and variables which define the state of a Hydraulics population
- class openalea.cnwgrass.integration.hydraulics_facade.hydraulicsFacade(shared_mtg, delta_t, update_parameters, model_axes_inputs_df, model_hiddenzones_inputs_df, model_elements_inputs_df, model_organs_inputs_df, model_soils_inputs_df, shared_axes_inputs_outputs_df, shared_hiddenzones_inputs_outputs_df, shared_elements_inputs_outputs_df, shared_organs_inputs_outputs_df, shared_soils_inputs_outputs_df, update_shared_df=True)[source]#
Bases:
objectThe hydraulicsFacade class permits to initialize, run the model Hydraulics from a
MTG, and update the MTG and the dataframes shared between all models.Use
run()to run the model.- static graphs(axes_postprocessing_df, hiddenzones_postprocessing_df, elements_postprocessing_df, organs_postprocessing_df, soils_postprocessing_df, meteo_data, graphs_dirpath='.')[source]#
Generate the graphs and save them into graphs_dirpath.
- Parameters:
axes_postprocessing_df (pandas.DataFrame) – CN-Metabolism outputs at axis scale
hiddenzones_postprocessing_df (pandas.DataFrame) – CN-Metabolism outputs at hidden zone scale
organs_postprocessing_df (pandas.DataFrame) – CN-Metabolism outputs at organ scale
elements_postprocessing_df (pandas.DataFrame) – CN-Metabolism outputs at element scale
soils_postprocessing_df (pandas.DataFrame) – CN-Metabolism outputs at soil scale
meteo_data (pandas.DataFrame) – the meteo dataframe having the mapping between t (hours) and calendar dates
graphs_dirpath (str) – the path of the directory to save the generated graphs in
- static postprocessing(axes_outputs_df, hiddenzone_outputs_df, elements_outputs_df, organs_outputs_df, soils_outputs_df, delta_t)[source]#
Run the postprocessing.
- param pandas.DataFrame axes_outputs_df:
the outputs of the model at axis scale.
- param pandas.DataFrame organs_outputs_df:
the outputs of the model at organ scale.
- param pandas.DataFrame hiddenzone_outputs_df:
the outputs of the model at hiddenzone scale.
- param pandas.DataFrame elements_outputs_df:
the outputs of the model at element scale.
- param pandas.DataFrame soils_outputs_df:
the outputs of the model at element scale.
- param int delta_t:
The delta between two runs, in seconds.
- Returns:
- post-processing for each scale:
plant (see
PLANTS_RUN_POSTPROCESSING_VARIABLES)axis (see
AXES_RUN_POSTPROCESSING_VARIABLES)metamer (see
PHYTOMERS_RUN_POSTPROCESSING_VARIABLES)organ (see
ORGANS_RUN_POSTPROCESSING_VARIABLES)hidden zone (see
HIDDENZONE_RUN_POSTPROCESSING_VARIABLES)element (see
ELEMENTS_RUN_POSTPROCESSING_VARIABLES)and soil (see
SOILS_RUN_POSTPROCESSING_VARIABLES)
depending of the dataframes given as argument. For example, if user passes only dataframes plants_df, axes_df and metamers_df, then only post-processing dataframes of plants, axes and metamers are returned.
- Return type:
dict [‘scale’ : pandas.DataFrame]
- openalea.cnwgrass.integration.hydraulics_facade.hydraulics_ATTRIBUTES_MAPPING = {<class 'openalea.cnwgrass.hydraulics.model.HiddenZone'>: 'hiddenzone', <class 'openalea.cnwgrass.hydraulics.model.Internode'>: 'internode', <class 'openalea.cnwgrass.hydraulics.model.Lamina'>: 'lamina', <class 'openalea.cnwgrass.hydraulics.model.Roots'>: 'roots', <class 'openalea.cnwgrass.hydraulics.model.Sheath'>: 'sheath', <class 'openalea.cnwgrass.hydraulics.model.Xylem'>: 'xylem'}#
the mapping of Hydraulics organ classes to the attributes in axis and phytomer which represent an organ
- openalea.cnwgrass.integration.hydraulics_facade.hydraulics_ORGANS_TO_ELEMENTS_MAPPING = {<class 'openalea.cnwgrass.hydraulics.model.Internode'>: <class 'openalea.cnwgrass.hydraulics.model.InternodeElement'>, <class 'openalea.cnwgrass.hydraulics.model.Lamina'>: <class 'openalea.cnwgrass.hydraulics.model.LaminaElement'>, <class 'openalea.cnwgrass.hydraulics.model.Sheath'>: <class 'openalea.cnwgrass.hydraulics.model.SheathElement'>}#
the mapping of Hydraulics photosynthetic organs to Hydraulics photosynthetic organ elements