epyt_flow.uncertainty

epyt_flow.uncertainty.model_uncertainty

Module provides a class for implementing model uncertainty.

class epyt_flow.uncertainty.model_uncertainty.ModelUncertainty(global_pipe_length_uncertainty: Uncertainty | None = None, global_pipe_roughness_uncertainty: Uncertainty | None = None, global_pipe_diameter_uncertainty: Uncertainty | None = None, global_base_demand_uncertainty: Uncertainty | None = None, global_demand_pattern_uncertainty: Uncertainty | None = None, global_elevation_uncertainty: Uncertainty | None = None, global_constants_uncertainty: Uncertainty | None = None, global_parameters_uncertainty: Uncertainty | None = None, local_pipe_length_uncertainty: dict[str, Uncertainty] | None = None, local_pipe_roughness_uncertainty: dict[str, Uncertainty] | None = None, local_pipe_diameter_uncertainty: dict[str, Uncertainty] | None = None, local_base_demand_uncertainty: dict[str, Uncertainty] | None = None, local_demand_pattern_uncertainty: dict[str, Uncertainty] | None = None, local_elevation_uncertainty: dict[str, Uncertainty] | None = None, local_constants_uncertainty: dict[str, Uncertainty] | None = None, local_parameters_uncertainty: dict[str, int, Uncertainty] | None = None, local_patterns_uncertainty: dict[str, Uncertainty] | None = None, local_msx_patterns_uncertainty: dict[str, Uncertainty] | None = None, seed: int | None = None, cache_original: bool | None = True, **kwds)[source]

Bases: JsonSerializable

Class implementing model uncertainty – i.e. uncertainties in pipe length, pipe roughness, base demand, etc.

Parameters:
  • global_pipe_length_uncertainty (Uncertainty, optional) –

    Global uncertainty of pipe lengths. None, in the case of no uncertainty.

    The default is None.

  • global_pipe_roughness_uncertainty (Uncertainty, optional) –

    Global uncertainty of pipe roughness coefficients. None, in the case of no uncertainty.

    The default is None.

  • global_pipe_diameter_uncertainty (Uncertainty, optional) –

    Global uncertainty of pipe diameters. None, in the case of no uncertainty.

    The default is None.

  • global_base_demand_uncertainty (Uncertainty, optional) –

    Global uncertainty of base demands. None, in the case of no uncertainty.

    The default is None.

  • global_demand_pattern_uncertainty (Uncertainty, optional) –

    Global uncertainty of demand patterns. None, in the case of no uncertainty.

    The default is None.

  • global_elevation_uncertainty (Uncertainty, optional) –

    Global uncertainty of elevations. None, in the case of no uncertainty.

    The default is None.

  • global_constants_uncertainty (Uncertainty, optional) –

    Global uncertainty of MSX constants. None, in the case of no uncertainty.

    The default is None.

  • global_parameters_uncertainty (Uncertainty, optional) –

    Global uncertainty of MSX parameters. None, in the case of no uncertaint.

    The default is None.

  • local_pipe_length_uncertainty (dict[str, Uncertainty], optional) –

    Local uncertainty of pipe lengths – i.e. a dictionary of pipe IDs and uncertainties.

    None, in the case of no uncertainty.

    The default is None.

  • local_pipe_roughness_uncertainty (dict[str, Uncertainty], optional) –

    Local uncertainty of pipe roughness coefficients – i.e. a dictionary of pipe IDs and uncertainties.

    None, in the case of no uncertainty.

    The default is None.

  • local_pipe_diameter_uncertainty (dict[str, Uncertainty], optional) –

    Local uncertainty of pipe diameters – i.e. a dictionary of pipe IDs and uncertainties.

    None, in the case of no uncertainty.

    The default is None.

  • local_base_demand_uncertainty (dict[str, Uncertainty], optional) –

    Local uncertainty of base demands – i.e. a dictionary of node IDs and uncertainties.

    None, in the case of no uncertainty.

    The default is None.

  • local_demand_pattern_uncertainty (dict[str, Uncertainty], optional) –

    Local uncertainty of demand patterns – i.e. a dictionary of demand pattern IDs and uncertainties.

    None, in the case of no uncertainty.

    The default is None.

  • local_elevation_uncertainty (dict[str, Uncertainty], optional) –

    Local uncertainty of elevations – i.e. a dictionary of node IDs and uncertainties.

    None, in the case of no uncertainty.

    The default is None.

  • local_constants_uncertainty (dict[str, Uncertainty], optional) –

    Local uncertainty of MSX constants – i.e. a dictionary of constant IDs and uncertainties.

    None, in the case of no uncertainty.

    The default is None.

  • local_parameters_uncertainty (dict[tuple[str, int, str] Uncertainty], optional) –

    Local uncertainty of MSX parameters – i.e. a dictionary of (parameter ID, item type, item ID) and uncertainties.

    None, in the case of no uncertainty.

    The default is None.

  • local_patterns_uncertainty (dict[str, Uncertainty], optional) –

    Local uncertainty of EPANET patterns – i.e. a dictionary of pattern IDs and uncertainties.

    None, in the case of no uncertainty.

    The default is None.

  • local_msx_patterns_uncertainty (dict[str, Uncertainty], optional) –

    Local uncertainty of EPANET-MSX patterns – i.e. a dictionary of MSX pattern IDs and uncertainties.

    None, in the case of no uncertainty.

    The default is None.

  • seed (int, optional) –

    Seed for the random number generator.

    Thed default is None.

  • cache_original (bool, optional) –

    If True, all original properties are cached before the uncertainties are applied. This is necessary if you have multiple simulation runs and you want to reset/re-apply the uncertainties before each run.

    You can set it to False if you do not and want to re-apply the uncertainties and save some working memory.

    The default is True.

