Installation¶
To install:
# In your virtual environment
pip install CassavaPy
# PyPi does not allow direct dependencies
pip install git+https://github.com/julienmalard/tradssat.git@master
The simplest example¶
Import modules:
from cassavapy import Experimental
Create the Experimental instance:
myInstance = Experimental(filename = "myFile",
exp_name = "myExperiment")
Set the necessary experimental information:
# Planting dates
myInstance.set_planting(n_plant = 2,
p_from = "2010-10-15",
p_by = 30)
# Harvest dates
myInstance.set_harvest(n_harvest = 2,
h_from = "2011-10-15",
h_by = 30)
# Genotype
myInstance.set_genotype(genotype = ["UC0006",
"MCol-1684"])
# Field
myInstance.set_field(code_id = "BACR",
soil_id = "IB00000002")
# Simulation Start Date
myInstance.set_simulation_start('2010-05-01')
When all is defined, create the treatment matrix just by:
myInstance.set_tratmatrix(tnames_prefix = "BA")
And write the .EXP file:
myInstance.write_file()
>> myFile.CSX file available at C:/DSSAT47/Cassava
What CassavaPy can do¶
The following explanation assume knowledge about DSSAT.
DSSAT allows the user to change any factor between environment, crop, genotype and management. Here, the focus is on:
- Cassava crop (MANIHOT model)
- Planting dates
- Harvest dates
- Irrigation management
That said, there are two ways for which a factor (genotype, planting dates etc) can be changed:
- Inside the
.EXPor.SNXfiles. The factor and its variable values are defined within the file.Planting Dates,Harvest DatesandIrrigation managementare in that category. - The variable factor is unique by file. You will have to make as many files as values you need to vary the factor.
Genotype,Field,Simulation Start Date,Simulation ControlsandInitial Conditionsare in that category.
Since setting the last factors is straightforward, here you will find how to set the first.
Go to next section to read about designs.
Design¶
Each Experimental (or Seasonal) file must have a design. But what is it?
Design was the solution we used to manage combinations of factors. For instance, I want to simulate cassava production varying the cycle length. That means I have One Planting Date and n Harvest Dates. That gives us that:
| Planting | Harvest |
|---|---|
| Plan 1 | Harv 1 |
| Plan 1 | Harv 2 |
| Plan 1 | Harv 3 |
| Plan 1 | Harv 4 |
This is called not fixed planting-harvest. I will understand why soon. In not fixed planting-harvest setting, each planting date is combined with all harvest dates.
Total number of treatments are equal to: n planting x n harvest.
It is different from fixed planting-harvest. If I set three planting dates and three harvest dates, using the fixed planting-harvest, I will get:
| Planting | Harvest |
|---|---|
| Plan 1 | Harv 1 |
| Plan 2 | Harv 2 |
| Plan 3 | Harv 3 |
As you can see, number of planting and harvest dates must match.
Total number of treatments are equal to: n planting.
You will have to choose what design you will use when you are creating your instance:
myInstance = Experimental(filename = "myFile",
exp_name = "myExperiment",
design = "phf")
In the code above we choosed the fixed planting-harvest design. The not fixed planting-harvest is the default.
Note
Until now, treatment number by file is limited to 99. If your simulation need more than that, you will have to “break” your treatments in more files. In the run moment, you can run all together.
Irrigation Designs¶
Designs are used for planting-harvest combinations, but also for irrigation. If you are using irrigation in your simulations, you will have to choose a design based on what you want.
There is three options for irrigation designs:
- All rainfed (default)
irf- fixed irrigationirnf- not fixed irrigation
Fixed irrigation means that you will set an “fixed” irrigation schedule and will choose for which treatments it will be applied. For instance:
| Treatment | Planting | Harvest | Irrigation |
|---|---|---|---|
| 1 | Plan 1 | Harv 1 | Irrig |
| 2 | Plan 2 | Harv 2 | Rainfed |
| 3 | Plan 3 | Harv 3 | Irrig |
In the design above, treatments One and Three are receiving the same irrigation management. That means they are receiving the same amount of water in the same DAP’s (days after planting) defined by the user.
By the other hand, in the Not fixed irrigation setting the user define as many irrigation schedules as he want and combine each with treatments. The following table shows the concept.
| Treatment | Planting | Harvest | Irrigation |
|---|---|---|---|
| 1 | Plan 1 | Harv 1 | Irrig 1 |
| 2 | Plan 1 | Harv 2 | Rainfed |
| 3 | Plan 2 | Harv 1 | Irrig 2 |
| 4 | Plan 2 | Harv 2 | Irrig 1 |
In the design above we defined two irrigation schedules and apply the first to treatments One and Four, and the second to treatment Three. Treatments One and Four are receiving the same amount of water in the same DAP’s (days after planting) defined by the schedule 1 (Irrig 1). Treatment Three, however, are receiving a different irrigation management.
You may be noted that in the last design (table) we used the not fixed planting-harvest setting with two Planting Dates and two Harvest Dates. We could use the fixed planting-harvest instead, with four Planting Dates and four Harvest Dates.
| Treatment | Planting | Harvest | Irrigation |
|---|---|---|---|
| 1 | Plan 1 | Harv 1 | Irrig 1 |
| 2 | Plan 2 | Harv 2 | Rainfed |
| 3 | Plan 3 | Harv 3 | Irrig 2 |
| 4 | Plan 4 | Harv 4 | Irrig 1 |
To reproduce the design above, write that when you are creating your instance:
myInstance = Experimental(filename = "myFile",
exp_name = "myExperiment",
design = ["phf", "irnf"])
If you are interested in the fixed irrigation with fixed planting-harvest design
myInstance = Experimental(filename = "myFile",
exp_name = "myExperiment",
design = ["phf", "irf"])
Or maybe fixed irrigation with not fixed planting-harvest design
myInstance = Experimental(filename = "myFile",
exp_name = "myExperiment",
# not fixed planting-harvest is the default
design = "irf")