Welcome to Crop2ML Documentation

Contents:

What is Crop2ML ?

Crop2ML is a centralized framework proposed by the Agricultural Model Exhange Initiative (AMEI) to exchange and reuse the plant and crop process-based model (PBM) component between PBM frameworks.
This framework provides a XML-(JSON-)based language used to describe different biological processes involved in the plant and crop growth and development regardless PBM frameworks.
Any model component represented with this language will be called Crop2ML model.

Objectives

The framework main objectives are:

  • define a declarative language to describe plant and crop model components

  • add semantic dimension to Crop2ML language by annotation of the models to allow the composition of components provided by different platforms by using the standards of the semantic web

  • develop a library to allow the transformation and the exchange of Crop2ML model between different Crop modelling and simulation platform

  • provide a web repository enabling registration, search and discovery of Crop2ML Models

  • facilitate Agricultural Model Exchange Initiative

Context

Nowadays, we observe the emergence of plant growth models which are built in different platforms. Although standard platform development initiatives are emerged, there is a lack of transparency, reusability, and exchange code between platforms due to the high diversity of modeling languages leading to a lack of benchmarking between the different platforms.
This project aims to gather developers and plant growth modelers to define a standard framework based on the development of declarative language and libraries to make effectiveness the exchange and reuse of model components between platforms.

AMEI Motivation

Our motivation is to:

  • Strengthen the synergy between crop modelers, users and scientific researchers

  • Facilitate model intercomparison (at the process level) and model improvement through the exchange of model components (algorithms) and code reuse between platforms/models.

  • Bridge the gap between ecophysiologists who develop models at the process level with crop modelers and model users and facilitate the integration in crop models of new knowledge in plant science (i.e. we are seeking the exchange of knowledge rather than black box models).

  • Increase capabilities and responsiveness to stakeholder’ needs.

  • Propose a solution to the AgMIP community for NexGen crop modeling tools.

AMEI Vision

  • Facilitate the development of complex models

  • Use modular modelling to share knowledge and rapidly develop operational tools.

  • Reuse model parts to leverage the expertise of third parties;

  • Renovate legacy code.

  • Realize the benefit of sharing and complementing different expertise.

  • Promote model sharing and reuse

Crop2ML Specification

A crop2ML model is a representation of a biophysical process involved in plant and crop growth and development into a Crop2ML format. Crop2ML offers a high modularity for model component description. Thus, a crop2ML model is either a model unit or a model composite.
A Crop2ML model unit is a crop2ML model with a fine granularity. It means that it doesn’t depend on another model.
A Crop2ML model composite is a composition of two or more model unit or model composite.
These two types of Crop2ML models each have a specific formal definition.

Specification description Terminology

The keywords “MUST”, “MUST NOT”, “SHALL”, “SHALL NOT”, and “MAY” in this document are to be interpreted as described in RFC 2119 .

The key type of information item “element” and “attribute” have to be interpreted as described in XML Information Set.

Crop2ML infoset: An XML information set containing a hierarchy of information items conforming to the rules described in this document. In this specification, such infosets are assumed to be Crop2ML infosets.

Crop2ML model: A discrete-time model represented by a hierarchy of one or more Crop2ML infosets, according to the rules described in this document. In this specification, the topmost Crop2ML infoset in a hierarchy is referred to as the top-level Crop2ML infoset.

Crop2ML Model Unit Specification

The ModelUnit element

The top-level element information item in a Crop2ML model unit infoset MUST be referred to as the ModelUnit element.

<?xml version="1.0" encoding= ?> (1)
     <!DOCTYPE ModelUnit PUBLIC " " "https://raw.githubusercontent.com/AgriculturalModelExchangeInitiative/crop2ml/master/ModelUnit.dtd"> (2)
     <ModelUnit modelid=" " timestep=" " name=" " version=""> (3)
                     ....
     </ModelUnit>
(1) XML header with version 1.0 and “utf-8” encoding
(2) External DTD declaration in the file
  1. A ModelUnit element MUST contain a name, a modelid, a version attributes. (3)

    • The value of the name attribute must obey a number of constraints

See the constraints

The ModelUnit is the highest level in the Crop2ML model file, not including the opening xml tags.

A Crop2ML name attribute must obey some constraints:

  • it starts by a letter

  • It is a single word

  • Only alphanumeric characters and underscore characters

    eg: name: CropHeatFlux or crop_heat_flux (valid names),

    name: crop-heat-flux or 1cropheatflux (not valid names)

  • It MUST NOT be a keyword of any programming language

These are valid Crop2ML name attributes:

  • myName is valid (both cases are permitted),

  • my_other_valid_name is valid (underscores are permitted), and

  • this1too is valid (numerals 0-9 are permitted).