apply(epanet_api: epanet_plus.EPyT) None[source]

Applies the specified model uncertainties to the scenario.

Parameters:

epanet_api (epanet_plus.EPyT) – Interface to EPANET and EPANET-MSX.

static file_ext() str

Returns the file extension of this class.

This function is automatically implemented by applying the serializable() decorator.

Returns:

File extension.

Return type:

str

get_attributes() dict[source]

Gets all attributes to be serialized – these attributes are passed to the constructor when the object is deserialized.

Returns:

Dictionary of attributes – i.e. pairs of attribute name + value.

Return type:

dict

property global_base_demand: Uncertainty

Returns the global base demand uncertainty.

Returns:

Global base demand uncertainty.

Return type:

Uncertainty

property global_constants: Uncertainty

Returns the global MSX constant uncertainty.

Returns:

Global MSX constant uncertainty.

Return type:

Uncertainty

property global_demand_pattern: Uncertainty

Returns the global demand pattern uncertainty.

Returns:

Global demand pattern uncertainty.

Return type:

Uncertainty

property global_elevation: Uncertainty

Returns the global node elevation uncertainty.

Returns:

Global node elevation uncertainty.

Return type:

Uncertainty

property global_parameters: Uncertainty

Returns the global MSX parameter uncertainty.

Returns:

Global MSX parameter uncertainty.

Return type:

Uncertainty

property global_pipe_diameter: Uncertainty

Returns the global pipe diameter uncertainty.

Returns:

Global pipe diameter uncertainty.

Return type:

Uncertainty

property global_pipe_length: Uncertainty

Returns the global pipe length uncertainty.

Returns:

Global pipe length uncertainty.

Return type:

Uncertainty

property global_pipe_roughness: Uncertainty

Returns the global pipe roughness uncertainty.

Returns:

Global pipe roughness uncertainty.

Return type:

Uncertainty

property local_base_demand: dict[str, Uncertainty]

Returns the local base demand uncertainty.

Returns:

Local base demand uncertainty.

Return type:

dict[str, Uncertainty]

property local_constants: dict[str, Uncertainty]

Returns the local MSX constant uncertainty.

Returns:

Local MSX constant uncertainty.

Return type:

dict[str, Uncertainty]

property local_demand_pattern: dict[str, Uncertainty]

Returns the local demand pattern uncertainty.

Returns:

Local demand pattern uncertainty.

Return type:

dict[str, Uncertainty]

property local_elevation: dict[str, Uncertainty]

Returns the local node elevation uncertainty.

Returns:

Local node elevation uncertainty.

Return type:

dict[str, Uncertainty]

property local_msx_patterns: dict[str, Uncertainty]

Returns the local EPANET-MSX patterns uncertainty.

Returns:

Local EPANET-MSX patterns uncertainty.

Return type:

dict[str, Uncertainty]

property local_parameters: dict[tuple[str, int, str], Uncertainty]

