Welcome to Crop2ML Documentation¶
Contents:
What is Crop2ML ?¶
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¶
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¶
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
A
ModelUnit
element MUST contain aname
, amodelid
, aversion
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.
A
ModelUnit
element MAY contain atimestep
attribute. Without this attribute, a time step of one day is considered.A
ModelUnit
element MUST contain one additional specific element child:
A
Description
element;An
Inputs
element;An
Outputs
element;A
ParameterSets
element;A
TestSets
elementA
ModelUnit
element MUST contain one or moreAlgorithm
element childrenA
ModelUnit
element MAY contain oneInitialization
element childrenA
ModelUnit
element MAY contain one or moreFunction
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.
It MUST contain
Title
,Authors
,Institution
, andAbstract
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.A
Description
element MAY containReference
andURI
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>
A
Inputs
element MUST contain one or moreInput
element child.Each
Input
element MUST have exactly one of each of the following attributes: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 thename
attribute on any siblingInput
elementThe
description
attributeThe
datatype
attributeThe value of a
datatype
attribute is the data type of the value that input can take. A set of types is defined in Crop2ML asAn
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 emptyunit
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
The
inputtype
attributeThe value of an
inputtype
attribute is either variable or parameter.
Each
Input
element MAY have exactly one of each of the following attributes:
The
parametercategory
attribute SHOULD be defined when the value ofinputtype
attribute is parameterThe 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
The
variablecategory
attribute SHOULD be defined when the value ofinputtype
attribute is variableThe 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.
Other attributes
max
,min
,default
anduri
MAY be specified.
max
andmin
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>
The
Outputs
element MUST contain one or moreOutput
element children.Each
Output
element MUST have exactly one of each of the following attributes:The
name
attribute.The
description
attributeThe
datatype
attributeThe
unit
attribute
Each
Output
element MAY have exactly one of each of the following attributes:
The
variablecategory
attributeThe attributes
uri
,max
andmin
MAY be specified.
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>
An
Algorithm
element MUST contain one of thelanguage
attributeAn
Algorithm
element MAY contain one of each following attributesThe
platform
attributeThe
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>
An
Initialization
element MAY be specified if initial value is provided by a function or different from default value.eAn
Initialization
element MUST contain thename
andlanguage
attributesThe 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.
An
Initialization
element MAY contain thefilename
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>
A
Function
element MUST contain the following attriutes:A
name
attribute
A
language
attribute
A
type
attribute
The value of A
type
attribute MUST be eitherinternal
orexternal
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
.A
Function
element MAY contain adescription
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>
A
Parametersets
element MUST contain one or more Parameterset element.A
Parametersets
defines different ways to parameterize the model.Each
Parameterset
element MUST have aname
anddescription
attributesA
Parameterset
defines a set of values of parameters to parameterize the model.Each
Parameterset
element MAY have one or moreParam
elementsEach
Param
element MUST contain aname
attribute and is a text content.The value of the
name
attribute MUST already be specified as a value of thename
attribute of aninput
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>
A
Testsets
element MUST contain one or more Testset element.A
TestSet
defines different model unit tests.Each
Testset
element MUST have aname
, adescription
andparameterset
attributesThe value of the
parameterset
attribute MUST already be specified as a value of thename
attribute of anParameterset
element.Each
TestSet
element MUST contain one or moreTest
elementsA
Test
defines one unit test for the model checking.Each
Test
element MUST contain aname
attribute and it MAY havedescription
anduri
attributes.Each
Test
element MUST contain one or moreInputValue
andOutputValue
elements.The checking consists of run the model with the values of
InputValue
elements and compare the result with the values ofOutputValue
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.
A
ModelComposition
element MUST contain aname`and a :code:`id
attributes.A
ModelComposition
element MAY contain aversion
and atimestep
attribute.A
ModelComposition
element MUST contain one of each additional specific element child:
A
Description
element;An
Composition
element;A
ModelComposition
element MAY contain one of each additional specific element child:
An
Inputs
element;An
Outputs
element;An
Initialization
element;An
Algorithm
element;A
ParameterSets
element;A
TestSets
elementThe
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 ofModelComposition
element.It contains the same attributes as those of the
Description
element ofModelUnit
.The
Inputs
element¶..The
Inputs
element information item is a child ofModelComposition
element.It contains one or more
Input
element which are the same attributes as those of theInput
element ofModelUnit
.
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 ofModelComposition
element.It contains one or more
Output
element which are the same attributes as those of theOutput
element ofModelUnit
.
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 aModelComposition
element.It contains the same attributes as those of the
Initialization
element of aModelUnit
.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 aModelComposition
element.It contains the same attributes as those of the
Algorithm
element of aModelUnit
.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 aModelComposition
element.
A
Composition
element MUST contain one or moreModel
element
The
Model
element MUST have aname
, anid
and afilename
attributesThe
Model
element MAY have adixplayx
and adisplayy
attributes representing the position of the model in the space.A
Composition
element MUST contain oneLinks
element
The
Links
element MAY be empty in the case wherealgorithm
element is specified.If not, the
Links
element SHOULD have one or moreInputLinks
,InternalLinks
andOutputLinks
elements.
An InputLink is a link between an input of the model composite and an input of a sub-model.
An OutputLink is a link between an output of the model composite and an output of a sub-model.
An InternalLink is a link between an output of a sub-model and an input of a sub-model.
An
InputLink
element MUST contain atarget
and asource
attributes.
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 value of a
source
attribute MUST be the name of an input of the model composite.An
OutputLink
element MUST also contain atarget
and asource
attributes.
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.The value of a
target
attribute MUST be the name of an output of the model composite.An
InternalLink
element MUST also contain atarget
and asource
attributes.
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.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 aModelComposition
element.It contains the same elements type as those of the
ParameterSets
element of aModelUnit
.The
TestSets
element¶The
TestSets
element allows to make unit tests on the model composite...The
TestSets
element information item is a child of aModelComposition
element.It contains the same elements as those of the
TestSets
element of aModelUnit
.
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.
Contents
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.
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

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)
Credits¶
Development Lead¶
Cyrille Ahmed Midingoyi, <cyrille.midingoyi@inra.fr>
Christophe Pradal, <christophe.pradal@cirad.fr>
Contributors¶
None yet. Why not be the first?
Credits¶
Development Lead¶
Cyrille Ahmed Midingoyi, <cyrille.midingoyi@inra.fr>
Christophe Pradal, <christophe.pradal@cirad.fr>
Contributors¶
None yet. Why not be the first?