These are not valid Crop2ML name attributes:

  • my invalid name is not valid (spaces are not permitted),

  • thisIsInvalidToo! is not valid (special characters other than the underscore _ are not permitted),

  • 1amNotValidEither is not valid (must not begin with a number), and

  • " " empty string is not valid (a name must be present).

  • lambda is not valid (language keyword not permitted).

  • The value of the modelid attribute MUST ensure the provenance of the model. It is composed by an identifier of the platform and model package that provides the model and the name of the model unit separated by a dot. It is used to reference the model elsewhere and must be an unique identifier.

    Eg. SQ.EnergyBalance.CropHeatFlux where SQ.EnergyBalance means that it is a strategy of Energy Balance component of SiriusQuality (SQ) model and CropHeatFlux the name of the model unit

  • The value of the version corresponds to a state of evolution of the model unit. It is defined by numbering.

  1. A ModelUnit element MAY contain a timestep attribute. Without this attribute, a time step of one day is considered.

  2. A ModelUnit element MUST contain one additional specific element child:

    1. A Description element;

    2. An Inputs element;

    3. An Outputs element;

    4. A ParameterSets element;

    5. A TestSets element

  3. A ModelUnit element MUST contain one or more Algorithm element children

  4. A ModelUnit element MAY contain one Initialization element children

  5. A ModelUnit element MAY contain one or more Function element children

The Description element

This element gives the general information on the model and is composed of a set of character elements.

<ModelUnit modelid=" " timestep=" " name=" " version =" ">
        <Description>
                <Title>title</Title>
                <Authors>authors</Authors>
                <Institution>institution</Institution>
                <Reference>reference</Reference>
                <Abstract><![CDATA[abstract]]></Abstract>
         </Description>
             ...
</ModelUnit>

The Description element information item is a child of ModelUnit element.

  1. It MUST contain Title, Authors, Institution, and Abstract elements with text content.

    • The value of Title element is the explicit name of the model and is based on no constraint. It gives the meaning of the process.

    • The value of Authors element is the names of the authors of the implemented model in a specific platform.

    • The value of Institution element is the name of the institution providing the component.

    • The value of Abstract element is a brief description of the meaning of the process and provide the context of some experimental conditions used to calibrate the models.

  2. A Description element MAY contain Reference and URI element.

    • The value of Reference provides the reference of scientific knowledge of the process.

    • The value of URI provides the link of the documentation of the process.

The Inputs element

The Inputs element information item is a child of a ModelUnit element.

<ModelUnit modelid=" " timestep=" " name=" " version =" ">
   ...
   <Inputs>
      <Input name=" " description=" " variablecategory=" " datatype=" " min=" " max=" " default=" " unit=" " uri="" inputtype="variable"/>
      <Input name=" " description=" " parametercategory=" " datatype=" " min=" " max=" " default=" " unit=" " uri=" " inputtype="parameter"/>
      ...
   </Inputs>
   ...
</ModelUnit>
  1. A Inputs element MUST contain one or more Input element child.

  2. Each Input element MUST have exactly one of each of the following attributes:

    1. The name attribute. The value of the name MUST be a valid Crop2ML name attribute.

      The value of a name attribute MUST NOT be identical to the value of the name attribute on any sibling Input element

    2. The description attribute

    3. The datatype attribute

      The value of a datatype attribute is the data type of the value that input can take. A set of types is defined in Crop2ML as

    4. An Unit attribute MUST be associated to each variable or parameter. Crop2Ml uses by default the SI units or their composition.

      Eg: unit of Temperature is “degC”,
      unit of thermal time is “degC*d”, d represents “day”.
      The symbole * is used for the product of two units.
      The symbole / is used for the division of two units.
      The symbole ** is used for the exponential of two units.
      An empty unit is expressed by : “dimensionless”.

See Data Representation Format in Crop2ML

  • The required datatype attribute is the type of input value specified in default (the default value in the input), min (the minimum value in the input) and max (the maximum value in the input). A set of types is defined in Crop2ML as:

    • STRING to manipulate string variables, eg: phenology development stade “Anthesis”

    • DATE : A convention used to express date is dd/mm/yyyy where dd is the day, mm the month and yyyy the year. eg: “15/12/2007”

    • DOUBLE: a real number with a decimal eg (15.0 not 15)

    • INT: an integer number

    • BOOLEAN: A boolean variable takes one of these two values “TRUE” or “FALSE”

    Array variables have fixed length which values are between “[” and “]” brackets:

    • STRINGARRAY: an array of string variables.

    • DOUBLEARRAY: an array of real variables

    • INTARRAY: an array of integer variables

    • DATEARRAY: an array of dates variables

    • BOOLEANARRAY: an array of boolean variables

    List variables have variable length which values are between “[” and “]” brackets:

    • STRINGLIST: a list of string variables

    • INTLIST: a list of integer variables

    • DOUBLELIST: a list of real variables

    • BOOLEANLIST: a list of boolean variable

    • DATELIST: a list of date variable

  1. The inputtype attribute

    The value of an inputtype attribute is either variable or parameter.

  1. Each Input element MAY have exactly one of each of the following attributes:

  1. The parametercategory attribute SHOULD be defined when the value of inputtype attribute is parameter

