Hydrology

Note

This is the complete exposed API. Not all classes and functions are meant for the End-user, the documentation is a work in progress

Shyft hydrology python api providing basic types

class shyft.hydrology.ARegionEnvironment

Bases: pybind11_object

Contains all geo-located sources to be used by a Shyft core model

__init__(self: shyft.hydrology.ARegionEnvironment) None
static create_from_geo_ts_matrix(m: shyft.time_series.GeoTsMatrix, t: int = 0, e: int = 0, v: list[int] = []) shyft.hydrology.ARegionEnvironment

Construct ARegionEnvironment from a specified slice of a GeoTsMatrix

Parameters:
  • m (GeoTsMatrix) – The matrix from which to extract temperature,precipitation,radiation,wind-speed,rel-hum data

  • t (int) – the forecast index to extract

  • e (int) – the ensemble index to extract

Returns:

ARegionEnvironment. A ready to use region environment for interpolation

v (IntVector): variable indicies that in order of appearance selects temperature,precipitation,radiation,wind-speed,rel-hum.If empty/default, same as [0,1,2,3,4]

Return type:

ARegionEnvironment

static deserialize(blob: shyft.time_series.ByteVector) shyft.hydrology.ARegionEnvironment

convert a blob, as returned by .serialize() into a ARegionEnvironment

property precipitation

precipitation sources

Type:

PrecipitationSourceVector

property radiation

radiation sources

Type:

RadiationSourceVector

property rel_hum

rel-hum sources

Type:

RelHumSourceVector

serialize(self: shyft.hydrology.ARegionEnvironment) shyft.time_series.ByteVector

convert ARegionEnvironment into a binary blob that later can be restored with the .deserialize(blob) method

property temperature

temperature sources

Type:

TemperatureSourceVector

property variables
property wind_speed

wind-speed sources

Type:

WindSpeedSourceVector

shyft.hydrology.ActualEvapotranspirationCalculate_step(water_level: float, potential_evapotranspiration: float, scale_factor: float, snow_fraction: float, dt: shyft.time_series.time) float

actual_evapotranspiration calculates actual evapotranspiration, returning same unit as input pot.evap based on supplied parameters

Parameters:
  • () (dt) – [mm] water level eqvivalent in ground, ae goes to zero if ground is drying out

  • () – [mm/x], x time-unit

  • () – typically 1.5

  • () – 0..1 there is to ae over snow surface, so snow_fraction 1.0, yields 0.0

  • () – [s] timestep length, currently not part of the formula

Returns:

actual evapotranspiration.

class shyft.hydrology.ActualEvapotranspirationParameter

Bases: pybind11_object

__init__(self: shyft.hydrology.ActualEvapotranspirationParameter, ae_scale_factor: float = 1.5) None
property ae_scale_factor
class shyft.hydrology.ActualEvapotranspirationResponse

Bases: pybind11_object

__init__(*args, **kwargs)
property ae

actual evapotranspiration

Type:

float

class shyft.hydrology.BTKParameter

Bases: pybind11_object

BTKParameter class with time varying gradient based on day no

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.BTKParameter) -> None

  2. __init__(self: shyft.hydrology.BTKParameter, temperature_gradient: float, temperature_gradient_sd: float) -> None

specifying default temp.grad(not used) and std.dev[C/100m]

  1. __init__(self: shyft.hydrology.BTKParameter, temperature_gradient: float, temperature_gradient_sd: float, sill: float = 25.0, nugget: float = 0.5, range: float = 200000.0, zscale: float = 20.0) -> None

nug(self: shyft.hydrology.BTKParameter) float

Nugget magnitude,default=0.5

range(self: shyft.hydrology.BTKParameter) float

Point where semivariogram flattens out,default=200000.0

sill(self: shyft.hydrology.BTKParameter) float

Value of semivariogram at range default=25.0

temperature_gradient(self: shyft.hydrology.BTKParameter, p: shyft.time_series.UtcPeriod) float

return default temp.gradient based on day of year calculated for midst of utcperiod p

temperature_gradient_sd(self: shyft.hydrology.BTKParameter) float

returns Prior standard deviation of temperature gradient in [C/m]

zscale(self: shyft.hydrology.BTKParameter) float

Height scale used during distance computations,default=20.0

class shyft.hydrology.CalibrationOption

Bases: pybind11_object

The CalibrationOption controls how the calibration optmizer is run regarding method and termination criterias. Notice that the different optmizers do have variations in the termination criterias. All optimization algorithms expect at least one-dimensional paramteter space.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.CalibrationOption) -> None

  2. __init__(self: shyft.hydrology.CalibrationOption, method: shyft.hydrology.OptimizerMethod, max_iterations: int = 1500, time_limit: shyft.time_series.time = time(0), solver_epsilon: float = 0.001, x_epsilon: float = 0.001, y_epsilon: float = 0.001, tr_start: float = 0.1, tr_stop: float = 1e-05) -> None

Initialises a ParameterOptimizer instance.

method (OptimizerMethod): select which parameter optimizer to use.

max_iterations (int): stop after this number of iterations (default 1500).

time_limit (float): GLOBAL: don’t run the global search longer than this (default 0, off).

solver_epsilon (float): GLOBAL: select which parameter optimizer to use (default 0.001).

x_epsilon (float): SCEUA: stop when normalized parameters x is within this range in variation.

y_epsilon (float): SCEUA: stop when goal function is stable within this range (not improving any further).

tr_start (float): BOBYQA: trust region start (default 0.1).

tr_stop (float): BOBYQA: trust region stop/end (default 1e-5).

static bobyqa(max_iterations: int, tr_start: float, tr_stop: float) shyft.hydrology.CalibrationOption

Construct bobyqa options.

max_iterations (int): stop after this number of iterations (default 1500).

tr_start (float): BOBYQA: trust region start (default 0.1).

tr_stop (float): trust region stop/end (default 1e-5).

Returns:

co. An instance of CalibrationOption for the relevant optmization algorithm.

Return type:

CalibrationOption

static dream(max_iterations: int) shyft.hydrology.CalibrationOption

Construct dream options

max_iterations (int): stop after this number of iterations (default 1500).

Returns:

co. An instance of CalibrationOption for the relevant optmization algorithm.

Return type:

CalibrationOption

Construct global search options

max_iterations (int): stop after this number of iterations (default 1500).

time_limit (float): don’t run the global search longer than this (default 0, off).

solver_epsilon (float): select which parameter optimizer to use (default 0.001).

Returns:

co. An instance of CalibrationOption for the relevant optmization algorithm.

Return type:

CalibrationOption

property max_iterations

stop after this number of iterations (default 1500)

Type:

int

property method

OptimizerMethod, which parameter optimizer to use

Type:

int

static sceua(max_iterations: int, x_epsilon: float, y_epsilon: float) shyft.hydrology.CalibrationOption

Construct sceua options

max_iterations (int): stop after this number of iterations (default 1500).

x_epsilon (float): stop when normalized parameters x is within this range in variation.

y_epsilon (float): stop when goal function is stable within this range (not improving any further).

Returns:

co. An instance of CalibrationOption for the relevant optmization algorithm.

Return type:

CalibrationOption

property solver_epsilon

select which parameter optimizer to use (default 0.001)

Type:

float

Type:

GLOBAL

property time_limit

don’t run the global search longer than this (default 0, off)

Type:

time

Type:

GLOBAL

property tr_start

trust region start (default 0.1)

Type:

float

Type:

BOBYQA

property tr_stop

trust region stop/end (default 1e-5)

Type:

float

Type:

BOBYQA

property x_epsilon

stop when normalized parameters x is within this range in variation

Type:

float

Type:

SCEUA

property y_epsilon

stop when goal function is stable within this range (not improving any further)

Type:

float

Type:

SCEUA

class shyft.hydrology.CalibrationStatus

Bases: pybind11_object

The CalibrationStatus is returned from drms, or local call to the region model calibration object.It provides status, progress, and current trace of parameters and goal function values

__init__(*args, **kwargs)
result(self: shyft.hydrology.CalibrationStatus) object

returns resulting calibrated parameter if available

property running

True if the calibration is still running

Type:

bool

trace_goal_function_value(self: shyft.hydrology.CalibrationStatus, i: int) float

returns the i’th goal function value

property trace_goal_function_values

goal function values obtained so far

Type:

DoubleVector

trace_parameter(self: shyft.hydrology.CalibrationStatus, i: int) object

returns the i’th parameter tried, corresponding to the i’th trace_goal_function value

property trace_size

returns the size of the parameter-trace

See also

trace_goal_function_value,trace_parameter

Type:

int

class shyft.hydrology.CatchmentPropertyType

Bases: pybind11_object

Members:

DISCHARGE

SNOW_COVERED_AREA

SNOW_WATER_EQUIVALENT

ROUTED_DISCHARGE

CELL_CHARGE

CELL_CHARGE = <CatchmentPropertyType.CELL_CHARGE: 4>
DISCHARGE = <CatchmentPropertyType.DISCHARGE: 0>
ROUTED_DISCHARGE = <CatchmentPropertyType.ROUTED_DISCHARGE: 3>
SNOW_COVERED_AREA = <CatchmentPropertyType.SNOW_COVERED_AREA: 1>
SNOW_WATER_EQUIVALENT = <CatchmentPropertyType.SNOW_WATER_EQUIVALENT: 2>
__init__(self: shyft.hydrology.CatchmentPropertyType, value: int) None
property name
property value
class shyft.hydrology.CellEnvironment

Bases: pybind11_object

Contains all ts projected to a certain cell-model using interpolation step (if needed)

__init__(self: shyft.hydrology.CellEnvironment) None
has_nan_values(self: shyft.hydrology.CellEnvironment) bool

scans all time-series for nan-values

Returns:

has_nan. true if any nan is encounted, otherwise false

Return type:

bool

init(self: shyft.hydrology.CellEnvironment, ta: shyft.time_series.TimeAxisFixedDeltaT) None

zero all series, set time-axis ta

property precipitation

precipitation

Type:

TsFixed

property radiation

radiation

Type:

TsFixed

property rel_hum

relhum

Type:

TsFixed

property temperature

temperature

Type:

TsFixed

property wind_speed

wind speed

Type:

TsFixed

class shyft.hydrology.CellStateId

Bases: pybind11_object

Unique cell pseudo identifier of a state

A lot of Shyft models can appear in different geometries and resolutions.In a few rare cases we would like to store the state of a model.This would be typical for example for hydrological new - year 1 - sept in Norway. To ensure that each cell - state have a unique identifier so that we never risk mixing state from different cells or different geometries, we create a pseudo unique id that helps identifying unique cell - states given this usage and context.

The primary usage is to identify which cell a specific identified state belongs to.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.CellStateId) -> None

  2. __init__(self: shyft.hydrology.CellStateId, cid: int, x: int, y: int, area: int) -> None

construct CellStateId with specified parameters

property area

area in [m^2]

Type:

int

property cid

catchment identifier

Type:

int

property x

x position in [m]

Type:

int

property y

y position in [m]

Type:

int

class shyft.hydrology.DrmClient

Bases: pybind11_object

Distributed region model client provides all needed functionality to transfer Shyft region-models, and then run simulations/optimizations

__init__(self: shyft.hydrology.DrmClient, host_port: str, timeout_ms: int, operation_timeout_ms: int = 0) None
adjust_q(self: shyft.hydrology.DrmClient, mid: str, indexes: list[int], wanted_q: float, start_step: int = 0, scale_range: float = 3.0, scale_eps: float = 0.001, max_iter: int = 300, n_steps: int = 1) shyft.hydrology.FlowAdjustResult

State adjustment to achieve wanted/observed flow

Parameters:
  • mid (str) – model identifier

  • indexes (List[int]) – cell ids that should be adjusted

  • wanted_q (float) – the average flow first time-step we want to achieve, in m**3/s

  • start_step (int) – time-axis start step index, default=0

  • scale_range (float) – default=3, min,max= scale0/scale_range.. scale0*scale_range

  • scale_eps (float) – default 1e-3, stop iteration when scale-change is less than this

  • max_iter (int) – default=300, stop searching for solution after this limit is reached

  • n_steps (int) – default=1, number of steps on time-axis to average to match wanted flow

Returns:

. obtained flow in m**3/s. This can deviate from wanted flow due to model and state constraints. q_r is optimized q and q_0 is unadjusted.

Return type:

q_adjust_result

cancel_calibration(self: shyft.hydrology.DrmClient, mid: str) bool

Cancels any ongoing not finished calibration for the specified model

Parameters:

mid (str) – model identifier

Returns:

. indicating success

Return type:

bool

check_calibration(self: shyft.hydrology.DrmClient, mid: str) shyft.hydrology.CalibrationStatus

Check ongoing calibration, return intermediate status with trace, or final status with trace and resulting parameters

Parameters:

() (mid) – model identifier

Returns:

. Calibration Status class with information and results

clone_model(self: shyft.hydrology.DrmClient, mid: str, new_mid: str) bool

clone the specified model

Parameters:
  • mid (str) – original model

  • new_mid (str) – the model-id for the cloned model

Returns:

. true if succeeded

Return type:

bool

close(self: shyft.hydrology.DrmClient) None

Close the connection. It will automatically reopen if needed.

copy_model(self: shyft.hydrology.DrmClient, mid: str, new_mid: str) bool

full copy of the specified model

Parameters:
  • mid (str) – original model

  • new_mid (str) – the model-id for the copied model

Returns:

. true if succeeded

Return type:

bool

create_model(self: shyft.hydrology.DrmClient, mid: str, mtype: shyft.hydrology.RegionModelType, gcd: shyft.hydrology.GeoCellDataVector) bool

create the model

Parameters:
  • mid (str) – model identifier

  • mtype (enum rmodel_type) – rmodel_type.pt_gs_k rmodel_type.pt_gs_k_opt or similar model type

  • gcd (GeoCellDataVector) – strongly typed list of GeoCellData

Returns:

. true if succeeded

Return type:

bool

fx(self: shyft.hydrology.DrmClient, mid: str, fx_args: str) bool

Invoke the serverside fx callback, on the exlusively locked model given by mid

Parameters:
  • mid (str) – model identifier

  • fx_args (str) – args to the callback, typically a json string

Returns:

. the server side evaluation result, as pr. callback return value

Return type:

bool

get_catchment_parameter(self: shyft.hydrology.DrmClient, mid: str, cid: int) object

Get the effective catchment parameter for the specified catchment

Parameters:
  • mid (str) – model identifier

  • cid (int) – catchment identifier

Returns:

. The catchment parameter for specified catchment

Return type:

XXXParameter

get_charge(self: shyft.hydrology.DrmClient, mid: str, indexes: list[int], index_type: shyft.hydrology.stat_scope = <stat_scope.catchment: 1>) shyft.time_series.TimeSeries

get the charge

Parameters:
  • mid (str) – model identifier

  • indexes (List[int]) – indexes to be retrieved, the index_type tells if it’s cells or catchment indexes

  • index_type (stat_scope) – stat_scope.(cell|catchment) denotes the type of indexes passed. cell returns sum of cell indexes, catchment returns sum of catchments

Returns:

. returns sum for catcment_ids

Return type:

TimeSeries

get_description(self: shyft.hydrology.DrmClient, mid: str) str

returns the user specified description string, typically a json formatted string.

Parameters:

mid (str) – model identifier

Returns:

. The description(json string) for the specified model

Return type:

str

get_discharge(self: shyft.hydrology.DrmClient, mid: str, indexes: list[int], index_type: shyft.hydrology.stat_scope = <stat_scope.catchment: 1>) shyft.time_series.TimeSeries

get the discharge

Parameters:
  • mid (str) – model identifier

  • indexes (List[int]) – indexes to be retrieved, the index_type tells if it’s cells or catchment indexes

  • index_type (stat_scope) – stat_scope.(cell|catchment) denotes the type of indexes passed. cell returns sum of cell indexes, catchment returns sum of catchments

Returns:

. returns sum for catcment_ids

Return type:

TimeSeries

get_geo_cell_data(self: shyft.hydrology.DrmClient, mid: str) shyft.hydrology.GeoCellDataVector

returns the geo cell data vector for the specified model.

Parameters:

mid (str) – model identifier

Returns:

. The GeoCellDataVector for the specified model

Return type:

GeoCellDataVector

get_interpolation_parameter(self: shyft.hydrology.DrmClient, mid: str) shyft.hydrology.InterpolationParameter

returns the current interpolation parameters used to interpolate region-env to the cells.

Parameters:

mid (str) – model identifier

Returns:

. The interpolation parameter for the specified model

Return type:

InterpolationParameter

get_model_ids(self: shyft.hydrology.DrmClient) list[str]

returns a list of model ids (mids) that is alive and known at the remote server

Returns:

. Strongly typed list of strings naming the available models on the drms

Return type:

StringList

get_precipitation(self: shyft.hydrology.DrmClient, mid: str, indexes: list[int], index_type: shyft.hydrology.stat_scope = <stat_scope.catchment: 1>) shyft.time_series.TimeSeries

get the precipitation

Parameters:
  • mid (str) – model identifier

  • indexes (List[int]) – indexes to be retrieved, the index_type tells if it’s cells or catchment indexes

  • index_type (stat_scope) – stat_scope.(cell|catchment) denotes the type of indexes passed. cell returns sum of cell indexes, catchment returns sum of catchments

Returns:

. returns sum for catcment_ids

Return type:

TimeSeries

get_radiation(self: shyft.hydrology.DrmClient, mid: str, indexes: list[int], index_type: shyft.hydrology.stat_scope = <stat_scope.catchment: 1>) shyft.time_series.TimeSeries

get the radiation

Parameters:
  • mid (str) – model identifier

  • indexes (List[int]) – indexes to be retrieved, the index_type tells if it’s cells or catchment indexes

  • index_type (stat_scope) – stat_scope.(cell|catchment) denotes the type of indexes passed. cell returns sum of cell indexes, catchment returns sum of catchments

Returns:

. returns sum for catcment_ids

Return type:

TimeSeries

get_region_env(self: shyft.hydrology.DrmClient, mid: str) shyft.hydrology.ARegionEnvironment

returns the current region-env for the specified model.

Parameters:

mid (str) – model identifier

Returns:

. The region envirionment for the specified model

Return type:

ARegionEnvironment

get_region_parameter(self: shyft.hydrology.DrmClient, mid: str) object

Get the region model parameter settings

Parameters:

mid (str) – model identifier

Returns:

. The region parameter for the model

Return type:

XXXParameter

get_rel_hum(self: shyft.hydrology.DrmClient, mid: str, indexes: list[int], index_type: shyft.hydrology.stat_scope = <stat_scope.catchment: 1>) shyft.time_series.TimeSeries

get the rel_hum

Parameters:
  • mid (str) – model identifier

  • indexes (List[int]) – indexes to be retrieved, the index_type tells if it’s cells or catchment indexes

  • index_type (stat_scope) – stat_scope.(cell|catchment) denotes the type of indexes passed. cell returns sum of cell indexes, catchment returns sum of catchments

Returns:

. returns sum for catcment_ids

Return type:

TimeSeries

get_server_version(self: shyft.hydrology.DrmClient) str

returns the server version

Returns:

version. Server version string

Return type:

str

get_snow_sca(self: shyft.hydrology.DrmClient, mid: str, indexes: list[int], index_type: shyft.hydrology.stat_scope = <stat_scope.catchment: 1>) shyft.time_series.TimeSeries

get the snow_sca

Parameters:
  • mid (str) – model identifier

  • indexes (List[int]) – indexes to be retrieved, the index_type tells if it’s cells or catchment indexes

  • index_type (stat_scope) – stat_scope.(cell|catchment) denotes the type of indexes passed. cell returns sum of cell indexes, catchment returns sum of catchments

Returns:

. returns sum for catcment_ids

Return type:

TimeSeries

get_snow_swe(self: shyft.hydrology.DrmClient, mid: str, indexes: list[int], index_type: shyft.hydrology.stat_scope = <stat_scope.catchment: 1>) shyft.time_series.TimeSeries

get the snow_swe

Parameters:
  • mid (str) – model identifier

  • indexes (List[int]) – indexes to be retrieved, the index_type tells if it’s cells or catchment indexes

  • index_type (stat_scope) – stat_scope.(cell|catchment) denotes the type of indexes passed. cell returns sum of cell indexes, catchment returns sum of catchments

Returns:

. returns sum for catcment_ids

Return type:

TimeSeries

get_state(self: shyft.hydrology.DrmClient, mid: str, indexes: list[int] = []) object

Extract cell state for the optionaly specified catchment ids, cids

Parameters:
  • mid (str) – model identifier

  • indexes (IntVector) – list of catchment-id’s, if empty, extract all

Returns:

. strongly typed list of stack state with identifier for the cells

Return type:

xStateWithIdVector

get_temperature(self: shyft.hydrology.DrmClient, mid: str, indexes: list[int], index_type: shyft.hydrology.stat_scope = <stat_scope.catchment: 1>) shyft.time_series.TimeSeries

get the temperature

Parameters:
  • mid (str) – model identifier

  • indexes (List[int]) – indexes to be retrieved, the index_type tells if it’s cells or catchment indexes

  • index_type (stat_scope) – stat_scope.(cell|catchment) denotes the type of indexes passed. cell returns sum of cell indexes, catchment returns sum of catchments

Returns:

. returns sum for catcment_ids

Return type:

TimeSeries

get_time_axis(self: shyft.hydrology.DrmClient, mid: str) shyft.time_series.TimeAxis

Get the current time-axis of the model

Parameters:

mid (str) – model identifier

Returns:

. The region model time-axis

Return type:

TimeAxis

get_wind_speed(self: shyft.hydrology.DrmClient, mid: str, indexes: list[int], index_type: shyft.hydrology.stat_scope = <stat_scope.catchment: 1>) shyft.time_series.TimeSeries

get the wind speed

Parameters:
  • mid (str) – model identifier

  • indexes (List[int]) – indexes to be retrieved, the index_type tells if it’s cells or catchment indexes

  • index_type (stat_scope) – stat_scope.(cell|catchment) denotes the type of indexes passed. cell returns sum of cell indexes, catchment returns sum of catchments

Returns:

. returns sum for catcment_ids

Return type:

TimeSeries

has_catchment_parameter(self: shyft.hydrology.DrmClient, mid: str, cid: int) bool

Get the current time-axis of the model

Parameters:
  • mid (str) – model identifier

  • cid (int) – catchment identifier

Returns:

. True if catchment has its own parameter setting

Return type:

bool

property host_port

Endpoint network address of the remote server.

Type:

str

is_calculated(self: shyft.hydrology.DrmClient, mid: str, catchment_id: int) bool

using the catchment_calculation_filter to decide if discharge etc. are calculated.

Parameters:
  • mid (str) – model identifier

  • cid (int) – catchment id

Returns:

. true if catchment id is calculated during runs

Return type:

bool

is_cell_env_ts_ok(self: shyft.hydrology.DrmClient, mid: str) bool

check if all values in cell.env_ts for selected calculation-filter is non-nan, i.e. valid numbers

Parameters:

mid (str) – model identifier

Returns:

. true if ok, false if not ok

Return type:

bool

property is_open

If the connection to the remote server is (still) open.

Type:

bool

property operation_timeout_ms

Operation timeout for remote server operations, in number milliseconds.

Type:

int

property reconnect_count

Number of reconnects to the remote server that have been performed.

Type:

int

remove_catchment_parameter(self: shyft.hydrology.DrmClient, mid: str, cid: int) None

Remove the specified catchments local parameter, and set it to the region parameter

Parameters:
  • mid (str) – model identifier

  • cid (int) – catchment identifier

remove_model(self: shyft.hydrology.DrmClient, mid: str) bool

remove the specified model

Parameters:

mid (str) – model identifier

Returns:

. true if succeeded

Return type:

bool