Returns the local MSX parameter uncertainty.

Returns:

Local MSX parameter uncertainty.

Return type:

dict[tuple[str, int, str], Uncertainty]

property local_patterns: dict[str, Uncertainty]

Returns the local EPANET patterns uncertainty.

Returns:

Local EPANET patterns uncertainty.

Return type:

dict[str, Uncertainty]

property local_pipe_diameter: dict[str, Uncertainty]

Returns the local pipe diameter uncertainty.

Returns:

Local pipe diameter uncertainty.

Return type:

dict[str, Uncertainty]

property local_pipe_length: dict[str, Uncertainty]

Returns the local pipe length uncertainty.

Returns:

Local pipe length uncertainty.

Return type:

dict[str, Uncertainty]

property local_pipe_roughness: dict[str, Uncertainty]

Returns the local pipe roughness uncertainty.

Returns:

Local pipe roughness uncertainty.

Return type:

dict[str, Uncertainty]

property seed: int

Returns the seed used for the random number generator.

Returns:

Seed for the random number generator.

Return type:

int

undo(epanet_api: epanet_plus.EPyT) None[source]

Undo all applied uncertainties – i.e, resets the properties to their original value.

Note that this function can only be used if cache_original (of the constructor) was set to True (default).

Parameters:

epanet_api – Interface to EPANET and EPANET-MSX

epyt_flow.uncertainty.sensor_noise

Module provides a class for implementing sensor noise (e.g. uncertainty in sensor readings).

class epyt_flow.uncertainty.sensor_noise.SensorNoise(global_uncertainty: Uncertainty | None = None, local_uncertainties: dict[int, str, Uncertainty] | None = None, seed: int | None = None, **kwds)[source]

Bases: JsonSerializable

Class implementing sensor noise/uncertainty.

Parameters:
  • global_uncertainty (Uncertainty, optional) –

    Global sensor uncertainty. If None, no global sensor uncertainties are applied.

    The default is None.

  • local_uncertainties (dict[tuple[int, str], Uncertainty], optional) –

    Local (i.e. sensor specific) uncertainties. If None, no local sensor uncertainties are applied.

    The default is None.

  • seed (int, optional) –

    Seed for the random number generator.

    The default is None.

apply_global_uncertainty(sensor_readings: numpy.ndarray) numpy.ndarray[source]

Applies the global sensor uncertainty to given sensor readings – i.e. sensor readings are perturbed according to the specified uncertainty.

Note

Note that state sensor readings such as valve states, pump states, etc. are NOT affected by sensor noise!

Parameters:

sensor_readings (numpy.ndarray) – All (global) senor readings.

Returns:

Perturbed sensor readings.

Return type:

numpy.ndarray

apply_local_uncertainty(map_sensor_to_idx: Callable[[int, str], int], sensor_readings: numpy.ndarray) numpy.ndarray[source]

Applies the local (i.e. sensor specific) sensor uncertainties – i.e. sensor readings are perturbed according to the specified uncertainties.

Parameters:
  • map_sensor_to_idx (Callable[[int, str], int]) – Function mapping sensor type (int) and sensor id (e.g. node id, link id, etc.) to indices in the final sensor readings.

  • sensor_readings – All (global) sensor readings (no matter if ther).

Returns:

Perturbed sensor readings.

Return type:

numpy.ndarray

static file_ext() str

Returns the file extension of this class.

This function is automatically implemented by applying the serializable() decorator.

Returns:

File extension.

Return type:

str

get_attributes() dict[source]

Gets all attributes to be serialized – these attributes are passed to the constructor when the object is deserialized.

Returns:

Dictionary of attributes – i.e. pairs of attribute name + value.

Return type:

dict

property global_uncertainty: Uncertainty

Returns the global sensor readings uncertainty.

Returns:

Global sensor readings uncertainty.

Return type:

Uncertainty

property local_uncertainties: dict[int, str, Uncertainty]

Returns the local (i.e. sensor specific) uncertainties.

Returns:

Local (i.e. sensor specific) uncertainties.

Return type:

dict[tuple[int, str], Uncertainty]

epyt_flow.uncertainty.uncertainties

Module provides classes for implementing different types of uncertainties.

class epyt_flow.uncertainty.uncertainties.AbsoluteDeepGaussianUncertainty(mean: float | None = None, **kwds)[source]