The value of parametercategory attribute MUST be : constant, species, soil or genotypic value.

  • Constant does not depend on the species, the soil and genotypic traits. Eg: Avogadro constant, latitude

  • soil is related to soil properties, eg : soil water retention

  • species is related to species properties: Response of vernalization rate to temperature

  • genotypic is related to the genotype

  1. The variablecategory attribute SHOULD be defined when the value of inputtype attribute is variable

    The value of variablecategory attribute MUST be a state, a rate or an “auxiliary”.

  • State variables characterize the behavior of the model. They result from the exchange processus in the system.

  • Rate variables characterizes the flux of these exchanges

  • Auxiliary variables may be the intermediate product or other.

  1. Other attributes max, min, default and uri MAY be specified.

    max and min are often used to implement tests of pre- and post-conditions.

    They state the domain of validity of the variables and parameters and constitute a criteria of model composability.

The Outputs element

..The Outputs element information item is a child of a ModelUnit element.

<ModelUnit modelid=" " timestep=" " name=" " version =" ">
   ...
   <Outputs>
      <Output name=" " description=" " datatype=" " min=" " max=" "  unit=" " uri=" "/>
      <Output name=" " description=" " datatype=" " min=" " max=" "  unit=" " uri=" "/>
      ...
   </Outputs>
   ...
</ModelUnit>
  1. The Outputs element MUST contain one or more Output element children.

  2. Each Output element MUST have exactly one of each of the following attributes:

    1. The name attribute.

    2. The description attribute

    3. The datatype attribute

    4. The unit attribute

  3. Each Output element MAY have exactly one of each of the following attributes:

  1. The variablecategory attribute

  2. The attributes uri, max and min MAY be specified.

The meanings and constraints of different attributes are the same as those of Input element.

The Algorithm element

The Algorithm element implements the mathematical behaviour of the model componenent in a language.

..An Algorithm element information item is a child of a ModelUnit element.

<ModelUnit modelid=" " timestep=" " name=" " version =" ">
   ...
   <Algorithm language =" " filename= "" platform=" ">
   ...
</ModelUnit>
  1. An Algorithm element MUST contain one of the language attribute

  2. An Algorithm element MAY contain one of each following attributes

    1. The platform attribute

    2. The filename attribute

The model specifications defined in Inputs and outputs are sufficient to generate the signature of the function or a skeleton of class in a specific language. So, in this code, It is just necessary to express a snippet of code to describe the dynamic of the model.

This is an example of algorithm of Diffusion Limited Evaporation of Energy Balance component implemented in C++. In this case all variables used have already declared in the model specification.

if (deficitOnTopLayers / 1000 <= 0)
        diffusionLimitedEvaporation = 8.3 * 1000;
else
{
        if (deficitOnTopLayers / 1000 < 25)
                diffusionLimitedEvaporation = (2 * soilDiffusionConstant * soilDiffusionConstant / (deficitOnTopLayers / 1000)) * 1000;
        else
                diffusionLimitedEvaporation = 0;
}

Six languages are supported : Fortran, Java, C++, C#, Python and R. In order to avoid a re-implementation in this multiplicity of languages, Crop2Ml defines a minimal language CyML based on an intersection of the above languages.

You can visit a full documentation of CyML Here .

Algorithm implemented in CyML

if deficitOnTopLayers / 1000 <= 0:
   diffusionLimitedEvaporation = 8.3 * 1000
else:
   if deficitOnTopLayers / 1000 < 25:
      diffusionLimitedEvaporation = (2 * soilDiffusionConstant * soilDiffusionConstant / (deficitOnTopLayers / 1000)) * 1000
   else:
      diffusionLimitedEvaporation = 0

The Initialization element

..An Initialization element information item is a child of the ModelUnit element.

Any model requires the initialization of its state variables.

<ModelUnit modelid=" " timestep=" " name=" " version =" ">
   ...
   <Initialization name=" " language=" " filename=" "/>

   ...
</ModelUnit>
  1. An Initialization element MAY be specified if initial value is provided by a function or different from default value.e

  2. An Initialization element MUST contain the name and language attributes

    The language used to express initialization code must be the same as that used to encode model algorithm.

    The name of initialisation process is prefixed by init. followed by the name of the model.

  3. An Initialization element MAY contain the filename attribute to specify the path of the initialization file

The Function element

..A Function element information item is a child of the ModelUnit element.

