Pattern#

module wntr.network.elements

class Pattern[source]#

Bases: object

Pattern class.

Constructor

This class is intended to be instantiated through the add_pattern method.

Parameters:
  • name (string) – Name of the pattern.

  • multipliers (list) – A list of multipliers that makes up the pattern.

  • time_options (wntr TimeOptions or tuple) – The water network model options.time object or a tuple of (pattern_start, pattern_timestep) in seconds.

  • wrap (bool, optional) – Boolean indicating if the pattern should be wrapped. If True (the default), then the pattern repeats itself forever; if False, after the pattern has been exhausted, it will return 0.0.


__init__(name, multipliers=[], time_options=None, wrap=True)[source]#
at(time)[source]#

Returns the pattern value at a specific time

Parameters:

time (int) – Time in seconds

classmethod binary_pattern(name, start_time, end_time, step_size, duration, wrap=False)[source]#

Creates a binary pattern (single instance of step up, step down).

Parameters:
  • name (string) – Name of the pattern.

  • start_time (int) – The time at which the pattern turns “on” (1.0).

  • end_time (int) – The time at which the pattern turns “off” (0.0).

  • step_size (int) – Pattern step size.

  • duration (int) – Total length of the pattern.

  • wrap (bool, optional) – Boolean indicating if the pattern should be wrapped. If True, then the pattern repeats itself forever; if False (the default), after the pattern has been exhausted, it will return 0.0.

Return type:

A new pattern object with a list of 1’s and 0’s as multipliers.

to_dict()[source]#

Dictionary representation of the pattern

property multipliers#

Returns the pattern multiplier values

property time_options#

Returns the TimeOptions object