rename_model(self: shyft.hydrology.DrmClient, mid: str, new_mid: str) bool

rename the specified model

Parameters:
  • mid (str) – model identifier

  • new_mid (str) – the new wanted model-id for the model

Returns:

. true if succeeded

Return type:

bool

revert_to_initial_state(self: shyft.hydrology.DrmClient, mid: str) bool

revert model to initial state, notice that this require that the set_current_state_as_initial_state() or run_cells() is called. The latter will set initial state if not already done.

Parameters:

mid (str) – model identifier

Returns:

. true if succeeded

Return type:

bool

run_cells(self: shyft.hydrology.DrmClient, mid: str, use_ncore: int = 0, start_step: int = 0, n_steps: int = 0) bool

Run calculation over the specified time axis. Requires that cells and environment have been initialized and interpolated.

Parameters:
  • mid (str) – model identifier

  • use_ncore (int) – default 0, means autodetect core, otherwise you can specify 1..n

  • start_step (int) – default 0, from start step of time-axis

  • n_steps (int) – default 0, means run entire time-axis, 1..n means number of steps from start_step

Returns:

. true if succeeded

Return type:

bool

run_interpolation(self: shyft.hydrology.DrmClient, mid: str, ip_parameter: shyft.hydrology.InterpolationParameter, ta: shyft.time_series.TimeAxis, r_env: shyft.hydrology.ARegionEnvironment, best_effort: bool) bool

initializes the cell environment and project region environment time_series to cells.

Parameters:
  • mid (str) – model identifier

  • ip_parameter (InterpolationParameter) – interpolation parameter

  • ta (TimeAxis) – time axis

  • r_env (ARegionEnvironment) – region environment containing all geo-located sources

  • best_effort (bool) – best effort type interpolation

Returns:

. true if succeeded

Return type:

bool

set_catchment_calculation_filter(self: shyft.hydrology.DrmClient, mid: str, catchment_id_list: list[int]) bool

set catchment calculation filter

Parameters:
  • mid (str) – model identifier

  • catchment_id_list (List[int]) – list of catchment indexes

Returns:

. true if succeeded

Return type:

bool

set_catchment_parameter(self: shyft.hydrology.DrmClient, mid: str, parameter: shyft.hydrology.pt_gs_k.PTGSKParameter | shyft.hydrology.pt_ss_k.PTSSKParameter | shyft.hydrology.pt_hs_k.PTHSKParameter | shyft.hydrology.pt_hps_k.PTHPSKParameter | shyft.hydrology.r_pm_gs_k.RPMGSKParameter | shyft.hydrology.pt_st_k.PTSTKParameter | shyft.hydrology.pt_st_hbv.PTSTHBVParameter | shyft.hydrology.r_pt_gs_k.RPTGSKParameter | shyft.hydrology.r_pm_st_k.RPMSTKParameter | shyft.hydrology.r_pmv_st_k.RPMVSTKParameter, cid: int) bool

set catchment parameter

Parameters:
  • mid (str) – model identifier

  • parameter (XXXXParameter) – strongly typed method stack parameter

  • cid (int) – catchment id that should get the supplied parameter

Returns:

. true if succeeded

Return type:

bool

set_cell_environment(self: shyft.hydrology.DrmClient, mid: str, ta: shyft.time_series.TimeAxis, r_env: shyft.hydrology.ARegionEnvironment) bool

Set the forcing data cell enviroment (cell.env_ts.* )

The method initializes the cell environment, that keeps temperature, precipitation etc for all the cells. The region-model time-axis is set to the supplied time-axis, so that the the region model is ready to run cells, using this time-axis.

There are strict requirements to the content of the region_env parameter:

  • rm.cells[i].mid_point()== region_env.temperature[i].mid_point() for all i

  • similar for precipitation,rel_hum,radiation,wind_speed

So same number of forcing data, in the same order and geo position as the cells. Tip: If time_axis is equal to the forcing time-axis, it is twice as fast.

Parameters:
  • mid (str) – model identifier

  • ta (TimeAxis) – specifies the time-axisfor the region-model, and thus the cells

  • r_env (ARegionEnvironment) – A region environment with ready to use forcing data for all the cells.

Returns:

success. true if successfull, raises exception otherwise

Return type:

bool

set_current_state_as_initial_state(self: shyft.hydrology.DrmClient, mid: str) bool

set current state as initial state for the region model. the method .revert_to_initial_state will restore this state.

Parameters:

mid (str) – model identifier

Returns:

. true if succeeded

Return type:

bool

set_description(self: shyft.hydrology.DrmClient, mid: str, description: str) bool

Set the user specified description string, typically a json formatted string.

Parameters:

mid (str) – model identifier

Returns:

. True if successful

Return type:

bool

set_region_parameter(self: shyft.hydrology.DrmClient, mid: str, parameter: shyft.hydrology.pt_gs_k.PTGSKParameter | shyft.hydrology.pt_ss_k.PTSSKParameter | shyft.hydrology.pt_hs_k.PTHSKParameter | shyft.hydrology.pt_hps_k.PTHPSKParameter | shyft.hydrology.r_pm_gs_k.RPMGSKParameter | shyft.hydrology.pt_st_k.PTSTKParameter | shyft.hydrology.pt_st_hbv.PTSTHBVParameter | shyft.hydrology.r_pt_gs_k.RPTGSKParameter | shyft.hydrology.r_pm_st_k.RPMSTKParameter | shyft.hydrology.r_pmv_st_k.RPMVSTKParameter) bool

set region parameter

Parameters:
  • mid (str) – model identifier

  • parameter (XXXXParameter) – strongly typed method stack parameter

Returns:

. true if succeeded

Return type:

bool

set_snow_sca_swe_collection(self: shyft.hydrology.DrmClient, mid: str, catchment_id: int, on_or_off: bool) bool

enable/disable collection of snow sca|sca for calibration purposes

Parameters:
  • mid (str) – model identifier

  • catchment_id (int) – to enable snow calibration for, -1 means turn on/off for all

  • on_or_off (bool) – on_or_off true|or false

Returns:

. true if succeeded

Return type:

bool

set_state(self: shyft.hydrology.DrmClient, mid: str, state: shyft.hydrology.pt_gs_k.PTGSKStateWithIdVector | shyft.hydrology.pt_ss_k.PTSSKStateWithIdVector | shyft.hydrology.pt_hs_k.PTHSKStateWithIdVector | shyft.hydrology.pt_hps_k.PTHPSKStateWithIdVector | shyft.hydrology.r_pm_gs_k.RPMGSKStateWithIdVector | shyft.hydrology.pt_st_k.PTSTKStateWithIdVector | shyft.hydrology.pt_st_hbv.PTSTHBVStateWithIdVector | shyft.hydrology.r_pt_gs_k.RPTGSKStateWithIdVector | shyft.hydrology.r_pm_st_k.RPMSTKStateWithIdVector | shyft.hydrology.r_pmv_st_k.RPMVSTKStateWithIdVector) bool

set the cell state

Parameters:
  • mid (str) – model identifier

  • state (StateWithIdVector) – strongly typed list of stack state with id vector

Returns:

. true if succeeded

Return type:

bool

set_state_collection(self: shyft.hydrology.DrmClient, mid: str, catchment_id: int, on_or_off: bool) bool

enable state collection for specified or all cells

Parameters:
  • mid (str) – model identifier

  • catchment_id (int) – to enable state collection for, -1 means turn on/off for all

  • on_or_off (bool) – on_or_off true|or false

Returns:

. true if succeeded

Return type:

bool

start_calibration(self: shyft.hydrology.DrmClient, mid: str, p_start: shyft.hydrology.pt_gs_k.PTGSKParameter | shyft.hydrology.pt_ss_k.PTSSKParameter | shyft.hydrology.pt_hs_k.PTHSKParameter | shyft.hydrology.pt_hps_k.PTHPSKParameter | shyft.hydrology.r_pm_gs_k.RPMGSKParameter | shyft.hydrology.pt_st_k.PTSTKParameter | shyft.hydrology.pt_st_hbv.PTSTHBVParameter | shyft.hydrology.r_pt_gs_k.RPTGSKParameter | shyft.hydrology.r_pm_st_k.RPMSTKParameter | shyft.hydrology.r_pmv_st_k.RPMVSTKParameter, p_min: shyft.hydrology.pt_gs_k.PTGSKParameter | shyft.hydrology.pt_ss_k.PTSSKParameter | shyft.hydrology.pt_hs_k.PTHSKParameter | shyft.hydrology.pt_hps_k.PTHPSKParameter | shyft.hydrology.r_pm_gs_k.RPMGSKParameter | shyft.hydrology.pt_st_k.PTSTKParameter | shyft.hydrology.pt_st_hbv.PTSTHBVParameter | shyft.hydrology.r_pt_gs_k.RPTGSKParameter | shyft.hydrology.r_pm_st_k.RPMSTKParameter | shyft.hydrology.r_pmv_st_k.RPMVSTKParameter, p_max: shyft.hydrology.pt_gs_k.PTGSKParameter | shyft.hydrology.pt_ss_k.PTSSKParameter | shyft.hydrology.pt_hs_k.PTHSKParameter | shyft.hydrology.pt_hps_k.PTHPSKParameter | shyft.hydrology.r_pm_gs_k.RPMGSKParameter | shyft.hydrology.pt_st_k.PTSTKParameter | shyft.hydrology.pt_st_hbv.PTSTHBVParameter | shyft.hydrology.r_pt_gs_k.RPTGSKParameter | shyft.hydrology.r_pm_st_k.RPMSTKParameter | shyft.hydrology.r_pmv_st_k.RPMVSTKParameter, spec: shyft.hydrology.TargetSpecificationVector, opt: shyft.hydrology.CalibrationOption) bool

Start calibration with specified parameters for the model given by ‘mid’

Parameters:
  • () (opt) – model identifier

  • () – starting parameters

  • () – min-range for parameters

  • () – max-range for parameters

  • () – goal function specification, including reference series and weights

  • () – optimizer options, like BOBYQA, GLOBAL,SCEUA or DREAM etc.

Returns:

. indicating success

Return type:

bool

property timeout_ms

Timout for remote server operations, in number milliseconds.

Type:

int

total_clients = 0
class shyft.hydrology.DrmServer

Bases: pybind11_object

The DRMS, distributed region model server provides the server part that implements the needed functionality to create, run and get results from hydrology region-models .Together with the DrmClient, it allow the Shyft hydrology region-model operations to be scaled out on several servers, giving providing support for system and analysis of any size

__init__(self: shyft.hydrology.DrmServer, config: shyft.time_series.ServerConfig = shyft.time_series.ServerConfig(stale_duration='1970-01-01T01:00:00Z', stale_sweep_interval='1970-01-01T00:00:00.100000Z', log=shyft.time_series.LogConfig(file='', level=200))) None

Creates a server object with stale connection detect parameters

property alive_connections

returns currently alive connections to the server

Type:

int

property fx

server-side callable function(lambda) that takes two parameters: mid : the model id fx_arg: arbitrary string to pass to the server-side function The server-side fx is called when the client (or web-api) invoke the c.fx(mid,fx_arg). The signature of the callback function should be callback(mid:str, fx_arg:str)->bool This feature is simply enabling the users to tailor server-side functionality in python! NOTE: Currently we do take exclusive lock on the model id, so that we avoid race conditions Examples:

>>> from shyft.hydrology import DrmServer
>>> s=DrmServer()
>>> def my_fx(mid:str, fx_arg:str)->bool:
>>>     print(f'invoked with mid={mid} fx_arg={fx_arg}')
>>>   # note we can use captured Server s here!>>>     return True
>>> # and then bind the function to the callback
>>> s.fx=my_fx
>>> s.start_server()
>>> : # later using client from anywhere to invoke the call
>>> fx_result=c.fx('my_model_id', 'my_args')
Type:

Callable[[str,str],bool]

get_listening_port(self: shyft.hydrology.DrmServer) int

returns the port number it’s listening at for serving incoming request

get_max_connections(self: shyft.hydrology.DrmServer) int

returns the maximum number of connections to be served concurrently

get_model(self: shyft.hydrology.DrmServer, arg0: str) object

returns the named model, so it can be inspected/modified WIP: needs to be sure that there is no activity on the model from the remote side

Returns:

. Of the type as set by the client

Return type:

Model

get_model_ids(self: shyft.hydrology.DrmServer) list[str]

returns a list of model ids (mids) that is alive and known in the server

Returns:

. Strongly typed list of strings naming the available models on the drms

Return type:

StringList

is_running(self: shyft.hydrology.DrmServer) bool

true if server is listening and running

See also

start_server()

set_listening_ip(self: shyft.hydrology.DrmServer, ip: str) None

set the listening port for the service

Parameters:

ip (str) – ip or host-name to start listening on

Returns:

nothing.

Return type:

None

set_listening_port(self: shyft.hydrology.DrmServer, port_no: int) None

set the listening port for the service

Parameters:
  • port_no (int) – a valid and available tcp-ip port number to listen on.

  • 20000 (typically it could be)

Returns:

nothing.

Return type:

None

set_max_connections(self: shyft.hydrology.DrmServer, max_connect: int) None

limits simultaneous connections to the server (it’s multithreaded, and uses on thread pr. connect)

Parameters:

max_connect (int) – maximum number of connections before denying more connections

See also

get_max_connections()

start_server(self: shyft.hydrology.DrmServer) int

start server listening in background, and processing messages

See also

set_listening_port(port_no),is_running

Returns:

port_no. the port used for listening operations, either the value as by set_listening_port, or if it was unspecified, a new available port

Return type:

in

stop_server(self: shyft.hydrology.DrmServer, ms: int = 2000) None

stop serving connections, gracefully.

See also

start_server()

class shyft.hydrology.FlowAdjustResult

Bases: pybind11_object

The result type of region-model .adjust_state_to_target_flow(..) method

__init__(self: shyft.hydrology.FlowAdjustResult) None
property diagnostics

If tuning failed, the diagnostics of failure, zero length/empty if success

Type:

str

property q_0

The flow m3/s from selected catchments before tuning

Type:

float

property q_r

The obtaioned flow m3/s after tuning

Type:

float

class shyft.hydrology.FreeWaterEvaporationCalculator

Bases: pybind11_object

Evapotranspiration model, Penman or combination method equation for open water, ponds and reservoirs, PM reference

L. Dingman Penmann evapotranspiration

[mm/s] units.

__init__(*args, **kwargs)
evaporation(self: shyft.hydrology.FreeWaterEvaporationCalculator, response: shyft.hydrology.FreeWaterEvaporationResponse, dt: shyft.time_series.time, swin_radiation: float, lw_radiation: float, tempmax: float, tempmin: float, rhumidity: float, water_area: float, albedo: float, elevation: float, windspeed: float) None

calculates evapotranspiration, updating response

class shyft.hydrology.FreeWaterEvaporationResponse

Bases: pybind11_object

__init__(self: shyft.hydrology.FreeWaterEvaporationResponse) None
property et

mm/h

Type:

float

class shyft.hydrology.GammaSnowCalculator

Bases: pybind11_object

__init__(self: shyft.hydrology.GammaSnowCalculator) None
step(self: shyft.hydrology.GammaSnowCalculator, state: shyft.hydrology.GammaSnowState, response: shyft.hydrology.GammaSnowResponse, t: shyft.time_series.time, dt: shyft.time_series.time, parameter: shyft.hydrology.GammaSnowParameter, temperature: float, radiation: float, precipitation: float, wind_speed: float, rel_hum: float, forest_fraction: float, altitude: float) None

Step the snow model forward from time t to t+dt, given state, parameters and input.

Updates the state and response upon return.

Parameters:
  • state (GammaSnowState) – param state state of type S,in/out, ref template parameters

  • response (GammaSnowResponse) – the response , out parameter.

  • t (float) – ttemperature degC, considered constant over timestep dt

  • dt (time) – length of time-step, seconds

  • param (GammaSnowParameter) – response result of type R, output only, ref. template parameters

  • radiation (float) – in W/m2, considered constant over timestep

  • precipitation (float) – in mm/h

  • wind_speed (float) – in m/s

  • rel_hum (float) – range 0..1

  • forest_fraction (float) – range 0..1, influences calculation of effective snow_cv

  • altitude (float) – 0..x [m], influences calculation of effective_snow_cv

class shyft.hydrology.GammaSnowParameter

Bases: pybind11_object

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.GammaSnowParameter) -> None

  2. __init__(self: shyft.hydrology.GammaSnowParameter, winter_end_day_of_year: int, initial_bare_ground_fraction: float = 0.04, snow_cv: float = 0.4, tx: float = -0.5, wind_scale: float = 2.0, wind_const: float = 1.0, max_water: float = 0.1, surface_magnitude: float = 30.0, max_albedo: float = 0.9, min_albedo: float = 0.6, fast_albedo_decay_rate: float = 5.0, slow_albedo_decay_rate: float = 5.0, snowfall_reset_depth: float = 0.4, glacier_albedo: float = False) -> None

property calculate_iso_pot_energy

Whether or not to calculate the potential energy flux,default=false

Type:

float

effective_snow_cv(self: shyft.hydrology.GammaSnowParameter, forest_fraction: float, altitude: float) float

returns the effective snow cv, taking the forest_fraction and altitude into the equations using corresponding factors

property fast_albedo_decay_rate

Albedo decay rate during melt [days],default=5.0

Type:

float

property glacier_albedo

Glacier ice fixed albedo, default=0.4

Type:

float

property initial_bare_ground_fraction

Bare ground fraction at melt onset,default= 0.04

Type:

float

is_snow_season(self: shyft.hydrology.GammaSnowParameter, t: shyft.time_series.time) bool

returns true if specified t is within the snow season, e.g. sept.. winder_end_day_of_year

is_start_melt_season(self: shyft.hydrology.GammaSnowParameter, t: shyft.time_series.time, dt: shyft.time_series.time = 0) bool

true if specified interval t day of year is wind_end_day_of_year

property max_albedo

Maximum albedo value,default=0.9

Type:

float

property max_water

Maximum liquid water content,default=0.1

Type:

float

property min_albedo

Minimum albedo value,default=0.6

Type:

float

property n_winter_days

number of winter-days, default 221

Type:

int

property slow_albedo_decay_rate

Albedo decay rate in cold conditions [days],default=5.0

Type:

float

property snow_cv

Spatial coefficient variation of fresh snowfall, default= 0.4

Type:

float

property snow_cv_altitude_factor

default=0.0, [1/m] the effective snow_cv gets an additional value of altitude[m]* snow_cv_altitude_factor

Type:

float

property snow_cv_forest_factor

default=0.0, [ratio] the effective snow_cv gets an additional value of geo.forest_fraction()*snow_cv_forest_factor

Type:

float

property snowfall_reset_depth

Snowfall required to reset albedo [mm],default=5.0

Type:

float

property surface_magnitude

Surface layer magnitude,default=30.0

Type:

float

property tx

default= -0.5 [degC]

Type:

float

property wind_const

Intercept in turbulent wind function,default=1.0

Type:

float

property wind_scale

Slope in turbulent wind function default=2.0 [m/s]

Type:

float

property winter_end_day_of_year

Last day of accumulation season,default= 100

Type:

int

class shyft.hydrology.GammaSnowResponse

Bases: pybind11_object

The response(output) from gamma-snow for one time-step

__init__(self: shyft.hydrology.GammaSnowResponse) None
property outflow

Water out from the snow pack [mm/h]

Type:

float

property sca

Snow covered area [0..1]

Type:

float

property storage

Snow storage in [mm] over the area

Type:

float

class shyft.hydrology.GammaSnowState

Bases: pybind11_object

The state description of the GammaSnow routine

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.GammaSnowState) -> None

  2. __init__(self: shyft.hydrology.GammaSnowState, albedo: float = 0.4, lwc: float = 0.1, surface_heat: float = 30000.0, alpha: float = 1.26, sdc_melt_mean: float = 0.0, acc_melt: float = 0.0, iso_pot_energy: float = 0.0, temp_swe: float = 0.0) -> None

property acc_melt

acc_melt (Accumulated melt depth) [mm],default = 0.0

Type:

float

property albedo

albedo (Broadband snow reflectivity fraction),default = 0.4

Type:

float

property alpha

alpha (Dynamic shape state in the SDC),default = 1.26

Type:

float

property iso_pot_energy

iso_pot_energy (Accumulated energy assuming isothermal snow surface) [J/m2],default = 0.0

Type:

float

property lwc

lwc (liquid water content) [mm],default = 0.1

Type:

float

property sdc_melt_mean

sdc_melt_mean (Mean snow storage at melt onset) [mm],default = 0.0

Type:

float

property surface_heat

surface_heat (Snow surface cold content) [J/m2],default = 30000.0

Type:

float

property temp_swe

temp_swe (Depth of temporary new snow layer during spring) [mm],default = 0.0

Type:

float

class shyft.hydrology.GeoCellData

Bases: pybind11_object

Represents common constant geo_cell properties across several possible models and cell assemblies. The idea is that most of our algorithms uses one or more of these properties, so we provide a common aspect that keeps this together. Currently it keep these items: - mid-point geo_point, (x,y,z) (default 0) - TIN data - the area in m^2, (default 1000 x 1000 m^2) - land_type_fractions (unspecified=1) - catchment_id def (-1) - radiation_slope_factor def 0.9 - routing_info def(0,0.0), i.e. not routed and hydrological distance=0.0m

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.GeoCellData) -> None

  2. __init__(self: shyft.hydrology.GeoCellData, mid_point: shyft.time_series.GeoPoint, area: float, catchment_id: int, radiation_slope_factor: float = 0.9, land_type_fractions: shyft.hydrology.LandTypeFractions = LandTypeFractions(glacier=0, lake=0, forest=0, unspecified=1), routing_info: shyft.hydrology.RoutingInfo = RoutingInfo(id=0, distance=0)) -> None

Constructs a GeoCellData with all parameters specified

Parameters:
  • mid_point (GeoPoint) – specifies the x,y,z mid-point of the cell-area

  • area (float) – area in unit [m^2]

  • catchment_id (int) – catchment-id that this cell is a part of

  • radiation_slope_factor (float) – aspect dependent factor used to calculate the effective radiation for this cell,range 0.0..1.0

  • land_type_fractions (LandTypeFractions) – specifies the fractions of glacier, forrest, lake and reservoirs for this cell

  • routing_info (RoutingInfo) – Specifies the destination routing network-node and velocity for this cell

  1. __init__(self: shyft.hydrology.GeoCellData, p1: shyft.time_series.GeoPoint, p2: shyft.time_series.GeoPoint, p3: shyft.time_series.GeoPoint, epsg_id: int, catchment_id: int, land_type_fractions: shyft.hydrology.LandTypeFractions = LandTypeFractions(glacier=0, lake=0, forest=0, unspecified=1), routing_info: shyft.hydrology.RoutingInfo = RoutingInfo(id=0, distance=0)) -> None

Constructs a TIN-based GeoCellData with all parameters specified, slope/aspect etc. is based on TIN

Parameters:
  • p1 (GeoPoint) – specifies the first vertex in TIN

  • p2 (GeoPoint) – specifies the second vertex in TIN

  • p3 (GeoPoint) – specifies the third vertex in TIN

  • epsg_id (int) – specifies the geo projection as epsg-id, used for projection from cartesian coord to long-lat algorithms that needs this(e.g. radiation, TIN-models)

  • catchment_id (int) – catchment-id that this cell is a part of

  • land_type_fractions (LandTypeFractions) – specifies the fractions of glacier, forrest, lake and reservoirs for this cell

  • routing_info (RoutingInfo) – Specifies the destination routing network-node and velocity for this cell

area(self: shyft.hydrology.GeoCellData) float

returns the effective area, as projected to the horisontal plane, in m^2

aspect(self: shyft.hydrology.GeoCellData) float

returns aspect, deg

