API reference¶
Simulation settings¶
Main simulation settings for the SWAP model.
Modules:
Name | Description |
---|---|
general |
General simulation settings for the SWAP model. |
metadata |
Metadata for the SWAP model. |
richards |
Richards simulation settings for the SWAP model. |
UNITRANGE = {'ge': 0.0, 'le': 1.0}
module-attribute
¶
Range of values between 0.0 and 1.0.
YEARRANGE = {'ge': 0, 'le': 366}
module-attribute
¶
Range of values for year (0 <= x <= 366).
GeneralSettings
¶
Bases: PySWAPBaseModel
General settings of the simulation.
Todo
- remove the individual file extension switches and replace with a list of extensions. Make the class automatically generate the switches based on the list of extensions.
Attributes:
Name | Type | Description |
---|---|---|
pathwork |
str
|
Path to the working directory |
pathatm |
str
|
Path to folder with weather files |
pathcrop |
str
|
Path to folder with crop files |
pathdrain |
str
|
Path to folder with drainage files |
swscre |
Literal[0, 1, 3]
|
Switch, display progression of simulation run to screen |
swerror |
Literal[0, 1]
|
Switch for printing errors to screen |
tstart |
date
|
Start date of simulation run, give day-month-year |
tend |
date
|
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 |
swheader |
Literal[0, 1]
|
Print header at the start of each balance period |
swwba |
Literal[0, 1]
|
Switch, output daily water balance |
swend |
Literal[0, 1]
|
Switch, output end-conditions |
swvap |
Literal[0, 1]
|
Switch, output soil profiles of moisture, solute and temperature |
swbal |
Literal[0, 1]
|
Switch, output file with yearly water balance |
swblc |
Literal[0, 1]
|
Switch, output file with detailed yearly water balance |
swsba |
Literal[0, 1]
|
Switch, output file of daily solute balance |
swate |
Literal[0, 1]
|
Switch, output file with soil temperature profiles |
swbma |
Literal[0, 1]
|
Switch, output file with water fluxes, only for macropore flow |
swdrf |
Literal[0, 1]
|
Switch, output of drainage fluxes, only for extended drainage |
swswb |
Literal[0, 1]
|
Switch, output surface water reservoir, only for extended drainage |
swini |
Literal[0, 1]
|
Switch, output of initial SoilPhysParam and HeatParam |
swinc |
Literal[0, 1]
|
Switch, output of water balance increments |
swcrp |
Literal[0, 1]
|
Switch, output of simple or detailed crop growth model |
swstr |
Literal[0, 1]
|
Switch, output of stress values for wetness, drought, salinity and frost |
swirg |
Literal[0, 1]
|
Switch, output of irrigation gifts |
swcsv |
Literal[0, 1]
|
Switch, csv output |
inlist_csv |
Optional[StringList]
|
list of variables for the csv output |
swcsv_tz |
Literal[0, 1]
|
Switch, csv output with depth |
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/simsettings/general.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 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 |
|
Metadata
¶
Bases: PySWAPBaseModel
Metadata of a SWAP model.
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/simsettings/metadata.py
PySWAPBaseModel
¶
Bases: BaseModel
Base class for PySWAP models.
Attributes:
Name | Type | Description |
---|---|---|
model_config |
ConfigDict
|
Overriding Pydantic model configuration. |
Methods:
Name | Description |
---|---|
save_element |
Saves model element to a file. |
model_string |
Returns a custom model string representation that matches the requirements of .swp file. |
_concat_sections |
Concatenate a string from individual sections. |
model_string |
Returns a custom model string representation that matches the requirements of .swp file. |
Source code in pyswap/core/basemodel.py
model_string()
¶
Returns a custom model string representation that matches the requirements of .swp file.
Note
If values are simple types, they are formatted as 'ATTR = VALUE'. If the valies are tables (in pySWAP pd.DataFrame are used), they are formatted simply as 'TABLE_VALUE'. Additionally, a custom serializer (pyswap.core.utils.serializers.quote_string) is used to quote strings.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Custom model string representation. |
Source code in pyswap/core/basemodel.py
save_element(string, path, filename, extension=None)
staticmethod
¶
Saves model element to a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
string |
str
|
String to be saved. |
required |
path |
str
|
Path to the file. |
required |
filename |
str
|
File name. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Success message. |
Source code in pyswap/core/basemodel.py
RichardsSettings
¶
Bases: PySWAPBaseModel
Settings for the Richards' equation.
Attributes:
Name | Type | Description |
---|---|---|
swkmean |
int
|
Switch for averaging method of hydraulic conductivity |
swkimpl |
Literal[0, 1]
|
Switch for updating hydraulic conductivity during iteration |
dtmin |
float
|
Minimum timestep |
dtmax |
float
|
Maximum timestep |
gwlconv |
float
|
Maximum difference of groundwater level between time steps |
critdevh1cp |
float
|
Maximum relative difference in pressure heads per compartment |
critdevh2cp |
float
|
Maximum absolute difference in pressure heads per compartment |
critdevponddt |
float
|
Maximum water balance error of ponding layer |
maxit |
int
|
Maximum number of iteration cycles |
maxbacktr |
int
|
Maximum number of back track cycles within an iteration cycle |
Source code in pyswap/simsettings/richards.py
general
¶
GeneralSettings
¶
Bases: PySWAPBaseModel
General settings of the simulation.
Todo
- remove the individual file extension switches and replace with a list of extensions. Make the class automatically generate the switches based on the list of extensions.
Attributes:
Name | Type | Description |
---|---|---|
pathwork |
str
|
Path to the working directory |
pathatm |
str
|
Path to folder with weather files |
pathcrop |
str
|
Path to folder with crop files |
pathdrain |
str
|
Path to folder with drainage files |
swscre |
Literal[0, 1, 3]
|
Switch, display progression of simulation run to screen |
swerror |
Literal[0, 1]
|
Switch for printing errors to screen |
tstart |
date
|
Start date of simulation run, give day-month-year |
tend |
date
|
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 |
swheader |
Literal[0, 1]
|
Print header at the start of each balance period |
swwba |
Literal[0, 1]
|
Switch, output daily water balance |
swend |
Literal[0, 1]
|
Switch, output end-conditions |
swvap |
Literal[0, 1]
|
Switch, output soil profiles of moisture, solute and temperature |
swbal |
Literal[0, 1]
|
Switch, output file with yearly water balance |
swblc |
Literal[0, 1]
|
Switch, output file with detailed yearly water balance |
swsba |
Literal[0, 1]
|
Switch, output file of daily solute balance |
swate |
Literal[0, 1]
|
Switch, output file with soil temperature profiles |
swbma |
Literal[0, 1]
|
Switch, output file with water fluxes, only for macropore flow |
swdrf |
Literal[0, 1]
|
Switch, output of drainage fluxes, only for extended drainage |
swswb |
Literal[0, 1]
|
Switch, output surface water reservoir, only for extended drainage |
swini |
Literal[0, 1]
|
Switch, output of initial SoilPhysParam and HeatParam |
swinc |
Literal[0, 1]
|
Switch, output of water balance increments |
swcrp |
Literal[0, 1]
|
Switch, output of simple or detailed crop growth model |
swstr |
Literal[0, 1]
|
Switch, output of stress values for wetness, drought, salinity and frost |
swirg |
Literal[0, 1]
|
Switch, output of irrigation gifts |
swcsv |
Literal[0, 1]
|
Switch, csv output |
inlist_csv |
Optional[StringList]
|
list of variables for the csv output |
swcsv_tz |
Literal[0, 1]
|
Switch, csv output with depth |
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/simsettings/general.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 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 |
|
metadata
¶
Metadata class collecting basic information about the model.
Classes:
Name | Description |
---|---|
Metadata |
Metadata of a SWAP model. |
Metadata
¶
Bases: PySWAPBaseModel
Metadata of a SWAP model.
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/simsettings/metadata.py
richards
¶
Settings for the Richards' equation with some reasonable defaults included.
Classes:
Name | Description |
---|---|
RichardsSettings |
Holds the settings for the Richards' equation. |
RichardsSettings
¶
Bases: PySWAPBaseModel
Settings for the Richards' equation.
Attributes:
Name | Type | Description |
---|---|---|
swkmean |
int
|
Switch for averaging method of hydraulic conductivity |
swkimpl |
Literal[0, 1]
|
Switch for updating hydraulic conductivity during iteration |
dtmin |
float
|
Minimum timestep |
dtmax |
float
|
Maximum timestep |
gwlconv |
float
|
Maximum difference of groundwater level between time steps |
critdevh1cp |
float
|
Maximum relative difference in pressure heads per compartment |
critdevh2cp |
float
|
Maximum absolute difference in pressure heads per compartment |
critdevponddt |
float
|
Maximum water balance error of ponding layer |
maxit |
int
|
Maximum number of iteration cycles |
maxbacktr |
int
|
Maximum number of back track cycles within an iteration cycle |
Source code in pyswap/simsettings/richards.py
Atmosphere subpackage¶
Meteorological settings and data for SWAP simulations.
Modules:
Name | Description |
---|---|
metfile |
meteorological data for SWAP simulations |
meteorology |
meteorological settings for SWAP simulations |
UNITRANGE = {'ge': 0.0, 'le': 1.0}
module-attribute
¶
Range of values between 0.0 and 1.0.
MetFile
¶
Bases: PySWAPBaseModel
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/atmosphere/metfile.py
Meteorology
¶
Bases: PySWAPBaseModel
Meteorological settings of the simulation.
Attributes:
Name | Type | Description |
---|---|---|
lat |
float
|
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 |
float
|
Altitude of the meteo station [m]. |
altw |
float
|
Altitude of the wind [m]. |
angstroma |
float
|
Fraction of extraterrestrial radiation reaching the earth on overcast days. |
angstromb |
float
|
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. |
Methods:
Name | Description |
---|---|
write_met |
Write the .met file. |
Source code in pyswap/atmosphere/meteorology.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 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 |
|
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/atmosphere/meteorology.py
PySWAPBaseModel
¶
Bases: BaseModel
Base class for PySWAP models.
Attributes:
Name | Type | Description |
---|---|---|
model_config |
ConfigDict
|
Overriding Pydantic model configuration. |
Methods:
Name | Description |
---|---|
save_element |
Saves model element to a file. |
model_string |
Returns a custom model string representation that matches the requirements of .swp file. |
_concat_sections |
Concatenate a string from individual sections. |
model_string |
Returns a custom model string representation that matches the requirements of .swp file. |
Source code in pyswap/core/basemodel.py
model_string()
¶
Returns a custom model string representation that matches the requirements of .swp file.
Note
If values are simple types, they are formatted as 'ATTR = VALUE'. If the valies are tables (in pySWAP pd.DataFrame are used), they are formatted simply as 'TABLE_VALUE'. Additionally, a custom serializer (pyswap.core.utils.serializers.quote_string) is used to quote strings.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Custom model string representation. |
Source code in pyswap/core/basemodel.py
save_element(string, path, filename, extension=None)
staticmethod
¶
Saves model element to a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
string |
str
|
String to be saved. |
required |
path |
str
|
Path to the file. |
required |
filename |
str
|
File name. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Success message. |
Source code in pyswap/core/basemodel.py
load_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/atmosphere/metfile.py
load_from_knmi(metfil, stations, variables=['TEMP', 'PRCP', 'Q', 'UG', 'FG', 'UX', 'UN'], start='20000101', end='20200101', frequency='day', inseason=False)
¶
Retrieves the meteorological data from KNMI API using knmi-py.
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 |
['TEMP', 'PRCP', 'Q', 'UG', 'FG', 'UX', 'UN']
|
start |
str | datetime
|
start date of the data |
'20000101'
|
end |
str | datetime
|
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/atmosphere/metfile.py
save_file(string, fname, path, mode='w', extension=None, encoding='ascii')
¶
Saves a string to a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
string |
str
|
The string to be saved to a file. |
required |
extension |
str | None
|
The extension that the file should have (e.g. 'txt', 'csv', etc.). |
None
|
fname |
str
|
The name of the file. |
required |
path |
str
|
The path where the file should be saved. |
required |
mode |
str
|
The mode in which the file should be opened (e.g. 'w' for write, 'a' for append, etc.). |
'w'
|
encoding |
str
|
The encoding to use for the file (default is 'ascii'). |
'ascii'
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in pyswap/core/files.py
meteorology
¶
Meteorological settings for SWAP simulations.
Note
Meteorology
object requires the MetFile
object to be passed upon initialization. When the model is run,
the MetFile
object is saved to a .met file.
Classes:
Name | Description |
---|---|
Meteorology |
Holds the settings of the meteo section of the .swp file. |
Meteorology
¶
Bases: PySWAPBaseModel
Meteorological settings of the simulation.
Attributes:
Name | Type | Description |
---|---|---|
lat |
float
|
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 |
float
|
Altitude of the meteo station [m]. |
altw |
float
|
Altitude of the wind [m]. |
angstroma |
float
|
Fraction of extraterrestrial radiation reaching the earth on overcast days. |
angstromb |
float
|
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. |
Methods:
Name | Description |
---|---|
write_met |
Write the .met file. |
Source code in pyswap/atmosphere/meteorology.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 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 |
|
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/atmosphere/meteorology.py
metfile
¶
Getting and formatting meteorological data for SWAP similation.
Classes:
Name | Description |
---|---|
MetFile |
meteorological data for the .met file |
Functions:
Name | Description |
---|---|
load_from_csv |
loading meteorological data from a CSV file |
load_from_knmi |
retrieving meteorological data from KNMI API |
MetFile
¶
Bases: PySWAPBaseModel
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/atmosphere/metfile.py
load_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/atmosphere/metfile.py
load_from_knmi(metfil, stations, variables=['TEMP', 'PRCP', 'Q', 'UG', 'FG', 'UX', 'UN'], start='20000101', end='20200101', frequency='day', inseason=False)
¶
Retrieves the meteorological data from KNMI API using knmi-py.
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 |
['TEMP', 'PRCP', 'Q', 'UG', 'FG', 'UX', 'UN']
|
start |
str | datetime
|
start date of the data |
'20000101'
|
end |
str | datetime
|
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/atmosphere/metfile.py
tables
¶
Plant subpackage¶
Crop settings and files for the SWAP simulation.
Modules:
Name | Description |
---|---|
crop |
The crop settings. |
crpfile |
The crop file. |
create_crp_tables |
Experimental module with functions to create crop tables. |
crop
¶
UNITRANGE = {'ge': 0.0, 'le': 1.0}
module-attribute
¶
Range of values between 0.0 and 1.0.
YEARRANGE = {'ge': 0, 'le': 366}
module-attribute
¶
Range of values for year (0 <= x <= 366).
CO2Correction
¶
Bases: PySWAPBaseModel
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/plant/crpfile.py
CompensateRWUStress
¶
Bases: PySWAPBaseModel
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/plant/crpfile.py
Crop
¶
Bases: PySWAPBaseModel
Holds the 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/plant/crop.py
CropDevelopmentSettings
¶
Bases: PySWAPBaseModel
Crop development settings (parts 1-xx form the template)
Note
The validation of this class should be optimized. The current implementation repeats the validation of the base class in each subclass. The observed issue is that when the validator is inherited from the base class and there is another validator in the subclass (even if they have different names), at the validation step of the child class the validator throws an error that the attribute is NoneType. To be fixed later.
Attributes:
Name | Type | Description |
---|---|---|
swcf |
Literal[1, 2]
|
Choose between crop factor and crop height
|
table_dvs_cf |
Optional[Table]
|
Table with crop factors as a function of development stage |
table_dvs_ch |
Optional[Table]
|
Table with crop height as a function of development stage |
albedo |
Optional[float]
|
Crop reflection coefficient |
rsc |
Optional[float]
|
Minimum canopy resistance |
rsw |
Optional[float]
|
Canopy resistance of intercepted water |
tsumea |
float
|
Temperature sum from emergence to anthesis |
tsumam |
float
|
Temperature sum from anthesis to maturity |
tbase |
Optional[float]
|
Start value of temperature sum |
kdif |
float
|
Extinction coefficient for diffuse visible light |
kdir |
float
|
Extinction coefficient for direct visible light |
swrd |
Optional[Literal[1, 2, 3]]
|
Switch development of root growth
|
rdtb |
Optional[Arrays]
|
Rooting Depth as a function of development stage |
rdi |
float
|
Initial rooting depth |
rri |
float
|
Maximum daily increase in rooting depth |
rdc |
float
|
Maximum rooting depth of particular crop |
swdmi2rd |
Optional[Literal[0, 1]]
|
Switch for calculation rooting depth
|
rlwtb |
Optional[Arrays]
|
rooting depth as function of root weight |
wrtmax |
float
|
Maximum root weight |
swrdc |
Literal[0, 1]
|
Switch for calculation of relative root density |
rdctb |
Arrays
|
root density as function of relative rooting depth |
Source code in pyswap/plant/crpfile.py
CropDevelopmentSettingsFixed
¶
Bases: CropDevelopmentSettings
Fixed crop development settings (parts 1-xx form the template)
Warning
This class is not complete. It is missing the validation.
Note
I noticed an issue with the tables here. They are actually arrays (each array is a column) that are preceeded by the variable name and "=". That variable name is the same for all options of tables which have different column names (e.g., DVS/LAI or DVS/SCF) but the variable name is the same (e.g., GCTB). TODO: implement a check of the column before the df is converted to string.
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/plant/crpfile.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/plant/crpfile.py
CropDevelopmentSettingsWOFOST
¶
Bases: CropDevelopmentSettings
Additional settings for the
Warning
The validation for this class is not complete. Also check the Optional attributes!
Note
Use serialization_alias to change the parameter names who are different between WOFOST and SWAP.
Attributes:
Name | Type | Description |
---|---|---|
idsl |
Literal[0, 1, 2]
|
|
dtsmtb |
Arrays
|
|
dlo |
Optional[float]
|
|
dlc |
Optional[float]
|
|
vernsat |
Optional[float]
|
|
vernbase |
Optional[float]
|
|
verndvs |
Optional[float]
|
|
verntb |
Optional[Arrays]
|
|
tdwi |
float
|
|
laiem |
float
|
|
rgrlai |
float
|
|
spa |
float
|
|
ssa |
float
|
|
span |
float
|
|
slatb |
Arrays
|
|
eff |
float
|
|
amaxtb |
Arrays
|
|
tmpftb |
Arrays
|
|
tmnftb |
Arrays
|
|
cvo |
float
|
|
cvl |
float
|
|
cvr |
float
|
|
cvs |
float
|
|
q10 |
float
|
|
rml |
float
|
|
rmo |
float
|
|
rmr |
float
|
|
rms |
float
|
|
rfsetb |
Arrays
|
|
frtb |
Arrays
|
|
fltb |
Arrays
|
|
fstb |
Arrays
|
|
fotb |
Arrays
|
|
perdl |
float
|
|
rdrrtb |
Arrays
|
|
rdrstb |
Arrays
|
|
Source code in pyswap/plant/crpfile.py
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 212 213 214 215 216 217 218 219 220 221 222 223 224 |
|
CropFile
¶
Bases: PySWAPBaseModel
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 |
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/plant/crpfile.py
DroughtStress
¶
Bases: PySWAPBaseModel
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 |
Optional[float]
|
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/plant/crpfile.py
GrasslandManagement
¶
Bases: PySWAPBaseModel
Settings specific to the dynamic grass growth module.
Warning
Validation still required.
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/plant/crpfile.py
690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 |
|
Interception
¶
Bases: PySWAPBaseModel
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/plant/crpfile.py
OxygenStress
¶
Bases: PySWAPBaseModel
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)
Source code in pyswap/plant/crpfile.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
|
Preparation
¶
Bases: PySWAPBaseModel
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/plant/crpfile.py
607 608 609 610 611 612 613 614 615 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 |
|
SaltStress
¶
Bases: PySWAPBaseModel
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/plant/crpfile.py
ScheduledIrrigation
¶
Bases: PySWAPBaseModel
Irrigation scheduling settings.
Warning
The docstring needs to be updated.
Note
This class is only used 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/irrigation/irrigation.py
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 |
|
open_file(file_path)
¶
Open file and detect encoding.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path |
str
|
Path to the file to be opened. |
required |
Source code in pyswap/core/files.py
crpfile
¶
Create .crp file 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.
Classes:
Name | Description |
---|---|
CropFile |
Class for the .crp file. |
CropDevelopmentSettings |
Class for the crop development settings. |
CropDevelopmentSettingsWOFOST |
Class for the crop development settings in WOFOST. |
CropDevelopmentSettingsFixed |
Class for the fixed 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. |
Warning
This script will undergo major changes in the future. Some things to improve include smoother integration with WOFOST configuration files (yaml) and code readability.
CO2Correction
¶
Bases: PySWAPBaseModel
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/plant/crpfile.py
CompensateRWUStress
¶
Bases: PySWAPBaseModel
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/plant/crpfile.py
CropDevelopmentSettings
¶
Bases: PySWAPBaseModel
Crop development settings (parts 1-xx form the template)
Note
The validation of this class should be optimized. The current implementation repeats the validation of the base class in each subclass. The observed issue is that when the validator is inherited from the base class and there is another validator in the subclass (even if they have different names), at the validation step of the child class the validator throws an error that the attribute is NoneType. To be fixed later.
Attributes:
Name | Type | Description |
---|---|---|
swcf |
Literal[1, 2]
|
Choose between crop factor and crop height
|
table_dvs_cf |
Optional[Table]
|
Table with crop factors as a function of development stage |
table_dvs_ch |
Optional[Table]
|
Table with crop height as a function of development stage |
albedo |
Optional[float]
|
Crop reflection coefficient |
rsc |
Optional[float]
|
Minimum canopy resistance |
rsw |
Optional[float]
|
Canopy resistance of intercepted water |
tsumea |
float
|
Temperature sum from emergence to anthesis |
tsumam |
float
|
Temperature sum from anthesis to maturity |
tbase |
Optional[float]
|
Start value of temperature sum |
kdif |
float
|
Extinction coefficient for diffuse visible light |
kdir |
float
|
Extinction coefficient for direct visible light |
swrd |
Optional[Literal[1, 2, 3]]
|
Switch development of root growth
|
rdtb |
Optional[Arrays]
|
Rooting Depth as a function of development stage |
rdi |
float
|
Initial rooting depth |
rri |
float
|
Maximum daily increase in rooting depth |
rdc |
float
|
Maximum rooting depth of particular crop |
swdmi2rd |
Optional[Literal[0, 1]]
|
Switch for calculation rooting depth
|
rlwtb |
Optional[Arrays]
|
rooting depth as function of root weight |
wrtmax |
float
|
Maximum root weight |
swrdc |
Literal[0, 1]
|
Switch for calculation of relative root density |
rdctb |
Arrays
|
root density as function of relative rooting depth |
Source code in pyswap/plant/crpfile.py
CropDevelopmentSettingsFixed
¶
Bases: CropDevelopmentSettings
Fixed crop development settings (parts 1-xx form the template)
Warning
This class is not complete. It is missing the validation.
Note
I noticed an issue with the tables here. They are actually arrays (each array is a column) that are preceeded by the variable name and "=". That variable name is the same for all options of tables which have different column names (e.g., DVS/LAI or DVS/SCF) but the variable name is the same (e.g., GCTB). TODO: implement a check of the column before the df is converted to string.
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/plant/crpfile.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/plant/crpfile.py
CropDevelopmentSettingsWOFOST
¶
Bases: CropDevelopmentSettings
Additional settings for the
Warning
The validation for this class is not complete. Also check the Optional attributes!
Note
Use serialization_alias to change the parameter names who are different between WOFOST and SWAP.
Attributes:
Name | Type | Description |
---|---|---|
idsl |
Literal[0, 1, 2]
|
|
dtsmtb |
Arrays
|
|
dlo |
Optional[float]
|
|
dlc |
Optional[float]
|
|
vernsat |
Optional[float]
|
|
vernbase |
Optional[float]
|
|
verndvs |
Optional[float]
|
|
verntb |
Optional[Arrays]
|
|
tdwi |
float
|
|
laiem |
float
|
|
rgrlai |
float
|
|
spa |
float
|
|
ssa |
float
|
|
span |
float
|
|
slatb |
Arrays
|
|
eff |
float
|
|
amaxtb |
Arrays
|
|
tmpftb |
Arrays
|
|
tmnftb |
Arrays
|
|
cvo |
float
|
|
cvl |
float
|
|
cvr |
float
|
|
cvs |
float
|
|
q10 |
float
|
|
rml |
float
|
|
rmo |
float
|
|
rmr |
float
|
|
rms |
float
|
|
rfsetb |
Arrays
|
|
frtb |
Arrays
|
|
fltb |
Arrays
|
|
fstb |
Arrays
|
|
fotb |
Arrays
|
|
perdl |
float
|
|
rdrrtb |
Arrays
|
|
rdrstb |
Arrays
|
|
Source code in pyswap/plant/crpfile.py
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 212 213 214 215 216 217 218 219 220 221 222 223 224 |
|
CropFile
¶
Bases: PySWAPBaseModel
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 |
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/plant/crpfile.py
DroughtStress
¶
Bases: PySWAPBaseModel
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 |
Optional[float]
|
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/plant/crpfile.py
GrasslandManagement
¶
Bases: PySWAPBaseModel
Settings specific to the dynamic grass growth module.
Warning
Validation still required.
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/plant/crpfile.py
690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 |
|
Interception
¶
Bases: PySWAPBaseModel
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/plant/crpfile.py
OxygenStress
¶
Bases: PySWAPBaseModel
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)
Source code in pyswap/plant/crpfile.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
|
Preparation
¶
Bases: PySWAPBaseModel
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/plant/crpfile.py
607 608 609 610 611 612 613 614 615 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 |
|
SaltStress
¶
Bases: PySWAPBaseModel
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/plant/crpfile.py
read_yaml
¶
Script reading YAML crop settings files.
WOFOSTCrop
¶
Bases: BaseModel
Class for managing the library of WOFOST crop parameters from https://github.com/ajwdewit.
The library is included as a submodule in pySWAP and is located at pyswap/libs/WOFOST_crop_parameters. All files in that library have .yaml extension and fairly uniform format so it made sense to set up a pySWAP specific data structure for reading them.
Source code in pyswap/plant/read_yaml.py
genericc3()
¶
Get generic settings for C3 crop types - plants that bind CO2 into 3-phosphoglycerate having three carbon atoms. E.g., wheat, rice
Source code in pyswap/plant/read_yaml.py
genericc4()
¶
Get generic settings for C4 crop types - plants that bind CO2 into oxaloacetate having four carbon atoms. E.g., maize, sugarcane
Source code in pyswap/plant/read_yaml.py
tables
¶
Tables for the crop settings
Classes:
Name | Description |
---|---|
RDTB |
Root depth table |
AMAXTB
¶
Bases: BaseModel
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/plant/tables.py
AMAXTB_GRASS
¶
Bases: BaseModel
maximum CO2 assimilation rate [0..100 kg/ha/hr, R] as function of development stage [0..2 -, R]
Attributes:
Name | Type | Description |
---|---|---|
DNR |
Series[float]
|
Day number. |
AMAX |
Series[float]
|
Maximum CO2 assimilation rate. |
Source code in pyswap/plant/tables.py
CHTB
¶
Bases: BaseModel
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. |
CH |
Series[float]
|
Crop height of the crop. |
Source code in pyswap/plant/tables.py
CHTB_GRASS
¶
Bases: BaseModel
Crop Height [0..1.d4 cm, R], as function of dev. stage [0..2 -, R]
Attributes:
Name | Type | Description |
---|---|---|
DNR |
Series[float]
|
day number. |
CH |
Series[float]
|
Crop height of the crop. |
Source code in pyswap/plant/tables.py
CROPROTATION
¶
Bases: BaseModel
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/plant/tables.py
DMGRZTB
¶
Bases: BaseModel
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/plant/tables.py
DMMOWDELAY
¶
Bases: BaseModel
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/plant/tables.py
DMMOWTB
¶
Bases: BaseModel
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/plant/tables.py
DTSMTB
¶
Bases: BaseModel
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/plant/tables.py
FLTB
¶
Bases: BaseModel
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/plant/tables.py
FLTB_GRASS
¶
Bases: BaseModel
fraction of total above ground dry matter increase partitioned to the leaves [kg/kg, R]
Attributes:
Name | Type | Description |
---|---|---|
DNR |
Series[float]
|
Day number. |
FL |
Series[float]
|
Fraction of total above ground dry matter increase partitioned to the leaves. |
Source code in pyswap/plant/tables.py
FOTB
¶
Bases: BaseModel
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/plant/tables.py
FRTB
¶
Bases: BaseModel
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/plant/tables.py
FRTB_GRASS
¶
Bases: BaseModel
fraction of total dry matter increase partitioned to the roots [kg/kg, R]
Attributes:
Name | Type | Description |
---|---|---|
DNR |
Series[float]
|
Day number. |
FR |
Series[float]
|
Fraction of total dry matter increase partitioned to the roots. |
Source code in pyswap/plant/tables.py
FSTB
¶
Bases: BaseModel
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/plant/tables.py
FSTB_GRASS
¶
Bases: BaseModel
fraction of total above ground dry matter increase partitioned to the stems [kg/kg, R]
Attributes:
Name | Type | Description |
---|---|---|
DNR |
Series[float]
|
Day number. |
FS |
Series[float]
|
Fraction of total above ground dry matter increase partitioned to the stems. |
Source code in pyswap/plant/tables.py
GCTB
¶
Bases: BaseModel
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/plant/tables.py
KYTB
¶
Bases: BaseModel
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/plant/tables.py
LSDATB
¶
Bases: BaseModel
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/plant/tables.py
LSDBTB
¶
Bases: BaseModel
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/plant/tables.py
MRFTB
¶
Bases: BaseModel
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/plant/tables.py
RDCTB
¶
Bases: BaseModel
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/plant/tables.py
RDRRTB
¶
Bases: BaseModel
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/plant/tables.py
RDRRTB_GRASS
¶
Bases: BaseModel
relative death rates of roots [kg/kg/d] as function of development stage [0..2 -, R]
Attributes:
Name | Type | Description |
---|---|---|
DNR |
Series[float]
|
Day number. |
RDRR |
Series[float]
|
Relative death rates of roots. |
Source code in pyswap/plant/tables.py
RDRSTB
¶
Bases: BaseModel
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/plant/tables.py
RDRSTB_GRASS
¶
Bases: BaseModel
relative death rates of stems [kg/kg/d] as function of development stage [0..2 -, R]
Attributes:
Name | Type | Description |
---|---|---|
DNR |
Series[float]
|
Day number. |
RDRS |
Series[float]
|
Relative death rates of stems. |
Source code in pyswap/plant/tables.py
RDTB
¶
Bases: BaseModel
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/plant/tables.py
RFSETB
¶
Bases: BaseModel
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/plant/tables.py
RFSETB_GRASS
¶
Bases: BaseModel
reduction factor of senescence [-, R] as function of development stage [0..2 -, R]
Attributes:
Name | Type | Description |
---|---|---|
DNR |
Series[float]
|
Day number. |
RFSE |
Series[float]
|
Reduction factor of senescence. |
Source code in pyswap/plant/tables.py
RLWTB
¶
Bases: BaseModel
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/plant/tables.py
SLATB
¶
Bases: BaseModel
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/plant/tables.py
SLATB_GRASS
¶
Bases: BaseModel
leaf area [0..1 ha/kg, R] as function of crop development stage [0..2 -, R]
Attributes:
Name | Type | Description |
---|---|---|
DNR |
Series[float]
|
Day number. |
SLA |
Series[float]
|
Leaf area. |
Source code in pyswap/plant/tables.py
TMNFTB
¶
Bases: BaseModel
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/plant/tables.py
TMPFTB
¶
Bases: BaseModel
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/plant/tables.py
WRTB
¶
Bases: BaseModel
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/plant/tables.py
Irrigation subpackage¶
Irrigation settings for the SWAP simulation.
Modules:
Name | Description |
---|---|
irrigation |
The irrigation settings. |
irgfile |
The irrigation file. |
irgfile
¶
Create the irrigation file for the SWAP model.
Classes:
Name | Description |
---|---|
IrrigationFile |
The irrigation file. |
IrgFile
¶
Bases: PySWAPBaseModel
The irrigation file.
Warning
The irrigation file is the first to have pandera validation. However, it is not yet complete. Some columns are set to non-required, but they might be required if solute transport is used.
Attributes:
Name | Type | Description |
---|---|---|
irgfil |
str
|
the name of the irgfile without .irg extension. |
content |
DataFrame
|
The content of the irrigation file. |
Source code in pyswap/irrigation/irgfile.py
irg_from_csv(irgfil, path)
¶
Load the irrigation file from a CSV file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
irgfil |
str
|
the name of the irgfile without .irg extension. |
required |
path |
str
|
The path to the CSV file. |
required |
Returns:
Name | Type | Description |
---|---|---|
IrgFile |
IrgFile
|
The irrigation file. |
Source code in pyswap/irrigation/irgfile.py
irrigation
¶
" Irrigation settings for the SWAP simuluation.
Classes:
Name | Description |
---|---|
FixedIrrigation |
Holds the settings for fixed irrigation. |
ScheduledIrrigation |
Holds the settings for scheduled irrigation. |
Irrigation |
Holds the irrigation settings of the simulation. |
FixedIrrigation
¶
Bases: PySWAPBaseModel
Fixed irrigation settings.
Note
This class is only used 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 |
table_irrigevents |
Optional[Table]
|
|
irgfil |
Optional[str]
|
|
irrigationdata |
Optional[IrrigationFile]
|
|
Source code in pyswap/irrigation/irrigation.py
ScheduledIrrigation
¶
Bases: PySWAPBaseModel
Irrigation scheduling settings.
Warning
The docstring needs to be updated.
Note
This class is only used 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/irrigation/irrigation.py
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 |
|
tables
¶
Tables for the irrigation settings.
Classes:
IRRIGATION
¶
Bases: BaseModel
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/irrigation/tables.py
Soil-water subpackage¶
Settings related to soil and water.
Modules:
Name | Description |
---|---|
evaporation |
Evaporation settings. |
soilmoisture |
Soil moisture settings. |
soilprofile |
Soil profile settings. |
surfaceflow |
Surface flow settings. |
snow |
Snow and frost settings. |
evaporation
¶
Settings for evaporation.
Classes:
Name | Description |
---|---|
Evaporation |
Evaporation settings. |
Evaporation
¶
Bases: PySWAPBaseModel
Evaporation settings.
Attributes:
Name | Type | Description |
---|---|---|
swcfbs |
int
|
Switch for use of soil factor CFBS to calculate Epot from ETref |
swredu |
int
|
Switch for the method for reduction of potential soil evaporation:
|
cfevappond |
Optional[float]
|
hen ETref is used, evaporation coefficient in case of ponding. |
cfbs |
Optional[float]
|
Coefficient for potential soil evaporation. |
rsoil |
Optional[float]
|
Soil resistance of wet soil. |
cofredbl |
Optional[float]
|
Soil evaporation coefficient of Black. |
rsigni |
Optional[float]
|
Minimum rainfall to reset method of Black. |
cofredbo |
Optional[float]
|
Soil evaporation coefficient of Boesten/Stroosnijder. |
Source code in pyswap/soilwater/evaporation.py
snow
¶
SnowAndFrost
¶
Bases: PySWAPBaseModel
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[float]
|
Initial snow water equivalent |
teprrain |
Optional[float]
|
Temperature above which all precipitation is rain |
teprsnow |
Optional[float]
|
Temperature below which all precipitation is snow |
snowcoef |
Optional[float]
|
Snowmelt calibration factor |
tfroststa |
Optional[float]
|
Soil temperature (oC) where reduction of water fluxes starts |
tfrostend |
Optional[float]
|
Soil temperature (oC) where reduction of water fluxes ends |
Source code in pyswap/soilwater/snow.py
soilmoisture
¶
SoilMoisture
¶
Bases: PySWAPBaseModel
Soil moisture content and water balance.
Warning
swinco = 3 is not yet implemented. The model will run, but the output will not be retrieved.
Attributes:
Name | Type | Description |
---|---|---|
swinco |
int
|
Switch for the type of initial soil moisture condition:
|
table_head_soildepth |
Optional[Table]
|
Table with head and soil depth data. |
gwli |
Optional[float]
|
Initial groundwater level [cm]. |
inifil |
Optional[str]
|
name of output file *.END which contains initial values. |
Source code in pyswap/soilwater/soilmoisture.py
soilprofile
¶
SoilProfile
¶
Bases: PySWAPBaseModel
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[float]
|
Minimum pressure head difference to change wetting-drying |
swmacro |
Literal[0, 1]
|
Switch for preferential flow due to macropores |
table_soilprofile |
Table
|
Table with soil profile data |
table_soilhydrfunc |
Optional[Table]
|
Table with soil hydraulic functions |
Source code in pyswap/soilwater/soilprofile.py
surfaceflow
¶
SurfaceFlow
¶
Bases: PySWAPBaseModel
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 |
float
|
Drainage resistance for surface runoff |
rsroexp |
float
|
Exponent for drainage equation of surface runoff |
pondmx |
Optional[float]
|
In case of ponding, minimum thickness for runoff |
rufil |
Optional[str]
|
Name of the runon file |
table_pondmxtb |
Optional[Table]
|
Minimum thickness for runoff as a function of time |
Source code in pyswap/soilwater/surfaceflow.py
tables
¶
tables for the soil-water module
INIPRESSUREHEAD
¶
Bases: BaseModel
Initial pressure head [cm, R] as a function of soil layer [1..N, I].
Attributes:
Name | Type | Description |
---|---|---|
ZI |
Series[int]
|
Series[int]: soil depth [-1.d5..0 cm, R]. |
H |
Series[float]
|
Series[float]: Initial soil water pressure head [-1.d10..1.d4 cm, R]. |
Source code in pyswap/soilwater/tables.py
MXPONDTB
¶
Bases: BaseModel
minimum thickness for runoff PONDMXTB [0..1000 cm, R] as function of time
Attributes:
Name | Type | Description |
---|---|---|
DATEPMX |
Series[DateTime]
|
Series[pa.DateTime]: Date of the ponding threshold for runoff. |
PONDMXTB |
Series[float]
|
Series[float]: Minimum thickness for runoff. |
Source code in pyswap/soilwater/tables.py
SOILHYDRFUNC
¶
Bases: BaseModel
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.
Attributes:
Name | Type | Description |
---|---|---|
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/soilwater/tables.py
SOILPROFILE
¶
Bases: BaseModel
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/soilwater/tables.py
Drainage subpackage¶
Handling drainage settings and creation of the .dra file.
Modules:
Name | Description |
---|---|
drainage |
Holds the drainage settings for the SWAP model. |
drafile |
Create the .dra file. |
drafile
¶
Compose the .dra file for SWAP simulation.
Classes:
Name | Description |
---|---|
DraFile |
Class for the .dra file. |
DraSettings |
Class for the settings of the drainage module. |
DrainageFluxTable |
Class for the drainage flux table. |
DrainageFormula |
Class for the drainage formula. |
DrainageInfiltrationResitance |
Class for the drainage infiltration resistance. |
Flux |
Class for the flux. |
DraFile
¶
Bases: PySWAPBaseModel
Main class representing the drainage file (.dra) for SWAP.
Attributes:
Name | Type | Description |
---|---|---|
drfil |
str
|
Name of the file. |
general |
Any
|
General settings. |
fluxtable |
Optional[Any]
|
Flux table. |
drainageformula |
Optional[Any]
|
Drainage formula. |
drainageinfiltrationres |
Optional[Any]
|
Drainage infiltration resistance. |
Source code in pyswap/drainage/drafile.py
DraSettings
¶
Bases: PySWAPBaseModel
General settings for the drainage file
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.
|
Source code in pyswap/drainage/drafile.py
DrainageFluxTable
¶
Bases: PySWAPBaseModel
Settings for the case when dramet is 1.
Attributes:
Name | Type | Description |
---|---|---|
lm1 |
float
|
Drain spacing |
table_qdrntb |
Table
|
Table of drainage flux - groundwater level. |
Source code in pyswap/drainage/drafile.py
DrainageFormula
¶
Bases: PySWAPBaseModel
Settings for the case when dramet is 2.
Attributes:
Name | Type | Description |
---|---|---|
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. |
Source code in pyswap/drainage/drafile.py
DrainageInfiltrationResitance
¶
Bases: PySWAPBaseModel
Settings for the case when dramet is 3.
Attributes:
Name | Type | Description |
---|---|---|
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. |
list_levelfluxes |
ObjectList
|
List of level fluxes. |
Source code in pyswap/drainage/drafile.py
Flux
¶
Bases: PySWAPBaseModel
These objects are needed for the DrainageInfiltrationResitance class. Flux object should be created for each level of drainage.
Attributes:
Name | Type | Description |
---|---|---|
level_number |
int
|
Number of the level. |
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.
|
table_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/drainage/drafile.py
drainage
¶
Lateral drainage settings.
Classes:
Name | Description |
---|---|
Drainage |
The lateral drainage settings. |
Drainage
¶
Bases: PySWAPBaseModel
The lateral drainage settings of the simulation.
Attributes:
Name | Type | Description |
---|---|---|
swdra |
Literal[0, 1, 2]
|
Switch for lateral drainage.
|
drafile |
Optional[Any]
|
Content of the drainage file. |
Source code in pyswap/drainage/drainage.py
Boundary subpackage¶
This subpackage deals with boundary conditions for the SWAP model.
Modules:
Name | Description |
---|---|
bottomboundary |
Bottom boundary condition settings for the SWAP model. |
bbcfile
¶
Bottom boundary condition settings for the SWAP model.
Classes:
Name | Description |
---|---|
BottomBoundary |
Holds the settings of the bottom boundary conditions of the .swp file. |
BBCFile
¶
Bases: PySWAPBaseModel
Bottom boundary settings for SWAP model.
Attributes:
Name | Type | Description |
---|---|---|
swbotb |
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.
|
bbcfile |
Optional[str]
|
Name of file with bottom boundary data (without .BBC extension). |
sinave |
Optional[float]
|
Average value of bottom flux. |
sinamp |
Optional[float]
|
Amplitude of bottom flux sine function. |
sinmax |
Optional[float]
|
Time of the year with maximum bottom flux. |
shape |
Optional[float]
|
Shape factor to derive average groundwater level. |
hdrain |
Optional[float]
|
Mean drain base to correct for average groundwater level. |
rimlay |
Optional[float]
|
Vertical resistance of aquitard. |
aqave |
Optional[float]
|
Average hydraulic head in underlaying aquifer. |
aqamp |
Optional[float]
|
Amplitude hydraulic head sinus wave. |
aqtmax |
Optional[float]
|
First time of the year with maximum hydraulic head. |
aqper |
Optional[float]
|
Period of hydraulic head sinus wave. |
cofqha |
Optional[float]
|
Coefficient A for exponential relation for bottom flux. |
cofqhb |
Optional[float]
|
Coefficient B for exponential relation for bottom flux. |
cofqhc |
Optional[float]
|
Coefficient C for exponential relation for bottom flux. |
gwlevel |
Optional[Table]
|
Table with groundwater level data. |
table_qbot |
Optional[Table]
|
Table with bottom flux data. |
table_haquif |
Optional[Table]
|
Table with average pressure head in underlaying aquifer. |
table_qbot4 |
Optional[Table]
|
Table with bottom flux data. |
table_qtab |
Optional[Table]
|
Table with groundwater level-bottom flux relation |
table_hbot |
Optional[Table]
|
Table with the bottom compartment pressure head. |
Source code in pyswap/boundary/bbcfile.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 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 |
|
boundary
¶
Bottom boundary condition settings for the SWAP model.
Classes:
Name | Description |
---|---|
BottomBoundary |
Holds the settings of the bottom boundary conditions of the .swp file. |
BottomBoundary
¶
Bases: PySWAPBaseModel
Bottom boundary settings for SWAP model.
Attributes:
Name | Type | Description |
---|---|---|
swbbcfile |
Literal[0, 1]
|
Switch for file with bottom boundary data:
|
swbotb |
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.
|
bbcfile |
Optional[str]
|
Name of file with bottom boundary data (without .BBC extension). |
sinave |
Optional[float]
|
Average value of bottom flux. |
sinamp |
Optional[float]
|
Amplitude of bottom flux sine function. |
sinmax |
Optional[float]
|
Time of the year with maximum bottom flux. |
shape |
Optional[float]
|
Shape factor to derive average groundwater level. |
hdrain |
Optional[float]
|
Mean drain base to correct for average groundwater level. |
rimlay |
Optional[float]
|
Vertical resistance of aquitard. |
aqave |
Optional[float]
|
Average hydraulic head in underlaying aquifer. |
aqamp |
Optional[float]
|
Amplitude hydraulic head sinus wave. |
aqtmax |
Optional[float]
|
First time of the year with maximum hydraulic head. |
aqper |
Optional[float]
|
Period of hydraulic head sinus wave. |
cofqha |
Optional[float]
|
Coefficient A for exponential relation for bottom flux. |
cofqhb |
Optional[float]
|
Coefficient B for exponential relation for bottom flux. |
cofqhc |
Optional[float]
|
Coefficient C for exponential relation for bottom flux. |
gwlevel |
Optional[Table]
|
Table with groundwater level data. |
table_qbot |
Optional[Table]
|
Table with bottom flux data. |
table_haquif |
Optional[Table]
|
Table with average pressure head in underlaying aquifer. |
table_qbot4 |
Optional[Table]
|
Table with bottom flux data. |
table_qtab |
Optional[Table]
|
Table with groundwater level-bottom flux relation |
table_hbot |
Optional[Table]
|
Table with the bottom compartment pressure head. |
Source code in pyswap/boundary/boundary.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 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 |
|
Additional settings¶
heatflow
¶
Heat flow settings for SWAP simulation.
Classes:
Name | Description |
---|---|
HeatFlow |
Heat flow settings for SWAP simulation. |
HeatFlow
¶
Bases: PySWAPBaseModel
Heat flow settings for SWAP simulation.
Warning
table_initsoil is not validated because it depends of swinco setting.
Attributes:
Name | Type | Description |
---|---|---|
swhea |
Literal[0, 1]
|
Switch for heat flow. |
swcalt |
Optional[Literal[1, 2]]
|
|
tampli |
Optional[float]
|
Amplitude of annual temperature wave at soil surface [0..50 oC, R] |
tmean |
Optional[float]
|
Mean annual temperature at soil surface [-10..30 oC, R] |
timref |
Optional[float]
|
Time at which the sinus temperature wave reaches it's top [0..366.0 d, R] |
ddamp |
Optional[float]
|
Damping depth of soil temperature wave [1..500 cm, R] |
swtopbhea |
Optional[Literal[1, 2]]
|
Define top boundary condition
|
tsoilfile |
Optional[str]
|
name of input file with soil surface temperatures without extension .TSS |
swbotbhea |
Optional[Literal[1, 2]]
|
Define bottom boundary condition
|
table_soiltextures |
Optional[Table]
|
for each physical soil layer the soil texture (g/g mineral parts) and the organic matter content (g/g dry soil) |
table_initsoil |
Optional[Table]
|
initial temperature TSOIL [-50..50 oC, R] as function of soil depth ZH [-100000..0 cm, R] |
table_bbctsoil |
Optional[Table]
|
bottom boundary temperature TBOT [-50..50 oC, R] as function of date DATET [date] |
Source code in pyswap/extras/heatflow.py
solutetransport
¶
Solute transport settings for the SWAP simulation.
Classes:
Name | Description |
---|---|
SoluteTransport |
Solute transport settings. |
SoluteTransport
¶
Bases: PySWAPBaseModel
Solute transport settings.
Warning
Validation not yet included in the current release.
Attributes:
Name | Type | Description |
---|---|---|
swsolu |
Literal[0, 1]
|
|
cpre |
Optional[float]
|
|
cdrain |
Optional[float]
|
|
swbotbc |
Optional[Literal[0, 1]]
|
|
cseep |
Optional[float]
|
|
ddif |
Optional[float]
|
|
tscf |
Optional[float]
|
|
swsp |
Optional[Literal[0, 1]]
|
|
frexp |
Optional[float]
|
|
cref |
Optional[float]
|
|
swdc |
Optional[Literal[0, 1]]
|
|
gampar |
Optional[float]
|
|
rtheta |
Optional[float]
|
|
bexp |
Optional[float]
|
|
swbr |
Optional[Literal[0, 1]]
|
|
daquif |
Optional[float]
|
|
poros |
Optional[float]
|
|
kfsat |
Optional[float]
|
|
decsat |
Optional[float]
|
|
cdraini |
Optional[float]
|
|
table_cseeparrtb |
Optional[Table]
|
|
table_inissoil |
Optional[Table]
|
|
table_miscellaneous |
Optional[Table]
|
|
Source code in pyswap/extras/solutetransport.py
tables
¶
These are tables for the extras module
INITSOILTEMP
¶
Bases: BaseModel
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/extras/tables.py
SOILTEXTURES
¶
Bases: BaseModel
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/extras/tables.py
SWAP model package¶
The main subpackage for the SWAP model.
Modules:
Name | Description |
---|---|
model |
SWAP model class |
result |
SWAP result class |
model
¶
The main model class.
Classes:
Name | Description |
---|---|
Model |
Main class that runs the SWAP model. |
Model
¶
Bases: PySWAPBaseModel
Main class that runs the SWAP model.
The attributes must be valid pySWAP classes. For avoiding validation errors, for now the attributes are defined as Any.
Attributes:
Name | Type | Description |
---|---|---|
metadata |
Any
|
Metadata of the model. |
general_settings |
Any
|
Simulation settings. |
meteorology |
Any
|
Meteorological data. |
crop |
Any
|
Crop data. |
fixedirrigation |
Any
|
Fixed irrigation settings. |
soilmoisture |
Any
|
Soil moisture data. |
surfaceflow |
Any
|
Surface flow data. |
evaporation |
Any
|
Evaporation data. |
soilprofile |
Any
|
Soil profile data. |
snowandfrost |
Optional[Any]
|
Snow and frost data. Default is |
richards |
Optional[Any]
|
Richards data. |
lateraldrainage |
Any
|
Lateral drainage data. |
bottomboundary |
Any
|
Bottom boundary data. |
heatflow |
Optional[Any]
|
Heat flow data. |
solutetransport |
Optional[Any]
|
Solute transport data. |
Methods:
Name | Description |
---|---|
write_swp |
Write the .swp input file. |
_copy_executable |
Copy the appropriate SWAP executable to the temporary directory. |
_run_swap |
Run the SWAP executable. |
_read_output |
Read the output file. |
_read_output_tz |
Read the output file with time zone. |
_read_vap |
Read the .vap output file. |
_write_inputs |
Write the input files. |
_identify_warnings |
Identify warnings in the log file. |
_raise_swap_warning |
Raise a warning. |
_read_output_old |
Save the old output files. |
run |
Run the model. |
Source code in pyswap/model/model.py
34 35 36 37 38 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 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 |
|
run(path, silence_warnings=False, old_output=False)
¶
Main function that runs the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
Path to the working directory. |
required |
silence_warnings |
bool
|
If True, warnings will not be printed. |
False
|
old_output |
bool
|
If True, the old output files (like .vap) will be saved to a dictionary. |
False
|
Todo
It would be nice to have a nice output string that will concatenate all output including warnings and/or errors.
Warning
Reruns are for now not supported. Multiple runs of the model can be achieved by running model.run() multiple times.
Source code in pyswap/model/model.py
write_swp(path)
¶
result
¶
Capturing model results.
Tip
The Result class is now focusing on the output in CSV format and the log file. the other result files are also retrieved as a list of strings which user can access if needed.
Classes:
Name | Description |
---|---|
Result |
Stores the result of a model run. |
Result
¶
Bases: BaseModel
Class to store the result of a model run.
Attributes:
Name | Type | Description |
---|---|---|
log |
str
|
The log file of the model run. |
summary |
str
|
The summary file of the model run. |
output |
DataFrame
|
The output file of the model run. |
output_tz |
DataFrame
|
The output file of the model run with timezone. |
output_old |
Dict[str, str]
|
The old output files of the model run. |
warning |
List[str]
|
The warnings of the model run. |
model_config |
ConfigDict
|
The configuration for the model. |
Methods:
Name | Description |
---|---|
iteration_stats |
The part of the log file that describes the iteration statistics. |
blc_summary |
The .blc file if it exists. |
water_balance |
The water balance of the model run. |
Source code in pyswap/model/result.py
Core subpackage¶
Core package containing the main classes and functions for the SWAP model.
Modules:
Name | Description |
---|---|
basemodel |
Base model class for pySWAP. |
fields |
Field types for pyswap used for serialization. |
files |
Functions to interact with file system. |
serializers |
Functions to fine tune the serializatino of pySWAP objects. |
valueranges |
Objects containing value ranges used is validation of pySWAP objects. |
model |
Contains the classes for the model of the simulation. |
result |
Contains the classes for the results of the simulation. |
basemodel
¶
PySWAPBaseModel
¶
Bases: BaseModel
Base class for PySWAP models.
Attributes:
Name | Type | Description |
---|---|---|
model_config |
ConfigDict
|
Overriding Pydantic model configuration. |
Methods:
Name | Description |
---|---|
save_element |
Saves model element to a file. |
model_string |
Returns a custom model string representation that matches the requirements of .swp file. |
_concat_sections |
Concatenate a string from individual sections. |
model_string |
Returns a custom model string representation that matches the requirements of .swp file. |
Source code in pyswap/core/basemodel.py
model_string()
¶
Returns a custom model string representation that matches the requirements of .swp file.
Note
If values are simple types, they are formatted as 'ATTR = VALUE'. If the valies are tables (in pySWAP pd.DataFrame are used), they are formatted simply as 'TABLE_VALUE'. Additionally, a custom serializer (pyswap.core.utils.serializers.quote_string) is used to quote strings.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Custom model string representation. |
Source code in pyswap/core/basemodel.py
save_element(string, path, filename, extension=None)
staticmethod
¶
Saves model element to a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
string |
str
|
String to be saved. |
required |
path |
str
|
Path to the file. |
required |
filename |
str
|
File name. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Success message. |
Source code in pyswap/core/basemodel.py
database
¶
All modules related to the database connection and models.
Warning
This module is in review and may be significantly changed or removed in the future.
Tip
pySWAP is meant to enable saving model runs to a SQLite database. That way, the users will be able to easily exchange models they built and run them on their own machines.
connection
¶
This module is responsible for creating a connection to the database.
Classes:
Name | Description |
---|---|
DatabaseConnection |
Creates a connection to the database. |
DatabaseConnection
¶
Creates a connection to the database.
Upon calling the connect method, a check is made to see if the database file exists. If it does not, the file is created. The tables are then checked and created if they do not exist.
Attributes:
Name | Type | Description |
---|---|---|
engine |
The database engine. |
|
session |
The database session. |
|
db_path |
The path to the database file. |
Methods:
Name | Description |
---|---|
connect |
Connect to the database. |
Source code in pyswap/core/database/connection.py
connect()
¶
Connect to the dabase or create a new one.
Source code in pyswap/core/database/connection.py
hdf5
¶
This file contains classes and functions for handling HDF5 integration.
HDF5
¶
Bases: BaseModel
Source code in pyswap/core/database/hdf5.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 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 |
|
load(project, model=None, load_results=False, mode='python')
¶
Load a single model or all models within a specific project.
Source code in pyswap/core/database/hdf5.py
save_model(model, result=None, overwrite_datasets=False, overwrite_project=False, mode='python')
¶
Sava a model and its results to an HDF5 file.
Each model in its metadata attribute stores the project name. That is used as the name for the main group. If that name already exists, a new group is not created. Then the check is made if the version of the model already exists. If it does, the group is not created.
Source code in pyswap/core/database/hdf5.py
models
¶
SQLAlchemy models for the pySWAP database.
Important assumptions
- There is always an initial SWAP model which is saved in the SWAPModel table.
- Each SWAPModel belongs to only one project.
- Each SWAPModel has one or mode runs which are saved in the ModelRun table.
- One ModelRun has exactly one ModelOutput
Data
¶
Bases: Base
Stores data files like meteo data or crop data.
Source code in pyswap/core/database/models.py
SWAPRun
¶
Bases: Base
This model stores sections of the .swp file
Source code in pyswap/core/database/models.py
defaults
¶
Default values for the Richards' equation
fields
¶
Custom field types used for serilization in the model_dump(mode='json').
Other Parameters:
Name | Type | Description |
---|---|---|
Table |
DataFrame
|
A DataFrame object serialized as a string with just the headers and the data. |
Arrays |
DataFrame
|
A DataFrame object serialized as a string with just the columns of data (no headers), but with the variable name in front (e.g., FLUXTB = 0.0 0.0/n 1.0 1.0 ) |
CSVTable |
DataFrame
|
A DataFrame object serialized as a string with the headers and data in CSV format, specifically tailored for the .met file format. |
DayMonth |
date
|
A date object serialized as a string with just the day and month (e.g., '01 01'). |
StringList |
List[str]
|
A list of strings serialized as a string with the elements separated by commas, enclosed in quotation marks (e.g., 'string1, string2, string3'). |
FloatList |
List[float]
|
A list of floats serialized as a string with the elements separated by spaces. |
DateList |
List[date]
|
A list of date objects serialized as a string with the elements separated by newlines. |
Switch |
bool | int
|
A boolean or integer serialized as an integer (0 or 1). |
ObjectList |
list
|
A list of objects serialized as a string with the elements separated by newlines. |
files
¶
Simple module to interact with files.
open_file(file_path)
¶
Open file and detect encoding.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path |
str
|
Path to the file to be opened. |
required |
Source code in pyswap/core/files.py
save_file(string, fname, path, mode='w', extension=None, encoding='ascii')
¶
Saves a string to a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
string |
str
|
The string to be saved to a file. |
required |
extension |
str | None
|
The extension that the file should have (e.g. 'txt', 'csv', etc.). |
None
|
fname |
str
|
The name of the file. |
required |
path |
str
|
The path where the file should be saved. |
required |
mode |
str
|
The mode in which the file should be opened (e.g. 'w' for write, 'a' for append, etc.). |
'w'
|
encoding |
str
|
The encoding to use for the file (default is 'ascii'). |
'ascii'
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in pyswap/core/files.py
plot
¶
Plotting functionality for pySWAP.
Modules:
Name | Description |
---|---|
evapotranspiration |
Functions for plotting evapotranspiration data. |
gwl |
Functions for plotting groundwater level data. |
watercontent |
Functions for plotting water content data. |
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
gwl(simulated, observed, title='Groundwater levels')
¶
Plot groundwater levels (observed vs simulated) and compute the RMSE.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulated |
DataFrame
|
Simulated groundwater levels |
required |
observed |
DataFrame
|
Observed groundwater levels |
required |
title |
str
|
Title of the plot. Defaults to 'Groundwater levels'. |
'Groundwater levels'
|
Source code in pyswap/core/plot/gwl.py
water_content(df_vap, title='Water content')
¶
Plot water content as heatmap with time on the x-axis and depth on the y-axis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df_vap |
DataFrame
|
DataFrame containing the water content data |
required |
title |
str
|
Title of the plot. Defaults to 'Water content'. |
'Water content'
|
Source code in pyswap/core/plot/watercontent.py
watercontent
¶
water_content(df_vap, title='Water content')
¶
Plot water content as heatmap with time on the x-axis and depth on the y-axis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df_vap |
DataFrame
|
DataFrame containing the water content data |
required |
title |
str
|
Title of the plot. Defaults to 'Water content'. |
'Water content'
|
Source code in pyswap/core/plot/watercontent.py
serializers
¶
Functions serializing obects to the appropriate format used in the custom pyswap fields (pyswap.core.utils.fields)
is_scientific_notation(s)
¶
Check if a string represents a number in scientific notation.
The pattern matches strings in scientific notation, e.g., '1.23e-4', '2E+2'
Parameters:
Name | Type | Description | Default |
---|---|---|---|
s |
str
|
The string to be checked. |
required |
Source code in pyswap/core/serializers.py
quote_string(string)
¶
Quote the string if it contains alphabetic characters or './', except for scientific notation.
Source code in pyswap/core/serializers.py
serialize_arrays(table)
¶
Convert the DataFrame to a string without headers and newline in front
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table |
DataFrame
|
The DataFrame to be serialized. |
required |
serialize_csv_table(table)
¶
Convert the DataFrame to a string in CSV format.
This serializer is specifically tailored to output the data in the format of the ,met files used in SWAP.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table |
DataFrame
|
The DataFrame to be serialized. |
required |
Source code in pyswap/core/serializers.py
serialize_object_list(list)
¶
serialize_table(table)
¶
Convert the DataFrame to a string with the headers in uppercase.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table |
DataFrame
|
The DataFrame to be serialized. |
required |
Source code in pyswap/core/serializers.py
tablevalidation
¶
Pandera schemas for validating tables in pySWAP.
The schemas are used to validate pandas DataFrames used in the pySWAP models. They also help to enforce the appropriate data types required by the SWAP model.
Warning
This is an experimental feature and is currently only implemented in the irrigation subpackage. If no bugs are found, it will be implemented in the other subpackages.
Classes:
Name | Description |
---|---|
BaseModel |
Base class for all pySWAP schemas. |
BaseModel
¶
Bases: DataFrameModel
Base model with create method for preprocessing and validation.
Source code in pyswap/core/tablevalidation.py
valueranges
¶
Commonly used ranges of values for pydantic Field() objects.
Other Parameters:
Name | Type | Description |
---|---|---|
UNITRANGE |
dict
|
Range of values between 0.0 and 1.0. |
YEARRANGE |
dict
|
Range of values for year (0 <= x <= 366). |
DVSRANGE |
dict
|
Range of values for development stage (0 <= x <= 2). |
Plotting functionality for pySWAP.
Modules:
Name | Description |
---|---|
evapotranspiration |
Functions for plotting evapotranspiration data. |
gwl |
Functions for plotting groundwater level data. |
watercontent |
Functions for plotting water content data. |
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
gwl(simulated, observed, title='Groundwater levels')
¶
Plot groundwater levels (observed vs simulated) and compute the RMSE.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulated |
DataFrame
|
Simulated groundwater levels |
required |
observed |
DataFrame
|
Observed groundwater levels |
required |
title |
str
|
Title of the plot. Defaults to 'Groundwater levels'. |
'Groundwater levels'
|
Source code in pyswap/core/plot/gwl.py
water_content(df_vap, title='Water content')
¶
Plot water content as heatmap with time on the x-axis and depth on the y-axis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df_vap |
DataFrame
|
DataFrame containing the water content data |
required |
title |
str
|
Title of the plot. Defaults to 'Water content'. |
'Water content'
|
Source code in pyswap/core/plot/watercontent.py
watercontent
¶
water_content(df_vap, title='Water content')
¶
Plot water content as heatmap with time on the x-axis and depth on the y-axis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df_vap |
DataFrame
|
DataFrame containing the water content data |
required |
title |
str
|
Title of the plot. Defaults to 'Water content'. |
'Water content'
|