Module parameteriser¶
MhData
¶
Data log from metaheuristic calibration processes
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 |
|
data
property
¶
The inner data of this data log
bound_fitness(obj_lims=None)
¶
Return a copy of the log data with the fitness measure bound by min/max limits
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj_lims |
Sequence[float]
|
min/max limits, length 2. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
pd.DataFrame
|
pd.DataFrame: log data with bound fitness |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
rename_columns(colnames_map)
¶
Rename the columns of the data log according to a mapping.
This is handy for instance to change fully qualified parameter names such as 'subarea.Wolf_Creek.x1' to just 'x1' to produce more legible plots.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
colnames_map |
Dict[str, str]
|
mapping |
required |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
subset_by_message(pattern='Initial.*|Reflec.*|Contrac.*|Add.*')
¶
Subset the log by filtering the 'Message' column by a regexp pattern
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pattern |
str
|
regexp pattern, filter definition |
'Initial.*|Reflec.*|Contrac.*|Add.*'
|
Returns:
Name | Type | Description |
---|---|---|
Any |
MhData
|
New MhData object with subset data |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
subset_by_pattern(colname, pattern)
¶
Subset the log by filtering an attribute by a regexp pattern
Parameters:
Name | Type | Description | Default |
---|---|---|---|
colname |
str
|
column name to filter on |
required |
pattern |
str
|
regexp pattern, filter definition |
required |
Returns:
Name | Type | Description |
---|---|---|
Any |
MhData
|
New MhData object with subset data |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
add_to_hypercube(parameteriser, specs)
¶
Add entries to a hypercube
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameteriser |
HypercubeParameteriser
|
A HypercubeParameteriser wrapper, or a type inheriting from it |
required |
specs |
pd.DataFrame
|
An optional data frame description of the parameter set, with at least columns Name, Min, Max, Value. |
required |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
add_transform(parameteriser, param_name, inner_param_name, transform_id, a=1.0, b=0.0)
¶
Create a parameteriser for which parameter transformations can be defined
This allows to define e.g. a virtual parameter log_X instead of calibrating on the parameter X.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameteriser |
TransformParameteriser
|
A TransformParameteriser wrapper, or a type inheriting from it |
required |
param_name |
str
|
the name of the meta-parameter. Note that it can be the same value as inner_param_name, but this is NOT recommended. |
required |
inner_param_name |
str
|
the name of the parameter being transformed |
required |
transform_id |
str
|
identifier for a known bijective univariate function |
required |
a |
float
|
parameter in Y = F(ax+b). Defaults to 1.0. |
1.0
|
b |
float
|
parameter in Y = F(ax+b). Defaults to 0.0. |
0.0
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
apply_sys_config(parameteriser, simulation)
¶
Apply a model configuration to a simulation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameteriser |
HypercubeParameteriser
|
A HypercubeParameteriser wrapper, or a type inheriting from it |
required |
simulation |
Simulation
|
simulation |
required |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
as_py_structure(x)
¶
Try to convert an external pointer to a native python representation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
Any
|
object, presumably wrapper around an Xptr, to convert to a 'pure' python representation |
required |
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
backtransform(parameteriser)
¶
Get the parameteriser values in the untransformed space
Get the parameteriser values in the untransformed space, i.e. remove any transform added via wrapTransform. This allows to transform back e.g. from a virtual parameter log_X to the underlying model (or even virtual/meta) parameter X.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameteriser |
HypercubeParameteriser
|
A HypercubeParameteriser wrapper, or a type inheriting from it |
required |
Returns:
Type | Description |
---|---|
[HypercubeParameteriser]: The parameters definitions without the transforms (if there are any) |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
bound_values_df(x, colname, lim=None)
¶
min/max bound a column in a data frame
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
[type]
|
a data frame |
required |
colname |
[type]
|
a character vector, name of the column to bound |
required |
lim |
[type]
|
a num vector of the min/max limits to apply, for instance c(0, 1). Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
concatenate_parameterisers(*args, strategy='')
¶
Concatenate hypercubes to a single parameteriser
Parameters:
Name | Type | Description | Default |
---|---|---|---|
strategy |
str
|
The strategy to contatenate. Defaults to "", equivalent to "composite", the only available. May have other options in the future. |
''
|
Returns:
Name | Type | Description |
---|---|---|
CompositeParameteriser |
CompositeParameteriser
|
A concatenated parameteriser |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
create_multisite_obj_parameteriser(func_parameterisers, func_identifiers, prefixes=None, mix_func_parameteriser=None, hydro_parameteriser=None)
¶
Builds a parameteriser usable with a multisite multiobjective calculator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func_parameterisers |
[type]
|
list of external pointers, parameterisers for each function of a multiobjective calculation. |
required |
func_identifiers |
[type]
|
character, identifiers for each of the objectives defined in an multisite objective definition. |
required |
prefixes |
[type]
|
Optional prefixes to use to disambiguate short parameter names used in each function of a multiobjective calculator.. Defaults to None. |
None
|
mix_func_parameteriser |
[type]
|
parameteriser, default None. (FUTURE) Optional parameteriser used in mixing the multiple objectives.. Defaults to None. |
None
|
hydro_parameteriser |
[type]
|
parameteriser, default None. Optional parameteriser applied to the simulation model.. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
create_muskingum_param_constraints(inner_parameters, delta_t=1, param_name_k='K', param_name_x='X', simulation=None)
¶
Create a parameteriser with Muskingum-type constraints. Given an existing parameteriser, create a wrapper that adds constraints on two of its parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inner_parameters |
[HypercubeParameteriser]
|
A SWIFT parameteriser object. |
required |
delta_t |
int
|
the simulation time step in HOURS. Defaults to 1. |
1
|
param_name_k |
str
|
the variable identifier to use for the delay parameter of the Muskingum routing. Defaults to "K". |
'K'
|
param_name_x |
str
|
the variable identifier to use for the attenuation parameter of the Muskingum routing. Defaults to "X". |
'X'
|
simulation |
[Simulation]
|
the model simulation from which link properties are inspected to define constraints. The links' parameters must already be set.. Defaults to None. |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
[description] |
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
create_parameter_sampler(seed, parameteriser, type)
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seed |
[type]
|
seed integer, the seed to use for the sampler |
required |
parameteriser |
HypercubeParameteriser
|
A HypercubeParameteriser wrapper, or a type inheriting from it |
required |
type |
str
|
identifying a method such as 'urs' for uniform random sampling. |
required |
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
create_parameteriser(type='Generic subareas', specs=None)
¶
Create a SWIFT parameteriser
Parameters:
Name | Type | Description | Default |
---|---|---|---|
type |
str
|
A string identifying the (likely SWIFT-specific) type of parameteriser to use. Recognised types are (case insensitive) 'log-likelihood', 'generic', 'subareas', 'links', 'nodes' and 'muskingum'. Defaults to "Generic subareas". |
'Generic subareas'
|
specs |
pd.DataFrame
|
An optional data frame description of the parameter set, with at least columns Name, Min, Max, Value. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
[HypercubeParameteriser]: new parameteriser |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
create_sce_optim_swift(objective, termination_criterion, sce_params, population_initialiser)
¶
Build an SCE optimiser for a SWIFT model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
objective |
ObjectiveEvaluator
|
an objective calculator |
required |
termination_criterion |
SceTerminationCondition
|
An object that can be passed to SCE for testing the completion of the algorithm. |
required |
sce_params |
dict
|
optional; parameters controlling the behavior of the SCE optimisers. |
required |
population_initialiser |
CandidateFactorySeed
|
an S4 object 'ExternalObjRef' [package "cinterop"] with external pointer type HYPERCUBE_PTR or coercible to it, or a type of object that can seed a sampler i.e. coercible to a type CANDIDATE_FACTORY_SEED_WILA_PTR. If the argument is a hypercube, a uniform random sampler is created. |
required |
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
create_sce_termination_wila(type, arguments)
¶
Create a type of termination criteria suitable for the SCE algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
type |
str
|
A type of termination criterion; currently at least "relative standard deviation" and "maximum evaluations" are valid options |
required |
arguments |
Sequence[str]
|
Arguments, in string forms even for numeric values, options for the selected type. |
required |
Returns:
Name | Type | Description |
---|---|---|
SceTerminationCondition |
SceTerminationCondition
|
[description] |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
evaluate_score_for_parameters(objective, parameteriser)
¶
Computes the value of an objective for a given set of parameters
Parameters:
Name | Type | Description | Default |
---|---|---|---|
objective |
[type]
|
an objective calculator |
required |
parameteriser |
HypercubeParameteriser
|
A HypercubeParameteriser wrapper, or a type inheriting from it |
required |
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
example_parameteriser(type, strict=False)
¶
Get examples of typical parameterisers
Parameters:
Name | Type | Description | Default |
---|---|---|---|
type |
str
|
identifier for a type of parameteriser including 'log-likelihood' |
required |
strict |
bool
|
If True an error is raised if the type is not found, otherwise a dummy empty parameteriser is returned.. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
execute_optimisation(optimiser)
¶
Launch an optimization task, as defined by the object passed as an argument
Parameters:
Name | Type | Description | Default |
---|---|---|---|
optimiser |
Optimiser
|
the instance of the optimiser that has been created for the optimisation task about to be launched. |
required |
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
feasible_muskingum_bounds(simulation, delta_t_hours=1)
¶
[summary]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation |
Simulation
|
[description] |
required |
delta_t_hours |
int
|
[description]. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
filtered_parameters(parameteriser)
¶
Wrap a parameteriser in a filter that can hide some parameters
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameteriser |
HypercubeParameteriser
|
A HypercubeParameteriser wrapper, or a type inheriting from it. A deep copy of the input is taken. |
required |
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
get_best_score(scores_population, score_name='NSE', convert_to_py=False)
¶
Gets the best score in a population for a given objective
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scores_population |
[type]
|
an S4 object 'ExternalObjRef' [package "cinterop"] with external pointer type VEC_OBJECTIVE_SCORES_PTR |
required |
score_name |
str
|
name of the objective to use for sorting. Defaults to "NSE". |
'NSE'
|
convert_to_py |
bool
|
should the returned score be converted to an R representation. Default False. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
get_default_sce_parameters()
¶
[summary]
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
get_logger_content(optimiser, add_numbering=False)
¶
Gets logger content on an optimiser, recorded detail of the optimisation process for post-optimisation analysis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
optimiser |
[type]
|
the instance of the optimiser that has been created for the optimisation task about to be launched. |
required |
add_numbering |
bool
|
Add an explicit column for numbering the lines of the log. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
pd.DataFrame
|
pd.DataFrame: The data log of the optimiser |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
get_marginal_termination(tolerance=1e-06, cutoff_no_improvement=10, max_hours=0.05)
¶
Create an termination criterion based on the rate of marginal fitness improvement
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tolerance |
[type]
|
the increment in the objective below which the improvement is considered negligible. Defaults to 1e-06. |
1e-06
|
cutoff_no_improvement |
int
|
the maximum number of successive times the algorithm fails to improve the objective function.. Defaults to 10. |
10
|
max_hours |
float
|
the maximum wall time runtime for the optimisation. Defaults to 0.05. |
0.05
|
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
get_max_iteration_termination(max_iterations=1000)
¶
Create an termination criterion based on the number of objective evaluations
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_iterations |
int
|
number of iterations, which, if less than total count of optim objective evaluations, defines optim termination.. Defaults to 1000. |
1000
|
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
get_max_runtime_termination(max_hours=0.05)
¶
Create an termination criterion based on the wall clock runtime
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_hours |
float
|
the maximum wall time runtime in hours for the optimisation. Defaults to 0.05. |
0.05
|
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
get_score_at_index(scores_population, index)
¶
Get an objective scores in a vector thereof
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scores_population |
[type]
|
an S4 object 'ExternalObjRef' [package "cinterop"] with external pointer type VEC_OBJECTIVE_SCORES_PTR |
required |
index |
int
|
one-based index in the population |
required |
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
hide_parameters(parameteriser, patterns, regex=False, starts_with=False, strict=False)
¶
Hide some parameters (from the outside e.g. optimisers) in a filter parameteriser
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameteriser |
HypercubeParameteriser
|
A HypercubeParameteriser wrapper, or a type inheriting from it |
required |
patterns |
[type]
|
character, one or more pattern to match and hide matching parameters. Match according to other parameters. |
required |
regex |
bool
|
logical, defaults False, should the patterns be used as regular expressions.. Defaults to False. |
False
|
starts_with |
bool
|
logical, defaults False. Ignored if regex is True. Should the patterns be used as starting strings in the parameter names.. Defaults to False. |
False
|
strict |
bool
|
logical, default False. Used only if regex and starts_with are False. If True, raises an error if one of the "patterns" has no exact match in the parameters.. Defaults to False. |
False
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
is_hypercube(p_set)
¶
Is the object a native parameteriser that can be cast as a hypercube?
Parameters:
Name | Type | Description | Default |
---|---|---|---|
p_set |
CffiNativeHandle
|
[description] |
required |
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
is_sampler_seeding(obj)
¶
Is the argument a native object that is a seeded candidate parameteriser factory
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj |
CffiNativeHandle
|
[description] |
required |
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
is_score(x)
¶
OBJECTIVE_SCORES_WILA_PTR
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
[type]
|
[description] |
required |
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
is_set_of_scores(x)
¶
VEC_OBJECTIVE_SCORES_PTR
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
[type]
|
[description] |
required |
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
linear_parameteriser(param_name, state_name, scaling_var_name, min_p_val, max_p_val, value, selector_type='subareas', intercept=0.0)
¶
Create a scaled linear parameteriser, tying by a linear transformation a (resp several) model state to a (resp several) parameter values
This allows to define tied parameters where pval = a * modelStateVal + intercept. The intent in particular is to define virtual model parameters such as initial store value as a fraction of the maximum storage capacity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
param_name |
VecStr
|
the name of the meta-parameter. Note that it can be the same value as inner_param_name without interference, though this may be confusing a choice. |
required |
state_name |
VecStr
|
the name of the model state to modify, based on the value of the meta-parameter and the state found in 'scalingVarName' |
required |
scaling_var_name |
VecStr
|
the name of the parameter for each subarea model, to which to apply the area scaled value. |
required |
min_p_val |
VecNum
|
minimum value allowed for the meta-parameter |
required |
max_p_val |
VecNum
|
minimum value allowed for the meta-parameter |
required |
value |
VecNum
|
value for the meta parameter. |
required |
selector_type |
str
|
an identifier to define to which catchment element(s) the parameteriser will be applied. Defaults to "subareas". |
'subareas'
|
intercept |
VecNum
|
intercepts in the linear relationship(s). Defaults to 0.0. |
0.0
|
Returns:
Type | Description |
---|---|
[ScalingParameteriser]: new ScalingParameteriser |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
linear_parameteriser_from(data_frame, selector_type='subareas')
¶
Create a scaled linear parameteriser, tying by a linear transformation a (resp several) model state to a (resp several) parameter values
This allows to define tied parameters where pval = a * modelStateVal + intercept. The intent in particular is to define virtual model parameters such as initial store value as a fraction of the maximum storage capacity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_frame |
pd.DataFrame
|
data frame with columns "param_name", "state_name", "scaling_var_name", "min_value", "max_value", "value", "intercept", |
required |
selector_type |
str
|
[description]. Defaults to "subareas". |
'subareas'
|
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
make_state_init_parameteriser(parameteriser)
¶
[summary]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameteriser |
HypercubeParameteriser
|
A HypercubeParameteriser wrapper, or a type inheriting from it |
required |
Returns:
Type | Description |
---|---|
[StateInitParameteriser]: new state initialisation parameteriser |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
parameteriser_as_dataframe(parameteriser)
¶
Convert an external object hypercube parameteriser to a pandas data frame
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameteriser |
HypercubeParameteriser
|
A HypercubeParameteriser wrapper, or a type inheriting from it |
required |
Returns:
Type | Description |
---|---|
[type]: [a data frame] |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
parameteriser_for_score(score)
¶
Gets the parameteriser for a score
Parameters:
Name | Type | Description | Default |
---|---|---|---|
score |
[type]
|
[description] |
required |
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
scores_as_dataframe(scores_population)
¶
Convert objective scores to a pandas data frame representation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scores_population |
[type]
|
[description] |
required |
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
set_calibration_logger(optimiser, type='')
¶
Sets logging on an optimiser, so as to record a detail of the optimisation process for post-optimisation analysis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
optimiser |
[type]
|
[description] |
required |
type |
str
|
[description]. Defaults to "". |
''
|
Returns:
Type | Description |
---|---|
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
set_hypercube(parameteriser, specs)
¶
Set the properties of a hypercube parameteriser
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameteriser |
HypercubeParameteriser
|
A HypercubeParameteriser wrapper, or a type inheriting from it |
required |
specs |
pd.DataFrame
|
An optional data frame description of the parameter set, with at least columns Name, Min, Max, Value. |
required |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
set_max_parameter_value(parameteriser, variable_name, value)
¶
Sets the maximum value of a model parameter value
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameteriser |
HypercubeParameteriser
|
A HypercubeParameteriser wrapper, or a type inheriting from it |
required |
variable_name |
str or iterable of str
|
model variable state identifier(s) |
required |
value |
numeric or iterable of numeric
|
value(s) |
required |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
set_min_parameter_value(parameteriser, variable_name, value)
¶
Sets the minimum value of a model parameter value
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameteriser |
HypercubeParameteriser
|
A HypercubeParameteriser wrapper, or a type inheriting from it |
required |
variable_name |
str or iterable of str
|
model variable state identifier(s) |
required |
value |
numeric or iterable of numeric
|
value(s) |
required |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
set_parameter_value(parameteriser, variable_name, value)
¶
Sets the value of a model parameter value
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameteriser |
HypercubeParameteriser
|
A HypercubeParameteriser wrapper, or a type inheriting from it |
required |
variable_name |
str or iterable of str
|
model variable state identifier(s) |
required |
value |
numeric or iterable of numeric
|
value(s) |
required |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
show_parameters(parameteriser, patterns, regex=False, starts_with=False)
¶
Show some parameters (from the outside e.g. optimisers) in a filter parameteriser
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameteriser |
HypercubeParameteriser
|
A HypercubeParameteriser wrapper, or a type inheriting from it |
required |
patterns |
[type]
|
character, one or more pattern to match and show matching parameters. Match according to other parameters |
required |
regex |
bool
|
should the patterns be used as regular expressions. Defaults to False. |
False
|
starts_with |
bool
|
should the patterns be used as starting strings in the parameter names. Defaults to False. |
False
|
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
sort_by_score(scores_population, score_name='NSE')
¶
Sort objective scores according to one of the objective values
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scores_population |
[type]
|
an S4 object 'ExternalObjRef' [package "cinterop"] with external pointer type VEC_OBJECTIVE_SCORES_PTR |
required |
score_name |
str
|
name of the objective to use for sorting. Defaults to "NSE". |
'NSE'
|
Returns:
Name | Type | Description |
---|---|---|
VectorObjectiveScores |
an S4 object 'ExternalObjRef' [package "cinterop"] with external pointer type VEC_OBJECTIVE_SCORES_PTR |
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
subcatchment_parameteriser(parameteriser, subcatchment)
¶
Create a parameteriser that gets applied to a subset of a whole catchment
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameteriser |
HypercubeParameteriser
|
A HypercubeParameteriser wrapper, or a type inheriting from it |
required |
subcatchment |
Simulation
|
the subcatchment, subset of a whole catchment, identifying which elements (subareas, nodes, links) will be parameterised by the new parameteriser. Other catchment elements are untouched. |
required |
Returns:
Type | Description |
---|---|
[HypercubeParameteriser]: New parameteriser whose application is limited to the subcatchment. |
Examples:
>>> sub_cats = simulation.split_to_subcatchments(["node.node_7", "node.node_10"])
>>> sc = sub_cats["node.node_7"]
>>> p = sp.create_parameteriser('generic subarea')
>>> p.add_parameter_to_hypercube("x1", 32, 1, 6e3)
>>> sp = p.subcatchment_parameteriser(sc)
>>> sp.apply_sys_config(simulation)
Source code in /home/per202/src/swift/bindings/python/swift2/swift2/parameteriser.py
wrap_transform(parameteriser)
¶
Create a parameteriser for which parameter transformations can be defined.
This allows to define e.g. a virtual parameter log_X instead of calibrating on the parameter X.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameteriser |
HypercubeParameteriser
|
A HypercubeParameteriser wrapper, or a type inheriting from it |
required |
Returns:
Name | Type | Description |
---|---|---|
TransformParameteriser |
A new parameteriser (TransformParameteriser) which has methods to define parameter transforms |