team-8/hydroshoot/example/potted_grapevine/sim.py

43 lines
1.3 KiB
Python
Raw Permalink Normal View History

2025-08-02 13:46:28 +02:00
"""This is an example on running HydroShoot on a potted grapevine with a
simple shoot architecture.
"""
from json import load
from pathlib import Path
from openalea.mtg import traversal, mtg
from openalea.plantgl.all import Scene
from hydroshoot import architecture, display, model
def build_mtg(path_file: Path, is_show_scene: bool = True) -> (mtg.MTG, Scene):
grapevine_mtg = architecture.vine_mtg(file_path=path_file)
for v in traversal.iter_mtg2(grapevine_mtg, grapevine_mtg.root):
architecture.vine_phyto_modular(grapevine_mtg, v)
architecture.vine_mtg_properties(grapevine_mtg, v)
architecture.vine_mtg_geometry(grapevine_mtg, v)
architecture.vine_transform(grapevine_mtg, v)
# Display of the plant mock-up (result in 'fig_01_plant_mock_up.png')
mtg_scene = display.visu(grapevine_mtg, def_elmnt_color_dict=True, scene=Scene(), view_result=is_show_scene)
return grapevine_mtg, mtg_scene
if __name__ == '__main__':
path_project = Path(__file__).parent
g, scene = build_mtg(path_file=path_project / 'grapevine_pot.csv')
with open(path_project / 'params.json') as f:
user_params = load(f)
summary_results = model.run(
g=g,
wd=path_project,
path_weather=path_project / 'meteo.input',
scene=scene,
psi_soil=-0.2,
gdd_since_budbreak=100.)