Function element is related to a mathematical function or service that can be called into model algorithm.

<ModelUnit modelid=" " timestep=" " name=" " version =" ">
   ...
   <Function name=" " language=" " filename=" "/>

   ...
</ModelUnit>
  1. A Function element MUST contain the following attriutes:

    1. A name attribute

    1. A language attribute

    1. A type attribute

    The value of A type attribute MUST be either internal or external

    Crop2ML provides a library of well-known mathematical functions such as fibonacci, interpolation.

    If the function exists in this library, the value of code:type attribute is internal.

  2. A Function element MAY contain a description attriute

A function can also be used for model adaptation such as temporal aggregation, unit conversion to link two models without changing.

In this case, it won’t be declared as a Function but as a Crop2ML model with no physiology meaning.

The ParameterSets element

..A Parametersets element information item is a child of a ModelUnit element.

<ModelUnit modelid=" " timestep=" " name=" " version =" ">
    ...
    <Parametersets>
       <Parameterset name="" description="" uri = ""/>
       <Parameterset name="" description="" >
          <Param name="">value</Param>
          <Param name="">value</Param>
          ...
       </Parameterset>
       ...
    ...
 </ModelUnit>
  1. A Parametersets element MUST contain one or more Parameterset element.

    A Parametersets defines different ways to parameterize the model.

  2. Each Parameterset element MUST have a name and description attributes

    A Parameterset defines a set of values of parameters to parameterize the model.

  3. Each Parameterset element MAY have one or more Param elements

  4. Each Param element MUST contain a name attribute and is a text content.

    The value of the name attribute MUST already be specified as a value of the name attribute of an input element.

The TestSets element

..A Testsets element information item is a child of a ModelUnit element.

<ModelUnit modelid=" " timestep=" " name=" " version =" ">
   ...
   <Testsets>
      <Testset name="" parameterset = "" description="" uri = ""/>
      <Testset name="" parameterset = "" description="" >
         <Test name="">
            <InputValue name="">value</InputValue>
            ...
            <OutputValue name="" precision ="">value</OutputValue>
            ...
         </Test>
         ...
      </Testset>
      ...
  </Testsets>
  ...
</ModelUnit>
  1. A Testsets element MUST contain one or more Testset element.

    A TestSet defines different model unit tests.

  2. Each Testset element MUST have a name, a description and parameterset attributes

    The value of the parameterset attribute MUST already be specified as a value of the name attribute of an Parameterset element.

  3. Each TestSet element MUST contain one or more Test elements

    A Test defines one unit test for the model checking.

  4. Each Test element MUST contain a name attribute and it MAY have description and uri attributes.

  5. Each Test element MUST contain one or more InputValue and OutputValue elements.

    The checking consists of run the model with the values of InputValue elements and compare the result with the values of OutputValue elements.

Crop2ML Model Composite Specification

The ModelComposition element

The top-level element information item in a Crop2ML model composite infoset MUST be referred to as the ModelComposition element.

  1. A ModelComposition element MUST contain a name`and a :code:`id attributes.

  2. A ModelComposition element MAY contain a version and a timestep attribute.

  3. A ModelComposition element MUST contain one of each additional specific element child:

    1. A Description element;

    2. An Composition element;

  4. A ModelComposition element MAY contain one of each additional specific element child:

    1. An Inputs element;

    2. An Outputs element;

    3. An Initialization element;

    4. An Algorithm element;

    5. A ParameterSets element;

    6. A TestSets element

    The Inputs`and :code:`Outputs elements are explicitely specified when model composite cannot be described as a graph of models.

    In this case an algorithm is provided.

The Description element

This element gives the general information on the model compoite and is composed of a set of character elements.

..The Description element information item is a child of ModelComposition element.

It contains the same attributes as those of the Description element of ModelUnit.

The Inputs element

..The Inputs element information item is a child of ModelComposition element.

It contains one or more Input element which are the same attributes as those of the Input element of ModelUnit.

  1. Implicitly, all the previous states variables, the parameters and the exogeneous variables are the inputs of the model composite.

The Outputs element

..The Outputs element information item is a child of ModelComposition element.

It contains one or more Output element which are the same attributes as those of the Output element of ModelUnit.

  1. Implicitly, all the current state variables are the outputs of the model composite.

The Initialization element

The Initialization element MAY implement the initialization of all state variables of the model composite.

..The Initialization element information item is a child of a ModelComposition element.

It contains the same attributes as those of the Initialization element of a ModelUnit.

The Algorithm element

The Algorithm element MAY implement the mathematical behaviour of the model composite in a language by calling other models.

..An Algorithm element information item is a child of a ModelComposition element.

It contains the same attributes as those of the Algorithm element of a ModelUnit.

The Composition element

The Composition element makes the difference between a model unit and a model composite.

