tag
This module consists of two classes, Tag
and VirtualTag
, which are used to represent data streams at a treatment facility.
- class pype_schema.tag.DownsampleType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Enum to represent common methods of downsampling data
- class pype_schema.tag.Tag(id, units, tag_type, source_unit_id, dest_unit_id, parent_id, totalized=False, contents=None, manufacturer=None, measure_freq=None, report_freq=None, downsample_method=None, calibration=<pype_schema.logbook.Logbook entries:{}>)[source]
Class to represent a SCADA or other data tag
- Parameters:
id (str) – Tag ID
units (str or Unit) – Units represented as a string or Pint unit. E.g., ‘MGD’ or ‘cubic meters’ or <Unit(‘MGD’)>
tag_type (TagType) – Type of data saved under the tag. E.g., InfluentFlow or RunTime
source_unit_id (int or str) – integer representing unit number, or total if a combined data point across all units of the source node
dest_unit_id (int or str) – integer representing unit number, or total if a combined data point across all units of the destination node. None if the Tag is associated with a Node object instead of a Connection
parent_id (str) – ID for the parent object (either a Node or Connection)
totalized (bool) – True if data is totalized. False otherwise
contents (ContentsType) – Data stream contents. E.g., WasteActivatedSludge or NaturalGas
manufacturer (str) – Name of the manufacturer for the physical sensor hardware. Default is None
measure_freq (pint.Quantity) – Measurement frequency of the data with units. None by default
report_freq (pint.Quantity) – Reporting frequency of the data with units. None by default
downsample_method (DownsampleType) – None by default, meaning that data is reported on the same frequency as measured
calibration (Logbook) – A history of sensor calibration.
- Variables:
id (str) – Tag ID
units (Unit) – Units represented as a Pint unit. E.g., <Unit(‘MGD’)>
tag_type (TagType) – Type of data saved under the tag. E.g., InfluentFlow or RunTime
source_unit_id (int or str) – integer representing unit number, or total if a combined data point across all units of the sources node
dest_unit_id (int or str) – integer representing unit number, or total if a combined data point across all units of the destination node
parent_id (str) – ID for the parent object (either a Node or Connection)
totalized (bool) – True if data is totalized. False by default
contents (ContentsType) – Contents moving through the node
manufacturer (str) – Name of the manufacturer for the physical sensor hardware. Default is None
measure_freq (pint.Quantity) – Measurement frequency of the data with units. None by default
report_freq (pint.Quantity) – Reporting frequency of the data with units. None by default
downsample_method (DownsampleType) – None by default, meaning that data is reported on the same frequency as measured
calibration (Logbook) – A history of sensor calibration.
- class pype_schema.tag.TagType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Enum to represent types of SCADA tags
- class pype_schema.tag.VirtualTag(id, tags, operations=None, units=None, tag_type=None, parent_id=None, contents=None)[source]
Representation for data that is not in the SCADA system, but is instead a combination of existing tags combined via the operations lambda function string
- Parameters:
id (str) – VirtualTag ID
tags (list of Tag) – List of Tag objects to combine
operations (str) – String a lambda function to apply to all tags, must have number of args equal to number of tags
tag_type (TagType) – Type of data saved under the tag. E.g., InfluentFlow or RunTime. Default is None, and it will be automatically determined from constituent Tags if they all have the same type.
parent_id (str) – ID for the parent object (either a Node or Connection)
contents (ContentsType) – Contents moving through the node. Default is None, and it will be automatically determined from consituent Tag contents
- Raises:
ValueError – When operations lambda function has the wrong number of elements When tag_type is not specified and constituent tags have different types. When contents of the constituent tags are different types.
UserWarning – When a mix of totalized and detotalized tags are combined When tags have different units
- Variables:
id (str) – Tag ID
operations – String giving a lambda function to apply to constituent tags
units (str or Unit) – Units represented as a string or Pint unit. E.g., ‘MGD’ or ‘cubic meters’ or <Unit(‘MGD’)>
tag_type (TagType) – Type of data saved under the tag. E.g., InfluentFlow or RunTime
totalized (bool) – True if data is totalized. False otherwise
parent_id (str) – ID for the parent object (either a Node or Connection)
contents (ContentsType) – Contents moving through the node
- calculate_values(data, tag_to_var_map={})[source]
Combine the given data according to the VirtualTag’s operations
- Parameters:
data (list, array, dict, or DataFrame) – a list, numpy array, or pandas DataFrame of data that has the correct dimensions. I.e., the number of columns is one more than binary operations and same length as unary operations
tag_to_var_map (dict) – dictionary of the form { tag.id : variable_name } for using data files that differ from the original SCADA tag naming system
- Returns:
numpy array of combined dataset
- Return type:
list, array, or Series
- process_ops(data, tag_to_var_map={})[source]
Transform the given data according to the VirtualTag’s lambda string
- Parameters:
data (list, array, dict, or DataFrame) – a list, numpy array, or pandas DataFrame of data that has the correct dimensions. I.e., the number of columns is one more than binary operations and same length as unary operations
tag_to_var_map (dict) – dictionary of the form { tag.id : variable_name } for using data files that differ from the original SCADA tag naming system
- Returns:
numpy array of combined dataset
- Return type:
list, array, or Series