Skip to content
Snippets Groups Projects
Commit f6a9fa9c authored by Lemaire Louis's avatar Lemaire Louis
Browse files

[docs] docstrings structure

use "Args" for keyword arguments and "Returns" for function output
parent 47141431
No related branches found
No related tags found
1 merge request!38[feature] Gras-Sim model doctrings
......@@ -7,12 +7,13 @@ class Plants():
Initialize the plants.
Set the grid, the PFT composition, the initial variables, the Kc values, the PFT values, and the variables to save.
grid -- tuple of (x, y), shape of the grid
pft_composition -- dictionary of PFT composition
inits -- dictionary of initial variables
kc_values -- dictionary of Kc values
pft_values -- pandas DataFrame of PFT values
variables_to_save -- list of strings of variables to save
Args:
grid: tuple of (x, y), shape of the grid
pft_composition: dictionary of PFT composition
inits: dictionary of initial variables
kc_values: dictionary of Kc values
pft_values: pandas DataFrame of PFT values
variables_to_save: list of strings of variables to save
"""
self.nyears_data = {}
......@@ -100,10 +101,11 @@ class Plants():
Initialize the daily loop. Set the day, the year, the weather data, today's irradiance and the potential evapotranspiration.
If the first day of the year, reset ST to zero and initialize the output dictionary for the year.
day -- datetime object
WD -- dictionary with the weather data (Rain [mm], Avg_temp [°C])
ET0 -- potential evapotranspiration [mm]
day_irr -- today's irradiance [MJ/m²]
Args:
day: datetime object
WD: dictionary with the weather data (Rain [mm], Avg_temp [°C])
ET0: potential evapotranspiration [mm]
day_irr: today's irradiance [MJ/m²]
"""
self.day = day
self.year = str(day.year)
......
......@@ -14,6 +14,16 @@ from MODULES.DATA_MANAGEMENT.yaml_inputs_provider import YAML_Inputs_provider
from MODULES.CROPS.evapotranspiration_FAO56_PM import get_ET0
def run_grassim(config, WD, daily_irr, lat, alt):
"""
Run the GRASSIM model.
Args:
config: dictionary of configuration filenames
WD: dictionary of daily weather data
daily_irr: dictionary of daily irradiance [MJ/m²]
lat: latitude [°] for ET0 computation
alt: altitude [m] for ET0 computation
"""
soil_init = YAML_Inputs_provider(file=f"CROPS/GRASSIM/soil/{config['soil_init']}").inputs
crop_init = YAML_Inputs_provider(file=f"CROPS/GRASSIM/crop/{config['crop_init']}").inputs
......@@ -54,6 +64,18 @@ def run_grassim(config, WD, daily_irr, lat, alt):
def run_daily_loop(day, ET0, WD, day_irr, soil, crop, management):
"""
Run the daily loop.
Args:
day: datetime object
ET0: potential evapotranspiration [mm]
WD: weather data
day_irr: numpy array of today's spatialized irradiance [MJ/m²]
soil: soil object
crop: crop object
management: management object
"""
crop.init_daily_loop(day=day, WD=WD, ET0=ET0, day_irr=day_irr)
soil.init_daily_loop(day=day)
......@@ -97,10 +119,13 @@ def run_daily_loop(day, ET0, WD, day_irr, soil, crop, management):
def get_sim_dates(weather_data):
"""
weather_data : Weather_data object from weather_data_provider
returns :
simulation_dates : list of simulation days
Get the simulation dates.
Args:
weather_data: Weather_data object from weather_data_provider
Returns:
simulation_dates: list of simulation days
"""
simulation_dates = {}
......@@ -113,11 +138,26 @@ def get_sim_dates(weather_data):
def get_yaml_params(filename):
"""
Get the parameters from a YAML file.
Args:
filename: string of the filename
Returns:
parameters: dictionary of parameters
"""
return YAML_Inputs_provider(file=filename).inputs
def get_grid_shape(daily_irradiance):
"""
daily irradiance : daily_irr_spat dictionnary attribut from Ray_casting_scene object
Get the shape of the grid.
Args:
daily_irradiance: dictionary of daily irradiance [MJ/m²]
Returns:
grid_shape: shape of the grid
"""
return daily_irradiance[next(iter(daily_irradiance))].shape[0]
\ No newline at end of file
......@@ -8,9 +8,10 @@ class Soil():
Set the grid, the initial variables, the variables to save.
Initialize the output dictionary and initialize the spatialized soil.
grid -- tuple of (x, y), shape of the grid
inits -- dictionary of initial variables
variables_to_save -- list of strings of variables to save
Args:
grid: tuple of (x, y), shape of the grid
inits: dictionary of initial variables
variables_to_save: list of strings of variables to save
"""
self.grid = grid
self.inits = inits
......@@ -46,7 +47,8 @@ class Soil():
Set the day, and the year.
If the first day of the year initialize the output dictionary for the year.
day -- datetime object
Args:
day: datetime object
"""
self.day = day
self.year = str(day.year)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment