Reference guide#
This manual details, for each module of openalea.fspmwheat,
the functions and objects included in openalea.fspmwheat,
describing what they are and what they do.
openalea.fspmwheat package#
openalea.fspmwheat.caribu_facade module#
- openalea.fspmwheat.caribu_facade.CARIBU_OUTPUTS = ['PARa', 'Erel', 'PARa_prim', 'Erel_prim']#
the outputs of Caribu
- class openalea.fspmwheat.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', azimuts=4, zenits=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’.
azimuts (int) – The number of azimutal positions.
zenits (int) – The number of zenital 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.fspmwheat.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.fspmwheat.cnwheat_facade module#
- openalea.fspmwheat.cnwheat_facade.CNWHEAT_ATTRIBUTES_MAPPING = {<class 'openalea.cnwheat.model.Chaff'>: 'chaff', <class 'openalea.cnwheat.model.Grains'>: 'grains', <class 'openalea.cnwheat.model.HiddenZone'>: 'hiddenzone', <class 'openalea.cnwheat.model.Internode'>: 'internode', <class 'openalea.cnwheat.model.Lamina'>: 'lamina', <class 'openalea.cnwheat.model.Peduncle'>: 'peduncle', <class 'openalea.cnwheat.model.Phloem'>: 'phloem', <class 'openalea.cnwheat.model.Roots'>: 'roots', <class 'openalea.cnwheat.model.Sheath'>: 'sheath'}#
the mapping of CNWheat organ classes to the attributes in axis and phytomer which represent an organ
- class openalea.fspmwheat.cnwheat_facade.CNWheatFacade(shared_mtg, delta_t, culm_density, update_parameters, 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, update_shared_df=True)[source]#
Bases:
objectThe CNWheatFacade class permits to initialize, run the model CNWheat 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, graphs_dirpath='.')[source]#
Generate the graphs and save them into graphs_dirpath.
- Parameters:
axes_postprocessing_df (pandas.DataFrame) – CN-Wheat outputs at axis scale
hiddenzones_postprocessing_df (pandas.DataFrame) – CN-Wheat outputs at hidden zone scale
organs_postprocessing_df (pandas.DataFrame) – CN-Wheat outputs at organ scale
elements_postprocessing_df (pandas.DataFrame) – CN-Wheat outputs at element scale
soils_postprocessing_df (pandas.DataFrame) – CN-Wheat outputs at soil scale
graphs_dirpath (str) – the path of the directory to save the generated graphs in
- 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 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:
tuple [pandas.DataFrame]
- openalea.fspmwheat.cnwheat_facade.MTG_RUN_VARIABLES = {'Ag', 'Amino_Acids_import', 'C_exudated', 'C_exudation', 'Conc_Nitrates_Soil', 'D_Fructan', 'D_Proteins', 'D_Starch', 'D_cytokinins', 'Export_Amino_Acids', 'Export_Nitrates', 'Export_cytokinins', 'HATS_LATS', 'Loading_Amino_Acids', 'Loading_Sucrose', 'N_exudation', 'Nitrates_import', 'Nstruct', 'Photosynthesis', 'RGR_Structure', 'R_Nnit_red', 'R_Nnit_upt', 'R_grain_growth_starch', 'R_grain_growth_struct', 'R_phloem_loading', 'R_residual', 'Regul_S_Fructan', 'Respi_growth', 'S_Amino_Acids', 'S_Fructan', 'S_Proteins', 'S_Starch', 'S_Sucrose', 'S_cytokinins', 'S_grain_starch', 'S_grain_structure', 'Tair', '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', 'mineralisation', 'mstruct', 'nb_replications', 'nitrates', 'proteins', 'ratio_DZ', 'regul_transpiration', 'senesced_mstruct', 'starch', 'structure', 'sucrose', 'sum_respi', 'sum_respi_roots', 'sum_respi_shoot', 'triosesP', 'volume'}#
all the variables to be stored in the MTG
- openalea.fspmwheat.cnwheat_facade.MTG_TO_CNWHEAT_AXES_ORGANS_MAPPING = {'grains': <class 'openalea.cnwheat.model.Grains'>, 'phloem': <class 'openalea.cnwheat.model.Phloem'>, 'roots': <class 'openalea.cnwheat.model.Roots'>}#
the mapping of organs (which belong to an axis) labels in MTG to organ classes in CNWheat
- openalea.fspmwheat.cnwheat_facade.MTG_TO_CNWHEAT_PHYTOMERS_ORGANS_MAPPING = {'blade': <class 'openalea.cnwheat.model.Lamina'>, 'ear': <class 'openalea.cnwheat.model.Chaff'>, 'hiddenzone': <class 'openalea.cnwheat.model.HiddenZone'>, 'internode': <class 'openalea.cnwheat.model.Internode'>, 'peduncle': <class 'openalea.cnwheat.model.Peduncle'>, 'sheath': <class 'openalea.cnwheat.model.Sheath'>}#
the mapping of organs (which belong to a phytomer) labels in MTG to organ classes in CNWheat
- openalea.fspmwheat.cnwheat_facade.POPULATION_RUN_VARIABLES = {'Ag', 'Amino_Acids_import', 'C_exudated', 'C_exudation', 'D_Fructan', 'D_Proteins', 'D_Starch', 'D_cytokinins', 'Export_Amino_Acids', 'Export_Nitrates', 'Export_cytokinins', 'HATS_LATS', 'Loading_Amino_Acids', 'Loading_Sucrose', 'N_exudation', 'Nitrates_import', 'Nstruct', 'Photosynthesis', 'RGR_Structure', 'R_Nnit_red', 'R_Nnit_upt', 'R_grain_growth_starch', 'R_grain_growth_struct', 'R_phloem_loading', 'R_residual', 'Regul_S_Fructan', 'Respi_growth', 'S_Amino_Acids', 'S_Fructan', 'S_Proteins', 'S_Starch', 'S_Sucrose', 'S_cytokinins', 'S_grain_starch', 'S_grain_structure', 'Tair', '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', 'mstruct', 'nb_replications', 'nitrates', 'proteins', 'ratio_DZ', 'regul_transpiration', 'senesced_mstruct', 'starch', 'structure', 'sucrose', 'sum_respi', 'sum_respi_roots', 'sum_respi_shoot', 'triosesP'}#
all the variables of a CNWheat population computed during a run step of the simulation
- openalea.fspmwheat.cnwheat_facade.POPULATION_STATE_VARIABLE = {'Ag', 'C_exudated', 'Nstruct', 'Tair', 'Tr', 'Ts', 'age_from_flowering', 'amino_acids', 'cytokinins', 'fructan', 'green_area', 'is_growing', 'mstruct', 'nitrates', 'proteins', 'ratio_DZ', 'senesced_mstruct', 'starch', 'structure', 'sucrose', 'sum_respi_roots', 'sum_respi_shoot', 'triosesP'}#
the parameters and variables which define the state of a CNWheat population
openalea.fspmwheat.elongwheat_facade module#
- class openalea.fspmwheat.elongwheat_facade.ElongWheatFacade(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, update_parameters=None, update_shared_df=True, option_static=False)[source]#
Bases:
objectThe ElongWheatFacade class permits to initialize, run the model ElongWheat 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
- run(Tair, Tsoil, option_static=False, optimal_growth_option=False, update_shared_df=None)[source]#
Run the model and update the MTG and the dataframes shared between all models.
- Parameters:
Tair (float) – Air temperature at t (degree Celsius)
Tsoil (float) – Soil temperature at t (degree Celsius)
option_static (bool) – Whether the model should be run for a static plant architecture
optimal_growth_option (bool) – if True the model will assume optimal growth conditions
update_shared_df (bool) – if ‘True’, update the shared dataframes at this time step.
openalea.fspmwheat.farquharwheat_facade module#
- openalea.fspmwheat.farquharwheat_facade.FARQUHARWHEAT_ELEMENTS_INPUTS = ['HiddenElement', 'StemElement', 'LeafElement1']#
names of the elements
- openalea.fspmwheat.farquharwheat_facade.FARQUHARWHEAT_ORGANS_NAMES = {'blade', 'ear', 'internode', 'peduncle', 'sheath'}#
the name of the organs modeled by FarquharWheat
- class openalea.fspmwheat.farquharwheat_facade.FarquharWheatFacade(shared_mtg, model_elements_inputs_df, model_axes_inputs_df, shared_elements_inputs_outputs_df, update_parameters=None, update_shared_df=True)[source]#
Bases:
objectThe FarquharWheatFacade class permits to initialize, run the model FarquharWheat 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.fspmwheat.farquharwheat_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.fspmwheat.fspmwheat_facade module#
- openalea.fspmwheat.fspmwheat_facade.AXES_TOPOLOGY_COLUMNS = ['plant', 'axis']#
columns which define the topology in the input/output dataframe
- openalea.fspmwheat.fspmwheat_facade.AXES_VARIABLES = {'C_exudated', 'GA', 'SAM_height', 'SAM_temperature', 'Total_Transpiration', 'cohort', 'delta_teq', 'delta_teq_roots', 'mstruct', 'nb_leaves', 'senesced_mstruct', 'status', 'sum_TT', 'sum_respi_roots', 'sum_respi_shoot', 'teq_since_primordium'}#
variables in each input/output dataframe
openalea.fspmwheat.fspmwheat_postprocessing module#
- openalea.fspmwheat.fspmwheat_postprocessing.calculate_performance_indices(scenario_outputs_dirpath, scenario_postprocessing_dirpath, meteo_dirpath, plant_density)[source]#
Average RUE and photosynthetic yield for the whole cycle.
- openalea.fspmwheat.fspmwheat_postprocessing.canopy_dynamics(scenario_postprocessing_dirpath, meteo_dirpath, plant_density=250)[source]#
Dynamics of variables at canopy level
openalea.fspmwheat.growthwheat_facade module#
- class openalea.fspmwheat.growthwheat_facade.GrowthWheatFacade(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, update_parameters=None, update_shared_df=True)[source]#
Bases:
objectThe GrowthWheatFacade class permits to initialize, run the model GrowthWheat 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.fspmwheat.senescwheat_facade module#
- openalea.fspmwheat.senescwheat_facade.PHOTOSYNTHETIC_ORGANS_NAMES = {'blade', 'ear', 'internode', 'peduncle', 'sheath'}#
the name of the photosynthetic organs modeled by SenescWheat
- openalea.fspmwheat.senescwheat_facade.SHARED_AXES_INPUTS_OUTPUTS_INDEXES = ['plant', 'axis']#
the columns which define the topology in the organs scale dataframe shared between all models
- openalea.fspmwheat.senescwheat_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.fspmwheat.senescwheat_facade.SHARED_ORGANS_INPUTS_OUTPUTS_INDEXES = ['plant', 'axis', 'organ']#
the columns which define the topology in the organs scale dataframe shared between all models
- class openalea.fspmwheat.senescwheat_facade.SenescWheatFacade(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 SenescWheatFacade class permits to initialize, run the model SenescWheat from a
MTG, and update the MTG and the dataframes shared between all models. Userun()to run the model.
openalea.fspmwheat.tools module#
- openalea.fspmwheat.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.fspmwheat.tools.plot_linear_regression(x_array, y_array, x_label='x', y_label='y', plot_filepath=None)[source]#
Perform a linear regression of x_array vs y_array and create a plot showing the fit against the original data. If plot_filepath is not None, save the plot to a PNG file. Otherwise display the plot.
This is derived from http://learningzone.rspsoc.org.uk/index.php/Learning-Materials/Python-Scripting/6.4-Fitting-linear-equations, which is under license CC BY-NC-SA 3.0 (https://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US).
- Parameters:
x_array (numpy.ndarray) – The first set of measurements.
y_array (numpy.ndarray) – The second set of measurements.
x_label (str) – The label of the abscissa axis. Default is ‘x’.
y_label (str) – The label of the ordinates axis. Default is ‘y’.
plot_filepath (str) – The file path to save the plot in. If None, do not save the plot.
- Examples:
>>> import pandas as pd >>> modelmaker_output_df = pd.read_csv('modelmaker_output.csv') # 'modelmaker_output.csv' must contain at least the column 'Sucrose_Phloem' >>> cnwheat_output_df = pd.read_csv('cnwheat_output.csv') # 'cnwheat_output.csv' must contain at least the column 'Sucrose_Phloem' >>> plot_linear_regression(modelmaker_output_df.Sucrose_Phloem, cnwheat_output_df.Sucrose_Phloem, x_label='modelmaker_{}'.format('Sucrose_Phloem'), y_label='cnwheat_{}'.format('Sucrose_Phloem'), plot_filepath='compare.png')