dpest.cul#
- dpest.cul.cul(cultivar=None, cul_file_path=None, output_path=None, new_template_file_extension=None, header_start=None, tpl_first_line=None, minima=None, maxima=None, mrk='~', **parameters_grouped)[source]#
Creates a
PEST template file (.TPL)for CERES-Wheat cultivar parameters based on theDSSAT cultivar file (.CUL). This module is specific to the CERES-Wheat model and uses default values tailored for this model.Required Arguments:#
cultivar (str): Name or ID of the cultivar to modify. This should match either the
VAR#(cultivar ID) orVAR-NAM(cultivar name) column in theDSSAT cultivar file (.CUL).cul_file_path (str): Full path to the
DSSAT cultivar file (.CUL). Typically, this is the path to theWHCER048.CULfile, usually located atC:\DSSAT48\Genotype\WHCER048.CUL.
Optional Arguments:#
output_path (str, default: current working directory): Directory to save the generated
PEST template file (.TPL).new_template_file_extension (str, default: “.TPL”): Extension for the generated
PEST template file (.TPL). This is the PEST default value and should not be changed without good reason.header_start (str, default: “@VAR#”): Identifier for the header row in the
DSSAT cultivar file (.CUL).tpl_first_line (str, default: “ptf”): First line to include in the
PEST template file (.TPL). This is the PEST default value and should not be changed without good reason.minima (str, default: “999991”): Row identifier for the minima parameter values.
maxima (str, default: “999992”): Row identifier for the maxima parameter values.
mrk (str, default: “~”) Primary marker delimiter character for the template file. Must be a single character and cannot be A-Z, a-z, 0-9, !, [, ], (, ), :, space, tab, or &.
parameters_grouped (dict, optional): Cultivar parameters to calibrate, grouped and comma-separated. If not provided, all cultivar parameters are calibrated. For example:
P='P1V, P1D, P5', G='G1, G2, G3', PHINT='PHINT'. Where, P, G, and PHINT are cultivar parameter group names, and the values are the specific cultivar parameters to calibrate, using the same names as in theDSSAT cultivar file (.CUL). Parameter group names should be less than 12 characters.
Returns:#
- tuple: A tuple containing:
- dict: A dictionary containing:
'parameters': Current cultivar parameter values for the specified cultivar.'minima_parameters': Minima values for all cultivar parameters.'maxima_parameters': Maxima values for all cultivar parameters.'parameters_grouped': The grouped cultivar parameters used for template generation.
str: The full path to the generated .TPL file.
Examples:#
Basic Usage (Required Arguments Only):
from dpest import cul # Call the module with only the required arguments my_cultivar_parameters, my_cultivar_tpl_path = cul( cultivar = 'MANITOU', cul_file_path = 'C:/DSSAT48/Genotype/WHCER048.CUL' ) # The returned tuple and path are saved in the variables, can be used in any names that the user prefer, to call them later
This example creates a
PEST template file (.TPL)using only the required arguments. Note that the returned tuple(cultivar_parameters, cultivar_tpl_path)is captured. Themy_cultivar_parametersdictionary will be used later to make the control file’s parameter groups and parameters sections using thepstmodule. Thecultivar_tpl_pathpath will be used in theinput_output_file_pairsargument of thepstmodule to match the original cultivar file to thePEST template file (.TPL).Specifying Parameter Groups (Tuple Not Saved):
from dpest import cul # Call the module specifying parameter groups, but not saving the returned tuple cul( cultivar = 'MANITOU', cul_file_path = 'C:/DSSAT48/Genotype/WHCER048.CUL', P = 'P1V, P1D', G = 'G1' )
This example demonstrates how to specify the
parameters_groupedargument to calibrate only specific cultivar parameters. In this case, the returned tuple is not saved, but thePEST template file (.TPL)is still created at the specified location. If you want to use the cultivar parameters and path for thepstmodule, the returned tuple should be saved in two variables.