catchment_id(self: shyft.hydrology.GeoCellData) int

returns the current catchment_id

property epsg_id

the epsg-id that should consistently identify the geo projection for all cells in a region model

Type:

int

is_tin(self: shyft.hydrology.GeoCellData) bool

returns true if the geo-cell is fully specified as a TIN model

land_type_fractions_info(self: shyft.hydrology.GeoCellData) shyft.hydrology.LandTypeFractions

land_type_fractions

mid_point(self: shyft.hydrology.GeoCellData) shyft.time_series.GeoPoint

returns the mid_point

radiation_slope_factor(self: shyft.hydrology.GeoCellData) float
property routing_info

routing information for the cell keep destination id and hydrological distance to destination

Type:

RoutingInfo

set_catchment_id(self: shyft.hydrology.GeoCellData, catchment_id: int) None

Set the catchment_id to specified value Note: Only use this method before a region-model is created

Parameters:

catchment_id (int) – Catchment-id for this cell

set_land_type_fractions(self: shyft.hydrology.GeoCellData, ltf: shyft.hydrology.LandTypeFractions) None

set new LandTypeFractions

set_tin_data(self: shyft.hydrology.GeoCellData, vertexes: shyft.time_series.GeoPointVector) None

set TIN data from vector of vertexes

slope(self: shyft.hydrology.GeoCellData) float

returns slope, deg

surface_area(self: shyft.hydrology.GeoCellData) float

returns the real surface area in m^2

vertexes(self: shyft.hydrology.GeoCellData) shyft.time_series.GeoPointVector

returns vector of tin vertexes

class shyft.hydrology.GeoCellDataClient

Bases: pybind11_object

The client api for the shyft.hydrology geo_cell_data model service.

__init__(self: shyft.hydrology.GeoCellDataClient, host_port: str, timeout_ms: int, operation_timeout_ms: int = 0) None

Creates a python client that can communicate with the corresponding server

close(self: shyft.hydrology.GeoCellDataClient) None

Close the connection. It will automatically reopen if needed.

get_model_infos(self: shyft.hydrology.GeoCellDataClient, mids: list[int], created_in: shyft.time_series.UtcPeriod = [not-valid-period>) list[shyft.time_series.ModelInfo]

returns all or selected model-info objects based on model-identifiers(mids)

Parameters:
  • mids (IntVector) – empty = all, or a list of known exisiting model-identifiers

  • created_in (UtcPeriod) – For which period you are interested in model-infos.

Returns:

model_infos. Strongly typed list of ModelInfo

Return type:

ModelInfoVector

property host_port

Endpoint network address of the remote server.

Type:

str

property is_open

If the connection to the remote server is (still) open.

Type:

bool

property operation_timeout_ms

Operation timeout for remote server operations, in number milliseconds.

Type:

int

read_model(self: shyft.hydrology.GeoCellDataClient, mid: int) shyft.hydrology.GeoCellDataModel

Read and return the model for specified model-identifier (mid)

Parameters:

mid (int) – the model-identifer for the wanted model

Returns:

  1. The resulting model from the server

Return type:

Model

read_models(self: shyft.hydrology.GeoCellDataClient, mids: list[int]) shyft.hydrology.GeoCellDataModelVector

Read and return the model for specified model-identifier (mid)

Parameters:

mids (list[int]) – A strongly typed list of ints, the model-identifers for the wanted models

Returns:

  1. The resulting model from the server

Return type:

Model

property reconnect_count

Number of reconnects to the remote server that have been performed.

Type:

int

remove_model(self: shyft.hydrology.GeoCellDataClient, mid: int) int

Remove the specified model bymodel-identifier (mid)

Parameters:

mid (int) – the model-identifer for the wanted model

Returns:

ec. 0 or error-code?

Return type:

int

store_model(self: shyft.hydrology.GeoCellDataClient, m: shyft.hydrology.GeoCellDataModel, mi: shyft.time_series.ModelInfo) int

Store the model to backend, if m.id==0 then a new unique model-info is created and used

Parameters:
  • m (Model) – The model to store

  • mi (ModelInfo) – The model-info to store for the model

Returns:

mid. model-identifier for the stored model and model-info

Return type:

int

property timeout_ms

Timout for remote server operations, in number milliseconds.

Type:

int

update_model_info(self: shyft.hydrology.GeoCellDataClient, mid: int, mi: shyft.time_series.ModelInfo) bool

Update the model-info for specified model-identifier(mid)

Parameters:
  • mid (int) – model-identifer

  • mi (ModelInfo) – The new updated model-info

Returns:

ok. true if success

Return type:

bool

class shyft.hydrology.GeoCellDataModel

Bases: pybind11_object

A model, with mandatory identifier and geo-cell-data vector. The optional filled in epsg, polygon and json members can provide useful information on how it was created, or can be presented.

__init__(self: shyft.hydrology.GeoCellDataModel) None
property epsg_id

EPSG code for the polygon coordinate reference system

Type:

int

property geo_cell_data

a strongly typed list of geo-cell-data, the geo-personality of Shyft cells

Type:

GeoCellDataVector

property id

unique model identifier

Type:

int

property json

extra useful json formatted information

Type:

str

property polygon

convex hull for the geo_cell_data

Type:

GeoPointVector

class shyft.hydrology.GeoCellDataModelVector

Bases: pybind11_object

A strongly typed list of GeoCellDataModel’s

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.GeoCellDataModelVector) -> None

  2. __init__(self: shyft.hydrology.GeoCellDataModelVector, arg0: shyft.hydrology.GeoCellDataModelVector) -> None

Copy constructor

  1. __init__(self: shyft.hydrology.GeoCellDataModelVector, arg0: Iterable) -> None

append(self: shyft.hydrology.GeoCellDataModelVector, x: shyft.hydrology.GeoCellDataModel) None

Add an item to the end of the list

clear(self: shyft.hydrology.GeoCellDataModelVector) None

Clear the contents

extend(*args, **kwargs)

Overloaded function.

  1. extend(self: shyft.hydrology.GeoCellDataModelVector, L: shyft.hydrology.GeoCellDataModelVector) -> None

Extend the list by appending all the items in the given list

  1. extend(self: shyft.hydrology.GeoCellDataModelVector, L: Iterable) -> None

Extend the list by appending all the items in the given list

insert(self: shyft.hydrology.GeoCellDataModelVector, i: int, x: shyft.hydrology.GeoCellDataModel) None

Insert an item at a given position.

pop(*args, **kwargs)

Overloaded function.

  1. pop(self: shyft.hydrology.GeoCellDataModelVector) -> shyft.hydrology.GeoCellDataModel

Remove and return the last item

  1. pop(self: shyft.hydrology.GeoCellDataModelVector, i: int) -> shyft.hydrology.GeoCellDataModel

Remove and return the item at index i

size(self: shyft.hydrology.GeoCellDataModelVector) int
class shyft.hydrology.GeoCellDataServer

Bases: pybind11_object

The server-side component for the shyft.hydrology geo_cell_data model repository.

__init__(self: shyft.hydrology.GeoCellDataServer, root_dir: str, config: shyft.time_series.ServerConfig = shyft.time_series.ServerConfig(stale_duration='1970-01-01T01:00:00Z', stale_sweep_interval='1970-01-01T00:00:00.100000Z', log=shyft.time_series.LogConfig(file='', level=200))) None

Creates a server object that serves models from root_dir. The root_dir will be create if it does not exists.

Parameters:
  • root_dir (str) – Path to the root-directory that keeps/will keep the model-files

  • config (ServerConfig) – Configuration of the server

get_listening_port(self: shyft.hydrology.GeoCellDataServer) int

returns the port number it’s listening at for serving incoming request

get_max_connections(self: shyft.hydrology.GeoCellDataServer) int

returns the maximum number of connections to be served concurrently

get_model_infos(self: shyft.hydrology.GeoCellDataServer, mids: list[int], created_in: shyft.time_series.UtcPeriod = [not-valid-period>) list[shyft.time_series.ModelInfo]

returns all or selected model-info objects based on model-identifiers(mids)

Parameters:
  • mids (IntVector) – empty = all, or a list of known exisiting model-identifiers

  • created_in (UtcPeriod) – For which period you are interested in model-infos.

Returns:

model_infos. Strongly typed list of ModelInfo

Return type:

ModelInfoVector

is_running(self: shyft.hydrology.GeoCellDataServer) bool

true if server is listening and running

See also

start_server()

read_model(self: shyft.hydrology.GeoCellDataServer, mid: int) shyft.hydrology.GeoCellDataModel

Read and return the model for specified model-identifier (mid)

Parameters:

mid (int) – the model-identifer for the wanted model

Returns:

  1. The resulting model from the server

Return type:

Model

read_model_blob(self: shyft.hydrology.GeoCellDataServer, mid: int) shyft.time_series.ByteVector

Read and return the model blob for specified model-identifier (mid)

Parameters:

mid (int) – the model-identifer for the wanted model

Returns:

  1. The resulting blob model from the server

Return type:

ByteVector

read_models(self: shyft.hydrology.GeoCellDataServer, mids: list[int]) shyft.hydrology.GeoCellDataModelVector

Read and return the model for specified model-identifier (mid)

Parameters:

mids (list[int]) – A strongly typed list of ints, the model-identifers for the wanted models

Returns:

  1. The resulting model from the server

Return type:

Model

remove_model(self: shyft.hydrology.GeoCellDataServer, mid: int) int

Remove the specified model bymodel-identifier (mid)

Parameters:

mid (int) – the model-identifer for the wanted model

Returns:

ec. 0 or error-code?

Return type:

int

set_listening_ip(self: shyft.hydrology.GeoCellDataServer, ip: str) None

set the listening port for the service

Parameters:

ip (str) – ip or host-name to start listening on

Returns:

nothing.

Return type:

None

set_listening_port(self: shyft.hydrology.GeoCellDataServer, port_no: int) None

set the listening port for the service

Parameters:
  • port_no (int) – a valid and available tcp-ip port number to listen on.

  • 20000 (typically it could be)

Returns:

nothing.

Return type:

None

set_max_connections(self: shyft.hydrology.GeoCellDataServer, max_connect: int) None

limits simultaneous connections to the server (it’s multithreaded, and uses on thread pr. connect)

Parameters:

max_connect (int) – maximum number of connections before denying more connections

See also

get_max_connections()

property stale_connection_close_count

returns count of connection closed due to stale/no communication activity

Type:

int

start_server(self: shyft.hydrology.GeoCellDataServer) int

start server listening in background, and processing messages

See also

set_listening_port(port_no),is_running

Returns:

port_no. the port used for listening operations, either the value as by set_listening_port, or if it was unspecified, a new available port

Return type:

in

stop_server(self: shyft.hydrology.GeoCellDataServer, timeout: int = 1000) None

stop serving connections, gracefully.

See also

start_server()

store_model(self: shyft.hydrology.GeoCellDataServer, m: shyft.hydrology.GeoCellDataModel, mi: shyft.time_series.ModelInfo) int

Store the model to backend, if m.id==0 then a new unique model-info is created and used

Parameters:
  • m (Model) – The model to store

  • mi (ModelInfo) – The model-info to store for the model

Returns:

mid. model-identifier for the stored model and model-info

Return type:

int

update_model_info(self: shyft.hydrology.GeoCellDataServer, mid: int, mi: shyft.time_series.ModelInfo) bool

Update the model-info for specified model-identifier(mid)

Parameters:
  • mid (int) – model-identifer

  • mi (ModelInfo) – The new updated model-info

Returns:

ok. true if success

Return type:

bool

class shyft.hydrology.GeoCellDataVector

Bases: pybind11_object

A vector, list, of GeoCellData

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.GeoCellDataVector) -> None

  2. __init__(self: shyft.hydrology.GeoCellDataVector, arg0: shyft.hydrology.GeoCellDataVector) -> None

Copy constructor

  1. __init__(self: shyft.hydrology.GeoCellDataVector, arg0: Iterable) -> None

append(self: shyft.hydrology.GeoCellDataVector, x: shyft.hydrology.GeoCellData) None

Add an item to the end of the list

clear(self: shyft.hydrology.GeoCellDataVector) None

Clear the contents

static deserialize(arg0: shyft.time_series.ByteVector) object

deserialize from a binary to GeoCellDataVector

extend(*args, **kwargs)

Overloaded function.

  1. extend(self: shyft.hydrology.GeoCellDataVector, L: shyft.hydrology.GeoCellDataVector) -> None

Extend the list by appending all the items in the given list

  1. extend(self: shyft.hydrology.GeoCellDataVector, L: Iterable) -> None

Extend the list by appending all the items in the given list

insert(self: shyft.hydrology.GeoCellDataVector, i: int, x: shyft.hydrology.GeoCellData) None

Insert an item at a given position.

polygon_buffer(self: shyft.hydrology.GeoCellDataVector, distance: float) shyft.time_series.GeoPointVector

Computes the polygon_buffer of tin points, or mid-points, using boost::geometry::buffer algorithm If number of points is large, currently > 50, a reduction algorithm using convex_hull is first applied

Parameters:

distance (float) – metric[m] buffer distance

Returns:

polygon. A closed polygon envelope around the cells in the model

Return type:

GeoPointVector

pop(*args, **kwargs)

Overloaded function.

  1. pop(self: shyft.hydrology.GeoCellDataVector) -> shyft.hydrology.GeoCellData

Remove and return the last item

  1. pop(self: shyft.hydrology.GeoCellDataVector, i: int) -> shyft.hydrology.GeoCellData

Remove and return the item at index i

serialize(self: shyft.hydrology.GeoCellDataVector) object

serialize to a binary byte vector

size(self: shyft.hydrology.GeoCellDataVector) int
class shyft.hydrology.GeoPointSource

Bases: pybind11_object

GeoPointSource contains common properties, functions for the point sources in Shyft. Typically it contains a GeoPoint (3d position), plus a time-series

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.GeoPointSource) -> None

  2. __init__(self: shyft.hydrology.GeoPointSource, midpoint: shyft.time_series.GeoPoint, ts: shyft.time_series.TimeSeries) -> None

  3. __init__(self: shyft.hydrology.GeoPointSource, geo_ts: shyft.time_series.GeoTimeSeries) -> None

property geo_ts

returns a GeoTimeSeries where the geo-point are copied, but time-series are by-reference

Type:

GeoTimeSeries

mid_point(self: shyft.hydrology.GeoPointSource) shyft.time_series.GeoPoint

returns a copy of mid_point

property mid_point_

reference to internal mid_point

property ts

time-series

Type:

TimeSeries

property uid

user specified identifier, string

Type:

str

class shyft.hydrology.GeoPointSourceVector

Bases: pybind11_object

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.GeoPointSourceVector) -> None

  2. __init__(self: shyft.hydrology.GeoPointSourceVector, arg0: shyft.hydrology.GeoPointSourceVector) -> None

Copy constructor

  1. __init__(self: shyft.hydrology.GeoPointSourceVector, arg0: Iterable) -> None

append(self: shyft.hydrology.GeoPointSourceVector, x: shyft.hydrology.GeoPointSource) None

Add an item to the end of the list

clear(self: shyft.hydrology.GeoPointSourceVector) None

Clear the contents

extend(*args, **kwargs)

Overloaded function.

  1. extend(self: shyft.hydrology.GeoPointSourceVector, L: shyft.hydrology.GeoPointSourceVector) -> None

Extend the list by appending all the items in the given list

  1. extend(self: shyft.hydrology.GeoPointSourceVector, L: Iterable) -> None

Extend the list by appending all the items in the given list

insert(self: shyft.hydrology.GeoPointSourceVector, i: int, x: shyft.hydrology.GeoPointSource) None

Insert an item at a given position.

pop(*args, **kwargs)

Overloaded function.

  1. pop(self: shyft.hydrology.GeoPointSourceVector) -> shyft.hydrology.GeoPointSource

Remove and return the last item

  1. pop(self: shyft.hydrology.GeoPointSourceVector, i: int) -> shyft.hydrology.GeoPointSource

Remove and return the item at index i

size(self: shyft.hydrology.GeoPointSourceVector) int
values_at_time(self: shyft.hydrology.GeoPointSourceVector, arg0: shyft.time_series.time) list[float]
class shyft.hydrology.GlacierMeltParameter

Bases: pybind11_object

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.GlacierMeltParameter) -> None

  2. __init__(self: shyft.hydrology.GlacierMeltParameter, dtf: float, direct_response: float = 0.0) -> None

property direct_response

fraction that goes as direct response, (1-fraction) is routed through soil/kirchner routine,default=0.0

Type:

float

property dtf

degree timestep factor, default=6.0 [mm/day/degC]

Type:

float

class shyft.hydrology.GoalFunctionClient

Bases: pybind11_object

The client api for the shyft.hydrology goal-function model service.

__init__(self: shyft.hydrology.GoalFunctionClient, host_port: str, timeout_ms: int, operation_timeout_ms: int = 0) None

Creates a python client that can communicate with the corresponding server

close(self: shyft.hydrology.GoalFunctionClient) None

Close the connection. It will automatically reopen if needed.

get_model_infos(self: shyft.hydrology.GoalFunctionClient, mids: list[int], created_in: shyft.time_series.UtcPeriod = [not-valid-period>) list[shyft.time_series.ModelInfo]

returns all or selected model-info objects based on model-identifiers(mids)

Parameters:
  • mids (IntVector) – empty = all, or a list of known exisiting model-identifiers

  • created_in (UtcPeriod) – For which period you are interested in model-infos.

Returns:

model_infos. Strongly typed list of ModelInfo

Return type:

ModelInfoVector

property host_port

Endpoint network address of the remote server.

Type:

str

property is_open

If the connection to the remote server is (still) open.

Type:

bool

property operation_timeout_ms

Operation timeout for remote server operations, in number milliseconds.

Type:

int

read_model(self: shyft.hydrology.GoalFunctionClient, mid: int) shyft.hydrology.GoalFunctionModel

Read and return the model for specified model-identifier (mid)

Parameters:

mid (int) – the model-identifer for the wanted model

Returns:

  1. The resulting model from the server

Return type:

Model

read_models(self: shyft.hydrology.GoalFunctionClient, mids: list[int]) shyft.hydrology.GoalFunctionModelVector

Read and return the model for specified model-identifier (mid)

Parameters:

mids (list[int]) – A strongly typed list of ints, the model-identifers for the wanted models

Returns:

  1. The resulting model from the server

Return type:

Model

property reconnect_count

Number of reconnects to the remote server that have been performed.

Type:

int

remove_model(self: shyft.hydrology.GoalFunctionClient, mid: int) int

Remove the specified model bymodel-identifier (mid)

Parameters:

mid (int) – the model-identifer for the wanted model

Returns:

ec. 0 or error-code?

Return type:

int

store_model(self: shyft.hydrology.GoalFunctionClient, m: shyft.hydrology.GoalFunctionModel, mi: shyft.time_series.ModelInfo) int

Store the model to backend, if m.id==0 then a new unique model-info is created and used

Parameters:
  • m (Model) – The model to store

  • mi (ModelInfo) – The model-info to store for the model

Returns:

mid. model-identifier for the stored model and model-info

Return type:

int

property timeout_ms

Timout for remote server operations, in number milliseconds.

Type:

int

update_model_info(self: shyft.hydrology.GoalFunctionClient, mid: int, mi: shyft.time_series.ModelInfo) bool

Update the model-info for specified model-identifier(mid)

Parameters:
  • mid (int) – model-identifer

  • mi (ModelInfo) – The new updated model-info

Returns:

ok. true if success

Return type:

bool

class shyft.hydrology.GoalFunctionModel

Bases: pybind11_object

A model identifier and goal-funcions, aka TargetSpecificationVector used in Shyft region model calibrations. This plays the role of the goal-function specification for shyft region-models, so that they can be calibrated, and measured against observed quantities.

__init__(self: shyft.hydrology.GoalFunctionModel) None
property goal_functions

The goal functions

Type:

TargetSpecificationVector

property id

unique model id

Type:

int

class shyft.hydrology.GoalFunctionModelVector

Bases: pybind11_object

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.GoalFunctionModelVector) -> None

  2. __init__(self: shyft.hydrology.GoalFunctionModelVector, arg0: shyft.hydrology.GoalFunctionModelVector) -> None

Copy constructor

  1. __init__(self: shyft.hydrology.GoalFunctionModelVector, arg0: Iterable) -> None

append(self: shyft.hydrology.GoalFunctionModelVector, x: shyft.hydrology.GoalFunctionModel) None

Add an item to the end of the list

clear(self: shyft.hydrology.GoalFunctionModelVector) None

Clear the contents

extend(*args, **kwargs)

Overloaded function.

  1. extend(self: shyft.hydrology.GoalFunctionModelVector, L: shyft.hydrology.GoalFunctionModelVector) -> None

Extend the list by appending all the items in the given list

  1. extend(self: shyft.hydrology.GoalFunctionModelVector, L: Iterable) -> None

Extend the list by appending all the items in the given list

insert(self: shyft.hydrology.GoalFunctionModelVector, i: int, x: shyft.hydrology.GoalFunctionModel) None

Insert an item at a given position.

pop(*args, **kwargs)

Overloaded function.

  1. pop(self: shyft.hydrology.GoalFunctionModelVector) -> shyft.hydrology.GoalFunctionModel

Remove and return the last item

  1. pop(self: shyft.hydrology.GoalFunctionModelVector, i: int) -> shyft.hydrology.GoalFunctionModel

Remove and return the item at index i

size(self: shyft.hydrology.GoalFunctionModelVector) int
class shyft.hydrology.GoalFunctionServer

Bases: pybind11_object

The server-side component for the goal-function model repository.

__init__(self: shyft.hydrology.GoalFunctionServer, root_dir: str, config: shyft.time_series.ServerConfig = shyft.time_series.ServerConfig(stale_duration='1970-01-01T01:00:00Z', stale_sweep_interval='1970-01-01T00:00:00.100000Z', log=shyft.time_series.LogConfig(file='', level=200))) None

Creates a server object that serves models from root_dir. The root_dir will be create if it does not exists.

Parameters:
  • root_dir (str) – Path to the root-directory that keeps/will keep the model-files

  • config (ServerConfig) – Configuration of the server

get_listening_port(self: shyft.hydrology.GoalFunctionServer) int

returns the port number it’s listening at for serving incoming request

get_max_connections(self: shyft.hydrology.GoalFunctionServer) int

returns the maximum number of connections to be served concurrently

