Skip to content

Commit 4198a32

Browse files
committed
sections.py modified for merge
2 parents fd6aac6 + 4252538 commit 4198a32

19 files changed

Lines changed: 1277 additions & 1812 deletions

DSSATTools/__init__.py

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,46 @@
11
'''
2-
DSSAT library allows the user to create low-code scripts to run simulations with the DSSAT model. The library structure allows to execute the DSSAT model based on four input classes: `Crop`, `SoilProfile`, `WeatherStation` and `Management`.
2+
DSSATTools library allows the user to create low-code scripts to run simulations
3+
using the DSSAT modeling framework. The library structure allows to executes DSSAT
4+
based on four input classes: `Crop`, `SoilProfile`, `Weather` and `Management`.
5+
The simulation environment is managed by the `DSSAT` Class. There are three stages
6+
for the simulation to be performed:
37
4-
The simulation environment is represented by the `DSSAT` Class. There are three stages for the simulation to be excecuted:
5-
#. Initialize a `DSSAT` instance
6-
#. setup the simulation environment by using the `DSSAT.setup` method
7-
#. run the simulation using the `DSSAT.run` method.
8+
1. Initialize a `DSSAT` instance.
9+
2. setup the simulation environment by using the `DSSAT.setup` method. When that
10+
method is called a new directory is created in the provided location (a tmp
11+
directory is default) and all the files that are necessary to run the model are
12+
copied in that folder.
13+
3. run the simulation calling `DSSAT.run` method. That method needs four
14+
parameters to be pased. Each parameter indicates the crop, soil, weather, and management.
15+
This step can be performed as many times as one wants.
16+
4. close the environment using `DSSAT.close`. This removes the directory and the
17+
files created during the environment setup.
818
9-
During the environment setup (`DSSAT.setup`) a directory is created and all the static files required to run DSSAT are copied in that directory. This directory will be removed when the `DSSAT.close` method is called. After the environment has been set up, the `DSSAT.run` method can be called as many times as you want.
19+
The next simple example illustrates how to run a simulation using the five
20+
aforementioned classes:
1021
11-
Input clases are defined by sections and tabular subsections within some sections. Each section is an attribute of the input instance and is defined as an independent `RowBasedSection` class. This class inherits from `dict`, so you can modify any parameter in the section the same way that you'd modify a `dict`'s item.
22+
>>> crop = Crop('maize')
23+
>>> weather = Weather(
24+
df, # Weather data with a datetime index
25+
{"tn": "TMIN", "rad": "SRAD", "prec": "RAIN", "rh": "RHUM", "TMAX": "TMAX"},
26+
4.54, -75.1, 1800
27+
)
28+
>>> soil = SoilProfile(default_class='SIL')
29+
>>> man = Management(planting_date=datetime(12, 3, 2020))
30+
>>> dssat = DSSAT()
31+
>>> dssat.setup()
32+
>>> dssat.run(soil, wth, crop, man)
33+
>>> growth = dssat.output["PlantGro"]
34+
>>> dssat.close() # Terminate the simulation environment
1235
13-
All of the parameters and attributes of the four basic clases have the same name you find in the DSSAT files (Take a look at the .CDE files in https://github.com/DSSAT/dssat-csm-os/tree/develop/Data).
36+
The parameters for ecach class are described in their doucmentation. It is very
37+
important to highlight that this library will allow the user to run only one treatment
38+
at a time. If the users are familiar to DSSAT, they must know that DSSAT allows to
39+
define multiple treatments in the same experimental file.
40+
41+
All of the parameters for the four basic clases have the same names you find in
42+
the DSSAT files (Take a look at the .CDE files in
43+
https://github.com/DSSAT/dssat-csm-os/tree/develop/Data).
1444
1545
Up to date next crops and models are included:
1646
@@ -31,19 +61,20 @@
3161
Potato SUBSTOR
3262
Tomato CROPGRO
3363
Cabbage CROPGRO
64+
Potato SUBSTOR
65+
Sugarcane CANEGRO
3466
================== =====================
35-
3667
'''
3768
VERSION = '048'
3869

39-
from DSSATTools.crop import Crop
70+
from DSSATTools.crop import Crop, available_cultivars
4071
from DSSATTools.soil import SoilProfile, SoilLayer
41-
from DSSATTools.weather import WeatherStation, WeatherData
72+
from DSSATTools.weather import Weather
4273
from DSSATTools.management import Management
4374
from DSSATTools.run import DSSAT
4475
from DSSATTools.base.sections import TabularSubsection
4576

4677
__all__ = [
47-
'Crop', 'SoilProfile', 'SoilLayer', 'WeatherStation', 'WeatherData',
48-
'Management', 'DSSAT', 'TabularSubsection'
78+
'Crop', 'SoilProfile', 'SoilLayer', 'Weather', 'Management', 'DSSAT',
79+
'TabularSubsection', "available_cultivars"
4980
]

0 commit comments

Comments
 (0)