Model components¶
Each SWAP model is composed of components like lego blocks. This module defines all the components that can be used to build a SWAP model.
General settings¶
Model metadata.
Classes:
Name | Description |
---|---|
Metadata |
Metadata of a SWAP model. |
Metadata
¶
Bases: PySWAPBaseModel
, SerializableMixin
Metadata of a SWAP model.
Metadata is intended more as a modelling exercise metadata than a model
metadata. You should create one Metadata object at the beginning of your
model script and pass it to all Model objects you create in between. It is
used to describe model runs if they are stored in a database. Only project
is passed to the swap file.
Attributes:
Name | Type | Description |
---|---|---|
author |
str
|
Author of the model. |
institution |
str
|
Institution of the author. |
email |
str
|
Email of the author. |
project |
str
|
Name of the project. |
swap_ver |
str
|
Version of SWAP used. |
comment |
Optional[str]
|
Comment about the model. |
Source code in pyswap/components/metadata.py
General settings for the simulation and settings for the Richards' equation.
Classes:
Name | Description |
---|---|
GeneralSettings |
General settings of the simulation. |
RichardsSettings |
Settings for the Richards' equation. |
GeneralSettings
¶
Bases: PySWAPBaseModel
, SerializableMixin
, YAMLValidatorMixin
General settings of the simulation.
Attributes:
Name | Type | Description |
---|---|---|
pathwork |
str
|
Path to the working directory. Immutable attribute. |
pathatm |
str
|
Path to folder with weather files. Immutable attribute. |
pathcrop |
str
|
Path to folder with crop files. Immutable attribute. |
pathdrain |
str
|
Path to folder with drainage files. Immutable attribute. |
swscre |
Literal[0, 1, 3]
|
Switch, display progression of simulation run to screen |
swerror |
Literal[0, 1]
|
Switch for printing errors to screen |
tstart |
d
|
Start date of simulation run, give day-month-year |
tend |
d
|
End date of simulation run, give day-month-year |
nprintday |
int
|
Number of output times during a day |
swmonth |
Literal[0, 1]
|
Switch, output each month |
swyrvar |
Literal[0, 1]
|
Output times for overall water and solute balances in .BAL and .BLC file: choose output at a fixed date each year or at different dates |
period |
Optional[int]
|
Fixed output interval |
swres |
Optional[Literal[0, 1]]
|
Switch, reset output interval counter each year |
swodat |
Optional[Literal[0, 1]]
|
Switch, extra output dates are given in table below |
outdatin |
Optional[DateList]
|
list of specific dates |
datefix |
Optional[DayMonth]
|
fixed date for output |
outdat |
Optional[DateList]
|
specify all output dates |
outfil |
str
|
Generic file name of output files. Immutable attribute. |
swheader |
Literal[0, 1]
|
Print header at the start of each balance period |
extensions |
list
|
list of file extensions SWAP should return. Available options are: ["wba", "end", "vap", "bal", "blc", "sba", "ate", "bma", "drf", "swb", "ini", "inc", "crp", "str", "irg", "csv", "csv_tz"] |
inlist_csv |
Optional[StringList]
|
list of |
inlist_csv_tz |
Optional[StringList]
|
list of variables for the csv tz output |
swafo |
Literal[0, 1, 2]
|
Switch, output file with formatted hydrological data |
swaun |
Literal[0, 1, 2]
|
Switch, output file with unformatted hydrological data |
critdevmasbal |
Optional[float]
|
Critical Deviation in water balance during PERIOD |
swdiscrvert |
Literal[0, 1]
|
Switch to convert vertical discretization |
numnodnew |
Optional[int]
|
New number of nodes |
dznew |
Optional[FloatList]
|
Thickness of compartments |
Source code in pyswap/components/simsettings.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
|
RichardsSettings
¶
Bases: PySWAPBaseModel
, SerializableMixin
, YAMLValidatorMixin
Settings for the Richards' equation.
Attributes:
Name | Type | Description |
---|---|---|
swkmean |
Literal[1, 2, 3, 4, 5, 6]
|
Switch for averaging method of hydraulic conductivity |
swkimpl |
Literal[0, 1]
|
Switch for updating hydraulic conductivity during iteration |
dtmin |
float
|
Minimum timestep [1.d-7..0.1 d] |
dtmax |
float
|
Maximum timestep [dtmin..1 d] |
gwlconv |
float
|
Maximum difference of groundwater level between time steps [1.d-5..1000 cm] |
critdevh1cp |
float
|
Maximum relative difference in pressure heads per compartment [1.0d-10..1.d3] |
critdevh2cp |
float
|
Maximum absolute difference in pressure heads per compartment [1.0d-10..1.d3 cm] |
critdevponddt |
float
|
Maximum water balance error of ponding layer [1.0d-6..0.1 cm] |
maxit |
int
|
Maximum number of iteration cycles [5..100] |
maxbacktr |
int
|
Maximum number of back track cycles within an iteration cycle [1..10] |
Source code in pyswap/components/simsettings.py
Meteorological settings¶
Meteorology settings and data.
This module contains the classes and functions to handle meteorological settings and data for simulations.
Classes:
Name | Description |
---|---|
MetFile |
Meteorological data for the .met file. |
Meteorology |
Meteorological settings of the simulation. |
Functions:
Name | Description |
---|---|
load_from_csv |
Load meteorological data from a CSV file. |
load_from_knmi |
Load meteorological data from KNMI API. |
MetFile
¶
Bases: PySWAPBaseModel
, FileMixin
, SerializableMixin
Meteorological data for the .met file.
This object is created by functions fetching or loading meteorological data from various sources. The data is stored as a pandas.DataFrame, but is formatted with a custom field serializer of the CSVTable field type.
Attributes:
Name | Type | Description |
---|---|---|
metfil |
str
|
name of the .met file |
content |
CSVTable
|
meteorological data file |
Source code in pyswap/components/meteorology.py
Meteorology
¶
Bases: PySWAPBaseModel
, SerializableMixin
, YAMLValidatorMixin
Meteorological settings of the simulation.
Note
SWRAIN and SWETSINE should be optional, but Fortran code evaluates its presence anyway. They are set to 0 by default.
Attributes:
Name | Type | Description |
---|---|---|
meteo_location |
Location
|
a point GIS object. If provided, lat and alt must not be provided. By default they are overwritten. |
lat |
Decimal
|
latitude of the meteo station [degrees]. |
swetr |
int
|
Switch type of weather data for potential evapotranspiration:
|
swdivide |
int
|
Switch for distribution of E and T. Defaults to 0:
|
swmetdetail |
int
|
Switch for time interval of evapotranspiration and rainfall weather data:
|
swrain |
int
|
Switch for use of actual rainfall intensity, defaults to 0:
|
swetsine |
int
|
Switch, distribute daily Tp and Ep according to sinus wave, default to 0:
|
metfile |
MetFile
|
MetFile model containing meteorological data to be saved to .met file. |
alt |
Decimal
|
Altitude of the meteo station [m]. |
altw |
Decimal
|
Altitude of the wind [m]. |
angstroma |
Decimal
|
Fraction of extraterrestrial radiation reaching the earth on overcast days. |
angstromb |
Decimal
|
Additional fraction of extraterrestrial radiation reaching the earth on clear days. |
table_rainflux |
Table
|
rainfall intensity RAINFLUX as function of time TIME. |
rainfil |
str
|
file name of file with detailed rainfall data. |
nmetdetail |
int
|
Number of weather data records each day. |
Properties
met: Returns the string representation of the met file.
Methods:
Name | Description |
---|---|
write_met |
Writes the .met file. |
Source code in pyswap/components/meteorology.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
|
model_post_init(__context=None)
¶
Set lat, and alt from meteo_location
if Location object is provided.
Source code in pyswap/components/meteorology.py
write_met(path)
¶
Write the .met file.
Note
in this function the extension is not passed because swp file requires the metfile parameter to be passed already with the extension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
Path to the file. |
required |
Source code in pyswap/components/meteorology.py
metfile_from_csv(metfil, csv_path, **kwargs)
¶
Method for loading meteorological data from a CSV file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metfil
|
str
|
name of the .met file |
required |
csv_path
|
str
|
path to the CSV file |
required |
**kwargs
|
dict
|
keyword arguments for pandas.read_csv |
{}
|
Returns:
Type | Description |
---|---|
MetFile
|
MetFile object. |
Source code in pyswap/components/meteorology.py
metfile_from_knmi(metfil, stations, variables, start='20000101', end='20200101', frequency='day', inseason=False)
¶
Retrieves the meteorological data from KNMI API using knmi-py and enforces SWAP required format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metfil
|
str
|
name of the .met file |
required |
stations
|
str | list
|
station number(s) to retrieve data from |
required |
variables
|
str | list
|
variables to retrieve |
required |
start
|
str | dt
|
start date of the data |
'20000101'
|
end
|
str | dt
|
end date of the data |
'20200101'
|
frequency
|
Literal[day, hour]
|
frequency of the data (day or hour) |
'day'
|
inseason
|
bool
|
whether to retrieve in-season data |
False
|
Returns:
Type | Description |
---|---|
MetFile
|
MetFile object. |
Source code in pyswap/components/meteorology.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
|
Crop settings¶
Crop settings and crop files for SWAP model.
Similar to the .dra or .swp files, the .crp file is a configuration file for the SWAP model.
The classes in this module represent distincs sections of the .crp file. The main class is the
CropFile
class which holds the settings for the crop simulation.
SWAP has three modes for crop simulations which users define in the CROPROTATION _table in the .swp file:
* 1 - simple crop settings - use CropDevelopmentSettingsFixed
* 2 - detailed, WOFOST general settings - use CropDevelopmentSettingsWOFOST
* 3 - dynamic grass growth model - use CropDevelopmentSettingsGrass
For each choice, the .crp file will look different. Therefore, multiple classes are defined in this module to deal with thos different settings.
Classes:
Name | Description |
---|---|
CropFile |
Class for the .crp file. |
CropDevelopmentSettingsWOFOST |
Class for the crop development settings in WOFOST. |
CropDevelopmentSettingsFixed |
Class for the fixed crop development settings. |
CropDevelopmentSettingsGrass |
Class for the grass crop development settings. |
OxygenStress |
Class for the oxygen stress settings. |
DroughtStress |
Class for the drought stress settings. |
SaltStress |
Class for the salt stress settings. |
CompensateRWUStress |
Class for the compensate root water uptake stress settings. |
Interception |
Class for the interception settings. |
CO2Correction |
Class for the CO2 correction settings. |
ScheduledIrrigation |
Class for the scheduled irrigation settings. |
Preparation |
Class for the preparation settings. |
AMAXTB
¶
Bases: BaseTableModel
maximum CO2 assimilation rate [0..100 kg/ha/hr, R] as function of development stage [0..2 -, R]
Attributes:
Name | Type | Description |
---|---|---|
DVS |
Series[float]
|
Development stage of the crop. |
AMAX |
Series[float]
|
Maximum CO2 assimilation rate. |
Source code in pyswap/components/tables.py
CFTB
¶
Bases: BaseTableModel
Crop Height [0..1.d4 cm, R], as function of dev. stage [0..2 -, R]
Attributes:
Name | Type | Description |
---|---|---|
DVS |
Series[float]
|
Development stage of the crop. |
CF |
Series[float]
|
Crop factor. |
Source code in pyswap/components/tables.py
CO2Correction
¶
Bases: PySWAPBaseModel
, SerializableMixin
, YAMLValidatorMixin
, WOFOSTUpdateMixin
CO2 correction settings for WOFOST-type .crp file.
Attributes:
Name | Type | Description |
---|---|---|
swco2 |
Literal[0, 1]
|
Switch for assimilation correction due to CO2 impact
|
atmofil |
Optional[str]
|
alternative filename for atmosphere.co2 |
co2amaxtb |
Optional _Arrays]
|
Correction of photosynthesis as a function of atmospheric CO2 concentration |
co2efftb |
Optional _Arrays]
|
orrection of radiation use efficiency as a function of atmospheric CO2 concentration |
co2tratb |
Optional _Arrays]
|
Correction of transpiration as a function of atmospheric CO2 concentration |
Source code in pyswap/components/crop.py
CROPROTATION
¶
Bases: BaseTableModel
Crop rotation settings
Attributes:
Name | Type | Description |
---|---|---|
CROPSTART |
Series[DateTime]
|
Start date of the crop. |
CROPEND |
Series[DateTime]
|
End date of the crop. |
CROPFIL |
Series[str]
|
Crop file name. |
CROPTYPE |
Series[int]
|
Crop module type
|
Source code in pyswap/components/tables.py
CompensateRWUStress
¶
Bases: PySWAPBaseModel
, SerializableMixin
, YAMLValidatorMixin
Compensate root water uptake stress settings for .crp file.
Attributes:
Name | Type | Description |
---|---|---|
swcompensate |
Literal[0, 1, 2]
|
Switch for compensate root water uptake stress
|
swstressor |
Optional[Literal[1, 2, 3, 4, 5]]
|
Switch for stressor
|
alphacrit |
Optional[float]
|
Critical stress index for compensation of root water uptake |
dcritrtz |
Optional[float]
|
Threshold of rootzone thickness after which compensation occurs |
Source code in pyswap/components/crop.py
Crop
¶
Bases: PySWAPBaseModel
, SerializableMixin
, FileMixin
, YAMLValidatorMixin
Crop settings of the simulation.
Attributes:
Name | Type | Description |
---|---|---|
swcrop |
int
|
Switch for crop:
|
rds |
Optional[float]
|
Rooting depth of the crop [cm]. |
_table_croprotation |
Optional[Table]
|
_Table with crop rotation data. |
cropfiles |
Optional[List[CropFile]]
|
List of crop files. |
Methods:
Name | Description |
---|---|
write_crop |
Write the crop files. |
Source code in pyswap/components/crop.py
CropDevelopmentSettingsFixed
¶
Bases: _CropDevelopmentSettings
Fixed crop development settings (Additionaly to CropDevelopmentSettings).
Attributes:
Name | Type | Description |
---|---|---|
idev |
Literal[1, 2]
|
Duration of crop growing period
|
lcc |
Optional[int]
|
Duration of the crop growing period |
swgc |
Literal[1, 2]
|
Choose between Leaf Area Index or Soil Cover Fraction
|
gctb |
_Arrays
|
Soil Cover Fraction as a function of development stage |
Source code in pyswap/components/crop.py
CropDevelopmentSettingsGrass
¶
Bases: CropDevelopmentSettingsWOFOST
Crop development settings specific to grass growth.
Attributes:
Name | Type | Description |
---|---|---|
swtsum |
Literal[0, 1, 2]
|
Select either sum air temperatures or soil temperature at particular depth
|
tsumtemp |
Optional[float]
|
Specific stem area [0..1 ha/kg, R] |
tsumdepth |
Optional[float]
|
Life span under leaves under optimum conditions [0..366 d, R] |
tsumtime |
Optional[float]
|
Lower threshold temperature for ageing of leaves [-10..30 degree C, R] |
Source code in pyswap/components/crop.py
CropDevelopmentSettingsWOFOST
¶
Bases: _CropDevelopmentSettings
Additional settings as defined for the WOFOST model.
idsl (Literal[0, 1, 2]): Switch for crop development. dtsmtb _Arrays): List increase in temperature sum as function of daily average temperature. dlo (Optional[float]): Optimum day length for crop development. dlc (Optional[float]): Minimum day length. vernsat (Optional[float]): Saturated vernalisation requirement. vernbase (Optional[float]): Base vernalisation requirement. verndvs (Optional[float]): Critical development stage after which the effect of vernalisation is halted. verntb (Optional _Arrays]): _Table with rate of vernalisation as function of average air temperature. tdwi (float): Initial total crop dry weight. laiem (float): Leaf area index at emergence. rgrlai (float): Maximum relative increase in LAI. spa (float): Specific pod area. ssa (float): Specific stem area. span (float): Life span under leaves under optimum conditions. slatb _Arrays): List specific leaf area as function of crop development stage. eff (float): Light use efficiency for real leaf. amaxtb _Arrays): List maximum CO2 assimilation rate as function of development stage. tmpftb _Arrays): List reduction factor of AMAX as function of average day temperature. tmnftb _Arrays): List reduction factor of AMAX as function of minimum day temperature. cvo (float): Efficiency of conversion into storage organs. cvl (float): Efficiency of conversion into leaves. cvr (float): Efficiency of conversion into roots. cvs (float): Efficiency of conversion into stems. q10 (float): Increase in respiration rate with temperature. rml (float): Maintenance respiration rate of leaves. rmo (float): Maintenance respiration rate of storage organs. rmr (float): Maintenance respiration rate of roots. rms (float): Maintenance respiration rate of stems. rfsetb _Arrays): List reduction factor of senescence as function of development stage. frtb _Arrays): List fraction of total dry matter increase partitioned to the roots as function of development stage. fltb _Arrays): List fraction of total above ground dry matter increase partitioned to the leaves as function of development stage. fstb _Arrays): List fraction of total above ground dry matter increase partitioned to the stems as function of development stage. fotb _Arrays): List fraction of total above ground dry matter increase partitioned to the storage organs as function of development stage. perdl (float): Maximum relative death rate of leaves due to water stress. rdrrtb _Arrays): List relative death rates of roots as function of development stage. rdrstb _Arrays): List relative death rates of stems as function of development stage.
Source code in pyswap/components/crop.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
|
CropFile
¶
Bases: PySWAPBaseModel
, FileMixin
, SerializableMixin
Main class for the .crp file.
This class collects all the settings for the crop file. Currently the types of the attributes are set to Any because the validation is not yet implemented.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Name of the crop |
path |
Optional[str]
|
Path to the .crp file |
prep |
Optional[Preparation]
|
Preparation settings |
cropdev_settings |
Optional[CropDevelopmentSettings]
|
Crop development settings |
oxygenstress |
Optional[OxygenStress]
|
Oxygen stress settings |
droughtstress |
Optional[DroughtStress]
|
Drought stress settings |
saltstress |
Optional[SaltStress]
|
Salt stress settings |
compensaterwu |
Optional[CompensateRWUStress]
|
Compensate root water uptake stress settings |
interception |
Optional[Interception]
|
Interception settings |
scheduledirrigation |
Optional[ScheduledIrrigation]
|
Scheduled irrigation settings |
grassland_management |
Optional[GrasslandManagement]
|
Grassland management settings |
Source code in pyswap/components/crop.py
crp: str
property
¶
Return the model string of the .crp file.
DMGRZTB
¶
Bases: BaseTableModel
threshold of above ground dry matter [0..1d6 kg DM/ha, R] to trigger grazing as function of daynumber [1..366 d, R]
Attributes:
Name | Type | Description |
---|---|---|
DNR |
Series[float]
|
Day number. |
DMGRZ |
Series[float]
|
Dry matter growth rate of roots. |
Source code in pyswap/components/tables.py
DMMOWDELAY
¶
Bases: BaseTableModel
Relation between dry matter harvest [0..1d6 kg/ha, R] and days of delay in regrowth [0..366 d, I] after mowing
Attributes:
Name | Type | Description |
---|---|---|
DMMOWDELAY |
Series[float]
|
Dry matter harvest [0..1d6 kg/ha, R] |
DAYDELAY |
Series[int]
|
days of delay in regrowth [0..366 d, I] |
Source code in pyswap/components/tables.py
DMMOWTB
¶
Bases: BaseTableModel
List threshold of above ground dry matter [0..1d6 kg DM/ha, R] to trigger mowing as function of daynumber [1..366 d, R]
Note
maximum 20 records
Attributes:
Name | Type | Description |
---|---|---|
DNR |
Series[float]
|
Day number. |
DMMOW |
Series[float]
|
threshold of above ground dry matter [0..1d6 kg DM/ha, R] |
Source code in pyswap/components/tables.py
DTSMTB
¶
Bases: BaseTableModel
increase in temperature sum [0..60 oC, R] as function of daily average temperature [0..100 oC, R]
Attributes:
Name | Type | Description |
---|---|---|
TAV |
Series[float]
|
Daily average temperature. |
DTSM |
Series[float]
|
Increase in temperature sum. |
Source code in pyswap/components/tables.py
DroughtStress
¶
Bases: PySWAPBaseModel
, SerializableMixin
, YAMLValidatorMixin
Drought stress settings for .crp file.
Attributes:
Name | Type | Description |
---|---|---|
swdrought |
Literal[1, 2]
|
Switch for drought stress
|
swjarvis |
Optional[Literal[0, 1, 2, 3, 4]]
|
DEPRECATED Switch for Jarvis model for water uptake reduction |
alphcrit |
float | None
|
Optional[float] = DEPRECATED Critical stress index (Jarvis, 1989) for compensation of root water uptake [0.2..1 -, R] |
hlim3h |
Optional[float]
|
Pressure head below which water uptake reduction starts at high Tpot |
hlim3l |
Optional[float]
|
Pressure head below which water uptake reduction starts at low Tpot |
hlim4 |
Optional[float]
|
No water extraction at lower soil water pressure heads |
adcrh |
Optional[float]
|
Level of high atmospheric demand, corresponding to HLIM3H |
adcrl |
Optional[float]
|
Level of low atmospheric demand, corresponding to HLIM3L |
wiltpoint |
Optional[float]
|
Minimum pressure head in leaves |
kstem |
Optional[float]
|
Hydraulic conductance between leaf and root xylem |
rxylem |
Optional[float]
|
Xylem radius |
rootradius |
Optional[float]
|
Root radius |
kroot |
Optional[float]
|
Radial hydraulic conductivity of root tissue |
rootcoefa |
Optional[float]
|
Defines relative distance between roots at which mean soil water content occurs |
swhydrlift |
Optional[Literal[0, 1]]
|
Switch for possibility hydraulic lift in root system |
rooteff |
Optional[float]
|
Root system efficiency factor |
stephr |
Optional[float]
|
Step between values of hroot and hxylem in iteration cycle |
criterhr |
Optional[float]
|
Maximum difference of Hroot between iterations; convergence criterium |
taccur |
Optional[float]
|
Maximum absolute difference between simulated and calculated potential transpiration rate |
Source code in pyswap/components/crop.py
FLTB
¶
Bases: BaseTableModel
fraction of total above ground dry matter increase partitioned to the leaves [kg/kg, R]
Attributes:
Name | Type | Description |
---|---|---|
DVS |
Series[float]
|
Development stage of the crop. |
FL |
Series[float]
|
Fraction of total above ground dry matter increase partitioned to the leaves. |
Source code in pyswap/components/tables.py
FOTB
¶
Bases: BaseTableModel
fraction of total above ground dry matter increase partitioned to the storage organs [kg/kg, R]
Attributes:
Name | Type | Description |
---|---|---|
DVS |
Series[float]
|
Development stage of the crop. |
FO |
Series[float]
|
Fraction of total above ground dry matter increase partitioned to the storage organs. |
Source code in pyswap/components/tables.py
FRTB
¶
Bases: BaseTableModel
fraction of total dry matter increase partitioned to the roots [kg/kg, R]
Attributes:
Name | Type | Description |
---|---|---|
DVS |
Series[float]
|
Development stage of the crop. |
FR |
Series[float]
|
Fraction of total dry matter increase partitioned to the roots. |
Source code in pyswap/components/tables.py
FSTB
¶
Bases: BaseTableModel
fraction of total above ground dry matter increase partitioned to the stems [kg/kg, R]
Attributes:
Name | Type | Description |
---|---|---|
DVS |
Series[float]
|
Development stage of the crop. |
FS |
Series[float]
|
Fraction of total above ground dry matter increase partitioned to the stems. |
Source code in pyswap/components/tables.py
GCTB
¶
Bases: BaseTableModel
Leaf Area Index [0..12 (m2 leaf)/(m2 soil), R], as function of dev. stage [0..2 -, R]
Attributes:
Name | Type | Description |
---|---|---|
DVS |
Series[float]
|
Development stage of the crop. |
LAI |
Series[float]
|
Leaf Area Index of the crop. |
Source code in pyswap/components/tables.py
GrasslandManagement
¶
Bases: PySWAPBaseModel
, SerializableMixin
, YAMLValidatorMixin
Settings specific to the dynamic grass growth module.
Attributes:
Name | Type | Description |
---|---|---|
seqgrazmow |
IntList
|
sequence of periods with different practices within calender year. Available options:
|
swharvest |
Literal[1, 2]
|
Switch for timing harvest, either for mowing or grazing
|
dateharvest |
Optional[_DateList]
|
harvest dates (maximum 999) |
swdmgrz |
Optional[Literal[1, 2]]
|
Switch for dry matter threshold to trigger harvest by grazing
|
dmgrazing |
Optional[ _Arrays)]
|
Minimum dry matter amount for cattle to enter the field [0..1d6 kg DM/ha, R] |
dmgrztb |
Optional[int]
|
List threshold of above ground dry matter [0..1d6 kg DM/ha, R] to trigger grazing as function of daynumber [1..366 d, R] |
maxdaygrz |
Optional[int]
|
Maximum growing period after harvest [1..366 -, I] |
swlossgrz |
Optional[Literal[0, 1]]
|
Switch for losses due to insufficient pressure head during grazing
|
tagprest |
Optional[float]
|
Minimum amount of above ground DM after grazing [0..1d6 kg DM/ha, R] |
dewrest |
Optional[float]
|
Remaining yield above ground after dewooling event [0..1d6 kg DM/ha, R] |
_table_lsda |
Optional[Table]
|
Actual livestock density of each grazing period |
_table_lsdb |
Optional[Table]
|
Relation between livestock density, number of grazing days and dry matter uptake |
swdmmow |
Optional[int]
|
Switch for dry matter threshold to trigger harvest by mowing
|
dmharvest |
Optional[float]
|
Threshold of above ground dry matter to trigger mowing [0..1d6 kg DM/ha, R] |
daylastharvest |
Optional[int]
|
Last calendar day on which mowing may occur [1..366 -, I] |
dmlastharvest |
Optional[float]
|
Minimum above ground dry matter for mowing on last date [0..1d6 kg DM/ha, R] |
dmmowtb |
Optional[int]
|
Dry matter mowing threshold |
maxdaymow |
Optional[int]
|
Maximum growing period after harvest [1..366 -, I] |
swlossmow |
Optional[int]
|
Switch for losses due to insufficient pressure head during mowing
|
mowrest |
Optional[float]
|
Remaining yield above ground after mowing event [0..1d6 kg DM/ha, R] |
_table_dmmowdelay |
Optional[Optional[Table]]
|
Relation between dry matter harvest [0..1d6 kg/ha, R] and days of delay in regrowth [0..366 d, I] after mowing |
swpotrelmf |
int
|
Switch for calculation of potential yield
|
relmf |
float
|
Relative management factor to reduce theoretical potential yield to attainable yield [0..1 -, R] |
Source code in pyswap/components/crop.py
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 |
|
Interception
¶
Bases: PySWAPBaseModel
, SerializableMixin
, YAMLValidatorMixin
Interception settings for .crp file.
Attributes:
Name | Type | Description |
---|---|---|
swinter |
Literal[0, 1, 2]
|
Switch for rainfall interception method
|
cofab |
Optional[float]
|
Interception coefficient, corresponding to maximum interception amount |
_table_intertb |
Optional[Table]
|
_table with the following columns as a function of time T:
|
Source code in pyswap/components/crop.py
KYTB
¶
Bases: BaseTableModel
Yield response factor [0..5 -, R], as function of dev. stage [0..2 -, R]
Attributes:
Name | Type | Description |
---|---|---|
DVS |
Series[float]
|
Development stage of the crop. |
KY |
Series[float]
|
Yield response factor of the crop. |
Source code in pyswap/components/tables.py
LSDATB
¶
Bases: BaseTableModel
Actual livestock density of each grazing period
Note
total number of periods should be equal to number of periods in SEQGRAZMOW
Attributes:
Name | Type | Description |
---|---|---|
SEQNR |
Series[int]
|
number of the sequence period with mowing/grazing [0..366 d, I] |
LSDA |
Series[float]
|
Actual Live Stock Density of the grazing period [0.0..1000.0 LS/ha, R] |
Source code in pyswap/components/tables.py
LSDBTB
¶
Bases: BaseTableModel
Relation between livestock density, number of grazing days and dry matter uptake
Attributes:
Name | Type | Description |
---|---|---|
LSDB |
Series[float]
|
Basic Live Stock Density [0.0..1000.0 LS/ha, R] |
DAYSGRAZING |
Series[float]
|
Maximum days of grazing [0.0..366.0 d, R] |
UPTGRAZING |
Series[float]
|
Dry matter uptake by grazing [0.0..1000.0 kg/ha, R] (kg/ha DM) |
LOSSGRAZING |
Series[float]
|
Dry matter loss during grazing due to droppings and treading [0.0..1000.0 kg/ha, R] (kg/ha DM) |
Source code in pyswap/components/tables.py
MRFTB
¶
Bases: BaseTableModel
Ratio root total respiration / maintenance respiration [1..5.0 -, R]
Attributes:
Name | Type | Description |
---|---|---|
DVS |
Series[float]
|
Development stage of the crop. |
MAX_RESP_FACTOR |
Series[float]
|
Ratio root total respiration / maintenance respiration. |
Source code in pyswap/components/tables.py
OxygenStress
¶
Bases: PySWAPBaseModel
, SerializableMixin
, YAMLValidatorMixin
Oxygen stress settings for .crp file.
Attributes:
Name | Type | Description |
---|---|---|
swoxygen |
Literal[0, 1, 2]
|
Switch for oxygen stress
|
swoxygentype |
Optional[Literal[1, 2]]
|
switch for physical processes or repro. functions to calculate oxygen stress
|
swwrtnonox |
Literal[0, 1]
|
Switch for checking aerobic conditions in root zone to stop root(zone) development |
aeratecrit |
Optional[float]
|
Threshold to stop root extension in case of oxygenstress; 0.0 maximum oxygen stress |
hlim1 |
Optional[float]
|
No water extraction at higher pressure heads |
hlim2u |
Optional[float]
|
H below which optimum water extr. starts for top layer |
hlim2l |
Optional[float]
|
H below which optimum water extr. starts for sub layer |
q10_microbial |
Optional[float]
|
Relative increase in microbial respiration at temperature increase of 10 C |
specific_resp_humus |
Optional[float]
|
Respiration rate of humus at 25 C |
srl |
Optional[float]
|
Specific root length |
swrootradius |
Optional[Literal[1, 2]]
|
Switch for calculation of root radius
|
dry_mat_cont_roots |
Optional[float]
|
Dry matter content of roots |
air_filled_root_por |
Optional[float]
|
Air filled root porosity |
spec_weight_root_tissue |
Optional[float]
|
Specific weight of non-airfilled root tissue |
var_a |
Optional[float]
|
Variance of root radius |
root_radiuso2 |
Optional[float]
|
Root radius for oxygen stress module |
q10_root |
Optional[float]
|
Relative increase in root respiration at temperature increase of 10 oC |
f_senes |
Optional[float]
|
Reduction factor for senescence, used for maintenance respiration |
c_mroot |
Optional[float]
|
Maintenance coefficient of root |
_table_max_resp_factor |
Optional[Table]
|
Ratio root total respiration / maintenance respiration as a function of development stage |
_table_dvs_w_root_ss |
Optional[Table]
|
List dry weight of roots at soil surface as a function of development stage |
TODO: Find a way to validate the parameters that are required when the croptype=1 and swoxygen=2 (currently I cannot access the croptype parameter)
move it to the Model class validation at the end, when all the params are available
Source code in pyswap/components/crop.py
Preparation
¶
Bases: PySWAPBaseModel
, SerializableMixin
, YAMLValidatorMixin
Preparation, sowing and germination settings for .crp file.
Attributes:
Name | Type | Description |
---|---|---|
swprep |
Literal[0, 1]
|
Switch for preparation |
swsow |
Literal[0, 1]
|
Switch for sowing |
swgerm |
Literal[0, 1, 2]
|
Switch for germination
|
swharv |
Literal[0, 1]
|
Switch for harvest
|
dvsend |
Optional[float]
|
Development stage at harvest |
zprep |
Optional[float]
|
Z-level for monitoring work-ability for the crop |
hprep |
Optional[float]
|
Maximum pressure head during preparation |
maxprepdelay |
Optional[int]
|
Maximum delay of preparation from start of growing season |
zsow |
Optional[float]
|
Z-level for monitoring work-ability for the crop |
hsow |
Optional[float]
|
Maximum pressure head during sowing |
ztempsow |
Optional[float]
|
Z-level for monitoring temperature for sowing |
tempsow |
Optional[float]
|
Soil temperature needed for sowing |
maxsowdelay |
Optional[int]
|
Maximum delay of sowing from start of growing season |
tsumemeopt |
Optional[float]
|
Temperature sum needed for crop emergence |
tbasem |
Optional[float]
|
Minimum temperature, used for germination trajectory |
teffmx |
Optional[float]
|
Maximum temperature, used for germination trajectory |
hdrygerm |
Optional[float]
|
Pressure head rootzone for dry germination trajectory |
hwetgerm |
Optional[float]
|
Pressure head rootzone for wet germination trajectory |
zgerm |
Optional[float]
|
Z-level for monitoring average pressure head |
agerm |
Optional[float]
|
A-coefficient Eq. 24/25 Feddes & Van Wijk |
Source code in pyswap/components/crop.py
RDCTB
¶
Bases: BaseTableModel
List root density [0..100 cm/cm3, R] as function of relative rooting depth [0..1 -, R]
Attributes:
Name | Type | Description |
---|---|---|
RRD |
Series[float]
|
Relative rooting depth of the crop. |
RDENS |
Series[float]
|
Root density of the crop. |
Source code in pyswap/components/tables.py
RDRRTB
¶
Bases: BaseTableModel
relative death rates of roots [kg/kg/d] as function of development stage [0..2 -, R]
Attributes:
Name | Type | Description |
---|---|---|
DVS |
Series[float]
|
Development stage of the crop. |
RDRR |
Series[float]
|
Relative death rates of roots. |
Source code in pyswap/components/tables.py
RDRSTB
¶
Bases: BaseTableModel
relative death rates of stems [kg/kg/d] as function of development stage [0..2 -, R]
Attributes:
Name | Type | Description |
---|---|---|
DVS |
Series[float]
|
Development stage of the crop. |
RDRS |
Series[float]
|
Relative death rates of stems. |
Source code in pyswap/components/tables.py
RDTB
¶
Bases: BaseTableModel
Rooting Depth [0..1000 cm, R], as a function of development stage [0..2 -, R].
Attributes:
Name | Type | Description |
---|---|---|
DVS |
Series[float]
|
Development stage of the crop. |
RD |
Series[float]
|
Rooting depth of the crop. |
Source code in pyswap/components/tables.py
RFSETB
¶
Bases: BaseTableModel
reduction factor of senescence [-, R] as function of development stage [0..2 -, R]
Attributes:
Name | Type | Description |
---|---|---|
DVS |
Series[float]
|
Development stage of the crop. |
RFSE |
Series[float]
|
Reduction factor of senescence. |
Source code in pyswap/components/tables.py
RLWTB
¶
Bases: BaseTableModel
rooting depth RL [0..5000 cm, R] as function of root weight RW [0..5000 kg DM/ha, R]
Attributes:
Name | Type | Description |
---|---|---|
RW |
Series[float]
|
rooting depth |
RL |
Series[float]
|
root weight |
Source code in pyswap/components/tables.py
SLATB
¶
Bases: BaseTableModel
leaf area [0..1 ha/kg, R] as function of crop development stage [0..2 -, R]
Attributes:
Name | Type | Description |
---|---|---|
DVS |
Series[float]
|
Development stage of the crop. |
SLA |
Series[float]
|
Leaf area. |
Source code in pyswap/components/tables.py
SaltStress
¶
Bases: PySWAPBaseModel
, SerializableMixin
, YAMLValidatorMixin
Salt stress settings for .crp file.
Attributes:
Name | Type | Description |
---|---|---|
swsalinity |
Literal[0, 1, 2]
|
Switch for salt stress
|
saltmax |
Optional[float]
|
Threshold salt concentration in soil water |
saltslope |
Optional[float]
|
Decline of root water uptake above threshold |
salthead |
Optional[float]
|
Conversion factor salt concentration (mg/cm3) into osmotic head (cm) |
Source code in pyswap/components/crop.py
TMNFTB
¶
Bases: BaseTableModel
reduction factor of AMAX [-, R] as function of minimum day temperature [-10..50 oC, R]
Attributes:
Name | Type | Description |
---|---|---|
TMNR |
Series[float]
|
Minimum temperature. |
TMNF |
Series[float]
|
Reduction factor of AMAX. |
Source code in pyswap/components/tables.py
TMPFTB
¶
Bases: BaseTableModel
reduction factor of AMAX [-, R] as function of average day temperature [-10..50 oC, R]
Attributes:
Name | Type | Description |
---|---|---|
TAVD |
Series[float]
|
Minimum temperature. |
TMPF |
Series[float]
|
Reduction factor of AMAX. |
Source code in pyswap/components/tables.py
WRTB
¶
Bases: BaseTableModel
dry weight of roots at soil surface [0..10 kg/m3, R], as a function of development stage [0..2 -,R]
Attributes:
Name | Type | Description |
---|---|---|
DVS |
Series[float]
|
Development stage of the crop. |
W_ROOT_SS |
Series[float]
|
Dry weight of roots at soil surface. |
Source code in pyswap/components/tables.py
Crop database¶
Classes that wrap the crop parameters database for WOFOST (A. de Wit).
From the classes here, only the WOFOSTCropDB is directly accessed by the user, however, the final usable object will be the CropVariety.
Classes:
Name | Description |
---|---|
WOFOSTCropFile |
Manage a single WOFOST crop file content. |
CropVariety |
Manage crop variety parameters. |
WOFOSTCropDB |
Manage a single WOFOST crop file content. |
CropVariety
¶
Bases: BaseModel
Manage crop variety parameters.
Attributes:
Name | Type | Description |
---|---|---|
variety |
dict
|
Parameters for crop variety from the YAML file (with metadata). |
Properties
parameters: Bare parameters of the variety (all metadata removed). metadata: The metadata of the variety.
Source code in pyswap/db/cropdb.py
WOFOSTCropDB
¶
Bases: BaseModel
Simple class for managing crop parameters files.
Initially, it's meant to be used with A. de Wit's WOFOST crop parameters database which is a collection of YAML files. However, it can be easily extended to support other formats and databases when they emerge. All methods should return the content as WOFOSTCropFile instances. This way we ensure that whatever the source format is, the content is always usable in the same way.
Attributes:
Name | Type | Description |
---|---|---|
libdir |
Path
|
Path to the directory with crop parameters |
Properties
croptypes: List all available crop types (files in the directory)
Methods:
Name | Description |
---|---|
load_crop_file |
Load a specific crop file and return the content as a WOFOSTCropFile instance |
Source code in pyswap/db/cropdb.py
WOFOSTCropFile
¶
Bases: BaseModel
Manage a single WOFOST crop file content.
Attributes:
Name | Type | Description |
---|---|---|
yaml_content |
dict
|
The entire content of the YAML file. |
Properties
metadata: Metadata of the crop file. ecotypes: List of eco-types. genericc3: Generic settings for C3 crop types. genericc4: Generic settings for C4 crop types. varieties: List of available varieties.
Methods:
Name | Description |
---|---|
get_variety |
Get the parameters of a specific variety. |
Source code in pyswap/db/cropdb.py
Irrigation¶
Irrigation settings for the SWAP simuluation.
Classes:
Name | Description |
---|---|
IrgFile |
The irrigation file. |
FixedIrrigation |
Fixed irrigation settings. |
ScheduledIrrigation |
Irrigation scheduling settings. |
Functions:
Name | Description |
---|---|
irg_from_csv |
Load the irrigation file from a CSV file. |
FixedIrrigation
¶
Bases: PySWAPBaseModel
, SerializableMixin
, FileMixin
, YAMLValidatorMixin
Fixed irrigation settings in the .swp file.
Attributes:
Name | Type | Description |
---|---|---|
swirfix |
Literal[0, 1]
|
Switch for fixed irrigation applications |
swirgfil |
Literal[0, 1]
|
Switch for separate file with fixed irrigation applications |
irrigevents |
Optional[Table]
|
|
irgfil |
Optional[str]
|
|
Source code in pyswap/components/irrigation.py
model_string(**kwargs)
¶
Override the model_string to handle optional file generation.
Return the full section if swirgfil is set to 1, otherwise, irrigevents is excluded from the string and saved in a separate .irg file.
Source code in pyswap/components/irrigation.py
write_irg(path)
¶
Write irrigation data to .irg file.
This method is only available when the swirgfil attribute is set to 1.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path
|
Path to the directory where the .irg file will be saved. |
required |
Source code in pyswap/components/irrigation.py
IRRIGEVENTS
¶
Bases: BaseTableModel
information for each fixed irrigation event.
Attributes:
Name | Type | Description |
---|---|---|
IRDATE |
Series[datetime]
|
date of irrigation. |
IRDEPTH |
Series[float]
|
amount of water [0..1000 mm, R]. |
IRCONC |
Series[float]
|
concentration of irrigation water [0..1000 mg/cm3, R]. |
IRTYPE |
Series[int]
|
type of irrigation
|
Source code in pyswap/components/tables.py
ScheduledIrrigation
¶
Bases: PySWAPBaseModel
, SerializableMixin
, YAMLValidatorMixin
Irrigation scheduling settings in the .crp file.
Attributes:
Name | Type | Description |
---|---|---|
schedule |
Literal[0, 1]
|
Switch for application irrigation scheduling |
startirr |
str
|
Specify day and month at which irrigation scheduling starts |
endirr |
str
|
Specify day and month at which irrigation scheduling stops |
cirrs |
float
|
Solute concentration of irrigation water |
isuas |
int
|
Switch for type of irrigation method
|
tcs |
int
|
Choose one of the following timing criteria options
|
phFieldCapacity |
float
|
Soil water pressure head at field capacity |
irgthreshold |
Optional[float]
|
Threshold value for weekly irrigation |
dcrit |
Optional[float]
|
Depth of the sensor |
swcirrthres |
Optional[bool]
|
Switch for over-irrigation |
cirrthres |
Optional[float]
|
Threshold salinity concentration above which over-irrigation occur |
perirrsurp |
Optional[float]
|
Over-irrigation of the usually scheduled irrigation depth |
tcsfix |
Optional[int]
|
Switch for minimum time interval between irrigation applications |
irgdayfix |
Optional[int]
|
Minimum number of days between irrigation applications |
phormc |
Optional[int]
|
Switch for the use of pressure head or water content
|
dvs_tc1 |
Optional[Table]
|
|
dvs_tc2 |
Optional[Table]
|
|
dvs_tc3 |
Optional[Table]
|
|
dvs_tc4 |
Optional[Table]
|
|
dvs_tc5 |
Optional[Table]
|
|
Source code in pyswap/components/irrigation.py
Soil-water¶
Evaporation
¶
Bases: PySWAPBaseModel
, SerializableMixin
, YAMLValidatorMixin
Evaporation settings.
Attributes:
Name | Type | Description |
---|---|---|
swcfbs |
Literal[0, 1]
|
Switch for use of soil factor CFBS to calculate Epot from ETref. |
swredu |
Literal[0, 1, 2]
|
Switch for the method for reduction of potential soil evaporation:
|
cfevappond |
Optional[Decimal2f]
|
When ETref is used, evaporation coefficient in case of ponding [0..3]. |
cfbs |
Optional[Decimal2f]
|
Coefficient for potential soil evaporation [0.5..1.5]. |
rsoil |
Optional[Decimal2f]
|
Soil resistance of wet soil [0..1000.0]. |
cofredbl |
Optional[Decimal2f]
|
Soil evaporation coefficient of Black [0..1]. |
rsigni |
Optional[Decimal2f]
|
Minimum rainfall to reset method of Black [0..100]. |
cofredbo |
Optional[Decimal2f]
|
Soil evaporation coefficient of Boesten/Stroosnijder [0..1]. |
Source code in pyswap/components/soilwater.py
SOILHYDRFUNC
¶
Bases: BaseTableModel
Soil hydraulic functions table.
!!! warning
ALFAW required only when the hysteresis option is set to 1 or 2. This column is set as optional column and (for now) is not checked.
('ORES', 'OSAT', 'ALFA', 'NPAR', 'KSATFIT', 'LEXP', 'ALFAW', 'H_ENPR', 'KSATEXM', 'BDENS') Attributes: ORES (Series[float]): Residual water content [0..1 cm3/cm3, R] OSAT (Series[float]): Saturated water content [0..1 cm3/cm3, R] ALFA (Series[float]): Parameter alfa of main drying curve [0.0001..100 /cm, R] NPAR (Series[float]): Parameter n [1.001..9 -, R] LEXP (Series[float]): Exponent in hydraulic conductivity function [-25..25 -, R] KSATFIT (Series[float]): Fitting parameter Ksat of hydraulic conductivity function [1.d-5..1d5 cm/d, R] H_ENPR (Series[float]): Air entry pressure head [-40.0..0.0 cm, R] KSATEXM (Series[float]): Measured hydraulic conductivity at saturated conditions [1.d-5..1d5 cm/d, R] BDENS (Series[float]): Dry soil bulk density [100..1d4 mg/cm3, R] ALFAW (Optional[Series[float]]): Alfa parameter of main wetting curve in case of hysteresis [0.0001..100 /cm, R]
Source code in pyswap/components/tables.py
SOILPROFILE
¶
Bases: BaseTableModel
Vertical discretization of soil profile
Attributes:
Name | Type | Description |
---|---|---|
ISUBLAY |
Series[int]
|
Series[int]: number of sub layer, start with 1 at soil surface [1..MACP, I]. |
ISOILLAY |
Series[int]
|
Series[int]: number of soil physical layer, start with 1 at soil surface [1..MAHO, I]. |
HSUBLAY |
Series[float]
|
Series[float]: height of sub layer [0..1.d4 cm, R]. |
HCOMP |
Series[float]
|
Series[float]: height of compartments in the sub layer [0.0..1000.0 cm, R]. |
NCOMP |
Series[int]
|
Series[int]: number of compartments in the sub layer (Mind NCOMP = HSUBLAY/HCOMP) [1..MACP, I]. |
Source code in pyswap/components/tables.py
SnowAndFrost
¶
Bases: PySWAPBaseModel
, SerializableMixin
, YAMLValidatorMixin
Snow and frost settings for the model.
Attributes:
Name | Type | Description |
---|---|---|
swsnow |
Literal[0, 1]
|
Switch for calculation of snow accumulation and melt. |
swfrost |
Literal[0, 1]
|
Switch, in case of frost reduce soil water flow. |
snowinco |
Optional[Decimal2f]
|
Initial snow water equivalent [0..1000 cm]. |
teprrain |
Optional[Decimal2f]
|
Temperature above which all precipitation is rain [0..10 oC]. |
teprsnow |
Optional[Decimal2f]
|
Temperature below which all precipitation is snow [-10..0 oC]. |
tfroststa |
Optional[Decimal2f]
|
Soil temperature (oC) where reduction of water fluxes starts [-10.0..5.0 oC]. |
tfrostend |
Optional[Decimal2f]
|
Soil temperature (oC) where reduction of water fluxes ends [-10.0..5.0 oC]. |
Source code in pyswap/components/soilwater.py
SoilMoisture
¶
Bases: PySWAPBaseModel
, SerializableMixin
, YAMLValidatorMixin
Soil moisture content and water balance.
Attributes:
Name | Type | Description |
---|---|---|
swinco |
Literal[1, 2, 3]
|
Switch for the type of initial soil moisture condition:
|
head_soildepth |
Optional[Table]
|
Table with head and soil depth data. |
gwli |
Optional[Decimal2f]
|
Initial groundwater level [-10000..100 cm]. |
inifil |
Optional[str]
|
name of output file *.END which contains initial values. |
Source code in pyswap/components/soilwater.py
SoilProfile
¶
Bases: PySWAPBaseModel
, SerializableMixin
, YAMLValidatorMixin
Vertical discretization of soil profile, soil hydraulic functions and hysteresis of soil water retention.
Covers parts 4, 5, 6 and 7 of the .swp file.
Attributes:
Name | Type | Description |
---|---|---|
swsophy |
Literal[0, 1]
|
Switch for analytical functions or tabular input
|
swhyst |
Literal[0, 1, 2]
|
Hysteresis of soil water retention function
|
filenamesophy |
Optional[str]
|
Names of input files with soil hydraulic tables for each soil layer |
tau |
Optional[Decimal2f]
|
Minimum pressure head difference to change wetting-drying [0..1000]. |
swmacro |
Literal[0, 1]
|
Switch for preferential flow due to macropores |
soilprofile |
Table
|
Table with soil profile data |
soilhydrfunc |
Optional[Table]
|
Table with soil hydraulic functions |
Source code in pyswap/components/soilwater.py
SurfaceFlow
¶
Bases: PySWAPBaseModel
, SerializableMixin
, YAMLValidatorMixin
Surface flow settings (ponding, runoff and runon).
Attributes:
Name | Type | Description |
---|---|---|
swpondmx |
Literal[0, 1]
|
Switch for variation ponding threshold for runoff
|
swrunon |
Literal[0, 1]
|
Switch for runon
|
rsro |
Optional[Decimal2f]
|
Drainage resistance for surface runoff [0.001..1.0]. |
rsroexp |
Optional[Decimal2f]
|
Exponent for drainage equation of surface runoff [0.01..10.0]. |
pondmx |
Optional[Decimal2f]
|
In case of ponding, minimum thickness for runoff [0..1000]. |
rufil |
Optional[str]
|
Name of the runon file. |
pondmxtb |
Optional[Table]
|
Minimum thickness for runoff as a function of time. |
Source code in pyswap/components/soilwater.py
Drainage¶
Lateral drainage settings
Settings for the lateral drainage of the .swp file, including the .dra file settings.
Classes:
Name | Description |
---|---|
Flux |
Fluxes between drainage levels in .dra file. |
DraFile |
Drainage file (.dra) settings. |
Drainage |
The lateral drainage settings of .swp file. |
DraFile
¶
Bases: PySWAPBaseModel
, FileMixin
, SerializableMixin
Content of the drainage file (.dra).
Attributes:
Name | Type | Description |
---|---|---|
dramet |
Literal[1, 2, 3]
|
Method of lateral drainage calculation
|
swdivd |
Literal[1, 2]
|
Calculate vertical distribution of drainage flux in groundwater. |
cofani |
Optional[FloatList]
|
specify anisotropy factor COFANI (horizontal/vertical saturated hydraulic conductivity) for each soil layer (maximum MAHO) |
swdislay |
Literal[0, 1, 2, 3, '-']
|
Switch to adjust upper boundary of model discharge layer.
|
lm1 |
float
|
Drain spacing |
table_qdrntb |
Table
|
Table of drainage flux - groundwater level. |
lm1 |
float | None
|
float = _Field(ge=1.0, le=1000.0) |
qdrntb |
Table | None
|
_Table |
lm2 |
float
|
Drain spacing. |
shape |
float
|
Shape factor to account for actual location between drain and water divide. |
wetper |
float
|
Wet perimeter of the drain. |
zbotdr |
float
|
Level of drain bottom. |
entres |
float
|
Drain entry resistance. |
ipos |
Literal[1, 2, 3, 4, 5]
|
Position of drain
|
basegw |
float
|
Level of impervious layer. |
khtop |
float
|
Horizontal hydraulic conductivity of the top layer. |
khbot |
Optional[float]
|
Horizontal hydraulic conductivity of the bottom layer. |
zintf |
Optional[float]
|
Interface level of the coarse and fine soil layer. |
kvtop |
Optional[float]
|
Vertical hydraulic conductivity of the top layer. |
kvbot |
Optional[float]
|
Vertical hydraulic conductivity of the bottom layer. |
geofac |
Optional[float]
|
Geometric factor of Ernst. |
nrlevs |
int
|
Number of drainage levels. |
swintfl |
Literal[0, 1]
|
Option for interflow in highest drainage level (shallow system with short residence time). |
cofintflb |
float
|
Coefficient for interflow relation. |
expintflb |
float
|
Exponent for interflow relation. |
swtopnrsrf |
Literal[0, 1]
|
Switch to enable adjustment of model discharge layer. |
fluxes |
Subsection
|
List of level fluxes. |
altcu |
float
|
Altitude of the control unit relative to reference level. |
nrsrf |
int
|
Number of subsurface drainage levels. |
swnrsrf |
Literal[0, 1, 2]
|
Switch to introduce rapid subsurface drainage. |
rsurfdeep |
Optional[float]
|
Maximum resistance of rapid subsurface drainage. |
rsurfshallow |
Optional[float]
|
Minimum resistance of rapid subsurface drainage. |
swsrf |
Literal[1, 2, 3]
|
Switch for interaction with surface water system. |
swsec |
Optional[Literal[1, 2]]
|
Option for surface water level of secondary system. |
wlact |
Optional[float]
|
Initial surface water level. |
osswlm |
Optional[float]
|
Criterium for warning about oscillation. |
nmper |
Optional[int]
|
Number of management periods. |
swqhr |
Optional[Literal[1, 2]]
|
Switch for type of discharge relationship. |
sofcu |
Optional[float]
|
Size of the control unit. |
Source code in pyswap/components/drainage.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
|
Drainage
¶
Bases: PySWAPBaseModel
, SerializableMixin
, YAMLValidatorMixin
The lateral drainage settings inside .swp file.
Attributes:
Name | Type | Description |
---|---|---|
swdra |
Literal[0, 1, 2]
|
Switch for lateral drainage.
|
drfil |
str
|
Name of the file. This attribute is frozen, there is no need to change it. |
drafile |
Optional[Any]
|
Content of the drainage file. |
Source code in pyswap/components/drainage.py
Flux
¶
Bases: PySWAPBaseModel
, SerializableMixin
, YAMLValidatorMixin
Fluxes between drainage levels in .dra file.
Note
This was rewritten to be a single class instead of a list of classe. Simplicity over DRY. Anyway, the prefered way to set this up would be through the table from the extended section I guess.
Attributes:
Name | Type | Description |
---|---|---|
drares |
float
|
Drainage resistance. |
infres |
float
|
Infiltration resistance. |
swallo |
Literal[1, 2]
|
Switch to allow drainage from this level. |
l |
Optional[float]
|
Drain spacing. |
zbotdr |
float
|
Level of the bottom of the drain. |
swdtyp |
Literal[1, 2]
|
Drainage type.
|
datowltb |
Table
|
date DATOWL [date] and channel water level LEVEL. Add suffix to the dataframe headers according to the level number. |
Source code in pyswap/components/drainage.py
Boundary conditions¶
Boundary conditions settings.
Classes:
BottomBoundary: Bottom boundary settings.
BottomBoundary
¶
Bases: PySWAPBaseModel
, SerializableMixin
, YAMLValidatorMixin
, FileMixin
Bottom boundary settings.
Technically in SWAP boundary conditions can be specified either inside the
.swp file or in a separate .bbc file. The swbbcfile
attribute determines
whether the boundary conditions are written to a .bbc file.
Attributes:
Name | Type | Description |
---|---|---|
swbbcfile |
Optional[Literal[0, 1]]
|
Specify boundary conditions in current file (0) or in a separate .bbc file (1). The preferred is to define the boundary conditions in the .swp file. bbcfil might become deprecated in the future. |
swbotb |
Optional[Literal[1, 2, 3, 4, 5, 6, 7, 8]]
|
Switch for type of bottom boundary.
|
sw2 |
Optional[Literal[1, 2]]
|
Specify whether a sinus function or a table are used for the bottom flux.
|
sw3 |
Optional[Literal[1, 2]]
|
Specify whether a sinus function or a table are used for the hydraulic head in the deep aquifer.
|
sw4 |
Optional[Literal[0, 1]]
|
An extra groundwater flux can be specified which is added to above specified flux.
|
swbotb3resvert |
Optional[Literal[0, 1]]
|
Switch for vertical hydraulic resistance between bottom boundary and groundwater level.
|
swbotb3impl |
Optional[Literal[0, 1]]
|
Switch for numerical solution of bottom flux.
|
swqhbot |
Optional[Literal[1, 2]]
|
Specify whether an exponential relation or a table is used.
|
bbcfil |
Optional[String]
|
Name of file with bottom boundary data (without .BBC extension). |
sinave |
Optional[Decimal2f]
|
Average value of bottom flux. |
sinamp |
Optional[Decimal2f]
|
Amplitude of bottom flux sine function. |
sinmax |
Optional[Decimal2f]
|
Time of the year with maximum bottom flux. |
shape |
Optional[Decimal2f]
|
Shape factor to derive average groundwater level. |
hdrain |
Optional[Decimal2f]
|
Mean drain base to correct for average groundwater level. |
rimlay |
Optional[Decimal2f]
|
Vertical resistance of aquitard. |
aqave |
Optional[Decimal2f]
|
Average hydraulic head in underlaying aquifer. |
aqamp |
Optional[Decimal2f]
|
Amplitude hydraulic head sinus wave. |
aqtmax |
Optional[Decimal2f]
|
First time of the year with maximum hydraulic head. |
aqper |
Optional[Decimal2f]
|
Period of hydraulic head sinus wave. |
cofqha |
Optional[Decimal2f]
|
Coefficient A for exponential relation for bottom flux. |
cofqhb |
Optional[Decimal2f]
|
Coefficient B for exponential relation for bottom flux. |
cofqhc |
Optional[Decimal2f]
|
Coefficient C for exponential relation for bottom flux. |
gwlevel |
Optional[Table]
|
Table with groundwater level data. |
qbot |
Optional[Table]
|
Table with bottom flux data. |
haquif |
Optional[Table]
|
Table with average pressure head in underlaying aquifer. |
qbot4 |
Optional[Table]
|
Table with bottom flux data. |
qtab |
Optional[Table]
|
Table with groundwater level-bottom flux relation. |
hbot5 |
Optional[Table]
|
Table with the bottom compartment pressure head. |
Source code in pyswap/components/boundary.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|
bbc()
¶
model_string(**kwargs)
¶
Override model_string method to handle the swbbcfile attribute.
This method is called in the final serialization step, when each section is converted into a string representation. So, depending on the swbbcfile attribute, this function will return:
- a full section string representation, as for when all boundary
conditions are included in the .swp file, or;
- it will only include swbbcfile and bbcfil (the name of the file
when the other parameters are defined). In that case, the other
parameters are written to a separate .bbc file using the
write_bbc method.
Source code in pyswap/components/boundary.py
write_bbc(path)
¶
Write bottom boundary conditions to a .bbc file.
This method is only available when the swbbcfile attribute is set to 1. Writes entire setion settings (except swbbcfile and bbcfil, defined in the .swp file) to a separate .bbc file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path
|
Path to the directory where the .bbc file will be saved. |
required |
Source code in pyswap/components/boundary.py
Transport¶
HeatFlow
¶
Bases: PySWAPBaseModel
, SerializableMixin
, YAMLValidatorMixin
Heat flow settings for SWAP simulation.
Attributes:
Name | Type | Description |
---|---|---|
swhea |
Literal[0, 1]
|
Switch for heat flow. |
swcalt |
Optional[Literal[1, 2]]
|
|
tampli |
Optional[Decimal2f]
|
Amplitude of annual temperature wave at soil surface [0..50 oC, R] |
tmean |
Optional[Decimal2f]
|
Mean annual temperature at soil surface [-10..30 oC, R] |
timref |
Optional[Decimal2f]
|
Time at which the sinus temperature wave reaches its top [0..366.0 d, R] |
ddamp |
Optional[Decimal2f]
|
Damping depth of soil temperature wave [1..500 cm, R] |
swtopbhea |
Optional[Literal[1, 2]]
|
Define top boundary condition * 1 - use air temperature of meteo input file as top boundary * 2 - use measured top soil temperature as top boundary |
tsoilfile |
Optional[str]
|
Name of input file with soil surface temperatures without extension .TSS |
swbotbhea |
Optional[Literal[1, 2]]
|
Define bottom boundary condition * 1 - no heat flux * 2 - prescribe bottom temperature |
soiltextures |
Optional[Table]
|
For each physical soil layer the soil texture (g/g mineral parts) and the organic matter content (g/g dry soil) |
initsoil |
Optional[Table]
|
Initial temperature TSOIL [-50..50 oC, R] as function of soil depth ZH [-100000..0 cm, R] |
bbctsoil |
Optional[Table]
|
Bottom boundary temperature TBOT [-50..50 oC, R] as function of date DATET [date] |
Source code in pyswap/components/transport.py
INITSOILTEMP
¶
Bases: BaseTableModel
Table for initial soil temperature.
Attributes:
Name | Type | Description |
---|---|---|
ZH |
float
|
Depth of soil layer [cm, R] |
TSOIL |
float
|
Initial temperature [oC, R] |
Source code in pyswap/components/tables.py
SOILTEXTURES
¶
Bases: BaseTableModel
Table for soil textures.
Attributes:
Name | Type | Description |
---|---|---|
PSAND |
float
|
Depth of soil layer [cm, R] |
PSILT |
float
|
Sand content [g/g mineral parts, R] |
PCLAY |
float
|
Clay content [g/g mineral parts, R] |
ORGMAT |
float
|
Organic matter content [g/g dry soil, R] |
Source code in pyswap/components/tables.py
SoluteTransport
¶
Bases: PySWAPBaseModel
, SerializableMixin
, YAMLValidatorMixin
Solute transport settings.
Attributes:
swsolu (Literal[0, 1]): Switch for simulation of solute transport.
cpre (Optional[Decimal2f]): Solute concentration in precipitation [0..100 mg/cm3].
cdrain (Optional[Decimal2f]): Solute concentration in surface water [0..100 mg/cm3].
swbotbc (Optional[Literal[0, 1, 2]]): Switch for groundwater concentration in case of upward flow (seepage).
cseep (Optional[Decimal2f]): Solute concentration in surface water [0..100 mg/cm3].
ddif (Optional[Decimal2f]): Molecular diffusion coefficient [0..10 cm2/d].
tscf (Optional[Decimal2f]): Relative uptake of solutes by roots [0..10].
swsp (Optional[Literal[0, 1]]): Switch, consider solute adsorption.
frexp (Optional[Decimal2f]): Freundlich exponent [0..10].
cref (Optional[Decimal2f]): Reference solute concentration for adsorption [0..1000 mg/cm3].
swdc (Optional[Literal[0, 1]]): Switch, consider solute decomposition.
gampar (Optional[Decimal2f]): Factor reduction decomposition due to temperature [0..0.5 /C].
rtheta (Optional[Decimal2f]): Minimum water content for potential decomposition [0..0.4 cm3/cm3].
bexp (Optional[Decimal2f]): Exponent in reduction decomposition due to dryness [0..2].
swbr (Optional[Literal[0, 1]]): Switch, consider mixed reservoir of saturated zone.
daquif (Optional[Decimal2f]): Thickness saturated part of aquifer [0..10000 cm].
poros (Optional[Decimal2f]): Porosity of aquifer [0..0.6].
kfsat (Optional[Decimal2f]): Linear adsorption coefficient in aquifer [0..100 cm3/mg].
decsat (Optional[Decimal2f]): Decomposition rate in aquifer [0..10 /d].
cdraini (Optional[Decimal2f]): Initial solute concentration in groundwater [0..100 mg/cm3].
cseeparrtb (Optional[Table]): Table for groundwater concentration as function of time.
inissoil (Optional[Table]): Table for initial solute concentration as function of soil depth.
miscellaneous (Optional[Table]): Table for miscellaneous parameters as function of soil depth.
Source code in pyswap/components/transport.py
Database¶
Plot¶
Plotting functionality for pySWAP.
Plotting of results depends heavily on the application of the model. Therefore, in this module, I only inclduded a few examples of how to plot results for specific cases.
Modules:
Name | Description |
---|---|
evapotranspiration |
Functions for plotting evapotranspiration data. |
watercontent |
Functions for plotting water content data as heat map. |
water_content(df, depth_col, date_col, wcontent_col, title='Water content')
¶
Plot water content as heatmap.
For this function to work, the user should either use the vap
output
converted to a dataframe, or make sure that in the csv_tz output they
provide, only the water content data is present.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
DataFrame containing the water content data |
required |
depth_col
|
str
|
Column name for depth data |
required |
date_col
|
str
|
Column name for date data |
required |
wcontent_col
|
str
|
Column name for water content data |
required |
title
|
str
|
Title of the plot. Defaults to 'Water content'. |
'Water content'
|
Source code in pyswap/core/plot/watercontent.py
evapotranspiration
¶
Plot evapotranspiration (potential vs actual) and compute the RMSE.
evapotranspiration(potential, actual, title='Evapotranspiration')
¶
Plot evapotranspiration (potential vs actual) and compute the RMSE.
Paremeters
potential (DataFrame): DataFrame containing dates and values for potential evapotranspiration. actual (DataFrame): DataFrame containing dates and values for actual evapotranspiration. title (str, optional): Title of the plot. Defaults to 'Evapotranspiration'.
Source code in pyswap/core/plot/evapotranspiration.py
watercontent
¶
Functions:
Name | Description |
---|---|
water_content |
Plot water content as heatmap. |
water_content(df, depth_col, date_col, wcontent_col, title='Water content')
¶
Plot water content as heatmap.
For this function to work, the user should either use the vap
output
converted to a dataframe, or make sure that in the csv_tz output they
provide, only the water content data is present.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
DataFrame containing the water content data |
required |
depth_col
|
str
|
Column name for depth data |
required |
date_col
|
str
|
Column name for date data |
required |
wcontent_col
|
str
|
Column name for water content data |
required |
title
|
str
|
Title of the plot. Defaults to 'Water content'. |
'Water content'
|