..A Composition element information item is only a child of a ModelComposition element.

  1. A Composition element MUST contain one or more Model element

    1. The Model element MUST have a name , an id and a filename attributes

    2. The Model element MAY have a dixplayx and a displayy attributes representing the position of the model in the space.

  2. A Composition element MUST contain one Links element

    1. The Links element MAY be empty in the case where algorithm element is specified.

    2. If not, the Links element SHOULD have one or more InputLinks, InternalLinks and OutputLinks elements.

      1. An InputLink is a link between an input of the model composite and an input of a sub-model.

      2. An OutputLink is a link between an output of the model composite and an output of a sub-model.

      3. An InternalLink is a link between an output of a sub-model and an input of a sub-model.

    3. An InputLink element MUST contain a target and a source attributes.

      1. The value of a target attribute MUST be composed of the name of a sub-model and the name of an input of this sub-model separated by dot.

      2. The value of a source attribute MUST be the name of an input of the model composite.

    4. An OutputLink element MUST also contain a target and a source attributes.

      1. The value of a source attribute MUST be composed of the name of a sub-model and the name of an output of this sub-model separated by dot.

      2. The value of a target attribute MUST be the name of an output of the model composite.

    5. An InternalLink element MUST also contain a target and a source attributes.

      1. The value of a source attribute MUST be composed of the name of a sub-model and the name of an output of this sub-model separated by dot.

      2. The value of a target attribute MUST be composed of the name of a sub-model and the name of an input of this sub-model separated by dot.

The ParameterSets element

The ParameterSets element allows to parameterize the model composite.

..The ParameterSets element information item is a child of a ModelComposition element.

It contains the same elements type as those of the ParameterSets element of a ModelUnit.

The TestSets element

The TestSets element allows to make unit tests on the model composite.

..The TestSets element information item is a child of a ModelComposition element.

It contains the same elements as those of the TestSets element of a ModelUnit.

Crop2ML Package

Crop2ML package is a crop modelling exchange project with a specific structure and which contains Crop2ML files as xml files and algo, the sources files, data, tests and documentation.

Crop2ML package hierarchy

The structure of your new project looks like this:

├── LICENSE.txt        <- License file
├── README.md          <- The top-level README for AMEI members using this project.
├── data/              <- data used for model simulation
│
├── doc/               <- Package documentation
│
├── tests/             <- model tests for each language and platform
│
├── crop2ml/          <- model units and composite in crop2ml format.
│      ├── xml files
│      ├── Algo/
│
├── src/                <- Executable source codes in different language and platform
│   ├── pyx/
│   ├── java/
│   ├── py/
    ├── r/
    ├── cpp/
    ├── cs/
    ├── f90/
    ├── bioma
    ├── simplace
    ├── openalea
    ├── record
    ├── dssat
    ├── stics
    ├── apsim

Crop2ML XML files

Crop2ML directory contains model metadata and experiment files (XML files) of atomic models and composite model.

The name of atomic model must start with unit_ and the name of composite model by composition_.

Crop2ML algorithm

Crop2ML directory contains also a subdirectory named algo that contains for each language its repository including the file referenced in the algorithm part of xml file. These files are neither compilable nor executable.

src directory

Src directory is the directory of source codes generated from the metadata of xml files and the algo files. src contain a repository for each language and each platform which contains the code generated in the specific language or platform.

test directory

Test directory contain for each language and platform the unit test of different model unit generated from xml files.

data

Data is used to simulate the composite model.

How to add a Crop2ML package?

To add a crop2ML package, modeller should use Cookiecutter-Crop2ML. | Cookiecutter-Crop2ML is a standardized template used to generate Crop2ML project structure for sharing crop models components between crops modelling platform.

Requirements to use the cookiecutter template:

  • Python 2.7 or 3.5

  • Cookiecutter Python package >= 1.4.0: This can be installed with pip by or conda depending on how you manage your Python packages:

pip install cookiecutter

or

conda config --add channels conda-forge
conda install cookiecutter

To start a new project, run:

cookiecutter https://github.com/AgriculturalModelExchangeInitiative/cookiecutter-crop2ml
_images/cookiecutter.png

Usecases

From some legacy model units of crop modeling platforms we show: - their representation in crop2ml format (metadata and algorithm) - transformation in fortran codes - Test of model units

1- Priestly-Taylor potential evapotranspiration of DSSAT model

1-1- DSSAT fortran code

!  PETPT, Subroutine, J.T. Ritchie

!  Calculates Priestly-Taylor potential evapotranspiration

!-----------------------------------------------------------------------

!  REVISION HISTORY

!  ??/??/19?? JR  Written

!  11/04/1993 NBP Modified

!  10/17/1997 CHP Updated for modular format.

!  09/01/1999 GH  Incorporated into CROPGRO

!  07/24/2006 CHP Use MSALB instead of SALB (includes mulch and soil

!                 water effects on albedo)

!-----------------------------------------------------------------------

!  Called by:   WATBAL

!  Calls:       None

    SUBROUTINE PETPT( &

        MSALB, SRAD, TMAX, TMIN, XHLAI,&  ! inputs

        EO)                                ! outputs
        IMPLICIT NONE

!       INPUT VARIABLES:

        REAL MSALB, SRAD, TMAX, TMIN, XHLAI

!       OUTPUT VARIABLES:

        REAL EO

!       LOCAL VARIABLES:

        REAL ALBEDO, EEQ, SLANG, TD


!       Should use TAVG here -- we have it from WEATHER variable!

!       SSJ 9/18/2006

!       TD = TAVG

!       JWJ 2/15/2007 - Can't use TAVG unless coefficients in EEQ

!         equation are recalibrated.  Keep TD calc as it was

!         developed.

    TD = 0.60*TMAX+0.40*TMIN
    IF (XHLAI .LE. 0.0) THEN
        ALBEDO = MSALB
    ELSE
        ALBEDO = 0.23-(0.23-MSALB)*EXP(-0.75*XHLAI)
    ENDIF
    SLANG = SRAD*23.923
    EEQ = SLANG*(2.04E-4-1.83E-4*ALBEDO)*(TD+29.0)
    EO = EEQ*1.1
    IF (TMAX .GT. 35.0) THEN
        EO = EEQ*((TMAX-35.0)*0.05+1.1)
    ELSE IF (TMAX .LT. 5.0) THEN
        EO = EEQ*0.01*EXP(0.18*(TMAX+20.0))
    ENDIF
    EO = MAX(EO,0.0001)
    RETURN
    END SUBROUTINE PETPT
!     PETPT VARIABLES:

! ALBEDO  Reflectance of soil-crop surface (fraction)

! EEQ     Equilibrium evaporation (mm/d)

! EO      Potential evapotranspiration rate (mm/d)

! MSALB   Soil albedo with mulch and soil water effects (fraction)

! SLANG   Solar radiation

! SRAD    Solar radiation (MJ/m2-d)

! TD      Approximation of average daily temperature (ºC)

! TMAX    Maximum daily temperature (°C)

! TMIN    Minimum daily temperature (°C)

! XHLAI   Leaf area index (m2[leaf] / m2[ground])

1-2- Creation of Crop2ML package

1-3- Crop2ML representation of model unit

metadata

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ModelUnit PUBLIC " " "https://raw.githubusercontent.com/AgriculturalModelExchangeInitiative/crop2ml/master/ModelUnit.dtd">
<ModelUnit name="PETPT" modelid="DSSAT.WheatModel.PETPT" timestep="1" version="1.0">
    <Description>
        <Title> PETPT, Subroutine, J.T. Ritchie,  Calculates Priestly-Taylor potential evapotranspiration </Title>
        <Authors>Kwang Soo Kim, luxkwang@snu.ac.kr </Authors>
        <Institution>Seoul National University, Seoul, Korea</Institution>
        <Reference>DSSAT 4.7; original fortran code was written by J.T. Ritchie </Reference>
        <Abstract> See Document at DSSAT 4.7 source code in PETPT.for </Abstract>
    </Description>
    <Inputs>
        <Input name="MSALB" description="Soil albedo with mulch and soil water effects (fraction)" datatype="DOUBLE" min="0" max="1" default="0.3" unit="" inputtype="variable" variablecategory="auxiliary" />
        <Input name="SRAD" description="Solar radiation" datatype="DOUBLE" min="0" max="100" default="100" unit="MJ m-2 d-1" inputtype="variable" variablecategory="auxiliary" />
        <Input name="TMAX" description="Maximum daily temperature" datatype="DOUBLE" min="-50" max="60" default="20" unit="°C" inputtype="variable" variablecategory="auxiliary" />
        <Input name="TMIN" description="Minimum daily temperature" datatype="DOUBLE" min="-50" max="60" default="10" unit="°C" inputtype="variable" variablecategory="auxiliary" />
        <Input name="XHLAI" description="Leaf area index" datatype="DOUBLE" min="0" max="10" default="3" unit="m2 m-2" inputtype="variable" variablecategory="state" />
    </Inputs>
    <Outputs>
        <Output name="EO" description="Potential evapotranspiration rate" datatype="DOUBLE" min="0.0" max="1.0" unit="mm d-1" variablecategory="rate" />
    </Outputs>
    <Algorithm language="cyml" platform="" filename="algo/pyx/petpt.pyx">
    </Algorithm>
    <Parametersets>
        <Parameterset name="Paramset1" description="some values in there" >
        </Parameterset>
    </Parametersets>
    <Testsets>
        <Testset name="Testset1" parameterset = "Paramset1" description="some values in there" >
            <Test name ="test1">
                <InputValue name="MSALB">0.3</InputValue>
                <InputValue name="SRAD">100</InputValue>
                <InputValue name="TMAX">20</InputValue>
                <InputValue name="TMIN">10</InputValue>
                <InputValue name="XHLAI">3</InputValue>
                <OutputValue name="EO" precision ="2">19.01</OutputValue>
            </Test>

        </Testset>

    </Testsets>

