dpest.pst#
- dpest.pst.pst(cultivar_parameters=None, ecotype_parameters=None, dataframe_observations=None, output_path=None, model_comand_line=None, noptmax=1000, pst_filename='PEST_CONTROL.pst', input_output_file_pairs=None)[source]#
Creates a
PEST control file (.PST)for DSSAT crop models calibration. This file guides the model calibration process by specifying input and output files, parameter bounds, and directions for PEST to extract and compare model-generated observations with experimental data. The module takes model parameters (with their values, groupings, and bounds) and observation DataFrames as inputs.Conditionally Required Arguments:#
To properly create the
PEST control file (.PST), the user must specify at least one of the following arguments:cultivar_parameters (dict, optional, but required if ``ecotype_parameters`` is not specified): Dictionary containing cultivar model parameters with their values, bounds, and groupings. It is obtained from the
culmodule (seedpest.wheat.ceres.cul).ecotype_parameters (dict, optional, but required if ``cultivar_parameters`` is not specified): Dictionary containing ecotype model parameters with their values, bounds, and groupings. This dictionary is obtained from the
ecomodule (seedpest.wheat.ceres.eco).
Required Arguments:#
dataframe_observations (
pd.DataFrameorlist): DataFrame or list of DataFrames containing observations to be used during model calibration and included in thePEST control file (.PST). It can be a single dataframe asdataframe_observations = dataframe, or a list of dataframes asdataframe_observations = [dataframe1, dataframe2]. These DataFrames are created by thedpest.wheat.overviewanddpest.wheat.plantgromodules, and each DataFrame must contain columns named'variable_name','value_measured', and'group'.model_comand_line (str): Command line used to run the DSSAT model executable.
input_output_file_pairs (
list): List of tuples where each tuple contains an input and output file pair. The required tuples depend on the other arguments passed to this module:If
cultivar_parametersis specified, this list must contain a tuple with thePEST template file (.TPL)for the cultivar and the correspondingDSSAT cultivar file (.CUL).If
ecotype_parametersis specified, this list must contain a tuple with thePEST template file (.TPL)for the ecotype and the correspondingDSSAT ecotype file (.ECO).For each DataFrame specified in
dataframe_observations, this list must contain a tuple with thePEST instruction file (.INS)created by theovervieworplantgromodule and the correspondingOVERVIEW.OUTorPlantGro.OUTfile.
Each element on the list follows this structure:
[(input_file1, output_file1), (input_file2, output_file2)]. The first element of each tuple is the path to either aPEST template file (.TPL)or aPEST instruction file (.INS), and the second element is the path to the corresponding DSSAT input or output file.
Optional Arguments:#
output_path (str, default: current working directory): Directory to save the
PEST control file (.PST). By default, the file is created in the same directory where the script is located.noptmax (int, default: 1000): Maximum number of iterations for the optimization process.
pst_filename (str, default: “PEST_CONTROL.pst”): File name for the
PEST control file (.PST)to be created.
Returns:#
None: This module creates thePEST control file (.PST)at the specifiedoutput_path(or in the script’s directory by default) with the providedpst_filename. It validates inputs, processes observation data, sets up parameters, and writes the resultingPEST control file (.PST).
Examples:#
Creating a PEST Control File with Cultivar and Ecotype Parameters, End-of-Season Crop Performance Metrics, and Plant Growth Dynamics:
from dpest import pst pst( cultivar_parameters = cultivar_parameters, ecotype_parameters = ecotype_parameters, dataframe_observations = [overview_observations, plantgro_observations], model_comand_line = r'py "C:/pest18/run-dssat.py"', input_output_file_pairs = [ (cultivar_tpl_path, 'C://DSSAT48/Genotype/WHCER048.CUL'), (ecotype_tpl_path, 'C://DSSAT48/Genotype/WHCER048.ECO'), (overview_ins_path, 'C://DSSAT48/Wheat/OVERVIEW.OUT'), (plantgro_ins_path, 'C://DSSAT48/Wheat/PlantGro.OUT') ] )
This example shows how to create a
PEST control file (.PST)using both cultivar and ecotype parameters. Thedataframe_observationsargument is assigned a list of two DataFrames: (1) end-of-season crop performance metrics created using thedpest.wheat.overviewmodule, and (2) plant growth dynamics data created using thedpest.wheat.plantgromodule. The example specifies the model command line and lists the required input and output file pairs.Creating a PEST Control File with Only Cultivar Parameters, Model Performance Metrics, and Plant Growth Data:
from dpest import pst pst( cultivar_parameters = cultivar_parameters, dataframe_observations = [overview_observations, plantgro_observations], model_comand_line = r'py "C:/pest18/run-dssat.py"', input_output_file_pairs = [ (cultivar_tpl_path, 'C://DSSAT48/Genotype/WHCER048.CUL'), (overview_ins_path, 'C://DSSAT48/Wheat/OVERVIEW.OUT'), (plantgro_ins_path, 'C://DSSAT48/Wheat/PlantGro.OUT') ] )
This example demonstrates how to create a
PEST control file (.PST)using only cultivar parameters. Thedataframe_observationsargument uses a list of two DataFrames: one representing model performance data created by thedpest.wheat.overviewmodule, and another containing plant growth data created by thedpest.wheat.plantgromodule.Creating a PEST Control File with Cultivar Parameters and Just Plant Growth Data:
from dpest import pst pst( cultivar_parameters = cultivar_parameters, dataframe_observations = plantgro_observations, model_comand_line=r'py "C:/pest18/run-dssat.py"', input_output_file_pairs = [ (cultivar_tpl_path, 'C://DSSAT48/Genotype/WHCER048.CUL'), (plantgro_ins_path, 'C://DSSAT48/Wheat/PlantGro.OUT') ] )
This example shows the use of a single
dataframe_observationsargument containing plant growth dynamics metrics created with thedpest.wheat.plantgromodule, along with the cultivar parameters and the appropriate input and output file pairs.