get_model_infos(self: shyft.hydrology.GoalFunctionServer, mids: list[int], created_in: shyft.time_series.UtcPeriod = [not-valid-period>) list[shyft.time_series.ModelInfo]

returns all or selected model-info objects based on model-identifiers(mids)

Parameters:
  • mids (IntVector) – empty = all, or a list of known exisiting model-identifiers

  • created_in (UtcPeriod) – For which period you are interested in model-infos.

Returns:

model_infos. Strongly typed list of ModelInfo

Return type:

ModelInfoVector

is_running(self: shyft.hydrology.GoalFunctionServer) bool

true if server is listening and running

See also

start_server()

read_model(self: shyft.hydrology.GoalFunctionServer, mid: int) shyft.hydrology.GoalFunctionModel

Read and return the model for specified model-identifier (mid)

Parameters:

mid (int) – the model-identifer for the wanted model

Returns:

  1. The resulting model from the server

Return type:

Model

read_model_blob(self: shyft.hydrology.GoalFunctionServer, mid: int) shyft.time_series.ByteVector

Read and return the model blob for specified model-identifier (mid)

Parameters:

mid (int) – the model-identifer for the wanted model

Returns:

  1. The resulting blob model from the server

Return type:

ByteVector

read_models(self: shyft.hydrology.GoalFunctionServer, mids: list[int]) shyft.hydrology.GoalFunctionModelVector

Read and return the model for specified model-identifier (mid)

Parameters:

mids (list[int]) – A strongly typed list of ints, the model-identifers for the wanted models

Returns:

  1. The resulting model from the server

Return type:

Model

remove_model(self: shyft.hydrology.GoalFunctionServer, mid: int) int

Remove the specified model bymodel-identifier (mid)

Parameters:

mid (int) – the model-identifer for the wanted model

Returns:

ec. 0 or error-code?

Return type:

int

set_listening_ip(self: shyft.hydrology.GoalFunctionServer, ip: str) None

set the listening port for the service

Parameters:

ip (str) – ip or host-name to start listening on

Returns:

nothing.

Return type:

None

set_listening_port(self: shyft.hydrology.GoalFunctionServer, port_no: int) None

set the listening port for the service

Parameters:
  • port_no (int) – a valid and available tcp-ip port number to listen on.

  • 20000 (typically it could be)

Returns:

nothing.

Return type:

None

set_max_connections(self: shyft.hydrology.GoalFunctionServer, max_connect: int) None

limits simultaneous connections to the server (it’s multithreaded, and uses on thread pr. connect)

Parameters:

max_connect (int) – maximum number of connections before denying more connections

See also

get_max_connections()

property stale_connection_close_count

returns count of connection closed due to stale/no communication activity

Type:

int

start_server(self: shyft.hydrology.GoalFunctionServer) int

start server listening in background, and processing messages

See also

set_listening_port(port_no),is_running

Returns:

port_no. the port used for listening operations, either the value as by set_listening_port, or if it was unspecified, a new available port

Return type:

in

stop_server(self: shyft.hydrology.GoalFunctionServer, timeout: int = 1000) None

stop serving connections, gracefully.

See also

start_server()

store_model(self: shyft.hydrology.GoalFunctionServer, m: shyft.hydrology.GoalFunctionModel, mi: shyft.time_series.ModelInfo) int

Store the model to backend, if m.id==0 then a new unique model-info is created and used

Parameters:
  • m (Model) – The model to store

  • mi (ModelInfo) – The model-info to store for the model

Returns:

mid. model-identifier for the stored model and model-info

Return type:

int

update_model_info(self: shyft.hydrology.GoalFunctionServer, mid: int, mi: shyft.time_series.ModelInfo) bool

Update the model-info for specified model-identifier(mid)

Parameters:
  • mid (int) – model-identifer

  • mi (ModelInfo) – The new updated model-info

Returns:

ok. true if success

Return type:

bool

shyft.hydrology.HbvActualEvapotranspirationCalculate_step(soil_moisture: float, potential_evapotranspiration: float, lp: float, snow_fraction: float, dt: shyft.time_series.time) float

actual_evapotranspiration calculates actual evapotranspiration, returning same unit as input pot.evap based on supplied parameters, formula like (1.0 - snow_fraction)*(soil_moisture < lp ? pot_evapo*(soil_moisture / lp):pot_evapo)

Parameters:
  • () (dt) – [mm] water level eqvivalent in ground, ae goes to zero if ground is drying out

  • () – [mm/x], x time-unit

  • () – [mm] soil_moisture threshold, lp typically 150

  • () – 0..1 there is to ae over snow surface, so snow_fraction 1.0, yields 0.0

  • () – [s] timestep length, currently not part of the formula

Returns:

actual evapotranspiration.

class shyft.hydrology.HbvActualEvapotranspirationParameter

Bases: pybind11_object

__init__(self: shyft.hydrology.HbvActualEvapotranspirationParameter, lp: float = 150.0) None
property lp

typical value 150

Type:

float

class shyft.hydrology.HbvActualEvapotranspirationResponse

Bases: pybind11_object

__init__(self: shyft.hydrology.HbvActualEvapotranspirationResponse) None
property ae

ae value

Type:

float

class shyft.hydrology.HbvPhysicalSnowCalculator

Bases: pybind11_object

Generalized quantile based HBV Physical Snow model method

This algorithm uses arbitrary quartiles to model snow. No checks are performed to assert valid input. The starting points of the quantiles have to partition the unity, include the end points 0 and 1 and must be given in ascending order.

__init__(self: shyft.hydrology.HbvPhysicalSnowCalculator, parameter: shyft.hydrology.HbvPhysicalSnowParameter) None

creates a calculator with given parameter and initial state, notice that state is updated in this call(hmm)

step(self: shyft.hydrology.HbvPhysicalSnowCalculator, state: shyft.hydrology.HbvPhysicalSnowState, response: shyft.hydrology.HbvPhysicalSnowResponse, t: shyft.time_series.time, dt: shyft.time_series.time, temperature: float, rad: float, prec_mm_h: float, wind_speed: float, rel_hum: float) None

steps the model forward from t to t+dt, updating state and response

class shyft.hydrology.HbvPhysicalSnowParameter

Bases: pybind11_object

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.HbvPhysicalSnowParameter, tx: float = 0.0, lw: float = 0.1, cfr: float = 0.5, wind_scale: float = 2.0, wind_const: float = 1.0, surface_magnitude: float = 30.0, max_albedo: float = 0.9, min_albedo: float = 0.6, fast_albedo_decay_rate: float = 5.0, slow_albedo_decay_rate: float = 5.0, snowfall_reset_depth: float = 5.0, calculate_iso_pot_energy: bool = False) -> None

  2. __init__(self: shyft.hydrology.HbvPhysicalSnowParameter, snow_redist_factors: list[float], quantiles: list[float], tx: float = 0.0, lw: float = 0.1, cfr: float = 0.5, wind_scale: float = 2.0, wind_const: float = 1.0, surface_magnitude: float = 30.0, max_albedo: float = 0.9, min_albedo: float = 0.6, fast_albedo_decay_rate: float = 5.0, slow_albedo_decay_rate: float = 5.0, snowfall_reset_depth: float = 5.0, calculate_iso_pot_energy: bool = False) -> None

create a parameter with snow re-distribution factors, quartiles and optionally the other parameters

property calculate_iso_pot_energy

whether or not to calculate the potential energy flux

Type:

float

property cfr

cfr

Type:

float

property fast_albedo_decay_rate

albedo decay rate during melt [days]

Type:

float

property intervals

snow quantiles list default 0, 0.25 0.5 1.0

Type:

DoubleVector

property lw

max liquid water content of the snow

Type:

float

property max_albedo

maximum albedo value

Type:

float

property min_albedo

minimum albedo value

Type:

float

property s

snow redistribution factors,default =1.0..

Type:

DoubleVector

set_snow_quantiles(self: shyft.hydrology.HbvPhysicalSnowParameter, quantiles: list[float]) None
set_snow_redistribution_factors(self: shyft.hydrology.HbvPhysicalSnowParameter, snow_redist_factors: list[float]) None
property slow_albedo_decay_rate

albedo decay rate in cold conditions [days]

Type:

float

property snowfall_reset_depth

snowfall required to reset albedo [mm]

Type:

float

property surface_magnitude

surface layer magnitude

Type:

float

property tx

threshold temperature determining if precipitation is rain or snow

Type:

float

property wind_const

intercept in turbulent wind function

Type:

float

property wind_scale

slope in turbulent wind function [m/s]

Type:

float

class shyft.hydrology.HbvPhysicalSnowResponse

Bases: pybind11_object

__init__(self: shyft.hydrology.HbvPhysicalSnowResponse) None
property hps_state

current state instance

Type:

HbvPhysicalSnowState

property outflow

from snow-routine in [mm]

Type:

float

property sca

snow-covered area

Type:

float

property storage

snow storage [mm]

Type:

float

class shyft.hydrology.HbvPhysicalSnowState

Bases: pybind11_object

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.HbvPhysicalSnowState) -> None

  2. __init__(self: shyft.hydrology.HbvPhysicalSnowState, albedo: list[float], iso_pot_energy: list[float], surface_heat: float = 30000.0, swe: float = 0.0, sca: float = 0.0) -> None

property albedo

albedo (Broadband snow reflectivity fraction)

Type:

float

distribute(self: shyft.hydrology.HbvPhysicalSnowState, p: shyft.hydrology.HbvPhysicalSnowParameter, force: bool = True) None

Distribute state according to parameter settings.

Parameters:
  • p (HbvPhysicalSnowParameter) – descr

  • force (bool) – default true, if false then only distribute if state vectors are of different size than parameters passed

Returns:

.

Return type:

None

property iso_pot_energy

iso_pot_energy (Accumulated energy assuming isothermal snow surface) [J/m2]

Type:

float

property sca

snow covered area [0..1]

Type:

float

property sp

snow dry[mm]

Type:

DoubleVector

property surface_heat

surface_heat (Snow surface cold content) [J/m2]

Type:

float

property sw

snow water[mm]

Type:

DoubleVector

property swe

snow water equivalent[mm]

Type:

float

class shyft.hydrology.HbvSnowCalculator

Bases: pybind11_object

Generalized quantile based HBV Snow model method

This algorithm uses arbitrary quartiles to model snow. No checks are performed to assert valid input. The starting points of the quantiles have to partition the unity, include the end points 0 and 1 and must be given in ascending order.

__init__(self: shyft.hydrology.HbvSnowCalculator, parameter: shyft.hydrology.HbvSnowParameter) None
step(self: shyft.hydrology.HbvSnowCalculator, state: shyft.hydrology.HbvSnowState, response: shyft.hydrology.HbvSnowResponse, t0: shyft.time_series.time, t1: shyft.time_series.time, precipitation: float, temperature: float) None

steps the model forward from t0 to t1, updating state and response

class shyft.hydrology.HbvSnowParameter

Bases: pybind11_object

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.HbvSnowParameter, tx: float = 0.0, cx: float = 1.0, ts: float = 0.0, lw: float = 0.1, cfr: float = 0.5) -> None

  2. __init__(self: shyft.hydrology.HbvSnowParameter, snow_redist_factors: list[float], quantiles: list[float], tx: float = 0.0, cx: float = 1.0, ts: float = 0.0, lw: float = 0.1, cfr: float = 0.5) -> None

create a parameter with snow re-distribution factors, quartiles and optionally the other parameters

property cfr

cfr

Type:

float

property cx

temperature index, i.e., melt = cx(t - ts) in mm per degree C

Type:

float

property intervals

snow quantiles list default 0, 0.25 0.5 1.0

Type:

DoubleVector

property lw

max liquid water content of the snow

Type:

float

property s

snow redistribution factors,default =1.0..

Type:

DoubleVector

set_snow_quantiles(self: shyft.hydrology.HbvSnowParameter, quantiles: list[float]) None
set_snow_redistribution_factors(self: shyft.hydrology.HbvSnowParameter, snow_redist_factors: list[float]) None
property ts

threshold temperature for melt onset

Type:

float

property tx

threshold temperature determining if precipitation is rain or snow

Type:

float

class shyft.hydrology.HbvSnowResponse

Bases: pybind11_object

__init__(self: shyft.hydrology.HbvSnowResponse) None
property outflow

from snow-routine in [mm]

Type:

float

property snow_state

swe and snow covered area

Type:

HbvSnowState

class shyft.hydrology.HbvSnowState

Bases: pybind11_object

__init__(self: shyft.hydrology.HbvSnowState, swe: float = 0.0, sca: float = 0.0) None
distribute(self: shyft.hydrology.HbvSnowState, p: shyft.hydrology.HbvSnowParameter, force: bool = True) None

Distribute state according to parameter settings.

Parameters:
  • p (HbvSnowParameter) – descr

  • force (bool) – default true, if false then only distribute if state vectors are of different size than parameters passed

Returns:

.

Return type:

None

property sca

snow covered area [0..1]

Type:

float

property sp

snow dry[mm]

Type:

DoubleVector

property sw

snow water[mm]

Type:

DoubleVector

property swe

snow water equivalent[mm]

Type:

float

class shyft.hydrology.HbvSoilCalculator

Bases: pybind11_object

Computing water through the soil moisture zone of the HBV model.

Reference:

Notes

Lake and glacier are treated in the stack

__init__(self: shyft.hydrology.HbvSoilCalculator, parameter: shyft.hydrology.HbvSoilParameter, land_fraction: float) None
step(self: shyft.hydrology.HbvSoilCalculator, state: shyft.hydrology.HbvSoilState, response: shyft.hydrology.HbvSoilResponse, insoil: float, pe: float, sca: float) None

One step of the model, given state, parameters and input.

Updates the state and response.

Parameters:
  • state (HbvSoilState) – param of type S, in/out, ref template parameters

  • response (HbvSoilResponse) – param of type R, in/out, ref template parameters

  • insoil (float) – inflow to soil

  • pe (float) – potential evaporation

  • sca (float) – the response , out parameter.

  • land_fraction (float) – Land-fraction of the cell. Not directly used/desribed in ref. ‘Nils Roar’, but introduced here to adopt to the stack.

class shyft.hydrology.HbvSoilParameter

Bases: pybind11_object

__init__(self: shyft.hydrology.HbvSoilParameter, fc: float = 32.2755689, beta: float = 1.50738409) None
property beta

(unitless) exponent in the nonlinear relationship between soil moisture and field capacity. default=1.50738409

Type:

float

property fc
  1. maximum water content of the soil (Field Capacity), default=32.2755689

Type:

float

property infmax

(mm/h) maximum input rate to the soil moisture zone. Excess water will go directly to upper ground water zone. default=2.0

Type:

float

property lpdel

(unitless) dimensionless parameter (<1), from which level evapotranspiration is potential. Some publications use fcdel instead. default= 0.848557794

Type:

float

class shyft.hydrology.HbvSoilResponse

Bases: pybind11_object

__init__(self: shyft.hydrology.HbvSoilResponse, inuz: float = 0.0, ae: float = 0.0) None
property ae

(mm/h) Actual evapotranspiration. default=0

Type:

float

property inuz

(mm/h) Perculation to upper ground water zone. Called cuz by Nils Roar. default=0

Type:

float

class shyft.hydrology.HbvSoilState

Bases: pybind11_object

__init__(self: shyft.hydrology.HbvSoilState, sm: float = 10.0) None
property sm

Soil moisture [mm]. default=10

Type:

float

class shyft.hydrology.HbvTankCalculator

Bases: pybind11_object

Computing water through the HBV ground water zone of the HBV model.

Reference:

Notes

Lake and glacier are treated in the stack

__init__(self: shyft.hydrology.HbvTankCalculator, parameter: shyft.hydrology.HbvTankParameter, lake_fraction: float) None

creates a calculator with given parameters

step(self: shyft.hydrology.HbvTankCalculator, state: shyft.hydrology.HbvTankState, response: shyft.hydrology.HbvTankResponse, from_soil: float, precip: float, t2m: float) None

One step of the model, given state, parameters and input.

Updates the state and response.

Parameters:
  • state (HbvSoilState) – param of type S, in/out, ref template parameters

  • response (HbvSoilResponse) – param of type R, in/out, ref template parameters

  • from_soil (float) – [mm/step] Inflow to upper zone (from soil moisture)

  • precip (float) – [mm/step] Routed precipitation. Assumed that it is corrected for lake fraction already.

  • t2m (float) – [deg C] Air-temperature at 2m (proxy for water temperature)

  • lake_fraction (float) – [unitless] Lake-fraction of the cell. Not directly used/desribed in ref.’Nils Roar’, but introduced here to adopt to the stack.

class shyft.hydrology.HbvTankParameter

Bases: pybind11_object

__init__(self: shyft.hydrology.HbvTankParameter, uz1: float = 10.0, uz2: float = 50.0, kuz0: float = 0.05, kuz1: float = 0.1, kuz2: float = 0.0, perc: float = 0.6, klz: float = 0.05, ce: float = 0.007083333333333334, cevpl: float = 1.1) None
property ce

[ mm/deg/day ] Evapotranspiration constant (degree-day-factor). default=0.17/24

Type:

float

property cevpl

[ unitless ], adjustment factor for potential evapotranspiration on lakes. default=1.1

Type:

float

property klz

[ 1/step ] Slow response coefficient lower ground water zone. default=0.05

Type:

float

property kuz0

[ 1/step ] Slow response coefficient upper ground water zone. default=0.05

Type:

float

property kuz1

[ 1/step ] Mid response coefficient upper ground water zone. default=0.1

Type:

float

property kuz2

[ 1/step ] Fast response coefficient upper ground water zone. default=0 (not active)

Type:

float

property perc

[ mm/step ] Perculation to lower ground water zone. default=0.6

Type:

float

property uz1

[ mm ] Mid-threshold for upper ground water zone. default=10

Type:

float

property uz2

[ mm ] High-threshold for upper ground water zone. default=50

Type:

float

class shyft.hydrology.HbvTankResponse

Bases: pybind11_object

__init__(self: shyft.hydrology.HbvTankResponse, quz0: float = 0.0, quz1: float = 0.0, quz2: float = 0.0, qlz: float = 0.0, elake: float = 0.0, perculation: float = 0.0) None
property elake

[ mm/step ] Evaporation from lake

Type:

float

property perculation

[ mm/step ] Effective perculation from upper to lower

Type:

float

property q

[mm/step] Total discharge from tank

Type:

float

property qlz

[mm/step] Total for lower zone

Type:

float

property quz

[mm/step] Total for upper zone

Type:

float

property quz0

[mm/step] Upper zone slow response

Type:

float

property quz1

[mm/step] Upper zone mid response

Type:

float

property quz2

[mm/step] Upper zone fast response

Type:

float

class shyft.hydrology.HbvTankState

Bases: pybind11_object

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.HbvTankState) -> None

  2. __init__(self: shyft.hydrology.HbvTankState, uz: float = 10, lz: float = 10) -> None

create a state with specified values

property lz

Lower ground water zone content [mm]

Type:

float

property uz

Upper ground water zone content [mm]

Type:

float

class shyft.hydrology.IDWParameter

Bases: pybind11_object

IDWParameter is a simple place-holder for IDW parameters used during interpolation process. The two most common is max_distance and max_members. Additionally it keep distance measure-factor, so that the IDW distance is computed as 1 over pow(euclid distance,distance_measure_factor). zscale is used to discriminate neighbors that are at different elevation than target point.

__init__(self: shyft.hydrology.IDWParameter, max_members: int = 10, max_distance: float = 200000.0, distance_measure_factor: float = 2.0) None
property distance_measure_factor

IDW distance is computed as 1 over pow(euclid distance,distance_measure_factor), default=2.0

Type:

float

property max_distance

[meter] only neighbours within max distance is used for each destination-cell,default= 200000.0

Type:

float

property max_members

maximum members,neighbors used to interpolate into a point,default=10

Type:

int

property zscale

Use to weight neighbors having same elevation, default=1.0

Type:

float

class shyft.hydrology.IDWPrecipitationParameter

Bases: IDWParameter

For precipitation,the scaling model needs the scale_factor. adjusted_precipitation = precipitation* (scale_factor)^(z-distance-in-meters/100.0) Ref to IDWParameter for the other parameters

__init__(self: shyft.hydrology.IDWPrecipitationParameter, scale_factor: float = 1.02, max_members: int = 20, max_distance: float = 200000.0) None
property scale_factor

ref. formula for adjusted_precipitation, default=1.02

Type:

float

class shyft.hydrology.IDWTemperatureParameter

Bases: IDWParameter

For temperature inverse distance, also provide default temperature gradient to be used when the gradient can not be computed, or is outside specified limits. if gradient_by_equation is set true, and number of points >3, the temperature gradient computer will try to use the 4 closest points and determine the 3d gradient including the vertical gradient. In scenarios with constant gradients(vertical/horizontal), this is accurate) If the number of valide nearby points is to few to do the full gradient equation, or the gradient_by_equation is set to False, then the two points with maximum vertical distance (required to be more than the minimum_z_distance) is used to compute the gradient. If all of the above fails, the default-gradient is used. Please note: Carefully selecting the maximum horizontal distances, and number of neighbors is required to get optimal results. In case of non-grid, or sparse-grid scenarios, you might consider setting the parameters to enforce default-gradient or you can also consider using the bayesian temperature krieging algorithm if there are few temperature sources

__init__(self: shyft.hydrology.IDWTemperatureParameter, default_gradient: float = -0.006, max_members: int = 20, max_distance: float = 200000.0, gradient_by_equation: bool = False, minimum_z_distance: float = 50, gradient_min: float = -0.01, gradient_max: float = 0.01) None

construct IDW for temperature as specified by arguments

property default_temp_gradient

[degC/m], default=-0.006

Type:

float

property gradient_by_equation

if true, gradient is computed using 4 closest neighbors, solving equations to find 3D temperature gradients.

Type:

bool

property gradient_max

[degC/m] default +0.01, if computed gradient larger than this, the default-gradient is used instead

Type:

float

property gradient_min

[degC/m] default -0.01, if computed gradient less than this, the default-gradient is used instead

Type:

float

property minimum_z_distance

[m] default 50m, the minimum vertical distance requirement for two points to be used for gradient computation

Type:

float

class shyft.hydrology.InterpolationParameter

Bases: pybind11_object

The InterpolationParameter keep parameters needed to perform the interpolation steps, IDW,BTK etc It is used as parameter in the model.run_interpolation() method

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.InterpolationParameter) -> None

  2. __init__(self: shyft.hydrology.InterpolationParameter, temperature: shyft.hydrology.BTKParameter, precipitation: shyft.hydrology.IDWPrecipitationParameter, wind_speed: shyft.hydrology.IDWParameter, radiation: shyft.hydrology.IDWParameter, rel_hum: shyft.hydrology.IDWParameter) -> None

  3. __init__(self: shyft.hydrology.InterpolationParameter, temperature: shyft.hydrology.IDWTemperatureParameter, precipitation: shyft.hydrology.IDWPrecipitationParameter, wind_speed: shyft.hydrology.IDWParameter, radiation: shyft.hydrology.IDWParameter, rel_hum: shyft.hydrology.IDWParameter) -> None

property precipitation

IDW parameters for precipitation

Type:

IDWPrecipitationParameter

property radiation

IDW parameters for radiation

Type:

IDWParameter

property rel_hum

IDW parameters for relative humidity

Type:

IDWParameter

property temperature

BTK for temperature (in case .use_idw_for_temperature is false)

Type:

BTKParameter

property temperature_idw

IDW for temperature(in case .use_idw_for_temperature is true)

Type:

IDWTemperatureParameter

property use_idw_for_temperature

if true, the IDW temperature is used instead of BTK, useful for grid-input scenarios

Type:

bool

property wind_speed

IDW parameters for wind_speed

Type:

IDWParameter

class shyft.hydrology.KalmanBiasPredictor

Bases: pybind11_object

A bias predictor using a daily pattern KalmanFilter for temperature (etc.) (tbd)

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.KalmanBiasPredictor) -> None

  2. __init__(self: shyft.hydrology.KalmanBiasPredictor, filter: shyft.hydrology.KalmanFilter) -> None

  3. __init__(self: shyft.hydrology.KalmanBiasPredictor, filter: shyft.hydrology.KalmanFilter, state: shyft.hydrology.KalmanState) -> None

compute_running_bias(self: shyft.hydrology.KalmanBiasPredictor, arg0: shyft.time_series.TimeSeries, arg1: shyft.time_series.TimeSeries, arg2: shyft.time_series.TimeAxis) shyft.time_series.TimeSeries
static compute_running_bias_ts(bias_predictor: shyft.hydrology.KalmanBiasPredictor, forecast_ts: shyft.time_series.TimeSeries, observation_ts: shyft.time_series.TimeSeries, time_axis: shyft.time_series.TimeAxis) shyft.time_series.TimeSeries

compute the running bias timeseries, using one ‘merged’ - forecasts and one observation time - series.

Before each day - period, the bias - values are copied out to form a continuous bias prediction time-series.