</ModelUnit>

Algorithm

cdef float ALBEDO, EEQ, SLANG, TD
TD = 0.60*TMAX + 0.40*TMIN
if (XHLAI <= 0.0):
    ALBEDO = MSALB
else:
    ALBEDO = 0.23 - (0.23-MSALB)*exp(-0.75*XHLAI)
SLANG = SRAD * 23.923
EEQ = SLANG * (2.04E-4 - 1.83E-4 * ALBEDO)*(TD+29.0)
EO = EEQ*1.1
if (TMAX > 35.0):
    EO = EEQ*((TMAX-35.0)*0.05+1.1)
elif (TMAX < 5.0):
    EO = EEQ*0.01*exp(0.18*(TMAX+20.0))
EO = max(EO, 0.0001)

1-4- Fortran code generated

SUBROUTINE petpt_(MSALB, &
    SRAD, &
    TMAX, &
    TMIN, &
    XHLAI, &
    EO)
    REAL, INTENT(OUT) :: EO
    REAL:: ALBEDO
    REAL:: EEQ
    REAL:: SLANG
    REAL:: TD
    REAL, INTENT(IN) :: MSALB
    REAL, INTENT(IN) :: SRAD
    REAL, INTENT(IN) :: TMAX
    REAL, INTENT(IN) :: TMIN
    REAL, INTENT(IN) :: XHLAI
    !- Description:
!            - Model Name:  PETPT, Subroutine, J.T. Ritchie,  Calculates Priestly-Taylor potential evapotranspiration
!            - Author: Kwang Soo Kim, luxkwang@snu.ac.kr
!            - Reference: DSSAT 4.7; original fortran code was written by J.T. Ritchie
!            - Institution: Seoul National University, Seoul, Korea
!            - Abstract:  See Document at DSSAT 4.7 source code in PETPT.for
    !- inputs:
!            - name: MSALB
!                          - description : Soil albedo with mulch and soil water effects (fraction)
!                          - datatype : DOUBLE
!                          - min : 0
!                          - max : 1
!                          - default : 0.3
!                          - unit :
!                          - inputtype : variable
!                          - variablecategory : auxiliary
!            - name: SRAD
!                          - description : Solar radiation
!                          - datatype : DOUBLE
!                          - min : 0
!                          - max : 100
!                          - default : 100
!                          - unit : MJ m-2 d-1
!                          - inputtype : variable
!                          - variablecategory : auxiliary
!            - name: TMAX
!                          - description : Maximum daily temperature
!                          - datatype : DOUBLE
!                          - min : -50
!                          - max : 60
!                          - default : 20
!                          - unit : °C
!                          - inputtype : variable
!                          - variablecategory : auxiliary
!            - name: TMIN
!                          - description : Minimum daily temperature
!                          - datatype : DOUBLE
!                          - min : -50
!                          - max : 60
!                          - default : 10
!                          - unit : °C
!                          - inputtype : variable
!                          - variablecategory : auxiliary
!            - name: XHLAI
!                          - description : Leaf area index
!                          - datatype : DOUBLE
!                          - min : 0
!                          - max : 10
!                          - default : 3
!                          - unit : m2 m-2
!                          - inputtype : variable
!                          - variablecategory : state
    !- outputs:
!            - name: EO
!                          - description : Potential evapotranspiration rate
!                          - datatype : DOUBLE
!                          - min : 0.0
!                          - max : 1.0
!                          - unit : mm d-1
!                          - variablecategory : rate
    TD = 0.60 * TMAX + 0.40 * TMIN
    IF(XHLAI .LE. 0.0) THEN
        ALBEDO = MSALB
    ELSE
        ALBEDO = 0.23 - (0.23 - MSALB) * EXP(-0.75 * XHLAI)
    END IF
    SLANG = SRAD * 23.923
    EEQ = SLANG * (2.04E-4 - 1.83E-4 * ALBEDO) * (TD + 29.0)
    EO = EEQ * 1.1
    IF(TMAX .GT. 35.0) THEN
        EO = EEQ * ((TMAX - 35.0) * 0.05 + 1.1)
    ELSE IF ( TMAX .LT. 5.0) THEN
        EO = EEQ * 0.01 * EXP(0.18 * (TMAX + 20.0))
    END IF
    EO = MAX(EO, 0.0001)