Bases: DeepGaussianUncertainty, JsonSerializable

Class implementing absolute deep Gaussian uncertainty – i.e. random Gaussian noise (mean and variance are changing over time) is added to the data.

apply(data: float) float[source]

Applies the uncertainty to a single value.

Parameters:

data (float) – The value to which the uncertainty is applied.

Returns:

Uncertainty applied to ‘data’.

Return type:

float

static file_ext() str

Returns the file extension of this class.

This function is automatically implemented by applying the serializable() decorator.

Returns:

File extension.

Return type:

str

class epyt_flow.uncertainty.uncertainties.AbsoluteDeepUncertainty(min_noise_value: float = 0.0, max_noise_value: float = 1.0, **kwds)[source]

Bases: DeepUncertainty, JsonSerializable

Class implementing absolute deep uncertainty – i.e. completely random noise is added to the data.

apply(data: float) float[source]

Applies the uncertainty to a single value.

Parameters:

data (float) – The value to which the uncertainty is applied.

Returns:

Uncertainty applied to ‘data’.

Return type:

float

static file_ext() str

Returns the file extension of this class.

This function is automatically implemented by applying the serializable() decorator.

Returns:

File extension.

Return type:

str

class epyt_flow.uncertainty.uncertainties.AbsoluteDeepUniformUncertainty(**kwds)[source]

Bases: DeepUniformUncertainty, JsonSerializable

Class implementing absolute deep uniform uncertainty – i.e. random uniform noise (shape of the noise is changing over time) is added to the data.

apply(data: float) float[source]

Applies the uncertainty to a single value.

Parameters:

data (float) – The value to which the uncertainty is applied.

Returns:

Uncertainty applied to ‘data’.

Return type:

float

static file_ext() str

Returns the file extension of this class.

This function is automatically implemented by applying the serializable() decorator.

Returns:

File extension.

Return type:

str

class epyt_flow.uncertainty.uncertainties.AbsoluteGaussianUncertainty(mean: float | None = None, scale: float | None = None, **kwds)[source]

Bases: GaussianUncertainty, JsonSerializable

Class implementing absolute Gaussian uncertainty – i.e. Gaussian noise is added to the data.

apply(data: float) float[source]

Applies the uncertainty to a single value.

Parameters:

data (float) – The value to which the uncertainty is applied.

Returns:

Uncertainty applied to ‘data’.

Return type:

float

static file_ext() str

Returns the file extension of this class.

This function is automatically implemented by applying the serializable() decorator.

Returns:

File extension.

Return type:

str

class epyt_flow.uncertainty.uncertainties.AbsoluteUniformUncertainty(low: float = 0.0, high: float = 1.0, **kwds)[source]

Bases: UniformUncertainty, JsonSerializable

Class implementing absolute uniform uncertainty – i.e. uniform noise is added to the data.

apply(data: float) float[source]

Applies the uncertainty to a single value.

Parameters:

data (float) – The value to which the uncertainty is applied.

Returns:

Uncertainty applied to ‘data’.

Return type:

float

static file_ext() str

Returns the file extension of this class.

This function is automatically implemented by applying the serializable() decorator.

Returns:

File extension.

Return type:

str

class epyt_flow.uncertainty.uncertainties.DeepGaussianUncertainty(mean: float | None = None, **kwds)[source]

Bases: Uncertainty, JsonSerializable

Base class implementing deep Gaussian uncertainty.

Parameters:

mean (float, optional) –

Fixed mean of Gaussian noise. If None, random means are generated.

The default is None.

abstract apply(data: float) float[source]

Applies the uncertainty to a single value.

Parameters:

data (float) – The value to which the uncertainty is applied.

Returns:

Uncertainty applied to ‘data’.

Return type:

float

set_random_generator(np_rand_generator) None[source]

Sets the random number generator that is going to be used for generating the uncertainties.

Parameters:

np_rand_generator (numpy.random.Generator, optional) –

The random number generator.

The default is the default BitGenerator (PCG64) as constructed by numpy.random.default_rng().

class epyt_flow.uncertainty.uncertainties.DeepUncertainty(min_noise_value: float = 0.0, max_noise_value: float = 1.0, **kwds)[source]

Bases: Uncertainty

Base class implementing deep uncertainty.

Parameters:
  • min_noise_value (float) – Lower bound on the noise.

  • max_noise_value (float) – Upper bound on the noise.