Parameters:
  • bias_predictor (KalmanBiasPredictor) – The bias predictor object it self

  • forecast_ts (TimeSeries) – a merged forecast ts, with period covering the observation_ts and time_axis supplied

  • observation_ts (TimeSeries) – the observation time-series

  • time_axis (TimeAxis) – covering the period/timesteps to be updated, e.g. yesterday, 3h resolution steps, according to the points in the filter

Returns:

bias_ts. With ts( time_axis,bias_vector,POINT_AVERAGE), computed running bias-ts

Return type:

TimeSeries

property filter
property state
update_with_forecast(*args, **kwargs)

Overloaded function.

  1. update_with_forecast(self: shyft.hydrology.KalmanBiasPredictor, arg0: shyft.hydrology.TemperatureSourceVector, arg1: shyft.time_series.TimeSeries, arg2: shyft.time_series.TimeAxis) -> None

  2. update_with_forecast(self: shyft.hydrology.KalmanBiasPredictor, arg0: list[shyft.time_series.TimeSeries], arg1: shyft.time_series.TimeSeries, arg2: shyft.time_series.TimeAxis) -> None

update_with_forecast_vector(self: shyft.hydrology.KalmanBiasPredictor, temperature_sources: list[shyft.time_series.TimeSeries], observation_ts: shyft.time_series.TimeSeries, time_axis: shyft.time_series.TimeAxis) None

update the bias-predictor with forecasts and observation After the update, the state is updated with new kalman estimates for the bias, .state.x

Parameters:
  • temperature_sources (TsVector) – a set of forecasts, in the order oldest to the newest.With the periods covering parts of the observation_ts and time_axis supplied

  • observation_ts (TimeSeries) – the observation time-series

  • time_axis (TimeAxis) – covering the period/timesteps to be updated, e.g. yesterday, 3h resolution steps, according to the points in the filter

update_with_geo_forecast(self: shyft.hydrology.KalmanBiasPredictor, temperature_sources: shyft.hydrology.TemperatureSourceVector, observation_ts: shyft.time_series.TimeSeries, time_axis: shyft.time_series.TimeAxis) None

update the bias-predictor with forecasts and observation After the update, the state is updated with new kalman estimates for the bias, .state.x

Parameters:
  • temperature_sources (TemperatureSourceVector) – ta set of forecasts, in the order oldest to the newest.Note that the geo part of source is not used in this context, only the tswith periods covering parts of the observation_ts and time_axis supplied

  • observation_ts (Timeseries) – the observation time-series

  • time_axis (TimeAxis) – covering the period/timesteps to be updated,e.g. yesterday, 3h resolution steps, according to the points in the filter

class shyft.hydrology.KalmanFilter

Bases: pybind11_object

Specialized kalman filter for temperature (e.g.:solar-driven bias patterns) The observation point(t, v) is folded on to corresponding period of the day(number of periods in a day is parameterized, typically 8). A simplified kalman filter algorithm using the forecast bias as the state - variable. Observed bias(fc - obs) is feed into the filter and establishes the kalman best predicted estimates(x) for the bias. This bias can then be used as a correction to forecast in the future to compensate for systematic forecast errors. Credits: Thanks to met.no for providing the original source for this algorithm.

__init__(self: shyft.hydrology.KalmanFilter, p: shyft.hydrology.KalmanParameter = KalmanParameter(n_daily_observations=8, hourly_correlation=0.93, covariance_init=0.5, std_error_bias_measurements=2, ratio_std_w_over_v=0.15)) None
create_initial_state(self: shyft.hydrology.KalmanFilter) shyft.hydrology.KalmanState
property parameter
update(self: shyft.hydrology.KalmanFilter, observed_bias: float, t: shyft.time_series.time, state: shyft.hydrology.KalmanState) None

update the with the observed_bias for a specific period starting at utctime t

Parameters:
  • observed_bias (float) – nan if no observation is available otherwise obs - fc

  • t (time) – utctime of the start of the observation period, this filter utilizes daily solar patterns, so time in day - cycle is the only important aspect.

  • state (KalmanState) – contains the kalman state,that is updated by the function upon return

class shyft.hydrology.KalmanParameter

Bases: pybind11_object

Defines the parameters that is used to tune the kalman-filter algorithm for temperature type of signals

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.KalmanParameter, n_daily_observations: int = 8, hourly_correlation: float = 0.93, covariance_init: float = 0.5, std_error_bias_measurements: float = 2.0, ratio_std_w_over_v: float = 0.15) -> None

Constructs KalmanParameter with default or supplied values

  1. __init__(self: shyft.hydrology.KalmanParameter, const_ref: shyft.hydrology.KalmanParameter) -> None

clone the supplied KalmanParameter

property covariance_init

default=0.5, for the error covariance P matrix start-values

Type:

float

property hourly_correlation

default=0.93, correlation from one-hour to the next

Type:

float

property n_daily_observations

default = 8 each 24hour, every 3 hour

Type:

int

property ratio_std_w_over_v

default=0.06, st.dev W /st.dev V ratio

Type:

float

property std_error_bias_measurements

default=2.0, st.dev for the bias measurements

Type:

float

class shyft.hydrology.KalmanState

Bases: pybind11_object

keeps the state of the specialized kalman-filter: * x : vector[n=n_daily_observations] best estimate * k : vector[n], gain factors * P : matrix[nxn], covariance * W : noise[nxn]

property P
property W
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.KalmanState) -> None

  2. __init__(self: shyft.hydrology.KalmanState, n_daily_observations: int, covariance_init: float, hourly_correlation: float, process_noise_init: float) -> None

  3. __init__(self: shyft.hydrology.KalmanState, clone: shyft.hydrology.KalmanState) -> None

clone the supplied state

static get_P(arg0: shyft.hydrology.KalmanState) list[float]
static get_W(arg0: shyft.hydrology.KalmanState) list[float]
static get_k(arg0: shyft.hydrology.KalmanState) list[float]
static get_x(arg0: shyft.hydrology.KalmanState) list[float]
property k
size(self: shyft.hydrology.KalmanState) int

returns the size of the state, corresponding to n_daily_observations

property x
class shyft.hydrology.KirchnerCalculator

Bases: pybind11_object

Kirchner model for computing the discharge based on precipitation and evapotranspiration data.

This algorithm is based on the log transform of the ode formulation of the time change in discharge as a function of measured precipitation, evapo-transpiration and discharge, i.e. equation 19 in the publication Catchments as simple dynamic systems: Catchment characterization, rainfall-runoff modeling, and doing ‘hydrology backward’ by James W. Kirchner, published in Water Resources Research, vol. 45, W02429, doi: 10.1029/2008WR006912, 2009.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.KirchnerCalculator, param: shyft.hydrology.KirchnerParameter) -> None

  2. __init__(self: shyft.hydrology.KirchnerCalculator, abs_err: float, rel_err: float, param: shyft.hydrology.KirchnerParameter) -> None

step(self: shyft.hydrology.KirchnerCalculator, state: shyft.hydrology.KirchnerState, response: shyft.hydrology.KirchnerResponse, t0: shyft.time_series.time, t1: shyft.time_series.time, precipitation: float, evapotranspiration: float) None

step Kirchner model forward from time t0 to time t1

note: If the supplied q (state) is less than min_q(0.00001, it represents mm water..), it is forced to min_q to ensure numerical stability

Parameters:
  • state (KirchnerState) – current state, updated on return

  • response (KirchnerResponse) – the response , out parameter.

  • t0 (time) – start time

  • t1 (time) – end time

  • precipitation (float) – in mm/h

  • evapotranspiration (float) – in mm/h

class shyft.hydrology.KirchnerParameter

Bases: pybind11_object

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.KirchnerParameter) -> None

  2. __init__(self: shyft.hydrology.KirchnerParameter, c1: float = 2.439, c2: float = 0.966, c3: float = -0.1) -> None

property c1

default =2.439

Type:

float

property c2

default= 0.966

Type:

float

property c3

default = -0.10

Type:

float

class shyft.hydrology.KirchnerResponse

Bases: pybind11_object

__init__(self: shyft.hydrology.KirchnerResponse) None
property q_avg

average discharge over time-step in [mm/h]

Type:

float

class shyft.hydrology.KirchnerState

Bases: pybind11_object

__init__(self: shyft.hydrology.KirchnerState, q: float = 0.0001) None
property q

state water ‘content’ in [mm/h], it defaults to 0.0001 mm, zero is not a reasonable valid value

Type:

float

class shyft.hydrology.LandTypeFractions

Bases: pybind11_object

LandTypeFractions are used to describe type of land, like glacier, lake, reservoir and forest. It is designed as a part of GeoCellData

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.LandTypeFractions) -> None

  2. __init__(self: shyft.hydrology.LandTypeFractions, glacier: float, lake: float, reservoir: float, forest: float, unspecified: float) -> None

construct LandTypeFraction specifying the area of each type

forest(self: shyft.hydrology.LandTypeFractions) float

returns the forest part

glacier(self: shyft.hydrology.LandTypeFractions) float

returns the glacier part

lake(self: shyft.hydrology.LandTypeFractions) float

returns the lake part

reservoir(self: shyft.hydrology.LandTypeFractions) float

returns the reservoir part

set_fractions(self: shyft.hydrology.LandTypeFractions, glacier: float, lake: float, reservoir: float, forest: float) None

set the fractions explicit, each a value in range 0..1, sum should be 1.0

snow_storage(self: shyft.hydrology.LandTypeFractions) float

returns the area where snow can build up, 1.0-lake-reservoir

unspecified(self: shyft.hydrology.LandTypeFractions) float

returns the unspecified part

class shyft.hydrology.MethodStackParameter

Bases: pybind11_object

Contains the parameters for the method-stack, related to inter-method and routing behaviour

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.MethodStackParameter) -> None

  2. __init__(self: shyft.hydrology.MethodStackParameter, clone: shyft.hydrology.MethodStackParameter) -> None

make a clone

property reservoir_direct_response_fraction

range 0..1, default 1.0, e.g. all precipitation on a reservoir goes to direct response - set to 0.0, then all precipitation is routed as pr. standard for the stack

Type:

float

class shyft.hydrology.OKCovarianceType

Bases: pybind11_object

Members:

GAUSSIAN

EXPONENTIAL

EXPONENTIAL = <OKCovarianceType.EXPONENTIAL: 1>
GAUSSIAN = <OKCovarianceType.GAUSSIAN: 0>
__init__(self: shyft.hydrology.OKCovarianceType, value: int) None
property name
property value
class shyft.hydrology.OKParameter

Bases: pybind11_object

Ordinary Kriging Parameter, keeps parameters that controls the ordinary kriging calculation

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.OKParameter) -> None

  2. __init__(self: shyft.hydrology.OKParameter, c: float = 1.0, a: float = 10000.0, cov_type: shyft.hydrology.OKCovarianceType = <OKCovarianceType.EXPONENTIAL: 1>, z_scale: float = 1.0) -> None

property a

the a-constant, range or distance, value in the covariance formula

Type:

float

property c

the c-constant, sill value in the covariance formula

Type:

float

property cov_type

covariance type EXPONENTIAL|GAUSSIAN to be used

Type:

OKCovarianceType

property z_scale

z_scale to be used for range|distance calculations

Type:

float

class shyft.hydrology.OptimizerMethod

Bases: pybind11_object

Shyft calibration allow the user to select between one of these parameter optimizer methods.

Members:

BOBYQA

GLOBAL

DREAM

SCEUA

BOBYQA = <OptimizerMethod.BOBYQA: 0>
DREAM = <OptimizerMethod.DREAM: 2>
GLOBAL = <OptimizerMethod.GLOBAL: 1>
SCEUA = <OptimizerMethod.SCEUA: 3>
__init__(self: shyft.hydrology.OptimizerMethod, value: int) None
property name
property value
class shyft.hydrology.ParameterClient

Bases: pybind11_object

The client api for the shyft.hydrology parameter model service.

__init__(self: shyft.hydrology.ParameterClient, host_port: str, timeout_ms: int, operation_timeout_ms: int = 0) None

Creates a python client that can communicate with the corresponding server

close(self: shyft.hydrology.ParameterClient) None

Close the connection. It will automatically reopen if needed.

get_model_infos(self: shyft.hydrology.ParameterClient, mids: list[int], created_in: shyft.time_series.UtcPeriod = [not-valid-period>) list[shyft.time_series.ModelInfo]

returns all or selected model-info objects based on model-identifiers(mids)

Parameters:
  • mids (IntVector) – empty = all, or a list of known exisiting model-identifiers

  • created_in (UtcPeriod) – For which period you are interested in model-infos.

Returns:

model_infos. Strongly typed list of ModelInfo

Return type:

ModelInfoVector

property host_port

Endpoint network address of the remote server.

Type:

str

property is_open

If the connection to the remote server is (still) open.

Type:

bool

property operation_timeout_ms

Operation timeout for remote server operations, in number milliseconds.

Type:

int

read_model(self: shyft.hydrology.ParameterClient, mid: int) shyft.hydrology.ParameterModel

Read and return the model for specified model-identifier (mid)

Parameters:

mid (int) – the model-identifer for the wanted model

Returns:

  1. The resulting model from the server

Return type:

Model

read_models(self: shyft.hydrology.ParameterClient, mids: list[int]) shyft.hydrology.ParameterModelVector

Read and return the model for specified model-identifier (mid)

Parameters:

mids (list[int]) – A strongly typed list of ints, the model-identifers for the wanted models

Returns:

  1. The resulting model from the server

Return type:

Model

property reconnect_count

Number of reconnects to the remote server that have been performed.

Type:

int

remove_model(self: shyft.hydrology.ParameterClient, mid: int) int

Remove the specified model bymodel-identifier (mid)

Parameters:

mid (int) – the model-identifer for the wanted model

Returns:

ec. 0 or error-code?

Return type:

int

store_model(self: shyft.hydrology.ParameterClient, m: shyft.hydrology.ParameterModel, mi: shyft.time_series.ModelInfo) int

Store the model to backend, if m.id==0 then a new unique model-info is created and used

Parameters:
  • m (Model) – The model to store

  • mi (ModelInfo) – The model-info to store for the model

Returns:

mid. model-identifier for the stored model and model-info

Return type:

int

property timeout_ms

Timout for remote server operations, in number milliseconds.

Type:

int

update_model_info(self: shyft.hydrology.ParameterClient, mid: int, mi: shyft.time_series.ModelInfo) bool

Update the model-info for specified model-identifier(mid)

Parameters:
  • mid (int) – model-identifer

  • mi (ModelInfo) – The new updated model-info

Returns:

ok. true if success

Return type:

bool

class shyft.hydrology.ParameterModel

Bases: pybind11_object

A model identifier and a strongly typed dict, cpp-map, of stack parameters, suitable for use with a region-model matching the type.

__init__(self: shyft.hydrology.ParameterModel) None
property id
property parameters
class shyft.hydrology.ParameterModelVector

Bases: pybind11_object

A strongly typed list of ParameterModels

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.ParameterModelVector) -> None

  2. __init__(self: shyft.hydrology.ParameterModelVector, arg0: shyft.hydrology.ParameterModelVector) -> None

Copy constructor

  1. __init__(self: shyft.hydrology.ParameterModelVector, arg0: Iterable) -> None

append(self: shyft.hydrology.ParameterModelVector, x: shyft.hydrology.ParameterModel) None

Add an item to the end of the list

clear(self: shyft.hydrology.ParameterModelVector) None

Clear the contents

extend(*args, **kwargs)

Overloaded function.

  1. extend(self: shyft.hydrology.ParameterModelVector, L: shyft.hydrology.ParameterModelVector) -> None

Extend the list by appending all the items in the given list

  1. extend(self: shyft.hydrology.ParameterModelVector, L: Iterable) -> None

Extend the list by appending all the items in the given list

insert(self: shyft.hydrology.ParameterModelVector, i: int, x: shyft.hydrology.ParameterModel) None

Insert an item at a given position.

pop(*args, **kwargs)

Overloaded function.

  1. pop(self: shyft.hydrology.ParameterModelVector) -> shyft.hydrology.ParameterModel

Remove and return the last item

  1. pop(self: shyft.hydrology.ParameterModelVector, i: int) -> shyft.hydrology.ParameterModel

Remove and return the item at index i

size(self: shyft.hydrology.ParameterModelVector) int
class shyft.hydrology.ParameterOptimizer

Bases: pybind11_object

The ParameterOptimizer allows for testing and comparing optimizer methods for the same inital parameters and goal function.

__init__(self: shyft.hydrology.ParameterOptimizer, p_min: list[float], p_max: list[float], fx: Callable[[list[float]], float]) None

Initialises a ParameterOptimizer instance.

p_min (Union[DoubleVector[float], DoubleVector[int]]): the lower parameter bound in at least one-dimensional space.

p_max (Union[DoubleVector[float], DoubleVector[int]]): the upper parameter bound in at least one-dimensional space.

fx (Callable): the goal function to be used in the parameter optimization problem.

property fx

goal function for which parameters are optimized

Type:

Callable[[],float]

goal_function(self: shyft.hydrology.ParameterOptimizer, x: list[float]) float

The goal function to be used in the optimization problem.

x (Union[DoubleVector[float], DoubleVector[int]]): the point in at least one-dimensional space at which the goal function is evaluated.

Returns:

  1. The function value f(x) at point x.

Return type:

DoubleVector[float]

optimize(self: shyft.hydrology.ParameterOptimizer, x: list[float], calibration_option: shyft.hydrology.CalibrationOption) list[float]

Run the optimizer for given parameters and configuration.

x (Union[DoubleVector[float], DoubleVector[int]]): the initial point in at least one-dimensional space for the optimization problem.

calibration_option (CalibrationOption): the calibration for the various optimization methods.

Returns:

x_opt. The optimal parameters for which the optimum of f(x) is found.

Return type:

DoubleVector[float]

See also

CalibrationOption

property p_max

upper parameter bound in at least one-dimensional space

Type:

DoubleVector

property p_min

lower parameter bound in at least one-dimensional space

Type:

DoubleVector

class shyft.hydrology.ParameterServer

Bases: pybind11_object

The server-side component for the shyft.hydrology parameter model repository.

__init__(self: shyft.hydrology.ParameterServer, root_dir: str, config: shyft.time_series.ServerConfig = shyft.time_series.ServerConfig(stale_duration='1970-01-01T01:00:00Z', stale_sweep_interval='1970-01-01T00:00:00.100000Z', log=shyft.time_series.LogConfig(file='', level=200))) None

Creates a server object that serves models from root_dir. The root_dir will be create if it does not exists.

Parameters:
  • root_dir (str) – Path to the root-directory that keeps/will keep the model-files

  • config (ServerConfig) – Configuration of the server

get_listening_port(self: shyft.hydrology.ParameterServer) int

returns the port number it’s listening at for serving incoming request

get_max_connections(self: shyft.hydrology.ParameterServer) int

returns the maximum number of connections to be served concurrently

get_model_infos(self: shyft.hydrology.ParameterServer, mids: list[int], created_in: shyft.time_series.UtcPeriod = [not-valid-period>) list[shyft.time_series.ModelInfo]

returns all or selected model-info objects based on model-identifiers(mids)

Parameters:
  • mids (IntVector) – empty = all, or a list of known exisiting model-identifiers

  • created_in (UtcPeriod) – For which period you are interested in model-infos.

Returns:

model_infos. Strongly typed list of ModelInfo

Return type:

ModelInfoVector

is_running(self: shyft.hydrology.ParameterServer) bool

true if server is listening and running

See also

start_server()

read_model(self: shyft.hydrology.ParameterServer, mid: int) shyft.hydrology.ParameterModel

Read and return the model for specified model-identifier (mid)

Parameters:

mid (int) – the model-identifer for the wanted model

Returns:

  1. The resulting model from the server

Return type:

Model

read_model_blob(self: shyft.hydrology.ParameterServer, mid: int) shyft.time_series.ByteVector

Read and return the model blob for specified model-identifier (mid)

Parameters:

mid (int) – the model-identifer for the wanted model

Returns:

  1. The resulting blob model from the server

Return type:

ByteVector

read_models(self: shyft.hydrology.ParameterServer, mids: list[int]) shyft.hydrology.ParameterModelVector

Read and return the model for specified model-identifier (mid)

Parameters:

mids (list[int]) – A strongly typed list of ints, the model-identifers for the wanted models

Returns:

  1. The resulting model from the server

Return type:

Model

remove_model(self: shyft.hydrology.ParameterServer, mid: int) int

Remove the specified model bymodel-identifier (mid)

Parameters:

mid (int) – the model-identifer for the wanted model

Returns:

ec. 0 or error-code?

Return type:

int

set_listening_ip(self: shyft.hydrology.ParameterServer, ip: str) None

set the listening port for the service

Parameters:

ip (str) – ip or host-name to start listening on

Returns:

nothing.

Return type:

None

set_listening_port(self: shyft.hydrology.ParameterServer, port_no: int) None

set the listening port for the service

Parameters:
  • port_no (int) – a valid and available tcp-ip port number to listen on.

  • 20000 (typically it could be)

Returns:

nothing.

Return type:

None

set_max_connections(self: shyft.hydrology.ParameterServer, max_connect: int) None

limits simultaneous connections to the server (it’s multithreaded, and uses on thread pr. connect)

Parameters:

max_connect (int) – maximum number of connections before denying more connections

See also

get_max_connections()

property stale_connection_close_count

returns count of connection closed due to stale/no communication activity

Type:

int

start_server(self: shyft.hydrology.ParameterServer) int

start server listening in background, and processing messages

See also

set_listening_port(port_no),is_running

Returns:

port_no. the port used for listening operations, either the value as by set_listening_port, or if it was unspecified, a new available port

Return type:

in

stop_server(self: shyft.hydrology.ParameterServer, timeout: int = 1000) None

stop serving connections, gracefully.

See also

start_server()

store_model(self: shyft.hydrology.ParameterServer, m: shyft.hydrology.ParameterModel, mi: shyft.time_series.ModelInfo) int

Store the model to backend, if m.id==0 then a new unique model-info is created and used

Parameters:
  • m (Model) – The model to store

  • mi (ModelInfo) – The model-info to store for the model

Returns:

mid. model-identifier for the stored model and model-info

Return type:

int

update_model_info(self: shyft.hydrology.ParameterServer, mid: int, mi: shyft.time_series.ModelInfo) bool

Update the model-info for specified model-identifier(mid)

Parameters:
  • mid (int) – model-identifer

  • mi (ModelInfo) – The new updated model-info

Returns:

ok. true if success

Return type:

bool

class shyft.hydrology.PenmanMonteithCalculator

Bases: pybind11_object

Evapotranspiration model, Penman-Monteith equation, PM reference

ASCE-EWRI The ASCE Standardized Reference Evapotranspiration Equation Environmental and
   * Water Resources Institute (EWRI) of the American Society of Civil Engineers Task Com- mittee on Standardization of
   * Reference Evapotranspiration Calculation, ASCE, Washington, DC, Environmental and Water Resources Institute (EWRI) of
   * the American Society of Civil Engineers Task Com- mittee on Standardization of Reference Evapotranspiration Calculation,
   * ASCE, Washington, DC, 2005

calculating reference evapotranspiration This function is plain and simple, taking albedo and turbidity into the constructor and provides function: reference_evapotranspiration; [mm/s] units.

__init__(self: shyft.hydrology.PenmanMonteithCalculator, param: shyft.hydrology.PenmanMonteithParameter) None
reference_evapotranspiration(self: shyft.hydrology.PenmanMonteithCalculator, response: shyft.hydrology.PenmanMonteithResponse, dt: shyft.time_series.time, net_radiation: float, tempmax: float, tempmin: float, rhumidity: float, elevation: float, windspeed: float) None

calculates reference evapotranspiration (standard or full based on full_model param), updating response

class shyft.hydrology.PenmanMonteithParameter

Bases: pybind11_object

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.PenmanMonteithParameter) -> None

  2. __init__(self: shyft.hydrology.PenmanMonteithParameter, height_veg: float, height_ws: float, height_t: float, rl: float, full_model: bool) -> None