END SUBROUTINE petpt_

1-5- Test in jupyterlab

[5]:
Program test_test1_PETPT
    REAL:: MSALB

    REAL:: SRAD

    REAL:: TMAX

    REAL:: TMIN

    REAL:: XHLAI

    REAL:: EO

    MSALB = 0.3

    SRAD = 100

    TMAX = 20

    TMIN = 10

    XHLAI = 3

    call petpt_(MSALB,SRAD,TMAX,TMIN,XHLAI,EO)
    print *,EO
CONTAINS
    SUBROUTINE petpt_(MSALB, &
        SRAD, &
        TMAX, &
        TMIN, &
        XHLAI, &
        EO)
        REAL, INTENT(OUT) :: EO
        REAL:: ALBEDO
        REAL:: EEQ
        REAL:: SLANG
        REAL:: TD
        REAL, INTENT(IN) :: MSALB
        REAL, INTENT(IN) :: SRAD
        REAL, INTENT(IN) :: TMAX
        REAL, INTENT(IN) :: TMIN
        REAL, INTENT(IN) :: XHLAI
        !- Description:
    !            - Model Name:  PETPT, Subroutine, J.T. Ritchie,  Calculates Priestly-Taylor potential evapotranspiration
    !            - Author: Kwang Soo Kim, luxkwang@snu.ac.kr
    !            - Reference: DSSAT 4.7; original fortran code was written by J.T. Ritchie
    !            - Institution: Seoul National University, Seoul, Korea
    !            - Abstract:  See Document at DSSAT 4.7 source code in PETPT.for
        !- inputs:
    !            - name: MSALB
    !                          - description : Soil albedo with mulch and soil water effects (fraction)
    !                          - datatype : DOUBLE
    !                          - min : 0
    !                          - max : 1
    !                          - default : 0.3
    !                          - unit :
    !                          - inputtype : variable
    !                          - variablecategory : auxiliary
    !            - name: SRAD
    !                          - description : Solar radiation
    !                          - datatype : DOUBLE
    !                          - min : 0
    !                          - max : 100
    !                          - default : 100
    !                          - unit : MJ m-2 d-1
    !                          - inputtype : variable
    !                          - variablecategory : auxiliary
    !            - name: TMAX
    !                          - description : Maximum daily temperature
    !                          - datatype : DOUBLE
    !                          - min : -50
    !                          - max : 60
    !                          - default : 20
    !                          - unit : °C
    !                          - inputtype : variable
    !                          - variablecategory : auxiliary
    !            - name: TMIN
    !                          - description : Minimum daily temperature
    !                          - datatype : DOUBLE
    !                          - min : -50
    !                          - max : 60
    !                          - default : 10
    !                          - unit : °C
    !                          - inputtype : variable
    !                          - variablecategory : auxiliary
    !            - name: XHLAI
    !                          - description : Leaf area index
    !                          - datatype : DOUBLE
    !                          - min : 0
    !                          - max : 10
    !                          - default : 3
    !                          - unit : m2 m-2
    !                          - inputtype : variable
    !                          - variablecategory : state
        !- outputs:
    !            - name: EO
    !                          - description : Potential evapotranspiration rate
    !                          - datatype : DOUBLE
    !                          - min : 0.0
    !                          - max : 1.0
    !                          - unit : mm d-1
    !                          - variablecategory : rate
        TD = 0.60 * TMAX + 0.40 * TMIN
        IF(XHLAI .LE. 0.0) THEN
            ALBEDO = MSALB
        ELSE
            ALBEDO = 0.23 - (0.23 - MSALB) * EXP(-0.75 * XHLAI)
        END IF
        SLANG = SRAD * 23.923
        EEQ = SLANG * (2.04E-4 - 1.83E-4 * ALBEDO) * (TD + 29.0)
        EO = EEQ * 1.1
        IF(TMAX .GT. 35.0) THEN
            EO = EEQ * ((TMAX - 35.0) * 0.05 + 1.1)
        ELSE IF ( TMAX .LT. 5.0) THEN
            EO = EEQ * 0.01 * EXP(0.18 * (TMAX + 20.0))
        END IF
        EO = MAX(EO, 0.0001)
    END SUBROUTINE petpt_
END Program
[5]:

19.0133114

Licence

Crop2ML is released under a MIT License.

Publication

1 The Agricultural Model Exchange Initiative (AMEI)

Glossary

Terminology

Model

Simplified representation of the crop system within specific objectives.

Credits

Development Lead

Contributors

None yet. Why not be the first?

History

Crop2ML 0.7.0

Credits

Development Lead

Contributors

None yet. Why not be the first?

History

Crop2ML 0.7.0

Indices and tables

Supported by:

_images/siriusquality.png
_images/simplace.png
_images/openalea.png
_images/record.png
_images/bioma.png