abstract apply(data: float) float[source]

Applies the uncertainty to a single value.

Parameters:

data (float) – The value to which the uncertainty is applied.

Returns:

Uncertainty applied to ‘data’.

Return type:

float

get_attributes() dict[source]

Gets all attributes to be serialized – these attributes are passed to the constructor when the object is deserialized.

Returns:

Dictionary of attributes – i.e. pairs of attribute name + value.

Return type:

dict

property max_noise_value: float

Gets the upper bound on the noise.

Returns:

Upper bound on the noise.

Return type:

float

property min_noise_value: float

Gets the lower bound on the noise.

Returns:

Lower bound on the noise.

Return type:

float

set_random_generator(np_rand_generator) None[source]

Sets the random number generator that is going to be used for generating the uncertainties.

Parameters:

np_rand_generator

The random number generator.

The default is the default BitGenerator (PCG64) as constructed by numpy.random.default_rng().

class epyt_flow.uncertainty.uncertainties.DeepUniformUncertainty(**kwds)[source]

Bases: Uncertainty

Base class implementing deep uniform uncertainty.

abstract apply(data: float) float[source]

Applies the uncertainty to a single value.

Parameters:

data (float) – The value to which the uncertainty is applied.

Returns:

Uncertainty applied to ‘data’.

Return type:

float

set_random_generator(np_rand_generator) None[source]

Sets the random number generator that is going to be used for generating the uncertainties.

Parameters:

np_rand_generator

The random number generator.

The default is the default BitGenerator (PCG64) as constructed by numpy.random.default_rng().

class epyt_flow.uncertainty.uncertainties.GaussianUncertainty(mean: float | None = None, scale: float | None = None, **kwds)[source]

Bases: Uncertainty

Base class implementing Gaussian uncertainty

Parameters:
  • mean (float, optional) –

    Mean of the Gaussian noise.

    If None, mean will be assigned a random value between 0 and 1.

    The default is None.

  • scale (float, optional) –

    Scale (i.e. standard deviation) of the Gaussian noise.

    If None, scale will be assigned a random value between 0 and 1.

    The default is None.

get_attributes() dict[source]

Gets all attributes to be serialized – these attributes are passed to the constructor when the object is deserialized.

Returns:

Dictionary of attributes – i.e. pairs of attribute name + value.

Return type:

dict

property mean: float

Gets the mean of the Gaussian noise.

Returns:

Mean of the Gaussian noise.

Return type:

float

property scale: float

Gets the scale (i.e. standard deviation) of the Gaussian noise.

Returns:

Scale (i.e. standard deviation) of the Gaussian noise.

Return type:

float

class epyt_flow.uncertainty.uncertainties.PercentageDeviationUncertainty(deviation_percentage: float, **kwds)[source]

Bases: UniformUncertainty, JsonSerializable

Class implementing a uniform data deviation – i.e. the data can deviate up to some percentage from its original value.

Parameters:

deviation_percentage (float) – Percentage (0-1) the data can deviate from its original value.

apply(data: float) float[source]

Applies the uncertainty to a single value.

Parameters:

data (float) – The value to which the uncertainty is applied.

Returns:

Uncertainty applied to ‘data’.

Return type:

float

static file_ext() str

Returns the file extension of this class.

This function is automatically implemented by applying the serializable() decorator.

Returns:

File extension.

Return type:

str

get_attributes() dict[source]

Gets all attributes to be serialized – these attributes are passed to the constructor when the object is deserialized.

Returns:

Dictionary of attributes – i.e. pairs of attribute name + value.

Return type:

dict

class epyt_flow.uncertainty.uncertainties.RelativeDeepGaussianUncertainty(**kwds)[source]

Bases: DeepGaussianUncertainty, JsonSerializable

Class implementing realtive deep Gaussian uncertainty – i.e. data is multiplied by random Gaussian noise (mean and variance are changing over time).

apply(data: float) float[source]

Applies the uncertainty to a single value.

Parameters:

data (float) – The value to which the uncertainty is applied.

Returns:

Uncertainty applied to ‘data’.

Return type:

float

static file_ext() str

Returns the file extension of this class.

This function is automatically implemented by applying the serializable() decorator.

Returns:

File extension.

Return type:

str