a new object with specified parameters

property full_model

boolean to specify if full penman-monteith required, set to false by default, so it is asce-ewri standard

Type:

bool

property height_t

typical value 2.0

Type:

float

property height_veg

grass 0.15

Type:

float

property height_ws

typical value 2.0

Type:

float

property rl

stomatal resistance, for full PM only, 140

Type:

float

class shyft.hydrology.PenmanMonteithResponse

Bases: pybind11_object

__init__(self: shyft.hydrology.PenmanMonteithResponse) None
property et_ref
Type:

float

property soil_heat
Type:

float

class shyft.hydrology.PenmanMonteithVegetationCalculator

Bases: pybind11_object

Evapotranspiration model, Penman-Monteith equation with vegetation properties, PM reference

L. Dingman Stewart-Penmann-Monteith evapotranspiration

[mm/s] units.

__init__(self: shyft.hydrology.PenmanMonteithVegetationCalculator, param: shyft.hydrology.PenmanMonteithVegetationParameter) None
evapotranspiration(self: shyft.hydrology.PenmanMonteithVegetationCalculator, response: shyft.hydrology.PenmanMonteithVegetationResponse, dt: shyft.time_series.time, swin_radiation: float, lw_radiation: float, tempmax: float, tempmin: float, rhumidity: float, lai: float, albedo: float, hvegetation: float, cleaf_max: float, ks: float, soil_moisture_deficit: float, elevation: float, windspeed: float) None

calculates evapotranspiration, updating response

class shyft.hydrology.PenmanMonteithVegetationParameter

Bases: pybind11_object

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.PenmanMonteithVegetationParameter) -> None

  2. __init__(self: shyft.hydrology.PenmanMonteithVegetationParameter, height_ws: float, height_t: float) -> None

property height_t

typical value 2.0

Type:

float

property height_ws

typical value 2.0

Type:

float

class shyft.hydrology.PenmanMonteithVegetationResponse

Bases: pybind11_object

__init__(*args, **kwargs)
property et
property soil_heat
class shyft.hydrology.PrecipitationCorrectionCalculator

Bases: pybind11_object

Scales precipitation with the specified scale factor

__init__(self: shyft.hydrology.PrecipitationCorrectionCalculator, scale_factor: float) None
calc(self: shyft.hydrology.PrecipitationCorrectionCalculator, precipitation: float) float

returns scale_factor*precipitation

class shyft.hydrology.PrecipitationCorrectionParameter

Bases: pybind11_object

__init__(self: shyft.hydrology.PrecipitationCorrectionParameter, scale_factor: float = 1.0) None
property scale_factor

default =1.0

Type:

float

class shyft.hydrology.PrecipitationSource

Bases: GeoPointSource

geo located precipitation[mm/h]

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.PrecipitationSource, midpoint: shyft.time_series.GeoPoint, ts: shyft.time_series.TimeSeries) -> None

  2. __init__(self: shyft.hydrology.PrecipitationSource, geo_ts: shyft.time_series.GeoTimeSeries) -> None

vector_t

alias of PrecipitationSourceVector

class shyft.hydrology.PrecipitationSourceVector

Bases: pybind11_object

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.PrecipitationSourceVector) -> None

  2. __init__(self: shyft.hydrology.PrecipitationSourceVector, arg0: shyft.hydrology.PrecipitationSourceVector) -> None

Copy constructor

  1. __init__(self: shyft.hydrology.PrecipitationSourceVector, arg0: Iterable) -> None

  2. __init__(self: shyft.hydrology.PrecipitationSourceVector, geo_ts_vector: shyft.time_series.GeoTimeSeriesVector) -> None

Construct from a GeoTimeSeriesVector, Reference to the shyft.time_series.GeoTsMatrix.extract_geo_ts_vector() to see how to create one from the dtss/geo extensions

append(self: shyft.hydrology.PrecipitationSourceVector, x: shyft.hydrology.PrecipitationSource) None

Add an item to the end of the list

clear(self: shyft.hydrology.PrecipitationSourceVector) None

Clear the contents

extend(*args, **kwargs)

Overloaded function.

  1. extend(self: shyft.hydrology.PrecipitationSourceVector, L: shyft.hydrology.PrecipitationSourceVector) -> None

Extend the list by appending all the items in the given list

  1. extend(self: shyft.hydrology.PrecipitationSourceVector, L: Iterable) -> None

Extend the list by appending all the items in the given list

static from_geo_and_ts_vector(geo_points: shyft.time_series.GeoPointVector, tsv: shyft.time_series.TsVector) shyft.hydrology.PrecipitationSourceVector

Create from a geo_points and corresponding ts-vectors

Parameters:

geo_points (GeoPointVector) – the geo-points

Returns:

src_vector. a newly created geo-located vector of specified type

tsv (TsVector): the corresponding time-series located at corresponding geo-point

Return type:

SourceVector

property geo_tsvector

returns a GeoTimeSeriesVector containing GeoTimeSeries where the geo-points are copied, but time-series are by-reference

Type:

GeoTimeSeriesVector

insert(self: shyft.hydrology.PrecipitationSourceVector, i: int, x: shyft.hydrology.PrecipitationSource) None

Insert an item at a given position.

pop(*args, **kwargs)

Overloaded function.

  1. pop(self: shyft.hydrology.PrecipitationSourceVector) -> shyft.hydrology.PrecipitationSource

Remove and return the last item

  1. pop(self: shyft.hydrology.PrecipitationSourceVector, i: int) -> shyft.hydrology.PrecipitationSource

Remove and return the item at index i

size(self: shyft.hydrology.PrecipitationSourceVector) int
values_at_time(self: shyft.hydrology.PrecipitationSourceVector, arg0: shyft.time_series.time) list[float]
class shyft.hydrology.PriestleyTaylorCalculator

Bases: pybind11_object

PriestleyTaylor,PT, (google for PriestleyTaylor) primitive implementation for calculating the potential evaporation. This function is plain and simple, taking land_albedo and PT.alpha into the constructor and provides a function that calculates potential evapotransporation [mm/s] units.

__init__(self: shyft.hydrology.PriestleyTaylorCalculator, land_albedo: float, alpha: float) None
potential_evapotranspiration(self: shyft.hydrology.PriestleyTaylorCalculator, temperature: float, global_radiation: float, rhumidity: float) float

Calculate PotentialEvapotranspiration, given specified parameters

  • param temperature in [degC]

  • param global_radiation [W/m2]

  • param rhumidity in interval [0,1]

  • return PotentialEvapotranspiration in [mm/s] units

class shyft.hydrology.PriestleyTaylorParameter

Bases: pybind11_object

__init__(self: shyft.hydrology.PriestleyTaylorParameter, albedo: float = 0.2, alpha: float = 1.26) None
property albedo

typical value 0.2

Type:

float

property alpha

typical value 1.26

Type:

float

class shyft.hydrology.PriestleyTaylorResponse

Bases: pybind11_object

__init__(*args, **kwargs)
property pot_evapotranspiration

response

Type:

float

class shyft.hydrology.RadiationCalculator

Bases: pybind11_object

Radiation,R,

reference

Allen, R. G.; Trezza, R. & Tasumi, M. Analytical integrated functions for daily solar radiation on slopes Agricultural and Forest Meteorology, 2006, 139, 55-73)
primitive implementation for calculating predicted clear-sky short-wave solar radiation for inclined surfaces

This function is plain and simple, taking albedo and turbidity into the constructor and provides 2 functions:

  • net_radiation calculates predicted solar radiation (if no measured data available) or translates measured data into the slope plus adds the longwave radiation: instantaneously;

  • net_radiation_step calculates predicted solar radiation or/and translates measured horizontal radiation into sloped surface for the time period between tstart and tend plus adds the lw radiation

Recommended usage is the net_radiation_step for 24h-steps; it was also tested with 1h and 3h steps

__init__(self: shyft.hydrology.RadiationCalculator, param: shyft.hydrology.RadiationParameter) None
net_radiation(self: shyft.hydrology.RadiationCalculator, response: shyft.hydrology.RadiationResponse, latitude: float, t1: shyft.time_series.time, dt: shyft.time_series.time, slope: float, aspect: float, temperature: float, rhumidity: float, elevation: float, rsm: float) None

calculates net radiation using either step or instantaneous method, updating response

net_radiation_inst(self: shyft.hydrology.RadiationCalculator, response: shyft.hydrology.RadiationResponse, latitude: float, t: shyft.time_series.time, slope: float, aspect: float, temperature: float, rhumidity: float, elevation: float, rsm: float) None

calculates net radiation using instantaneous method, updating response

net_radiation_step(self: shyft.hydrology.RadiationCalculator, response: shyft.hydrology.RadiationResponse, latitude: float, t1: shyft.time_series.time, dt: shyft.time_series.time, slope: float, aspect: float, temperature: float, rhumidity: float, elevation: float, rsm: float) None

calculates net radiation, updating response

net_radiation_step_asce_st(self: shyft.hydrology.RadiationCalculator, response: shyft.hydrology.RadiationResponse, latitude: float, t1: shyft.time_series.time, dt: shyft.time_series.time, slope: float, aspect: float, temperature: float, rhumidity: float, elevation: float, rsm: float) None

calculates net radiation, updating response

class shyft.hydrology.RadiationParameter

Bases: pybind11_object

__init__(self: shyft.hydrology.RadiationParameter, albedo: float = 0.2, turbidity: float = 1.0) None
property albedo

typical value 0.2

Type:

float

property turbidity

typical value 1.0

Type:

float

class shyft.hydrology.RadiationResponse

Bases: pybind11_object

__init__(self: shyft.hydrology.RadiationResponse) None
property net
Type:

float

property net_lw
Type:

float

property net_sw
Type:

float

property ra
Type:

float

property sw_cs_p
Type:

float

property sw_t
Type:

float

class shyft.hydrology.RadiationSource

Bases: GeoPointSource

geo located radiation[W/m2]

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.RadiationSource, midpoint: shyft.time_series.GeoPoint, ts: shyft.time_series.TimeSeries) -> None

  2. __init__(self: shyft.hydrology.RadiationSource, geo_ts: shyft.time_series.GeoTimeSeries) -> None

vector_t

alias of RadiationSourceVector

class shyft.hydrology.RadiationSourceVector

Bases: pybind11_object

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.RadiationSourceVector) -> None

  2. __init__(self: shyft.hydrology.RadiationSourceVector, arg0: shyft.hydrology.RadiationSourceVector) -> None

Copy constructor

  1. __init__(self: shyft.hydrology.RadiationSourceVector, arg0: Iterable) -> None

  2. __init__(self: shyft.hydrology.RadiationSourceVector, geo_ts_vector: shyft.time_series.GeoTimeSeriesVector) -> None

Construct from a GeoTimeSeriesVector, Reference to the shyft.time_series.GeoTsMatrix.extract_geo_ts_vector() to see how to create one from the dtss/geo extensions

append(self: shyft.hydrology.RadiationSourceVector, x: shyft.hydrology.RadiationSource) None

Add an item to the end of the list

clear(self: shyft.hydrology.RadiationSourceVector) None

Clear the contents

extend(*args, **kwargs)

Overloaded function.

  1. extend(self: shyft.hydrology.RadiationSourceVector, L: shyft.hydrology.RadiationSourceVector) -> None

Extend the list by appending all the items in the given list

  1. extend(self: shyft.hydrology.RadiationSourceVector, L: Iterable) -> None

Extend the list by appending all the items in the given list

static from_geo_and_ts_vector(geo_points: shyft.time_series.GeoPointVector, tsv: shyft.time_series.TsVector) shyft.hydrology.RadiationSourceVector

Create from a geo_points and corresponding ts-vectors

Parameters:

geo_points (GeoPointVector) – the geo-points

Returns:

src_vector. a newly created geo-located vector of specified type

tsv (TsVector): the corresponding time-series located at corresponding geo-point

Return type:

SourceVector

property geo_tsvector

returns a GeoTimeSeriesVector containing GeoTimeSeries where the geo-points are copied, but time-series are by-reference

Type:

GeoTimeSeriesVector

insert(self: shyft.hydrology.RadiationSourceVector, i: int, x: shyft.hydrology.RadiationSource) None

Insert an item at a given position.

pop(*args, **kwargs)

Overloaded function.

  1. pop(self: shyft.hydrology.RadiationSourceVector) -> shyft.hydrology.RadiationSource

Remove and return the last item

  1. pop(self: shyft.hydrology.RadiationSourceVector, i: int) -> shyft.hydrology.RadiationSource

Remove and return the item at index i

size(self: shyft.hydrology.RadiationSourceVector) int
values_at_time(self: shyft.hydrology.RadiationSourceVector, arg0: shyft.time_series.time) list[float]
class shyft.hydrology.RegionModelType

Bases: pybind11_object

Ref to DrmClient, used do specify what remote region-model type to create

Members:

PT_GS_K

PT_GS_K_OPT

PT_SS_K

PT_SS_K_OPT

PT_HS_K

PT_HS_K_OPT

PT_HPS_K

PT_HPS_K_OPT

R_PM_GS_K

R_PM_GS_K_OPT

PT_ST_K

PT_ST_K_OPT

PT_ST_HBV

PT_ST_K_HBV

R_PT_GS_K

R_PT_GS_K_OPT

R_PM_ST_K

R_PM_ST_K_OPT

R_PMV_ST_K

R_PMV_ST_K_OPT

PT_GS_K = <RegionModelType.PT_GS_K: 0>
PT_GS_K_OPT = <RegionModelType.PT_GS_K_OPT: 1>
PT_HPS_K = <RegionModelType.PT_HPS_K: 6>
PT_HPS_K_OPT = <RegionModelType.PT_HPS_K_OPT: 7>
PT_HS_K = <RegionModelType.PT_HS_K: 4>
PT_HS_K_OPT = <RegionModelType.PT_HS_K_OPT: 5>
PT_SS_K = <RegionModelType.PT_SS_K: 2>
PT_SS_K_OPT = <RegionModelType.PT_SS_K_OPT: 3>
PT_ST_HBV = <RegionModelType.PT_ST_HBV: 12>
PT_ST_K = <RegionModelType.PT_ST_K: 10>
PT_ST_K_HBV = <RegionModelType.PT_ST_K_HBV: 13>
PT_ST_K_OPT = <RegionModelType.PT_ST_K_OPT: 11>
R_PMV_ST_K = <RegionModelType.R_PMV_ST_K: 18>
R_PMV_ST_K_OPT = <RegionModelType.R_PMV_ST_K_OPT: 19>
R_PM_GS_K = <RegionModelType.R_PM_GS_K: 8>
R_PM_GS_K_OPT = <RegionModelType.R_PM_GS_K_OPT: 9>
R_PM_ST_K = <RegionModelType.R_PM_ST_K: 16>
R_PM_ST_K_OPT = <RegionModelType.R_PM_ST_K_OPT: 17>
R_PT_GS_K = <RegionModelType.R_PT_GS_K: 14>
R_PT_GS_K_OPT = <RegionModelType.R_PT_GS_K_OPT: 15>
__init__(self: shyft.hydrology.RegionModelType, value: int) None
property name
property value
class shyft.hydrology.RelHumSource

Bases: GeoPointSource

geo located relative humidity[%rh], range 0..1

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.RelHumSource, midpoint: shyft.time_series.GeoPoint, ts: shyft.time_series.TimeSeries) -> None

  2. __init__(self: shyft.hydrology.RelHumSource, geo_ts: shyft.time_series.GeoTimeSeries) -> None

vector_t

alias of RelHumSourceVector

class shyft.hydrology.RelHumSourceVector

Bases: pybind11_object

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.RelHumSourceVector) -> None

  2. __init__(self: shyft.hydrology.RelHumSourceVector, arg0: shyft.hydrology.RelHumSourceVector) -> None

Copy constructor

  1. __init__(self: shyft.hydrology.RelHumSourceVector, arg0: Iterable) -> None

  2. __init__(self: shyft.hydrology.RelHumSourceVector, geo_ts_vector: shyft.time_series.GeoTimeSeriesVector) -> None

Construct from a GeoTimeSeriesVector, Reference to the shyft.time_series.GeoTsMatrix.extract_geo_ts_vector() to see how to create one from the dtss/geo extensions

append(self: shyft.hydrology.RelHumSourceVector, x: shyft.hydrology.RelHumSource) None

Add an item to the end of the list

clear(self: shyft.hydrology.RelHumSourceVector) None

Clear the contents

extend(*args, **kwargs)

Overloaded function.

  1. extend(self: shyft.hydrology.RelHumSourceVector, L: shyft.hydrology.RelHumSourceVector) -> None

Extend the list by appending all the items in the given list

  1. extend(self: shyft.hydrology.RelHumSourceVector, L: Iterable) -> None

Extend the list by appending all the items in the given list

static from_geo_and_ts_vector(geo_points: shyft.time_series.GeoPointVector, tsv: shyft.time_series.TsVector) shyft.hydrology.RelHumSourceVector

Create from a geo_points and corresponding ts-vectors

Parameters:

geo_points (GeoPointVector) – the geo-points

Returns:

src_vector. a newly created geo-located vector of specified type

tsv (TsVector): the corresponding time-series located at corresponding geo-point

Return type:

SourceVector

property geo_tsvector

returns a GeoTimeSeriesVector containing GeoTimeSeries where the geo-points are copied, but time-series are by-reference

Type:

GeoTimeSeriesVector

insert(self: shyft.hydrology.RelHumSourceVector, i: int, x: shyft.hydrology.RelHumSource) None

Insert an item at a given position.

pop(*args, **kwargs)

Overloaded function.

  1. pop(self: shyft.hydrology.RelHumSourceVector) -> shyft.hydrology.RelHumSource

Remove and return the last item

  1. pop(self: shyft.hydrology.RelHumSourceVector, i: int) -> shyft.hydrology.RelHumSource

Remove and return the item at index i

size(self: shyft.hydrology.RelHumSourceVector) int
values_at_time(self: shyft.hydrology.RelHumSourceVector, arg0: shyft.time_series.time) list[float]
class shyft.hydrology.River

Bases: pybind11_object

A river that we use for routing, its a single piece of a RiverNetwork

The routing river have flow from:

  1. zero or more ‘cell_nodes’, typically a cell_model type, lateral flow,like cell.rc.average_discharge [m3/s]

  2. zero or more upstream connected rivers, taking their .output_m3s()

then a routing river can optionally be connected to a down-stream river providing a routing function (currently just a convolution of a uhg).

This definition is recursive, and we use RiverNetwork to ensure the routing graph is directed and with no cycles.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.River) -> None

  2. __init__(self: shyft.hydrology.River, id: int, downstream: shyft.hydrology.RoutingInfo = RoutingInfo(id=0, distance=0), parameter: shyft.hydrology.UHGParameter = UHGParameter(velocity=1, alpha=7, beta=0)) -> None

a new object with specified parameters, notice that a valid river-id|routing-id must be >0

property downstream

routing information for downstream, target-id, and hydrological distance

Type:

RoutingInfo

property id

a valid identifier >0 for the river|routing element

Type:

int

property parameter

describing the downstream propagation

Type:

UHGParameter

uhg(self: shyft.hydrology.River, dt: shyft.time_series.time) list[float]

create the hydro-graph for this river, taking specified delta-t, dt, static hydrological distance as well as the shape parameters alpha and beta used to form the gamma-function. The length of the uhg (delay) is determined by the downstream-distance, and the velocity parameter. The shape of the uhg is determined by alpha&beta parameters.

class shyft.hydrology.RiverNetwork

Bases: pybind11_object

A RiverNetwork takes care of the routing see also description of River The RiverNetwork provides all needed functions to build routing into the region model It ensures safe manipulation of rivers:

  • no cycles,

  • no duplicate object-id’s etc.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.RiverNetwork) -> None

  2. __init__(self: shyft.hydrology.RiverNetwork, clone: shyft.hydrology.RiverNetwork) -> None

make a clone of river-network

add(self: shyft.hydrology.RiverNetwork, river: shyft.hydrology.River) shyft.hydrology.RiverNetwork

add a river to the network, verifies river id, no cycles etc.

raises exception on error tip: build your river-network from downstream to upstream order

downstream_by_id(self: shyft.hydrology.RiverNetwork, id: int) int

return id of downstream river, 0 if none

network_contains_directed_cycle(self: shyft.hydrology.RiverNetwork) bool

True if network have cycles detected

remove_by_id(self: shyft.hydrology.RiverNetwork, id: int) None

disconnect and remove river for network

river_by_id(self: shyft.hydrology.RiverNetwork, id: int) shyft.hydrology.River

get river by id

set_downstream_by_id(self: shyft.hydrology.RiverNetwork, id: int, downstream_id: int) None

set downstream target for specified river id

upstreams_by_id(self: shyft.hydrology.RiverNetwork, id: int) list[int]

returns a list(vector) of id of upstream rivers from the specified one

class shyft.hydrology.RoutingInfo

Bases: pybind11_object

Describe the hydrological distance and the id of the target routing element (river)

__init__(self: shyft.hydrology.RoutingInfo, id: int = 0, distance: float = 0.0) None
property distance

the hydrological distance, in unit of [m]

Type:

float

property id

id of the target,down-stream river

Type:

int

class shyft.hydrology.SkaugenCalculator

Bases: pybind11_object

Skaugen snow model method

This algorithm uses theory from Skaugen

__init__(*args, **kwargs)
step(self: shyft.hydrology.SkaugenCalculator, delta_t: shyft.time_series.time, parameter: shyft.hydrology.SkaugenParameter, temperature: float, precipitation: float, radiation: float, wind_speed: float, state: shyft.hydrology.SkaugenState, response: shyft.hydrology.SkaugenResponse) None

steps the model forward delta_t seconds, using specified input, updating state and response

class shyft.hydrology.SkaugenParameter

Bases: pybind11_object

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.SkaugenParameter, alpha_0: float = 40.77, d_range: float = 113.0, unit_size: float = 0.1, max_water_fraction: float = 0.1, tx: float = 0.16, cx: float = 2.5, ts: float = 0.14, cfr: float = 0.01) -> None

  2. __init__(self: shyft.hydrology.SkaugenParameter, p: shyft.hydrology.SkaugenParameter) -> None

create a clone of p

property alpha_0

default = 40.77

Type:

float

property cfr

default = 0.01

Type:

float

property cx

default = 2.5

Type:

float

property d_range

default = 113.0

Type:

float

property max_water_fraction

default = 0.1

Type:

float

property ts

default = 0.14

Type:

float

property tx

default = 0.16

Type:

float

property unit_size

default = 0.1

Type:

float

class shyft.hydrology.SkaugenResponse

Bases: pybind11_object

__init__(*args, **kwargs)
property outflow

from snow-routine in [mm/h] over cell-area

Type:

float

property sca

snow-covered area in fraction

Type:

float

property swe

snow water equivalient [mm] over cell-area

Type:

float

property total_stored_water

same as swe(deprecated)

Type:

float

class shyft.hydrology.SkaugenState

Bases: pybind11_object

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.SkaugenState, nu: float = 4.077, alpha: float = 40.77, sca: float = 0.0, swe: float = 0.0, free_water: float = 0.0, residual: float = 0.0, num_units: float = 0) -> None

  2. __init__(self: shyft.hydrology.SkaugenState, s: shyft.hydrology.SkaugenState) -> None

create a clone of s

property alpha
Type:

float

property free_water
Type:

float

property nu
Type:

float

property num_units
Type:

int

property residual
Type:

float

property sca
Type:

float

property swe
Type:

float

class shyft.hydrology.SnowTilesCalculator

Bases: pybind11_object

Tile based snow model method

This algorithm uses …

