Module simulation¶
check_simulation(simulation)
¶
Checks whether a simulation is configured to a state where it is executable
Checks whether a simulation is configured to a state where it is executable
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation |
Simulation
|
A swift simulation object |
required |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
create_catchment(node_ids, node_names, link_ids, link_names, link_from_node, link_to_node, runoff_model_name='GR4J', areas_km2=None)
¶
Create a SWIFT catchment with a specified hydrologic model
Create a SWIFT catchment with a specified hydrologic model. This function is intended mostly for testing, not for usual modelling code.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node_ids |
Any
|
character, node unique identifiers |
required |
node_names |
Any
|
character, node display names |
required |
link_ids |
Any
|
character, links unique identifiers |
required |
link_names |
Any
|
character, links display names |
required |
link_from_node |
Any
|
character, identifier of the links' upstream node |
required |
link_to_node |
Any
|
character, identifier of the links' downstream node |
required |
runoff_model_name |
Any
|
A valid, known SWIFT model name (e.g. 'GR5H') |
'GR4J'
|
areas_km2 |
Any
|
The areas in square kilometres |
None
|
Returns:
Type | Description |
---|---|
A SWIFT simulation object (i.e. a model runner) |
Examples:
TODO
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
create_ensemble_forecast_simulation(simulation, data_library, start, end, input_map, lead_time, ensemble_size, n_time_steps_between_forecasts)
¶
Create an ensemble forecast simulation
Create an ensemble forecast simulation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation |
Simulation
|
A swift simulation object |
required |
data_library |
Any
|
external pointer type ENSEMBLE_DATA_SET_PTR, or a Python class wrapper around it |
required |
start |
Any
|
the start date of the simulation. The time zone will be forced to UTC. |
required |
end |
Any
|
the end date of the simulation. The time zone will be forced to UTC. |
required |
input_map |
Any
|
a named list were names are the data library data identifiers, and values are character vectors with model state identifiers. |
required |
lead_time |
Any
|
integer, the length in time steps of the forecasts. |
required |
ensemble_size |
Any
|
ensemble size |
required |
n_time_steps_between_forecasts |
Any
|
nTimeStepsBetweenForecasts |
required |
Returns:
Type | Description |
---|---|
An external pointer |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
create_subarea(model_name, area_km2)
¶
Create a SWIFT subarea with a specified hydrologic model
Create a SWIFT subarea with a specified hydrologic model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name |
Any
|
A valid, known SWIFT model name (e.g. 'GR5H') |
required |
area_km2 |
Any
|
The area in square kilometres |
required |
Returns:
Type | Description |
---|---|
A SWIFT simulation object (i.e. a model runner) |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
create_subarea_simulation(data_id='MMH', simul_start='1990-01-01', simul_end='2005-12-31', model_id='GR4J', tstep='daily', varname_rain='P', varname_pet='E')
¶
Creates a one sub-catchment simulation
Creates a one sub-catchment simulation. This function is intended for creating sample simulations, not for use in production.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataId |
Any
|
data identifier in swift_sample_data |
required |
simulStart |
Any
|
ISO string for the simulation start date time |
required |
simulEnd |
Any
|
ISO string for the simulation end date time |
required |
modelId |
Any
|
model identifier |
required |
tstep |
Any
|
character, 'daily' or 'hourly' |
'daily'
|
varNameRain |
Any
|
variable name to assign rainfall to |
required |
varNamePet |
Any
|
variable name to assign PET to |
required |
Returns:
Type | Description |
---|---|
A SWIFT simulation object, clone of the simulation but with a new model type in use. |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
exec_simulation(simulation, reset_initial_states=True)
¶
Execute a simulation
Execute a simulation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation |
Simulation
|
A swift simulation object |
required |
reset_initial_states |
Any
|
logical, should the states of the model be reinitialized before the first time step. |
True
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
get_link_ids(simulation)
¶
Gets all the identifiers of the links in the catchment
Gets all the identifiers of the links in the catchment
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation |
Simulation
|
A swift simulation object |
required |
Returns:
Type | Description |
---|---|
The identifiers of the links in the catchment |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
get_link_names(simulation)
¶
Gets all the names of the links in the catchment
Gets all the names of the links in the catchment
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation |
Simulation
|
A swift simulation object |
required |
Returns:
Type | Description |
---|---|
The names of the links in the catchment |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
get_node_ids(simulation)
¶
Gets all the identifiers of the nodes in the catchment
Gets all the identifiers of the nodes in the catchment
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation |
Simulation
|
A swift simulation object |
required |
Returns:
Type | Description |
---|---|
The identifiers of the nodes in the catchment |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
get_node_names(simulation)
¶
Gets all the names of the nodes in the catchment
Gets all the names of the nodes in the catchment
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation |
Simulation
|
A swift simulation object |
required |
Returns:
Type | Description |
---|---|
The names of the nodes in the catchment |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
get_state_value(simulation, var_id)
¶
Gets the value(s) of a model state(s)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation |
Simulation
|
A swift simulation object |
required |
var_id |
VecStr
|
string or sequence of str, model variable state identifier(s) |
required |
Returns:
Type | Description |
---|---|
numeric vector, value(s) of the requested model states |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
get_subarea_ids(simulation)
¶
Gets all the identifiers of the sub-areas in the catchment
Gets all the identifiers of the sub-areas in the catchment
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation |
Simulation
|
A swift simulation object |
required |
Returns:
Type | Description |
---|---|
The identifiers of the sub-areas in the catchment |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
get_subarea_names(simulation)
¶
Gets all the names of the sub-areas in the catchment
Gets all the names of the sub-areas in the catchment
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation |
Simulation
|
A swift simulation object |
required |
Returns:
Type | Description |
---|---|
The names of the sub-areas in the catchment |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
get_variable_ids(simulation, element_id=None, full_id=True)
¶
Gets all the names of the variables of an element within a catchment
Gets all the names of the variables of an element (link, node, subarea) within a catchment
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation |
Simulation
|
A swift simulation object |
required |
element_id |
Any
|
a character, identifier of the element within the catchment |
None
|
full_id |
Any
|
boolean, if TRUE return the full hierarchical identifier |
True
|
Returns:
Type | Description |
---|---|
character vector, names (identifiers) of model states in the element |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
is_variable_id(simulation, var_id)
¶
Is a variable identifier valid for a simulation
Is a variable identifier valid for a simulation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation |
Simulation
|
A swift simulation object |
required |
var_id |
Any
|
a character, identifier(s) of the variable(s) |
required |
Returns:
Type | Description |
---|---|
logical vector |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
reset_model_states(simulation)
¶
Reset the model states of a simulation, and apply one or more state initialers if the simulation is configured with any.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation |
Simulation
|
simulation |
required |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
set_error_correction_model(simulation, model_id, element_id, length=1, seed=0)
¶
Add an error correction model to an element in a catchment
Add an error correction model to an element in a catchment
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation |
Simulation
|
A swift simulation object |
required |
model_id |
str
|
the identifier of the new model to use, e.g. 'ERRIS' |
required |
element_id |
str
|
the identifier of the catchment element (node, link, subcatchment) whose outflow rate is corrected. |
required |
length |
int
|
other parameters to pass to the creation of the error correction model. Currently length of the AR model only supported. |
1
|
seed |
int
|
other parameters to pass to the creation of the error correction model. Currently length of the AR model only supported. |
0
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
set_simulation_span(simulation, start, end)
¶
Sets simulation span
Sets the simulation span
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation |
Simulation
|
A swift simulation object |
required |
start |
Any
|
the start date of the simulation. The time zone will be forced to UTC. |
required |
end |
Any
|
the end date of the simulation. The time zone will be forced to UTC. |
required |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
set_simulation_time_step(simulation, name)
¶
Sets the time step of a SWIFT simulation
Sets the time step of a SWIFT simulation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation |
Simulation
|
A swift simulation object |
required |
name |
Any
|
a time step identifier, currently 'daily' or 'hourly' are supported. The identifier is made lower case in the function. |
required |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
set_state_value(simulation, var_id, value)
¶
Sets the value of a model state
Sets the value of a model state
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation |
Simulation
|
A swift simulation object |
required |
var_id |
(str, Sequence[str])
|
character, model variable state identifier(s) |
required |
value |
(float, int, bool, Sequence)
|
numeric value(s) |
required |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
set_states(simulation, states)
¶
Apply memory states to a simulation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation |
Simulation
|
simulation |
required |
states |
MemoryStates
|
memory states |
required |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
snapshot_state(simulation)
¶
Take a snapshot of the memory states of a simulation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation |
Simulation
|
model simulation |
required |
Returns:
Name | Type | Description |
---|---|---|
MemoryStates |
MemoryStates
|
memory states, that can be stored and reapplied |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
sort_by_execution_order(simulation, split_element_ids, sorting_option='')
¶
Sort the specified element ids according to the execution order of the simulation
Sort the specified element ids according to the execution order of the simulation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation |
Simulation
|
A swift simulation object |
required |
split_element_ids |
Any
|
a character vector with element identifiers such as 'node.n1', 'link.linkId_2' |
required |
sorting_option |
Any
|
a character - for future options. Ignored for now. |
''
|
Returns:
Type | Description |
---|---|
values in split_element_ids sorted by simulation execution order |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/simulation.py
swap_model(simulation, model_id, what='runoff')
¶
Clone and change a simulation, using another runoff model
Clone and change a simulation, using another runoff model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation |
Simulation
|
A swift simulation object |
required |
model_id |
Any
|
the identifier of the new model to use, e.g. 'GR4J' |
required |
what |
Any
|
character identifying the type of structure: 'runoff', 'channel_routing' |
'runoff'
|
Returns:
Type | Description |
---|---|
A SWIFT simulation object, clone of the simulation but with a new model type in use. |