class epyt_flow.uncertainty.uncertainties.RelativeDeepUncertainty(min_noise_value: float = 0.0, max_noise_value: float = 1.0, **kwds)[source]

Bases: DeepUncertainty, JsonSerializable

Class implementing relative deep uncertainty – i.e. data is multiplied by completely random noise.

apply(data: float) float[source]

Applies the uncertainty to a single value.

Parameters:

data (float) – The value to which the uncertainty is applied.

Returns:

Uncertainty applied to ‘data’.

Return type:

float

static file_ext() str

Returns the file extension of this class.

This function is automatically implemented by applying the serializable() decorator.

Returns:

File extension.

Return type:

str

class epyt_flow.uncertainty.uncertainties.RelativeDeepUniformUncertainty(**kwds)[source]

Bases: DeepUniformUncertainty, JsonSerializable

Class implementing relative deep uniform uncertainty – i.e. data is multiplied by random uniform noise (shape of the noise is changing over time).

apply(data: float) float[source]

Applies the uncertainty to a single value.

Parameters:

data (float) – The value to which the uncertainty is applied.

Returns:

Uncertainty applied to ‘data’.

Return type:

float

static file_ext() str

Returns the file extension of this class.

This function is automatically implemented by applying the serializable() decorator.

Returns:

File extension.

Return type:

str

class epyt_flow.uncertainty.uncertainties.RelativeGaussianUncertainty(scale: float | None = None, **kwds)[source]

Bases: GaussianUncertainty, JsonSerializable

Class implementing relative Gaussian uncertainty – i.e. data is perturbed by Gaussian noise centered at zero.

Parameters:

scale (float, optional) –

Scale (i.e. standard deviation) of the Gaussian noise.

If None, scale will be assigned a random value between 0 and 1.

The default is None.

apply(data: float) float[source]

Applies the uncertainty to a single value.

Parameters:

data (float) – The value to which the uncertainty is applied.

Returns:

Uncertainty applied to ‘data’.

Return type:

float

static file_ext() str

Returns the file extension of this class.

This function is automatically implemented by applying the serializable() decorator.

Returns:

File extension.

Return type:

str

class epyt_flow.uncertainty.uncertainties.RelativeUniformUncertainty(low: float = 0.0, high: float = 1.0, **kwds)[source]

Bases: UniformUncertainty, JsonSerializable

Class implementing relative uniform uncertainty – i.e. data is multiplied by uniform noise.

apply(data: float) float[source]

Applies the uncertainty to a single value.

Parameters:

data (float) – The value to which the uncertainty is applied.

Returns:

Uncertainty applied to ‘data’.

Return type:

float

static file_ext() str

Returns the file extension of this class.

This function is automatically implemented by applying the serializable() decorator.

Returns:

File extension.

Return type:

str

class epyt_flow.uncertainty.uncertainties.Uncertainty(min_value: float | None = None, max_value: float | None = None, **kwds)[source]

Bases: ABC

Base class for uncertainties – i.e. perturbations of data/signals.

Parameters:
  • min_value (float, optional) –

    Lower bound on the data/signal that is perturbed by this uncertainty.

    The default is None.

  • max_value (float, optional) –

    Upper bound on the data/signal that is perturbed by this uncertainty.

    The default is None.

abstract apply(data: float)[source]

Applies the uncertainty to a single value.

Parameters:

data (float) – The value to which the uncertainty is applied.

Returns:

Uncertainty applied to ‘data’.

Return type:

float

apply_batch(data: numpy.ndarray) numpy.ndarray[source]

Applies the uncertainty to an array of values.

Parameters:

data – Array of values to which the uncertainty is applied.

Returns:

Uncertainty applied to data.

Return type:

numpy.ndarray

clip(data: numpy.ndarray) numpy.ndarray[source]

Clips values in a given array – i.e. every value must be in [min_value, max_value].

Parameters:

data – Array to be clipped.

Returns:

Clipped data.

Return type:

numpy.ndarray

get_attributes() dict[source]

Gets all attributes to be serialized – these attributes are passed to the constructor when the object is deserialized.

Returns:

Dictionary of attributes – i.e. pairs of attribute name + value.

Return type:

dict

property max_value: float

Gets the upper bound on the data/signal.

Returns:

Upper bound.

Return type:

float

property min_value: float

Gets the lower bound on the data/signal.

Returns:

Lower bound.

Return type:

float

property random_generator: numpy.random.Generator