__init__(self: shyft.hydrology.SnowTilesCalculator, parameter: shyft.hydrology.SnowTilesParameter) None
step(self: shyft.hydrology.SnowTilesCalculator, state: shyft.hydrology.SnowTilesState, response: shyft.hydrology.SnowTilesResponse, t0: shyft.time_series.time, t1: shyft.time_series.time, precipitation: float, temperature: float) None

steps the model forward from t0 to t1, updating state and response

class shyft.hydrology.SnowTilesParameter

Bases: pybind11_object

__init__(self: shyft.hydrology.SnowTilesParameter, shape: float = 2.0, tx: float = 0.0, cx: float = 1.0, ts: float = 0.0, lwmax: float = 0.1, cfr: float = 0.5, area_fractions: list[float] = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1]) None
property area_fractions

area fractions of the individual tiles, unit (-), range per tile [0.01, 1], the sum of the elements in the vector must equal 1

Type:

DoubleVector

property cfr

refreeze coefficient, unit (-), range [0, 1]

Type:

float

property cx

degree-day melt factor, unit (mm/C/day), range [0, 30]

Type:

float

property lwmax

max liquid water content given as a fraction of ice in the snowpack, unit (-), range [0, 1]

Type:

float

property shape

shape parameter of the Gamma distribution defining the multiplication factors for snowfall, unit (-), range [0.1, inf]

Type:

float

property ts

threshold temperature for melt onset, unit (C), range [-4, 4]

Type:

float

property tx

threshold temperature determining precipitation phase, unit (C), range [-4, 4]

Type:

float

class shyft.hydrology.SnowTilesResponse

Bases: pybind11_object

__init__(self: shyft.hydrology.SnowTilesResponse) None
property outflow

average outflow, rain and snowmelt, for the cell, unit (mm/hour)

property sca

average sca as a fraction of total cell area, unit (-)

Type:

float

property swe

average swe for the cell, unit (mm)

Type:

float

class shyft.hydrology.SnowTilesState

Bases: pybind11_object

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.SnowTilesState) -> None

  2. __init__(self: shyft.hydrology.SnowTilesState, fw: list[float], lw: list[float]) -> None

property fw

frozen water in the snowpack, unit (mm)

Type:

DoubleVector

property lw

liquid water in the snowpack, unit (mm)

Type:

DoubleVector

class shyft.hydrology.StateClient

Bases: pybind11_object

The client api for the shyft.hydrology state model service.

__init__(self: shyft.hydrology.StateClient, host_port: str, timeout_ms: int, operation_timeout_ms: int = 0) None

Creates a python client that can communicate with the corresponding server

close(self: shyft.hydrology.StateClient) None

Close the connection. It will automatically reopen if needed.

get_model_infos(self: shyft.hydrology.StateClient, mids: list[int], created_in: shyft.time_series.UtcPeriod = [not-valid-period>) list[shyft.time_series.ModelInfo]

returns all or selected model-info objects based on model-identifiers(mids)

Parameters:
  • mids (IntVector) – empty = all, or a list of known exisiting model-identifiers

  • created_in (UtcPeriod) – For which period you are interested in model-infos.

Returns:

model_infos. Strongly typed list of ModelInfo

Return type:

ModelInfoVector

property host_port

Endpoint network address of the remote server.

Type:

str

property is_open

If the connection to the remote server is (still) open.

Type:

bool

property operation_timeout_ms

Operation timeout for remote server operations, in number milliseconds.

Type:

int

read_model(self: shyft.hydrology.StateClient, mid: int) shyft.hydrology.StateModel

Read and return the model for specified model-identifier (mid)

Parameters:

mid (int) – the model-identifer for the wanted model

Returns:

  1. The resulting model from the server

Return type:

Model

read_models(self: shyft.hydrology.StateClient, mids: list[int]) shyft.hydrology.StateModelVector

Read and return the model for specified model-identifier (mid)

Parameters:

mids (list[int]) – A strongly typed list of ints, the model-identifers for the wanted models

Returns:

  1. The resulting model from the server

Return type:

Model

property reconnect_count

Number of reconnects to the remote server that have been performed.

Type:

int

remove_model(self: shyft.hydrology.StateClient, mid: int) int

Remove the specified model bymodel-identifier (mid)

Parameters:

mid (int) – the model-identifer for the wanted model

Returns:

ec. 0 or error-code?

Return type:

int

store_model(self: shyft.hydrology.StateClient, m: shyft.hydrology.StateModel, mi: shyft.time_series.ModelInfo) int

Store the model to backend, if m.id==0 then a new unique model-info is created and used

Parameters:
  • m (Model) – The model to store

  • mi (ModelInfo) – The model-info to store for the model

Returns:

mid. model-identifier for the stored model and model-info

Return type:

int

property timeout_ms

Timout for remote server operations, in number milliseconds.

Type:

int

update_model_info(self: shyft.hydrology.StateClient, mid: int, mi: shyft.time_series.ModelInfo) bool

Update the model-info for specified model-identifier(mid)

Parameters:
  • mid (int) – model-identifer

  • mi (ModelInfo) – The new updated model-info

Returns:

ok. true if success

Return type:

bool

class shyft.hydrology.StateModel

Bases: pybind11_object

A model identifier and a StateVector, where the vector can keep an uniform set of StateId of specified type

__init__(self: shyft.hydrology.StateModel) None
property id

unique model id

Type:

int

property states
class shyft.hydrology.StateModelVector

Bases: pybind11_object

A strongly typed list of StateModel’s

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.StateModelVector) -> None

  2. __init__(self: shyft.hydrology.StateModelVector, arg0: shyft.hydrology.StateModelVector) -> None

Copy constructor

  1. __init__(self: shyft.hydrology.StateModelVector, arg0: Iterable) -> None

append(self: shyft.hydrology.StateModelVector, x: shyft.hydrology.StateModel) None

Add an item to the end of the list

clear(self: shyft.hydrology.StateModelVector) None

Clear the contents

extend(*args, **kwargs)

Overloaded function.

  1. extend(self: shyft.hydrology.StateModelVector, L: shyft.hydrology.StateModelVector) -> None

Extend the list by appending all the items in the given list

  1. extend(self: shyft.hydrology.StateModelVector, L: Iterable) -> None

Extend the list by appending all the items in the given list

insert(self: shyft.hydrology.StateModelVector, i: int, x: shyft.hydrology.StateModel) None

Insert an item at a given position.

pop(*args, **kwargs)

Overloaded function.

  1. pop(self: shyft.hydrology.StateModelVector) -> shyft.hydrology.StateModel

Remove and return the last item

  1. pop(self: shyft.hydrology.StateModelVector, i: int) -> shyft.hydrology.StateModel

Remove and return the item at index i

size(self: shyft.hydrology.StateModelVector) int
class shyft.hydrology.StateServer

Bases: pybind11_object

The server-side component for the shyft.hydrology state model repository.

__init__(self: shyft.hydrology.StateServer, root_dir: str, config: shyft.time_series.ServerConfig = shyft.time_series.ServerConfig(stale_duration='1970-01-01T01:00:00Z', stale_sweep_interval='1970-01-01T00:00:00.100000Z', log=shyft.time_series.LogConfig(file='', level=200))) None

Creates a server object that serves models from root_dir. The root_dir will be create if it does not exists.

Parameters:
  • root_dir (str) – Path to the root-directory that keeps/will keep the model-files

  • config (ServerConfig) – Configuration of the server

get_listening_port(self: shyft.hydrology.StateServer) int

returns the port number it’s listening at for serving incoming request

get_max_connections(self: shyft.hydrology.StateServer) int

returns the maximum number of connections to be served concurrently

get_model_infos(self: shyft.hydrology.StateServer, mids: list[int], created_in: shyft.time_series.UtcPeriod = [not-valid-period>) list[shyft.time_series.ModelInfo]

returns all or selected model-info objects based on model-identifiers(mids)

Parameters:
  • mids (IntVector) – empty = all, or a list of known exisiting model-identifiers

  • created_in (UtcPeriod) – For which period you are interested in model-infos.

Returns:

model_infos. Strongly typed list of ModelInfo

Return type:

ModelInfoVector

is_running(self: shyft.hydrology.StateServer) bool

true if server is listening and running

See also

start_server()

read_model(self: shyft.hydrology.StateServer, mid: int) shyft.hydrology.StateModel

Read and return the model for specified model-identifier (mid)

Parameters:

mid (int) – the model-identifer for the wanted model

Returns:

  1. The resulting model from the server

Return type:

Model

read_model_blob(self: shyft.hydrology.StateServer, mid: int) shyft.time_series.ByteVector

Read and return the model blob for specified model-identifier (mid)

Parameters:

mid (int) – the model-identifer for the wanted model

Returns:

  1. The resulting blob model from the server

Return type:

ByteVector

read_models(self: shyft.hydrology.StateServer, mids: list[int]) shyft.hydrology.StateModelVector

Read and return the model for specified model-identifier (mid)

Parameters:

mids (list[int]) – A strongly typed list of ints, the model-identifers for the wanted models

Returns:

  1. The resulting model from the server

Return type:

Model

remove_model(self: shyft.hydrology.StateServer, mid: int) int

Remove the specified model bymodel-identifier (mid)

Parameters:

mid (int) – the model-identifer for the wanted model

Returns:

ec. 0 or error-code?

Return type:

int

set_listening_ip(self: shyft.hydrology.StateServer, ip: str) None

set the listening port for the service

Parameters:

ip (str) – ip or host-name to start listening on

Returns:

nothing.

Return type:

None

set_listening_port(self: shyft.hydrology.StateServer, port_no: int) None

set the listening port for the service

Parameters:
  • port_no (int) – a valid and available tcp-ip port number to listen on.

  • 20000 (typically it could be)

Returns:

nothing.

Return type:

None

set_max_connections(self: shyft.hydrology.StateServer, max_connect: int) None

limits simultaneous connections to the server (it’s multithreaded, and uses on thread pr. connect)

Parameters:

max_connect (int) – maximum number of connections before denying more connections

See also

get_max_connections()

property stale_connection_close_count

returns count of connection closed due to stale/no communication activity

Type:

int

start_server(self: shyft.hydrology.StateServer) int

start server listening in background, and processing messages

See also

set_listening_port(port_no),is_running

Returns:

port_no. the port used for listening operations, either the value as by set_listening_port, or if it was unspecified, a new available port

Return type:

in

stop_server(self: shyft.hydrology.StateServer, timeout: int = 1000) None

stop serving connections, gracefully.

See also

start_server()

store_model(self: shyft.hydrology.StateServer, m: shyft.hydrology.StateModel, mi: shyft.time_series.ModelInfo) int

Store the model to backend, if m.id==0 then a new unique model-info is created and used

Parameters:
  • m (Model) – The model to store

  • mi (ModelInfo) – The model-info to store for the model

Returns:

mid. model-identifier for the stored model and model-info

Return type:

int

update_model_info(self: shyft.hydrology.StateServer, mid: int, mi: shyft.time_series.ModelInfo) bool

Update the model-info for specified model-identifier(mid)

Parameters:
  • mid (int) – model-identifer

  • mi (ModelInfo) – The new updated model-info

Returns:

ok. true if success

Return type:

bool

class shyft.hydrology.TargetSpecCalcType

Bases: pybind11_object

Members:

NASH_SUTCLIFFE

KLING_GUPTA

ABS_DIFF

RMSE

ABS_DIFF = <TargetSpecCalcType.ABS_DIFF: 2>
KLING_GUPTA = <TargetSpecCalcType.KLING_GUPTA: 1>
NASH_SUTCLIFFE = <TargetSpecCalcType.NASH_SUTCLIFFE: 0>
RMSE = <TargetSpecCalcType.RMSE: 3>
__init__(self: shyft.hydrology.TargetSpecCalcType, value: int) None
property name
property value
class shyft.hydrology.TargetSpecificationPts

Bases: pybind11_object

To guide the model calibration, we have a goal-function that we try to minimize This class contains the needed specification of this goal-function so that we can:

  1. from simulations, collect time-series at catchment level for (DISCHARGE|SNOW_COVERED_AREA|SNOW_WATER_EQUIVALENT)

  2. from observations, have a user-specified series the expression above should be equal to

  3. use user specified kling-gupta factors to evaluate kind-of-difference between target and simulated

  4. scale-factor to put a weight on this specific target-specification compared to other(we can have multiple)

  5. a user specified id, uid, a string to identify the external source for calibration

  6. a user specified time-series expression with symbolic ref to sim, like TimeSeries(‘sim’).log()

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.TargetSpecificationPts) -> None

  2. __init__(self: shyft.hydrology.TargetSpecificationPts, ts: shyft.time_series.TsFixed, cids: list[int], scale_factor: float, calc_mode: shyft.hydrology.TargetSpecCalcType, s_r: float, s_a: float, s_b: float, catchment_property: shyft.hydrology.CatchmentPropertyType, uid: str) -> None

construct a target specification filled in with supplied parameters

Parameters:
  • ts (TsFixed) – time-series containing the target time-series

  • cids (IntVector) – A list of catchment id’s(cids) that together adds up into same as the target-ts

  • scale_factor (float) – the weight of this target-specification

  • calc_mode (TargetSpecCalcType) – specifies how to calculate the goal function, NS, KG, Abs,RMSE method

  • s_r (float) – KG scalefactor for correlation

  • s_a (float) – KG scalefactor for alpha(variance)

  • s_b (float) – KG scalefactor for beta(bias)

  • catchment_property (CatchmentPropertyType) – what to extract from catchment(DISCHARGE|SNOW_COVERED_AREA|SNOW_WATER_EQUIVALENT|ROUTED_DISCHARGE|CELL_CHARGE)

  • uid (str) – user specified string/id to help integration efforts

  1. __init__(self: shyft.hydrology.TargetSpecificationPts, ts: shyft.time_series.TimeSeries, cids: list[int], scale_factor: float, calc_mode: shyft.hydrology.TargetSpecCalcType, s_r: float, s_a: float, s_b: float, catchment_property: shyft.hydrology.CatchmentPropertyType, uid: str) -> None

construct a target specification filled in with supplied parameters

Parameters:
  • ts (TimeSeries) – time-series containing the target time-series, note that the time-axis of this ts must be a fixed-interval type

  • cids (IntVector) – A list of catchment id’s(cids) that together adds up into same as the target-ts

  • scale_factor (float) – the weight of this target-specification

  • calc_mode (TargetSpecCalcType) – specifies how to calculate the goal function, NS, KG, Abs method

  • s_r (float) – KG scalefactor for correlation

  • s_a (float) – KG scalefactor for alpha(variance)

  • s_b (float) – KG scalefactor for beta(bias)

  • catchment_property (CatchmentPropertyType) – what to extract from catchment(DISCHARGE|SNOW_COVERED_AREA|SNOW_WATER_EQUIVALENT|ROUTED_DISCHARGE|CELL_CHARGE)

  • uid (str) – user specified string/id to help integration efforts

  1. __init__(self: shyft.hydrology.TargetSpecificationPts, ts: shyft.time_series.TsFixed, cids: list[int], scale_factor: float, calc_mode: shyft.hydrology.TargetSpecCalcType) -> None

construct a target specification filled in with supplied parameters

Parameters:
  • ts (TsFixed) – time-series containing the target time-series

  • cids (IntVector) – A list of catchment id’s(cids) that together adds up into same as the target-ts

  • scale_factor (float) – the weight of this target-specification

  • calc_mode (TargetSpecCalcType) – specifies how to calculate the goal function, NS, KG, Abs method

  1. __init__(self: shyft.hydrology.TargetSpecificationPts, ts: shyft.time_series.TimeSeries, cids: list[int], scale_factor: float, calc_mode: shyft.hydrology.TargetSpecCalcType) -> None

construct a target specification filled in with supplied parameters

Parameters:
  • ts (TimeSeries) – time-series containing the target time-series, note the time-axis needs to be fixed_dt!

  • cids (IntVector) – A list of catchment id’s(cids) that together adds up into same as the target-ts

  • scale_factor (float) – the weight of this target-specification

  • calc_mode (TargetSpecCalcType) – specifies how to calculate the goal function, NS, KG, Abs method

  1. __init__(self: shyft.hydrology.TargetSpecificationPts, ts: shyft.time_series.TsFixed, rid: int, scale_factor: float, calc_mode: shyft.hydrology.TargetSpecCalcType, s_r: float, s_a: float, s_b: float, uid: str) -> None

construct a target specification filled in with supplied parameters

Parameters:
  • ts (TsFixed) – time-series containing the target time-series

  • rid (int) – A river-id identifying the point of flow in the river-network

  • scale_factor (float) – the weight of this target-specification

  • calc_mode (TargetSpecCalcType) – specifies how to calculate the goal function, NS, KG, Abs method

  • s_r (float) – KG scalefactor for correlation

  • s_a (float) – KG scalefactor for alpha(variance)

  • s_b (float) – KG scalefactor for beta(bias)

  • uid (str) – user specified string/id to help integration efforts

  1. __init__(self: shyft.hydrology.TargetSpecificationPts, ts: shyft.time_series.TimeSeries, rid: int, scale_factor: float, calc_mode: shyft.hydrology.TargetSpecCalcType, s_r: float, s_a: float, s_b: float, uid: str) -> None

construct a target specification filled in with supplied parameters

Parameters:
  • ts (TimeSeries) – time-series containing the target time-series, note time-axis required to be fixed-dt type

  • rid (int) – A river-id identifying the point of flow in the river-network

  • scale_factor (float) – the weight of this target-specification

  • calc_mode (TargetSpecCalcType) – specifies how to calculate the goal function, NS, KG, Abs method

  • s_r (float) – KG scalefactor for correlation

  • s_a (float) – KG scalefactor for alpha(variance)

  • s_b (float) – KG scalefactor for beta(bias)

  • uid (str) – user specified string/id to help integration efforts

property calc_mode

NASH_SUTCLIFFE, KLING_GUPTA,ABS_DIFF,RMSE

Type:

TargetSpecCalcType

property catchment_indexes

catchment indexes, ‘cids’

Type:

IntVector

property catchment_property

DISCHARGE,SNOW_COVERED_AREA, SNOW_WATER_EQUIVALENT

Type:

CatchmentPropertyType

evaluate_fx(self: shyft.hydrology.TargetSpecificationPts, ts: shyft.time_series.TimeSeries) shyft.time_series.TimeSeries

Compute the evaluated result using the fx expression.

Parameters:

ts (TimeSeries)

Returns:

result. The evaluated result using the passed time-series as substitute to symbolic reference(s).

Return type:

TimeSeries

property fx

TimeSeries(‘sim’).log()

Type:

TimeSeries

Type:

an expression to be applied to the simulated ts, e.g.

property river_id

river identifier for routed discharge calibration

Type:

int

property s_a

KG-scalefactor for alpha (variance)

Type:

float

property s_b

KG-scalefactor for beta (bias)

Type:

float

property s_r

KG-scalefactor for correlation

Type:

float

property scale_factor

the scale factor to be used when considering multiple target_specifications

Type:

float

property ts

target ts

Type:

TimeSeries

property uid

string

Type:

str

Type:

user specified identifier

class shyft.hydrology.TargetSpecificationVector

Bases: pybind11_object

A list of (weighted) target specifications to be used for model calibration

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.TargetSpecificationVector) -> None

  2. __init__(self: shyft.hydrology.TargetSpecificationVector, arg0: shyft.hydrology.TargetSpecificationVector) -> None

Copy constructor

  1. __init__(self: shyft.hydrology.TargetSpecificationVector, arg0: Iterable) -> None

append(self: shyft.hydrology.TargetSpecificationVector, x: shyft.hydrology.TargetSpecificationPts) None

Add an item to the end of the list

clear(self: shyft.hydrology.TargetSpecificationVector) None

Clear the contents

extend(*args, **kwargs)

Overloaded function.

  1. extend(self: shyft.hydrology.TargetSpecificationVector, L: shyft.hydrology.TargetSpecificationVector) -> None

Extend the list by appending all the items in the given list

  1. extend(self: shyft.hydrology.TargetSpecificationVector, L: Iterable) -> None

Extend the list by appending all the items in the given list

insert(self: shyft.hydrology.TargetSpecificationVector, i: int, x: shyft.hydrology.TargetSpecificationPts) None

Insert an item at a given position.

pop(*args, **kwargs)

Overloaded function.

  1. pop(self: shyft.hydrology.TargetSpecificationVector) -> shyft.hydrology.TargetSpecificationPts

Remove and return the last item

  1. pop(self: shyft.hydrology.TargetSpecificationVector, i: int) -> shyft.hydrology.TargetSpecificationPts

Remove and return the item at index i

size(self: shyft.hydrology.TargetSpecificationVector) int
class shyft.hydrology.TemperatureSource

Bases: GeoPointSource

geo located temperatures[deg Celcius]

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.TemperatureSource, midpoint: shyft.time_series.GeoPoint, ts: shyft.time_series.TimeSeries) -> None

  2. __init__(self: shyft.hydrology.TemperatureSource, geo_ts: shyft.time_series.GeoTimeSeries) -> None

vector_t

alias of TemperatureSourceVector

class shyft.hydrology.TemperatureSourceVector

Bases: pybind11_object

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.TemperatureSourceVector) -> None

  2. __init__(self: shyft.hydrology.TemperatureSourceVector, arg0: shyft.hydrology.TemperatureSourceVector) -> None

Copy constructor

  1. __init__(self: shyft.hydrology.TemperatureSourceVector, arg0: Iterable) -> None

  2. __init__(self: shyft.hydrology.TemperatureSourceVector, geo_ts_vector: shyft.time_series.GeoTimeSeriesVector) -> None

Construct from a GeoTimeSeriesVector, Reference to the shyft.time_series.GeoTsMatrix.extract_geo_ts_vector() to see how to create one from the dtss/geo extensions

append(self: shyft.hydrology.TemperatureSourceVector, x: shyft.hydrology.TemperatureSource) None

Add an item to the end of the list

clear(self: shyft.hydrology.TemperatureSourceVector) None

Clear the contents

extend(*args, **kwargs)

Overloaded function.

  1. extend(self: shyft.hydrology.TemperatureSourceVector, L: shyft.hydrology.TemperatureSourceVector) -> None

Extend the list by appending all the items in the given list

  1. extend(self: shyft.hydrology.TemperatureSourceVector, L: Iterable) -> None

Extend the list by appending all the items in the given list

static from_geo_and_ts_vector(geo_points: shyft.time_series.GeoPointVector, tsv: shyft.time_series.TsVector) shyft.hydrology.TemperatureSourceVector

Create from a geo_points and corresponding ts-vectors

Parameters:

geo_points (GeoPointVector) – the geo-points

Returns:

src_vector. a newly created geo-located vector of specified type

tsv (TsVector): the corresponding time-series located at corresponding geo-point

Return type:

SourceVector

property geo_tsvector

returns a GeoTimeSeriesVector containing GeoTimeSeries where the geo-points are copied, but time-series are by-reference

Type:

GeoTimeSeriesVector

insert(self: shyft.hydrology.TemperatureSourceVector, i: int, x: shyft.hydrology.TemperatureSource) None

Insert an item at a given position.

pop(*args, **kwargs)

Overloaded function.

  1. pop(self: shyft.hydrology.TemperatureSourceVector) -> shyft.hydrology.TemperatureSource

Remove and return the last item

  1. pop(self: shyft.hydrology.TemperatureSourceVector, i: int) -> shyft.hydrology.TemperatureSource

Remove and return the item at index i

size(self: shyft.hydrology.TemperatureSourceVector) int
values_at_time(self: shyft.hydrology.TemperatureSourceVector, arg0: shyft.time_series.time) list[float]
class shyft.hydrology.TsTransform

Bases: pybind11_object

transform the supplied time-series, f(t) interpreted according to its point_interpretation() policy into a new shyft core TsFixed time-series, that represents the true average for each of the n intervals of length dt, starting at start. the result ts will have the policy is set to POINT_AVERAGE_VALUE note: that the resulting ts is a fresh new ts, not connected to the source ts

