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 cul module (see dpest.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 eco module (see dpest.wheat.ceres.eco).

Required Arguments:#

  • dataframe_observations (pd.DataFrame or list): DataFrame or list of DataFrames containing observations to be used during model calibration and included in the PEST control file (.PST). It can be a single dataframe as dataframe_observations = dataframe, or a list of dataframes as dataframe_observations = [dataframe1, dataframe2]. These DataFrames are created by the dpest.wheat.overview and dpest.wheat.plantgro modules, 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_parameters is specified, this list must contain a tuple with the PEST template file (.TPL) for the cultivar and the corresponding DSSAT cultivar file (.CUL).

    • If ecotype_parameters is specified, this list must contain a tuple with the PEST template file (.TPL) for the ecotype and the corresponding DSSAT ecotype file (.ECO).

    • For each DataFrame specified in dataframe_observations, this list must contain a tuple with the PEST instruction file (.INS) created by the overview or plantgro module and the corresponding OVERVIEW.OUT or PlantGro.OUT file.

    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 a PEST template file (.TPL) or a PEST 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 the PEST control file (.PST) at the specified output_path (or in the script’s directory by default) with the provided pst_filename. It validates inputs, processes observation data, sets up parameters, and writes the resulting PEST control file (.PST).

Examples:#

  1. 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. The dataframe_observations argument is assigned a list of two DataFrames: (1) end-of-season crop performance metrics created using the dpest.wheat.overview module, and (2) plant growth dynamics data created using the dpest.wheat.plantgro module. The example specifies the model command line and lists the required input and output file pairs.

  2. 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. The dataframe_observations argument uses a list of two DataFrames: one representing model performance data created by the dpest.wheat.overview module, and another containing plant growth data created by the dpest.wheat.plantgro module.

  3. 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_observations argument containing plant growth dynamics metrics created with the dpest.wheat.plantgro module, along with the cultivar parameters and the appropriate input and output file pairs.