Returns the random number generator that is used for generating the uncertainties.

Returns:

The random number generator.

Return type:

numpy.random.Generator

set_random_generator(np_rand_generator: numpy.random.Generator) None[source]

Sets the random number generator that is going to be used for generating the uncertainties.

Parameters:

np_rand_generator

The random number generator.

The default is the default BitGenerator (PCG64) as constructed by numpy.random.default_rng().

class epyt_flow.uncertainty.uncertainties.UniformUncertainty(low: float = 0.0, high: float = 1.0, **kwds)[source]

Bases: Uncertainty

Base class implementing uniform uncertainty.

Parameters:
  • low (float, optional) –

    Lower bound of the uniform noise.

    The default is zero.

  • high (float, optional) –

    Upper bound of the uniform noise.

    The default is one.

get_attributes() dict[source]

Gets all attributes to be serialized – these attributes are passed to the constructor when the object is deserialized.

Returns:

Dictionary of attributes – i.e. pairs of attribute name + value.

Return type:

dict

property high: float

Gets the upper bound of the uniform noise.

Returns:

Upper bound of the uniform noise.

Return type:

float

property low: float

Gets the lower bound of the uniform noise.

Returns:

Lower bound of the uniform noise.

Return type:

float

epyt_flow.uncertainty.utils

Module provides some helper functions regarding the implementation of uncertainty.

epyt_flow.uncertainty.utils.create_deep_random_pattern(n_samples: int, min_value: float = 0.0, max_value: float = 1.0, init_value: float | None = None, np_rand_gen: numpy.random.Generator = numpy.random.default_rng) numpy.ndarray[source]

Generates a random pattern.

Parameters:
  • n_samples (int) – Number of random samples – i.e. length of the pattern.

  • min_value (float, optional) –

    Lower bound of the pattern.

    The default is zero.

  • max_value (float, optional) –

    Upper bound of the pattern.

    The default is one.

  • init_value (float, optional) –

    Value of the first sample in the pattern. If None, a random value is used.

    The default is None.

  • np_rand_generator

    The random number generator that is going to be used.

    The default is the default BitGenerator (PCG64) as constructed by numpy.random.default_rng().

Returns:

Random pattern.

Return type:

numpy.ndarray

epyt_flow.uncertainty.utils.generate_deep_random_gaussian_noise(n_samples: int, mean: float | None = None, np_rand_gen: numpy.random.Generator = numpy.random.default_rng) numpy.ndarray[source]

Generates random Gaussian noise where the standard deviations (and mean) are changing over time.

Parameters:
  • n_samples (int) – Number of random samples.

  • mean (float, optional) –

    Fixed mean at all points in time. If None, random means are generated.

    The default is None.

  • np_rand_generator

    The random number generator that is going to be used.

    The default is the default BitGenerator (PCG64) as constructed by numpy.random.default_rng().

Returns:

Random Gaussian noise.

Return type:

numpy.ndarray

epyt_flow.uncertainty.utils.generate_random_gaussian_noise(n_samples: int, np_rand_gen: numpy.random.Generator = numpy.random.default_rng) numpy.ndarray[source]

Generates Gaussian noise using a random mean ([0,1]) and random standard deviation ([0,1]).

Parameters:
  • n_samples (int) – Number of random samples.

  • np_rand_generator

    The random number generator that is going to be used.

    The default is the default BitGenerator (PCG64) as constructed by numpy.random.default_rng().

Returns:

Gaussian noise.

Return type:

numpy.ndarray

epyt_flow.uncertainty.utils.scale_to_range(pattern: numpy.ndarray, min_value: float, max_value: float) numpy.ndarray[source]

Scales a given pattern to an interval.

Parameters:
  • pattern – The pattern to be scaled.

  • min_value (float) – Lower bound of the pattern.

  • max_value (float) – Upper bound of the pattern.

Returns:

The scaled pattern.

Return type:

numpy.ndarray

epyt_flow.uncertainty.utils.smoothing(pattern: numpy.ndarray, sigma: float = 10.0) numpy.ndarray[source]

Smoothes a given pattern by applying a Gaussian filter.

Parameters:
  • pattern – The original pattern

  • sigma (float, optional) –

    Standard deviation for the Gaussian filter.

    The default is 10.

Returns:

The smoothed pattern.

Return type:

numpy.ndarray