__init__(self: shyft.hydrology.TsTransform) None
to_average(*args, **kwargs)

Overloaded function.

  1. to_average(self: shyft.hydrology.TsTransform, start: shyft.time_series.time, dt: shyft.time_series.time, n: int, src: shyft.time_series.TimeSeries) -> shyft.time_series.TsFixed

  2. to_average(self: shyft.hydrology.TsTransform, start: shyft.time_series.time, dt: shyft.time_series.time, n: int, src: shyft.time_series.TimeSeries) -> shyft.time_series.TsFixed

  3. to_average(self: shyft.hydrology.TsTransform, start: shyft.time_series.time, dt: shyft.time_series.time, n: int, src: shyft.time_series.TsFixed) -> shyft.time_series.TsFixed

  4. to_average(self: shyft.hydrology.TsTransform, start: shyft.time_series.time, dt: shyft.time_series.time, n: int, src: shyft.time_series.TsFixed) -> shyft.time_series.TsFixed

  5. to_average(self: shyft.hydrology.TsTransform, start: int, dt: int, n: int, src: shyft.time_series.TimeSeries) -> shyft.time_series.TsFixed

  6. to_average(self: shyft.hydrology.TsTransform, start: int, dt: int, n: int, src: shyft.time_series.TimeSeries) -> shyft.time_series.TsFixed

  7. to_average(self: shyft.hydrology.TsTransform, start: int, dt: int, n: int, src: shyft.time_series.TsFixed) -> shyft.time_series.TsFixed

  8. to_average(self: shyft.hydrology.TsTransform, start: int, dt: int, n: int, src: shyft.time_series.TsFixed) -> shyft.time_series.TsFixed

class shyft.hydrology.UHGParameter

Bases: pybind11_object

The Unit Hydro Graph Parameter contains sufficient description to create a unit hydro graph, that have a shape and a discretized ‘time-length’ according to the model time-step resolution. Currently we use a gamma function for the shape: <a ref=’https://en.wikipedia.org/wiki/Gamma_distribution’>gamma distribution</a>

__init__(self: shyft.hydrology.UHGParameter, velocity: float = 1.0, alpha: float = 7.0, beta: float = 0.0) None
property alpha

default 3.0,unit-less, ref. shape of gamma-function

Type:

float

property beta

default 0.0, unit-less, added to pdf of gamma(alpha,1.0)

Type:

float

property velocity

default 1.0, unit [m/s]

Type:

float

class shyft.hydrology.WindSpeedSource

Bases: GeoPointSource

geo located wind speeds[m/s]

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.WindSpeedSource, midpoint: shyft.time_series.GeoPoint, ts: shyft.time_series.TimeSeries) -> None

  2. __init__(self: shyft.hydrology.WindSpeedSource, geo_ts: shyft.time_series.GeoTimeSeries) -> None

vector_t

alias of WindSpeedSourceVector

class shyft.hydrology.WindSpeedSourceVector

Bases: pybind11_object

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: shyft.hydrology.WindSpeedSourceVector) -> None

  2. __init__(self: shyft.hydrology.WindSpeedSourceVector, arg0: shyft.hydrology.WindSpeedSourceVector) -> None

Copy constructor

  1. __init__(self: shyft.hydrology.WindSpeedSourceVector, arg0: Iterable) -> None

  2. __init__(self: shyft.hydrology.WindSpeedSourceVector, geo_ts_vector: shyft.time_series.GeoTimeSeriesVector) -> None

Construct from a GeoTimeSeriesVector, Reference to the shyft.time_series.GeoTsMatrix.extract_geo_ts_vector() to see how to create one from the dtss/geo extensions

append(self: shyft.hydrology.WindSpeedSourceVector, x: shyft.hydrology.WindSpeedSource) None

Add an item to the end of the list

clear(self: shyft.hydrology.WindSpeedSourceVector) None

Clear the contents

extend(*args, **kwargs)

Overloaded function.

  1. extend(self: shyft.hydrology.WindSpeedSourceVector, L: shyft.hydrology.WindSpeedSourceVector) -> None

Extend the list by appending all the items in the given list

  1. extend(self: shyft.hydrology.WindSpeedSourceVector, L: Iterable) -> None

Extend the list by appending all the items in the given list

static from_geo_and_ts_vector(geo_points: shyft.time_series.GeoPointVector, tsv: shyft.time_series.TsVector) shyft.hydrology.WindSpeedSourceVector

Create from a geo_points and corresponding ts-vectors

Parameters:

geo_points (GeoPointVector) – the geo-points

Returns:

src_vector. a newly created geo-located vector of specified type

tsv (TsVector): the corresponding time-series located at corresponding geo-point

Return type:

SourceVector

property geo_tsvector

returns a GeoTimeSeriesVector containing GeoTimeSeries where the geo-points are copied, but time-series are by-reference

Type:

GeoTimeSeriesVector

insert(self: shyft.hydrology.WindSpeedSourceVector, i: int, x: shyft.hydrology.WindSpeedSource) None

Insert an item at a given position.

pop(*args, **kwargs)

Overloaded function.

  1. pop(self: shyft.hydrology.WindSpeedSourceVector) -> shyft.hydrology.WindSpeedSource

Remove and return the last item

  1. pop(self: shyft.hydrology.WindSpeedSourceVector, i: int) -> shyft.hydrology.WindSpeedSource

Remove and return the item at index i

size(self: shyft.hydrology.WindSpeedSourceVector) int
values_at_time(self: shyft.hydrology.WindSpeedSourceVector, arg0: shyft.time_series.time) list[float]
shyft.hydrology.bayesian_kriging_temperature(src: shyft.hydrology.TemperatureSourceVector, dst: shyft.time_series.GeoPointVector, time_axis: shyft.time_series.TimeAxisFixedDeltaT, btk_parameter: shyft.hydrology.BTKParameter) shyft.hydrology.TemperatureSourceVector

Runs kriging for temperature sources and project the temperatures out to the destination geo-timeseries

Notice that bayesian kriging is currently not very efficient for large grid inputs, using only one thread, and considering all source-timeseries (entire grid) for all destinations For few sources, spread out on a grid, it’s quite efficient should work well

Parameters:
  • src (TemperatureSourceVector) – input a geo-located list of temperature time-series with filled in values (some might be nan etc.)

  • dst (GeoPointVector) – the GeoPoints,(x,y,z) locations to interpolate into

  • time_axis (TimeAxis) – the destination time-axis, recall that the inputs can be any-time-axis and they are transformed and interpolated into the destination-timeaxis

  • btk_parameter (BTKParameter) – the parameters to be used during interpolation

Returns:

result. with filled in temperatures according to their position, the idw_parameters and time_axis

Return type:

TemperatureSourceVector

shyft.hydrology.compute_geo_ts_values_at_time(*args, **kwargs)

Overloaded function.

  1. compute_geo_ts_values_at_time(geo_ts_vector: shyft.hydrology.GeoPointSourceVector, t: shyft.time_series.time) -> list[float]

compute the ts-values of the GeoPointSourceVector for the specified time t and return DoubleVector

Parameters:

geo_ts_vector (GeoPointSourceVector) – Any kind of GeoPointSource vector

Returns:

values. List of extracted values at same size/position as the geo_ts_vector

t (int): timestamp in utc seconds since epoch

Return type:

DoubleValue

  1. compute_geo_ts_values_at_time(geo_ts_vector: shyft.hydrology.TemperatureSourceVector, t: shyft.time_series.time) -> list[float]

compute the ts-values of the GeoPointSourceVector type for the specified time t and return DoubleVector

Parameters:

geo_ts_vector (GeoPointSourceVector) – Any kind of GeoPointSource vector

Returns:

values. List of extracted values at same size/position as the geo_ts_vector

t (int): timestamp in utc seconds since epoch

Return type:

DoubleValue

  1. compute_geo_ts_values_at_time(geo_ts_vector: shyft.hydrology.PrecipitationSourceVector, t: shyft.time_series.time) -> list[float]

compute the ts-values of the GeoPointSourceVector type for the specified time t and return DoubleVector

Parameters:

geo_ts_vector (GeoPointSourceVector) – Any kind of GeoPointSource vector

Returns:

values. List of extracted values at same size/position as the geo_ts_vector

t (int): timestamp in utc seconds since epoch

Return type:

DoubleValue

  1. compute_geo_ts_values_at_time(geo_ts_vector: shyft.hydrology.WindSpeedSourceVector, t: shyft.time_series.time) -> list[float]

compute the ts-values of the GeoPointSourceVector type for the specified time t and return DoubleVector

Parameters:

geo_ts_vector (GeoPointSourceVector) – Any kind of GeoPointSource vector

Returns:

values. List of extracted values at same size/position as the geo_ts_vector

t (int): timestamp in utc seconds since epoch

Return type:

DoubleValue

  1. compute_geo_ts_values_at_time(geo_ts_vector: shyft.hydrology.RelHumSourceVector, t: shyft.time_series.time) -> list[float]

compute the ts-values of the GeoPointSourceVector type for the specified time t and return DoubleVector

Parameters:

geo_ts_vector (GeoPointSourceVector) – Any kind of GeoPointSource vector

Returns:

values. List of extracted values at same size/position as the geo_ts_vector

t (int): timestamp in utc seconds since epoch

Return type:

DoubleValue

  1. compute_geo_ts_values_at_time(geo_ts_vector: shyft.hydrology.RadiationSourceVector, t: shyft.time_series.time) -> list[float]

compute the ts-values of the GeoPointSourceVector type for the specified time t and return DoubleVector

Parameters:

geo_ts_vector (GeoPointSourceVector) – Any kind of GeoPointSource vector

Returns:

values. List of extracted values at same size/position as the geo_ts_vector

t (int): timestamp in utc seconds since epoch

Return type:

DoubleValue

shyft.hydrology.create_precipitation_source_vector_from_np_array(time_axis: shyft.time_series.TimeAxis, geo_points: shyft.time_series.GeoPointVector, np_array: numpy.ndarray[numpy.float64], point_fx: shyft.time_series.point_interpretation_policy) shyft.hydrology.PrecipitationSourceVector

Create a PrecipitationSourceVector from specified time_axis,geo_points, 2-d np_array and point_fx.

Parameters:
  • time_axis (TimeAxis) – time-axis that matches in length to 2nd dim of np_array

  • geo_points (GeoPointVector) – the geo-positions for the time-series, should be of length n_ts

  • np_array (np.ndarray) – numpy array of dtype=np.float64, and shape(n_ts,n_points)

  • point_fx (point interpretation) – one of POINT_AVERAGE_VALUE|POINT_INSTANT_VALUE

Returns:

tsv. a PrecipitationSourceVector of length first np_array dim, n_ts, each with geo-point and time-series with time-axis, values and point_fx

Return type:

PrecipitationSourceVector

shyft.hydrology.create_radiation_source_vector_from_np_array(time_axis: shyft.time_series.TimeAxis, geo_points: shyft.time_series.GeoPointVector, np_array: numpy.ndarray[numpy.float64], point_fx: shyft.time_series.point_interpretation_policy) shyft.hydrology.RadiationSourceVector

Create a RadiationSourceVector from specified time_axis,geo_points, 2-d np_array and point_fx.

Parameters:
  • time_axis (TimeAxis) – time-axis that matches in length to 2nd dim of np_array

  • geo_points (GeoPointVector) – the geo-positions for the time-series, should be of length n_ts

  • np_array (np.ndarray) – numpy array of dtype=np.float64, and shape(n_ts,n_points)

  • point_fx (point interpretation) – one of POINT_AVERAGE_VALUE|POINT_INSTANT_VALUE

Returns:

tsv. a RadiationSourceVector of length first np_array dim, n_ts, each with geo-point and time-series with time-axis, values and point_fx

Return type:

RadiationSourceVector

shyft.hydrology.create_rel_hum_source_vector_from_np_array(time_axis: shyft.time_series.TimeAxis, geo_points: shyft.time_series.GeoPointVector, np_array: numpy.ndarray[numpy.float64], point_fx: shyft.time_series.point_interpretation_policy) shyft.hydrology.RelHumSourceVector

Create a RelHumSourceVector from specified time_axis,geo_points, 2-d np_array and point_fx.

Parameters:
  • time_axis (TimeAxis) – time-axis that matches in length to 2nd dim of np_array

  • geo_points (GeoPointVector) – the geo-positions for the time-series, should be of length n_ts

  • np_array (np.ndarray) – numpy array of dtype=np.float64, and shape(n_ts,n_points)

  • point_fx (point interpretation) – one of POINT_AVERAGE_VALUE|POINT_INSTANT_VALUE

Returns:

tsv. a RelHumSourceVector of length first np_array dim, n_ts, each with geo-point and time-series with time-axis, values and point_fx

Return type:

RelHumSourceVector

shyft.hydrology.create_temperature_source_vector_from_np_array(time_axis: shyft.time_series.TimeAxis, geo_points: shyft.time_series.GeoPointVector, np_array: numpy.ndarray[numpy.float64], point_fx: shyft.time_series.point_interpretation_policy) shyft.hydrology.TemperatureSourceVector

Create a TemperatureSourceVector from specified time_axis,geo_points, 2-d np_array and point_fx.

Parameters:
  • time_axis (TimeAxis) – time-axis that matches in length to 2nd dim of np_array

  • geo_points (GeoPointVector) – the geo-positions for the time-series, should be of length n_ts

  • np_array (np.ndarray) – numpy array of dtype=np.float64, and shape(n_ts,n_points)

  • point_fx (point interpretation) – one of POINT_AVERAGE_VALUE|POINT_INSTANT_VALUE

Returns:

tsv. a TemperatureSourceVector of length first np_array dim, n_ts, each with geo-point and time-series with time-axis, values and point_fx

Return type:

TemperatureSourceVector

shyft.hydrology.create_wind_speed_source_vector_from_np_array(time_axis: shyft.time_series.TimeAxis, geo_points: shyft.time_series.GeoPointVector, np_array: numpy.ndarray[numpy.float64], point_fx: shyft.time_series.point_interpretation_policy) shyft.hydrology.WindSpeedSourceVector

Create a WindSpeedSourceVector from specified time_axis,geo_points, 2-d np_array and point_fx.

Parameters:
  • time_axis (TimeAxis) – time-axis that matches in length to 2nd dim of np_array

  • geo_points (GeoPointVector) – the geo-positions for the time-series, should be of length n_ts

  • np_array (np.ndarray) – numpy array of dtype=np.float64, and shape(n_ts,n_points)

  • point_fx (point interpretation) – one of POINT_AVERAGE_VALUE|POINT_INSTANT_VALUE

Returns:

tsv. a WindSpeedSourceVector of length first np_array dim, n_ts, each with geo-point and time-series with time-axis, values and point_fx

Return type:

WindSpeedSourceVector

shyft.hydrology.glacier_melt_step(dtf: float, temperature: float, sca: float, glacier_fraction: float) float

Calculates outflow from glacier melt rate [mm/h].

Parameters:
  • dtf (float) – degree timestep factor [mm/day/deg.C]; lit. values for Norway: 5.5 - 6.4 in Hock, R. (2003), J. Hydrol., 282, 104-115.

  • temperature (float) – degC, considered constant over timestep dt

  • sca (float) – fraction of snow cover in cell [0..1], glacier melt occurs only if glacier fraction > snow fraction

  • glacier_fraction (float) – glacier fraction [0..1] in the total area

Returns:

glacier_melt. output from glacier, melt rate [mm/h]

Return type:

float

shyft.hydrology.idw_precipitation(src: shyft.hydrology.PrecipitationSourceVector, dst: shyft.time_series.GeoPointVector, time_axis: shyft.time_series.TimeAxisFixedDeltaT, idw_param: shyft.hydrology.IDWPrecipitationParameter) shyft.hydrology.PrecipitationSourceVector

Runs inverse distance interpolation to project precipitation sources out to the destination geo-timeseries

Parameters:
  • src (PrecipitationSourceVector) – a geo-located list of precipitation time-series with filled in values (some might be nan etc.)

  • dst (GeoPointVector) – the GeoPoints,(x,y,z) locations to interpolate into

  • time_axis (TimeAxis) – the destination time-axis, recall that the inputs can be any-time-axis, they are transformed and interpolated into the destination-timeaxis

  • idw_param (IDWPrecipitationParameter) – the parameters to be used during interpolation

Returns:

precipitation. with filled in precipitations according to their position, the idw_parameters and time_axis

Return type:

PrecipitationSourceVector

shyft.hydrology.idw_radiation(src: shyft.hydrology.RadiationSourceVector, dst: shyft.time_series.GeoPointVector, time_axis: shyft.time_series.TimeAxisFixedDeltaT, idw_param: shyft.hydrology.IDWParameter, slope_factors: list[float]) shyft.hydrology.RadiationSourceVector

Runs inverse distance interpolation to project radiation sources out to the destination geo-timeseries

Parameters:
  • src (RadiationSourceVector) – input a geo-located list of precipitation time-series with filled in values (some might be nan etc.)

  • dst (GeoPointVector) – the GeoPoints,(x,y,z) locations to interpolate into

  • time_axis (TimeAxis) – the destination time-axis, recall that the inputs can be any-time-axis, they are transformed and interpolated into the destination-timeaxis

  • idw_param (IDWParameter) – the parameters to be used during interpolation

  • slope_factors (DoubleVector) – the slope-factor corresponding to geopoints, typical 0.9

Returns:

radiation. with filled in radiation according to their position, the idw_parameters and time_axis

Return type:

RadiationSourceVector

shyft.hydrology.idw_relative_humidity(src: shyft.hydrology.RelHumSourceVector, dst: shyft.time_series.GeoPointVector, time_axis: shyft.time_series.TimeAxisFixedDeltaT, idw_param: shyft.hydrology.IDWParameter) shyft.hydrology.RelHumSourceVector

Runs inverse distance interpolation to project relative humidity sources out to the destination geo-timeseries

Parameters:
  • src (RelHumSourceVector) – input a geo-located list of precipitation time-series with filled in values (some might be nan etc.)

  • dst (GeoPointVector) – the GeoPoints,(x,y,z) locations to interpolate into

  • time_axis (TimeAxis) – the destination time-axis, recall that the inputs can be any-time-axis, they are transformed and interpolated into the destination-timeaxis

  • idw_param (IDWParameter) – the parameters to be used during interpolation

Returns:

relhum. with filled in relative humidity according to their position, the idw_parameters and time_axis

Return type:

RelHumSourceVector

shyft.hydrology.idw_temperature(src: shyft.hydrology.TemperatureSourceVector, dst: shyft.time_series.GeoPointVector, time_axis: shyft.time_series.TimeAxisFixedDeltaT, idw_param: shyft.hydrology.IDWTemperatureParameter) shyft.hydrology.TemperatureSourceVector

Runs inverse distance interpolation to project temperature sources out to the destination geo-timeseries

Parameters:
  • src (TemperatureSourceVectorn) – input a geo-located list of temperature time-series with filled in values (some might be nan etc.)

  • dst (GeoPointVector) – the GeoPoints,(x,y,z) locations to interpolate into

  • time_axis (TimeAxis) – the destination time-axis, recall that the inputs can be any-time-axis, they are transformed and interpolated into the destination-timeaxis

  • idw_param (IDWTemperatureParameter) – the parameters to be used during interpolation, defines the behaviour of the interpolation. Please use help on the IDWTemperatureParameter for details.

Returns:

temperatures. with filled in temperatures according to their position, the idw_parameters and time_axis

Return type:

TemperatureSourceVector

shyft.hydrology.idw_wind_speed(src: shyft.hydrology.WindSpeedSourceVector, dst: shyft.time_series.GeoPointVector, time_axis: shyft.time_series.TimeAxisFixedDeltaT, idw_param: shyft.hydrology.IDWParameter, shear_factor: float = nan, hub_height: float = nan, reference_height: float = nan) shyft.hydrology.WindSpeedSourceVector

Runs inverse distance interpolation to project geo located wind input sources out to the destination geo-timeseries

Parameters:
  • src (WindspeedSourceVector) – input a geo-located list of wind speed time-series with filled in values (some might be nan etc.)

  • dst (GeoPointVector) – the GeoPoints,(x,y,z) locations to interpolate into

  • time_axis (TimeAxis) – the destination time-axis, recall that the inputs can be any-time-axis, they are transformed and interpolated into the destination-timeaxis

  • idw_param (IDWParametern) – the parameters to be used during interpolation

  • shear_factor (float) – optional:wind shear coefficient to estimate the wind speed at higher elevations, typical 0.11 onshore and 0.15 offshore,>0.0

  • hub_height (float) – optional:distance from the ground to the middle of the turbine’s rotor, >0.0

  • reference_height (float) – optional: height above ground of measured wind speed, >0.0

Returns:

windspeed. with filled in wind speed according to their position, the idw_parameters and time_axis

Return type:

WindSpeedSourceVector

shyft.hydrology.make_uhg_from_gamma(n_steps: int, alpha: float, beta: float) list[float]

make_uhg_from_gamma a simple function to create a uhg (unit hydro graph) weight vector containing n_steps, given the gamma shape factor alpha and beta. ensuring the sum of the weight vector is 1.0 and that it has a min-size of one element (1.0)

Parameters:
  • n_steps (int) – number of time-steps, elements, in the vectorn

  • alpha (float) – the gamma_distribution gamma-factor

  • beta (float) – the base-line, added to pdf(gamma(alpha,1))

Returns:

unit hydro graph factors. - normalized to sum 1.0

shyft.hydrology.ordinary_kriging(src: shyft.hydrology.GeoPointSourceVector, dst: shyft.time_series.GeoPointVector, time_axis: shyft.time_series.TimeAxisFixedDeltaT, parameter: shyft.hydrology.OKParameter) shyft.hydrology.GeoPointSourceVector

Runs ordinary kriging for geo sources and project the source out to the destination geo-timeseries Notice that kriging is currently not very efficient for large grid inputs, using only one thread, and considering all source-timeseries (entire grid) for all destinations For few sources, spread out on a grid, it’s quite efficient should work well Also note that this function currently does not elicite observations with nan-data most useful when you have control on the inputs, providing full set of data.

Parameters:
  • src (GeoSourceVector) – input a geo-located list of time-series with filled in values

  • dst (GeoPointVector) – the GeoPoints,(x,y,z) locations to interpolate into

  • time_axis (TimeAxis) – the destination time-axis, recall that the inputs can be any-time-axis, and they are transformed and interpolated into the destination-timeaxis

  • parameter (OKParameter) – the parameters to be used during interpolation

Returns:

result. with filled in ts-values according to their position, the parameters and time_axis

Return type:

GeoSourceVector

shyft.hydrology.parse_cf_time(reference: str) shyft.time_series.UtcPeriod

parses cf time unit string like hours since 1970-01-01 00:00:00 and returs an UtcPeriod, where the .start is the reference time and the .timespan() is the delta time, e.g. 3600.0 If the reference is illformed, then the returned period is not .valid() The intended usage is to get the reference time and time-delta of netcdf files, replacing the need of cftime python library.

Parameters:

reference (str) – netcdf time-reference

Returns:

  1. p.valid()==True if well formed,p.start equal to the reference time, and p.timespan() equal to the time-delta specified

Return type:

UtcPeriod

class shyft.hydrology.stat_scope

Bases: pybind11_object

Defines the scope of the indexes passed to statistics functions .cell : the indexes are considered as the i’th cell .catchment : the indexes are considered catchment identifiers

The statistics is then covering the cells that matches the selected criteria

Members:

cell

catchment

__init__(self: shyft.hydrology.stat_scope, value: int) None
catchment = <stat_scope.catchment: 1>
cell = <stat_scope.cell: 0>
property name
property value
shyft.hydrology.version() str