pype_schema package
Subpackages
Submodules
pype_schema.connection module
- class pype_schema.connection.Connection[source]
Bases:
ABC
Abstract class for all connections
- Variables:
id (str) – Connection ID
contents (ContentsType) – Contents moving through the node
source (Node) – Starting point of the connection
destination (Node) – Endpoint of the connection
tags (dict of Tag) – Data tags associated with this connection
bidirectional (bool) – Whether flow can go from destination to source. False by default
exit_point (Node) – The child node from which this connection leaves its source. Default is None, indicating the source does not have any children
entry_point (Node) – The child node at which this connection enters its destination. Default is None, indicating the destination does not have any children
- contents: ContentsType = NotImplemented
- get_dest_node(recurse=False)[source]
Gets a connection’s destination node, returning its entry point if recurse is True
- Parameters:
recurse (bool) – Return entry_point if True. Otherwise just return destination
- Returns:
The destination node corresponding to connection
- Return type:
pype_schema.Node
- get_entry_point()[source]
- Returns:
name of the entry point Node (if it exists - None otherwise)
- Return type:
- get_exit_point()[source]
- Returns:
name of the exit point Node (if it exists - None otherwise)
- Return type:
- get_source_node(recurse=False)[source]
Gets a connection’s source node returning its exit point if recurse is True
- Parameters:
recurse (bool) – Return exit_point if True. Otherwise just return source
- Returns:
The source node corresponding to connection
- Return type:
pype_schema.Node
- get_tag(tag_name)[source]
Adds a tag to the node
- Parameters:
tag_name (str) – Name of the tag to receive
- class pype_schema.connection.Delivery(id, contents, source, destination, tags={}, bidirectional=False, exit_point=None, entry_point=None)[source]
Bases:
Connection
A class to represent a connection via delivery, such as monthly chemical deliveries or weekly trash disposal.
- Parameters:
id (str) – Delivery ID
contents (ContentsType) – Contents moving through the connection
source (Node) – Starting point of the connection
destination (Node) – Endpoint of the connection
frequency (pint.Quantity or float) – If a pint quantity it will be interpreted based on units. E.g., 0.25 days will be interpreted as 0.25 days between deliveries, or in other words 4 deliveries per day. Whereas 0.25 / day would indicate there is a quarter of a delivery per day, or more intuitively 4 days between each delivery. If unitless, assumed to be number of days between delivery
tags (dict of Tag) – Data tags associated with this pump
bidirectional (bool) – Whether deliveries are made from destination to source. False by default
exit_point (Node) – The child node from which this connection leaves its source. Default is None, indicating the source does not have any children
entry_point (Node) – The child node at which this connection enters its destination. Default is None, indicating the destination does not have any children
- Variables:
id (str) – Pipe ID
contents (ContentsType) – Contents moving through the connection.
source (Node) – Starting point of the connection
destination (Node) – Endpoint of the connection
bidirectional (bool) – Whether deliveries are made from destination to source. False by default
exit_point (Node) – The child node from which this connection leaves its source. Default is None, indicating the source does not have any children
entry_point (Node) – The child node at which this connection enters its destination. Default is None, indicating the destination does not have any children
- class pype_schema.connection.Pipe(id, contents, source, destination, min_flow, max_flow, design_flow, diameter=None, friction=None, min_pres=None, max_pres=None, design_pres=None, lower_heating_value=None, higher_heating_value=None, tags={}, bidirectional=False, exit_point=None, entry_point=None)[source]
Bases:
Connection
A generic class for pipes that transport any fluid, such as drinking water, natural gas, or industrial wastewater.
- Parameters:
id (str) – Pipe ID
contents (ContentsType) – Contents moving through the connection
source (Node) – Starting point of the connection
destination (Node) – Endpoint of the connection
min_flow (pint.Quantity or int) – Minimum flow rate through the pipe
max_flow (pint.Quantity or int) – Maximum flow rate through the pipe
avg_flow (pint.Quantity or int) – Average flow rate through the pipe
diameter (pint.Quantity or int) – Pipe diameter
friction (float) – Friction coefficient for the pipe
min_pres (pint.Quantity or int) – Minimum pressure inside the pipe
max_pres (pint.Quantity or int) – Maximum pressure inside the pipe
design_pres (pint.Quantity or int) – Design pressure of the pipe
lower_heating_value (float) – Lower heating value of gas in the pipe
higher_heating_value (float) – Higher heating value of gas in the pipe
tags (dict of Tag) – Data tags associated with this pipe
bidirectional (bool) – Whether flow can go from destination to source. False by default
exit_point (Node) – The child node from which this connection leaves its source. Default is None, indicating the source does not have any children
entry_point (Node) – The child node at which this connection enters its destination. Default is None, indicating the destination does not have any children
- Variables:
id (str) – Pipe ID
contents (ContentsType) – Contents moving through the connection
source (Node) – Starting point of the connection
destination (Node) – Endpoint of the connection
min_flow (pint.Quantity or int) – Minimum flow rate through the pipe
max_flow (pint.Quantity or int) – Maximum flow rate through the pipe
design_flow (pint.Quantity or int) – Design flow rate through the pipe
diameter (pint.Quantity or int) – Pipe diameter
friction_coeff (int) – Friction coefficient for the pipe
min_pressure (pint.Quantity or int) – Minimum pressure inside the pipe
max_pressure (pint.Quantity or int) – Maximum pressure inside the pipe
design_pressure (pint.Quantity or int) – Design pressure of the pipe
heating_values (tuple) – The lower and higher heating values of the gas in the pipe. None if the pipe is not transporting gas
bidirectional (bool) – Whether flow can go from destination to source. False by default
exit_point (Node) – The child node from which this connection leaves its source. Default is None, indicating the source does not have any children
entry_point (Node) – The child node at which this connection enters its destination. Default is None, indicating the destination does not have any children
- property design_flow
- property design_pressure
- property max_flow
- property max_pressure
- property min_flow
- property min_pressure
- set_flow_rate(min, max, design)[source]
Set the minimum, maximum, and average flow rate through the connection
- Parameters:
min (int) – Minimum flow rate through the connection
max (int) – Maximum flow rate through the connection
design (int) – Design flow rate through the connection
- class pype_schema.connection.Wire(id, contents, source, destination, tags={}, bidirectional=False, exit_point=None, entry_point=None)[source]
Bases:
Connection
A class for representing electrical connections.
- Parameters:
id (str) – Wire ID
contents (ContentsType) – Contents moving through the connection.
source (Node) – Starting point of the connection
destination (Node) – Endpoint of the connection
tags (dict of Tag) – Data tags associated with this wire
bidirectional (bool) – Whether electricity can flow from destination to source. False by default
exit_point (Node) – The child node from which this connection leaves its source. Default is None, indicating the source does not have any children
entry_point (Node) – The child node at which this connection enters its destination. Default is None, indicating the destination does not have any children
- Variables:
id (str) – Pipe ID
contents (ContentsType) – Contents moving through the connection.
source (Node) – Starting point of the connection
destination (Node) – Endpoint of the connection
bidirectional (bool) – Whether electricity can flow from destination to source. False by default
exit_point (Node) – The child node from which this connection leaves its source. Default is None, indicating the source does not have any children
entry_point (Node) – The child node at which this connection enters its destination. Default is None, indicating the destination does not have any children
- class pype_schema.connection.Wireless(id, contents, source, destination, tags={}, bidirectional=False, exit_point=None, entry_point=None)[source]
Bases:
Connection
A class for representing electrical connections.
- Parameters:
id (str) – Wireless connection ID
contents (ContentsType) – Contents moving through the connection.
source (Node) – Starting point of the connection
destination (Node) – Endpoint of the connection
tags (dict of Tag) – Data tags associated with this wire
bidirectional (bool) – Whether data can flow from destination to source. False by default
exit_point (Node) – The child node from which this connection leaves its source. Default is None, indicating the source does not have any children
entry_point (Node) – The child node at which this connection enters its destination. Default is None, indicating the destination does not have any children
- Variables:
id (str) – Pipe ID
contents (ContentsType) – Contents moving through the connection.
source (Node) – Starting point of the connection
destination (Node) – Endpoint of the connection
bidirectional (bool) – Whether data can flow from destination to source. False by default
exit_point (Node) – The child node from which this connection leaves its source. Default is None, indicating the source does not have any children
entry_point (Node) – The child node at which this connection enters its destination. Default is None, indicating the destination does not have any children
pype_schema.epyt_utils module
- class pype_schema.epyt_utils.NpEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]
Bases:
JSONEncoder
Custom JSON encoder for numpy types
- default(obj)[source]
Implement this method in a subclass such that it returns a serializable object for
o
, or calls the base implementation (to raise aTypeError
).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return super().default(o)
pype_schema.logbook module
- class pype_schema.logbook.LogCode(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
Enum to represent codes associated with logbook entries
- Critical = 4
- Error = 3
- Info = 1
- Warning = 2
- class pype_schema.logbook.LogEntry(timestamp, text, code=LogCode.Info)[source]
Bases:
object
A single text log entry in the digital Logbook with associated timestamp and code (e.g., info or error)
- Parameters:
timestamp (datetime.datetime) – The timestamp for the entry
text (str) – The text portion of the entry
code (LogCode) – The code associated with the entry. Default is Info
- Variables:
timestamp (datetime.datetime) – The timestamp for the entry
text (str) – The text portion of the entry
code (LogCode) – The code associated with the entry. Default is Info
- class pype_schema.logbook.Logbook(entries=None)[source]
Bases:
object
A digital logbook with built-in querying.
- Parameters:
entries (dict) – Dictionary of the form { int : LogEntry }. Default is an empty dictionary
- Variables:
entries (dict) – Dictionary of the form { int : LogEntry }
- add_entry(timestamp, text, code=LogCode.Info)[source]
Modifies self.entries to add the desired text with associated timestamp and code (e.g., info or error). Entries are saved with an automatically incremented counter as their ID.
- Parameters:
timestamp (datetime.datetime) – The timestamp for the entry to be added
text (str) – Plaintext logbook entry
code (LogCode) – Code associated with the entry. Default is Info
- load_entries(filepath)[source]
Adds all the logbook entries from the given filepath. Supports both JSON and CSV file formats.
- Parameters:
filpath (str) – The path to the file to load logbook entries from
- Raises:
ValueError – When file extension is not json or csv
- next_entry_id()[source]
Gets the next entry ID by checking the current maximum ID
- Returns:
ID for the next logbook entry
- Return type:
- print_query(start_dt, end_dt=None, keyword=None, code=None)[source]
Queries logbook entries based on timestamp, keywords, and code. Pretty prints the queried entries, and then also returns them
- Parameters:
start_dt (datetime.datetime) – First datetime to include in the timestamps of log entries to return.
end_dt (datetime.datetime) – Final datetime to include in the timestamps of log entries to return. None by default, meaning that all entries after start_dt will be returned
keyword (str) – Keyword to find in the log entry. None by default
code (LogCode) – The code associated with desired logbook entries. None by default, meaning all codes will be included
- Returns:
Dictionary of logbook entries between start_dt and end_dt that contain keyword and have a matching code
- Return type:
- query(start_dt, end_dt=None, keyword=None, code=None)[source]
Queries logbook entries based on timestamp, keywords, and code.
- Parameters:
start_dt (datetime.datetime) – First datetime to include in the timestamps of log entries to return.
end_dt (datetime.datetime) – Final datetime to include in the timestamps of log entries to return. None by default, meaning that all entries after start_dt will be returned
keyword (str) – Keyword to find in the log entry. None by default
code (LogCode) – The code associated with desired logbook entries. None by default, meaning all codes will be included
- Returns:
Dictionary of logbook entries between start_dt and end_dt that contain keyword and have a matching code
- Return type:
- remove_entry(entry_id)[source]
Modifies self.entries
- Parameters:
timestamp (datetime.datetime) – The timestamp for the entry to be removed
- save_query(start_dt, end_dt=None, keyword=None, code=None, outpath='')[source]
Queries logbook entries based on timestamp, keywords, and code. Saves the queried entries, and then also returns them
- Parameters:
start_dt (datetime.datetime) – First datetime to include in the timestamps of log entries to return.
end_dt (datetime.datetime) – Final datetime to include in the timestamps of log entries to return. None by default, meaning that all entries after start_dt will be returned
keyword (str) – Keyword to find in the log entry. None by default
code (LogCode) – The code associated with desired logbook entries. None by default, meaning all codes will be included
outpath (str) – Path where logbook will be saved. Supported filetypes are JSON and CSV. Default path is “”, meaning that no file will be written
- Returns:
Dictionary of logbook entries between start_dt and end_dt that contain keyword and have a matching code
- Return type:
- to_csv(outpath='')[source]
Save the current Logbook as a CSV file
- Parameters:
outpath (str) – Path where logbook will be saved. Default is “”, meaning no file will be saved
- Returns:
csv in DataFrame format
- Return type:
- to_json(outpath='', indent=4)[source]
Save the current Logbook as a JSON file
- Parameters:
outpath (str) – Path where logbook will be saved. Default is “”, meaning that no file will be written
indent (int) – number of spaces to indent the JSON file. Default is 4
- Returns:
json in dictionary format
- Return type:
pype_schema.node module
- class pype_schema.node.Aeration(id, input_contents, output_contents, min_flow, max_flow, design_flow, num_units, volume, tags={})[source]
Bases:
Node
A generic class for an aeration basin.
- Parameters:
id (str) – Aerator ID
input_contents (ContentsType or list of ContentsType) – Contents entering the aeration basin
output_contents (ContentsType or list of ContentsType) – Contents leaving the aeration basin
min_flow (pint.Quantity or int) – Minimum flow rate of a single aeration basin
max_flow (pint.Quantity or int) – Maximum flow rate of a single aeration basin
design_flow (pint.Quantity or int) – Design flow rate of a single aeration basin
num_units (int) – Number of aeration basins running in parallel
volume (pint.Quantity or int) – Volume of a single aeration basin in cubic meters
tags (dict of Tag) – Data tags associated with this aerator
- Variables:
id (str) – Aerator ID
input_contents (list of ContentsType) – Contents entering the aeration basin
output_contents (list of ContentsType) – Contents leaving the aeration basin
num_units (int) – Number of aeration basins running in parallel
volume (pint.Quantity or int) – Volume of a single aeration basin in cubic meters
min_flow (pint.Quantity or int) – Minimum flow rate of a single aeration basin
max_flow (pint.Quantity or int) – Maximum flow rate of a single aeration basin
design_flow (pint.Quantity or int) – Design flow rate of a single aeration basin
- class pype_schema.node.Battery(id, energy_capacity, charge_rate, discharge_rate, rte, leakage, tags={})[source]
Bases:
Node
A generic battery with metadata such as roundtrip efficiency (RTE), energy capacity, and charge/discharge rates.
- Parameters:
id (str) – Battery ID
energy_capacity (int) – Energy storage capacity of the battery in kWh
charge_rate (int) – Maximum charge rate of the battery in kW
discharge_rate (int) – Maximum discharge rate of the battery in kW
rte (float) – Round trip efficiency of the battery
tags (dict of Tag) – Data tags associated with this battery
- Variables:
id (str) – Battery ID
input_contents (list of ContentsType) – Contents entering the battery.
output_contents (list of ContentsType) – Contents leaving the battery.
energy_capacity (int) – Energy storage capacity of the battery in kWh
charge_rate (int) – Maximum discharge rate of the battery in kW
discharge_rate (int) – Maximum discharge rate of the battery in kW
rte (float) – Round trip efficiency of the battery
leakage (pint.Quantity) – Leakage of the battery as a Pint Quantity
- property charge_rate
- property energy_capacity
- property leakage
- property rte
- class pype_schema.node.Boiler(id, input_contents, min_gen, max_gen, design_gen, num_units, tags={})[source]
Bases:
Node
A class representing a boiler that produces heat through natural gas combustion.
- Parameters:
id (str) – Boiler ID
input_contents (ContentsType or list of ContentsType) – Contents entering the boiler
min_gen (int) – Minimum generation capacity of a single boiler
max_gen (int) – Maximum generation capacity of a single boiler
design_gen (int) – Design generation capacity of a single boiler
num_units (int) – Number of boiler units running in parallel
tags (dict of Tag) – Data tags associated with this boiler
- Variables:
id (str) – Boiler ID
input_contents (list of ContentsType) – Contents entering the boiler (biogas, natural gas, or a blend of the two)
output_contents (list of ContentsType) – Contents leaving the boiler (Electricity)
min_gen (int) – Minimum generation capacity of a single boiler
max_gen (int) – Maximum generation capacity of a single boiler
design_gen (int) – Design generation capacity of a single boiler
- num_unitsint
Number of boiler units running in parallel
- tagsdict of Tag
Data tags associated with this boiler
- thermal_efficiencyfunction
Function which takes in the current kWh and returns the efficiency as a fraction
- property design_gen
- property max_gen
- property min_gen
- class pype_schema.node.Chlorination(id, input_contents, output_contents, min_flow, max_flow, design_flow, num_units, volume, dosing_rate={}, residence_time=None, tags={})[source]
Bases:
Disinfection
A class for a chlorination basin.
- Parameters:
id (str) – Chlorinator ID
input_contents (ContentsType or list of ContentsType) – Contents entering the chlorinator
output_contents (ContentsType or list of ContentsType) – Contents leaving the chlorinator
min_flow (pint.Quantity or int) – Minimum flow rate of a single chlorinator
max_flow (pint.Quantity or int) – Maximum flow rate of a single chlorinator
design_flow (pint.Quantity or int) – Design flow rate of a single chlorinator
num_units (int) – Number of chlorinators running in parallel
volume (pint.Quantity or int) – Volume of a single chlorinator in cubic meters
dosing_rate (dict of DosingType:float) – Dosing information for the chlorinator (key: DosingType, value: rate)
residence_time (pint.Quantity or float) – Residence time of the chlorinator
tags (dict of Tag) – Data tags associated with this chlorinator
- Variables:
id (str) – Chlorinator ID
input_contents (list of ContentsType) – Contents entering the chlorinator
output_contents (list of ContentsType) – Contents leaving the chlorinator
num_units (int) – Number of chlorinators running in parallel
volume (pint.Quantity or int) – Volume of a single chlorinator in cubic meters
min_flow (pint.Quantity or int) – Minimum flow rate of a single chlorinator
max_flow (pint.Quantity or int) – Maximum flow rate of a single chlorinator
design_flow (pint.Quantity or int) – Design flow rate of a single chlorinator
dosing_rate (dict of DosingType:float) – Dosing information for the chlorinator (key: DosingType, value: rate)
residence_time (pint.Quantity or float) – Residence time of the chlorinator
tags (dict of Tag) – Data tags associated with this chlorinator
- class pype_schema.node.Clarification(id, input_contents, output_contents, min_flow, max_flow, design_flow, num_units, volume, tags={})[source]
Bases:
Node
A class representing a generic clarifier, sedimentation tank, or settling basin.
- Parameters:
id (str) – Clarifier ID
input_contents (ContentsType or list of ContentsType) – Contents entering the clarifier
output_contents (ContentsType or list of ContentsType) – Contents leaving the clarifier
min_flow (pint.Quantity or int) – Minimum flow rate of a single clarifier
max_flow (pint.Quantity or int) – Maximum flow rate of a single clarifier
design_flow (pint.Quantity or int) – Design flow rate of a single clarifier
num_units (int) – Number of clarifiers running in parallel
volume (pint.Quantity or int) – Volume of the clarifier in cubic meters
tags (dict of Tag) – Data tags associated with this clarifier
- Variables:
id (str) – Clarifier ID
input_contents (list of ContentsType) – Contents entering the clarifier
output_contents (list of ContentsType) – Contents leaving the clarifier
num_units (int) – Number of clarifiers running in parallel
volume (pint.Quantity or int) – Volume of a single clarifier in cubic meters
min_flow (pint.Quantity or int) – Minimum flow rate of a single clarifier
max_flow (pint.Quantity or int) – Maximum flow rate of a single clarifier
design_flow (pint.Quantity or int) – Design flow rate of a single clarifier
tags (dict of Tag) – Data tags associated with this clarifier
- class pype_schema.node.Cogeneration(id, input_contents, min_gen, max_gen, design_gen, num_units, tags={})[source]
Bases:
Node
A class representing a cogeneration engine that produces both heat and electricity through biogas and/or natural gas combustion.
- Parameters:
id (str) – Cogenerator ID
input_contents (ContentsType or list of ContentsType) – Contents entering the cogenerator
min_gen (int) – Minimum generation capacity of a single cogenerator
max_gen (int) – Maximum generation capacity of a single cogenerator
design_gen (int) – Design generation capacity of a single cogenerator
num_units (int) – Number of cogenerator units running in parallel
tags (dict of Tag) – Data tags associated with this cogenerator
- Variables:
id (str) – Cogenerator ID
input_contents (list of ContentsType) – Contents entering the cogenerator (biogas, natural gas, or a blend of the two)
output_contents (list of ContentsType) – Contents leaving the cogenerator (Electricity)
min_gen (int) – Minimum generation capacity of a single cogenerator
max_gen (int) – Maximum generation capacity of a single cogenerator
design_gen (int) – Average generation capacity of a single cogenerator
num_units (int) – Number of cogenerator units running in parallel
tags (dict of Tag) – Data tags associated with this cogenerator
electrical_efficiency (function) – Function which takes in the current kWh and returns the electrical efficiency as a fraction
thermal_efficiency (function) – Function which takes in the current kWh and returns the thermal efficiency as a fraction
- property design_gen
- property max_gen
- property min_gen
- set_electrical_efficiency(efficiency_curve)[source]
Set the cogeneration efficiency to the given function
- Parameters:
efficiency_curve (function) – function takes in the current kWh and returns the fractional efficency
- class pype_schema.node.Conditioning(id, input_contents, output_contents, min_flow, max_flow, design_flow, num_units, tags={})[source]
Bases:
Node
A class for representing biogas conditioners. The conditioner prepares ‘raw’ biogas from the digester by removing impurities and readying it for combustion for Cogeneration.
- Parameters:
id (str) – Conditioner ID
input_contents (ContentsType or list of ContentsType) – Contents entering the biogas conditioner
output_contents (ContentsType or list of ContentsType) – Contents leaving the biogas conditioner
min_flow (pint.Quantity or int) – Minimum flow rate of a single biogas conditioner
max_flow (pint.Quantity or int) – Maximum flow rate of a single biogas conditioner
design_flow (pint.Quantity or int) – Design flow rate of a single biogas conditioner
num_units (int) – Number of biogas conditioners running in parallel
tags (dict of Tag) – Data tags associated with this biogas conditioner
- Variables:
id (str) – Conditioner ID
input_contents (list of ContentsType) – Contents entering the biogas conditioner
output_contents (list of ContentsType) – Contents leaving the biogas conditioner
num_units (int) – Number of biogas conditioners running in parallel
min_flow (pint.Quantity or int) – Minimum flow rate of a single biogas conditioner
max_flow (pint.Quantity or int) – Maximum flow rate of a single biogas conditioner
design_flow (pint.Quantity or int) – Design flow rate of a single biogas conditioner
- class pype_schema.node.Digestion(id, input_contents, output_contents, min_flow, max_flow, design_flow, num_units, volume, digester_type, tags={})[source]
Bases:
Node
A class representing a sludge digester, either aerobic or anaerobic.
- Parameters:
id (str) – Digester ID
input_contents (ContentsType or list of ContentsType) – Contents entering the digester (e.g. biogas or wastewater)
output_contents (ContentsType or list of ContentsType) – Contents leaving the digester (e.g. biogas or wastewater)
min_flow (pint.Quantity or int) – Minimum flow rate through the digester
max_flow (pint.Quantity or int) – Maximum flow rate through the digester
design_flow (pint.Quantity or int) – Design flow rate through the digester
num_units (int) – Number of digesters running in parallel
volume (pint.Quantity or int) – Volume of the digester in cubic meters
digester_type (DigesterType) – Type of digestion (aerobic or anaerobic)
tags (dict of Tag) – Data tags associated with this digester
- Variables:
id (str) – Digester ID
input_contents (list of ContentsType) – Contents entering the digester (e.g. biogas or wastewater)
output_contents (list of ContentsType) – Contents leaving the digester (e.g. biogas or wastewater)
num_units (int) – Number of digesters running in parallel
volume (pint.Quantity or int) – Volume of the digester in cubic meters
min_flow (pint.Quantity or int) – Minimum flow rate through the digester
max_flow (pint.Quantity or int) – Maximum flow rate through the digester
design_flow (pint.Quantity or int) – Design flow rate through the digester
digester_type (DigesterType) – Type of digestion (aerobic or anaerobic)
tags (dict of Tag) – Data tags associated with this digester
- class pype_schema.node.Disinfection(id, input_contents, output_contents, min_flow, max_flow, design_flow, num_units, volume, dosing_rate={}, residence_time=None, tags={})[source]
Bases:
Node
A generic class for a disinfection process, such as chlorination, ozone, or UV light.
- Parameters:
id (str) – Disinfector ID
input_contents (ContentsType or list of ContentsType) – Contents entering the disinfector
output_contents (ContentsType or list of ContentsType) – Contents leaving the disinfector
min_flow (pint.Quantity or int) – Minimum flow rate of a single disinfector
max_flow (pint.Quantity or int) – Maximum flow rate of a single disinfector
design_flow (pint.Quantity or int) – Design flow rate of a single disinfector
num_units (int) – Number of disinfectors running in parallel
volume (pint.Quantity or int) – Volume of a single disinfectors in cubic meters
dosing_rate (dict of DosingType:float) – Dosing information for the disinfector (key: DosingType, value: rate)
residence_time (pint.Quantity or float) – Residence time of the disinfector
tags (dict of Tag) – Data tags associated with this disinfector
- Variables:
id (str) – Disinfector ID
input_contents (list of ContentsType) – Contents entering the disinfector
output_contents (list of ContentsType) – Contents leaving the disinfector
num_units (int) – Number of disinfector running in parallel
volume (pint.Quantity or int) – Volume of a single disinfector in cubic meters
min_flow (pint.Quantity or int) – Minimum flow rate of a single disinfector
max_flow (pint.Quantity or int) – Maximum flow rate of a single disinfector
design_flow (pint.Quantity or int) – Design flow rate of a single disinfector
dosing_rate (dict of DosingType:float) – Dosing information for the disinfector (key: DosingType, value: rate)
residence_time (pint.Quantity or float) – Residence time of the disinfector
tags (dict of Tag) – Data tags associated with this disinfector
- property dosing_rate
- property residence_time
- class pype_schema.node.Facility(id, input_contents, output_contents, elevation, min_flow, max_flow, design_flow, tags={}, nodes={}, connections={})[source]
Bases:
Network
A class representing any industrial facility from wastewater treatment to desalination to solid waste management.
- Parameters:
id (str) – Facility ID
input_contents (ContentsType or list of ContentsType) – Contents entering the network.
output_contents (ContentsType or list of ContentsType) – Contents leaving the network.
elevation (pint.Quantity or int) – Elevation of the facility
min_flow (pint.Quantity or int) – Minimum flow rate through the facility
max_flow (pint.Quantity or int) – Maximum flow rate through the facility
design_flow (pint.Quantity or int) – Design flow rate through the facility
tags (dict of Tag) – Data tags associated with this facility
nodes (dict of Node) – nodes in the facility, e.g. pumps, tanks, or processes
connections (dict of Connections) – connections in the facility, e.g. pipes
- Variables:
id (str) – Facility ID
input_contents (list of ContentsType) – Contents entering the facility.
output_contents (list of ContentsType) – Contents leaving the facility.
elevation (pint.Quantity or int) – Elevation of the facility in meters above sea level
tags (dict of Tag) – Data tags associated with this facility
min_flow (pint.Quantity or int) – Minimum flow rate through the facility
max_flow (pint.Quantity or int) – Maximum flow rate through the facility
design_flow (pint.Quantity or int) – Design flow rate through the facility
nodes (dict of Node) – nodes in the facility, e.g. pumps, tanks, or processes
connections (dict of Connections) – connections in the facility, e.g. pipes
- class pype_schema.node.Filtration(id, input_contents, output_contents, min_flow, max_flow, design_flow, num_units, volume, dosing_rate={}, settling_time=0.0, tags={})[source]
Bases:
Node
The parent class for a wide range of filtration methods, such as sand filters, trickling filters, or reverse osmosis membranes.
- Parameters:
id (str) – Filter ID
input_contents (ContentsType or list of ContentsType) – Contents entering the filter
output_contents (ContentsType or list of ContentsType) – Contents leaving the filter
min_flow (pint.Quantity or int) – Minimum flow rate of a single filter
max_flow (pint.Quantity or int) – Maximum flow rate of a single filter
design_flow (pint.Quantity or int) – Design flow rate of a single filter
num_units (int) – Number of filters running in parallel
volume (pint.Quantity or int) – Volume of a single filter in cubic meters
dosing_rate (dict of DosingType:float) – Dosing information for the filter (key: DosingType, value: rate)
settling_time (float) – time it takes for the filter to reach the desired operation mode in seconds
tags (dict of Tag) – Data tags associated with this filter
- Variables:
id (str) – Filter ID
input_contents (list of ContentsType) – Contents entering the filter
output_contents (list of ContentsType) – Contents leaving the filter
num_units (int) – Number of filters running in parallel
volume (pint.Quantity or int) – Volume of a single filter in cubic meters
min_flow (pint.Quantity or int) – Minimum flow rate of a single filter
max_flow (pint.Quantity or int) – Maximum flow rate of a single filter
design_flow (pint.Quantity or int) – Design flow rate of a single filter
dosing_rate (dict of DosingType:float) – Dosing information for the filter (key: DosingType, value: rate)
settling_time (float) – time it takes for the filter to reach the desired operation mode
- property dosing_rate
- class pype_schema.node.Flaring(id, num_units, min_flow, max_flow, design_flow, tags={})[source]
Bases:
Node
- Parameters:
id (str) – Flare ID
num_units (int) – Number of flares running in parallel
min_flow (pint.Quantity or int) – Minimum flow rate of a single flare
max_flow (pint.Quantity or int) – Maximum flow rate of a single flare
design_flow (pint.Quantity or int) – Design flow rate of a single flare
tags (dict of Tag) – Data tags associated with this flare
- Variables:
id (str) – Flare ID
input_contents (list of ContentsType) – Contents entering the flare
num_units (int) – Number of flares running in parallel
min_flow (pint.Quantity or int) – Minimum flow rate of a single flare
max_flow (pint.Quantity or int) – Maximum flow rate of a single flare
design_flow (pint.Quantity or int) – Design flow rate of a single flare
- class pype_schema.node.Joint(id, input_contents, output_contents, tags={})[source]
Bases:
Node
A joint in the network, where multiple pipes meet.
- Parameters:
id (str) – Joint ID
input_contents (ContentsType or list of ContentsType) – Contents entering the joint
output_contents (ContentsType or list of ContentsType) – Contents leaving the joint
tags (dict of Tag) – Data tags associated with this joint
- class pype_schema.node.ModularUnit(id, input_contents, output_contents, num_units, tags={}, nodes={}, connections={})[source]
Bases:
Network
Modular Unit in the network, such as a reverse osmosis skid.
- Parameters:
id (str) – ModularUnit ID
input_contents (ContentsType or list of ContentsType) – Contents entering the ModularUnit.
output_contents (ContentsType or list of ContentsType) – Contents leaving the ModularUnit.
tags (dict of Tag) – Data tags associated with this ModularUnit
nodes (dict of Node) – nodes in the ModularUnit, e.g. pumps, tanks, or filters
connections (dict of Connections) – connections in the ModularUnit, e.g. pipes
num_units (int) – Number of units running in parallel
- Variables:
id (str) – ModularUnit ID
input_contents (list of ContentsType) – Contents entering the ModularUnit.
output_contents (list of ContentsType) – Contents leaving the ModularUnit.
tags (dict of Tag) – Data tags associated with this ModularUnit
nodes (dict of Node) – nodes in the ModularUnit, e.g. pumps, tanks, or filters
num_units (int) – Number of units running in parallel
connections (dict of Connections) – connections in the ModularUnit, e.g. pipes
- class pype_schema.node.Network(id, input_contents, output_contents, tags={}, nodes={}, connections={}, num_units=1)[source]
Bases:
Node
A water utility represented as a set of connections and nodes
- Parameters:
id (str) – Network ID
input_contents (ContentsType or list of ContentsType) – Contents entering the network.
output_contents (ContentsType or list of ContentsType) – Contents leaving the network.
tags (dict of Tag) – Data tags associated with this network
nodes (dict of Node) – nodes in the network, e.g. pumps, tanks, or facilities
connections (dict of Connections) – connections in the network, e.g. pipes
num_units (int, default 1) – Number of units in the network
- Variables:
id (str) – Network ID
input_contents (list of ContentsType) – Contents entering the network.
output_contents (list of ContentsType) – Contents leaving the network.
nodes (dict of Node) – nodes in the network, e.g. pumps, tanks, or facilities
connections (dict of Connections) – connections in the network, e.g. pipes
num_units (int) – Number of networks running in parallel
- add_connection(connection)[source]
Adds a connection to the network
- Parameters:
connection (Connection) – Connection object to add to the network
- add_node(node)[source]
Adds a node to the network
- Parameters:
node (Node) – Node object to add to the network
- get_list_of_type(desired_type, recurse=False)[source]
Searches the Facility and returns a list of all objects of desired_type
- Parameters:
desired_type (Node or Connection subclass)
recurse (bool) – Whether or not to get objects recursively. Default is False, meaning that only direct children will be returned.
- Returns:
Objects of desired_type inside this Facility. If recurse is True, all children, grandchildren, etc. are returned. If False, only direct children are returned.
- Return type:
list of desired_type
- remove_connection(connection_name, recurse=False)[source]
Removes a connection from the network :Parameters: * connection_name (str) – name of connection to remove
recurse (bool)
- Raises:
KeyError – if connection_name is not found
- remove_node(node_name, recurse=False)[source]
Removes a node from the network
- Parameters:
node_name (str) – name of node to remove
recurse (bool) – Whether or not to removed nodes recursively. Default is False, meaning that only direct children will be removed.
- Raises:
KeyError – if node_name is not found
- class pype_schema.node.Node[source]
Bases:
ABC
Abstract class for all nodes
- Variables:
id (str) – Node ID
input_contents (list of ContentsType) – Contents entering the node.
output_contents (list of ContentsType) – Contents leaving the node.
- property design_flow
- get_all_connections(recurse=False)[source]
Gets all Connection objects associated with this Node
- Parameters:
recurse (bool) – Whether or not to get connections recursively. Default is False, meaning that only direct children will be returned.
- Returns:
Connection objects inside this Node. If recurse is True, all children, grandchildren, etc. are returned. If False, only direct children are returned.
- Return type:
list of Connection
- get_all_connections_from(node)[source]
Gets all connections leaving the specified Node, including those from a different level of the hierarchy with exit_point specified.
Paremeters
- nodeNode
pype_schema Node object for which we want to get connections
- returns:
List of Connection objects leaving the specified node
- rtype:
list of Connection
- get_all_connections_to(node)[source]
Gets all connections entering the specified Node, including those from a different level of the hierarchy with entry_point specified.
Paremeters
- nodeNode
pype_schema Node object for which we want to get connections
- returns:
List of Connection objects entering the specified node
- rtype:
list of Connection
- get_all_nodes(recurse=False)[source]
Gets all Node objects associated with this Node
- Parameters:
recurse (bool) – Whether or not to get nodes recursively. Default is False, meaning that only direct children will be returned.
- Returns:
Node objects inside this Node. If recurse is True, all children, grandchildren, etc. are returned. If False, only direct children are returned.
- Return type:
- get_all_tags(virtual=True, recurse=False)[source]
Gets all Tag objects associated with this Node
- Parameters:
virtual (bool) – Whether to include VirtualTag objects or just regular Tag. True by default.
recurse (bool) – Whether or not to get tags recursively. Default is False, meaning that only tags involving direct children (and this Node itself) will be returned.
- Returns:
Tag objects inside this Node. If recurse is True, all children, grandchildren, etc. are returned. If False, only direct children are returned.
- Return type:
list of Tag and VirtualTag
- get_capacities()[source]
Gets a dictionary of capacity-related attributes
- Returns:
Dictionary of attribute names and values
- Return type:
- get_connection(connection_name, recurse=False)[source]
Get a connection from the network
- Parameters:
connection_name (str) – name of connection to retrieve
recurse (bool) – Whether or not to get connections recursively. Default is False, meaning that only direct children will be returned.
- Returns:
Connection object if node is found. None otherwise
- Return type:
Connection or None
- get_efficiencies()[source]
Gets a dictionary of efficiency-related attributes
- Returns:
Dictionary of attribute names and values
- Return type:
- get_node(node_name, recurse=False)[source]
Get a node from the network
- Parameters:
node_name (str) – name of node to retrieve
recurse (bool) – Whether or not to get nodes recursively. Default is False, meaning that only direct children will be returned.
- Returns:
Node object if node is found. None otherwise
- Return type:
Node or None
- get_node_or_connection(obj_id, recurse=False)[source]
Gets the Node or Connection object with name obj_id
- Parameters:
obj_id (str) – name of the object to query
recurse (bool) – Whether or not to get connections or nodes recursively. Default is False, meaning that only direct children will be returned.
- Returns:
object with the name obj_id
- Return type:
Node or Connection
- get_parent(child_obj)[source]
Gets the parent object of a Tag, Connection, or Node object, as long as both child_obj and its parent object are children of self
- Parameters:
child_obj (Tag, VirtualTag, Connection, or Node) – object for which we want the parent object
- Returns:
parent object of child_obj
- Return type:
Node or Connection
- get_parent_from_tag(tag)[source]
Gets the parent object of a Tag object, as long as both the tag and its parent object are children of self
- Parameters:
tag (Tag or VirtualTag) – object for which we want the parent object
- Returns:
parent object of the Tag
- Return type:
Node or Connection
- get_tag(tag_name, recurse=False)[source]
Gets the Tag object associated with tag_name
- Parameters:
tag_name (str)
recurse (bool) – Whether or not to get tags recursively. Default is False, meaning that only tags involving direct children (and this Node itself) will be returned.
- Returns:
pype_schema Tag object associated with the variable name. Returns None if the tag_name is not found
- Return type:
Tag or VirtualTag
- input_contents: list[pype_schema.utils.ContentsType] = NotImplemented
- property max_flow
- property min_flow
- output_contents: list[pype_schema.utils.ContentsType] = NotImplemented
- remove_tag(tag_name)[source]
Removes a tag from the node
- Parameters:
tag_name (str) – name of tag to remove
- select_objs(source_id=None, dest_id=None, source_unit_id=None, dest_unit_id=None, exit_point_id=None, entry_point_id=None, source_node_type=None, dest_node_type=None, exit_point_type=None, entry_point_type=None, contents_type=None, tag_type=None, obj_type=None, recurse=False)[source]
Selects from this Node all Node, Connection, or Tag objects which match source/destination node class, unit ID, and contents. (If none given, returns all objects in self)
- Parameters:
source_id (str) – Optional id of the source node to filter by. None by default
dest_id (str) – Optional id of the destination node to filter by. None by default
source_unit_id (int, str) – Optional unit id of the source to filter by. None by default
dest_unit_id (int, str) – Optional unit id of the destination to filter by. None by default
exit_point_id (str) – Optional id of the exit_point node to filter by. None by default
entry_point_id (str) – Optional id of the entry_point node to filter by. None by default
source_node_type (class) – Optional source Node subclass to filter by. None by default
dest_node_type (class) – Optional destination Node subclass to filter by. None by default
exit_point_type (class) – Optional exit_point Node subclass to filter by. None by default
entry_point_type (class) – Optional entry_point Node subclass to filter by. None by default
contents_type (ContentsType) – Optional contents to filter by. None by default
tag_type (TagType) – Optional tag type to filter by. None by default
obj_type ([Node, Connection, VirtualTag, Tag]) – The type of object to filter by. None by default
recurse (bool) – Whether to search for objects within nodes. False by default
- Raises:
ValueError – When a source/destination node type is provided to subset tags
TypeError – When the objects to select among are not of type {pype_schema.Tag, pype_schema.Connection, pype_schema.Node}
- Returns:
List of Tag, Connection, or Node objects subset according to source/destination id and contents_type
- Return type:
- select_tags(tag, source_id=None, dest_id=None, source_unit_id=None, dest_unit_id=None, exit_point_id=None, entry_point_id=None, source_node_type=None, dest_node_type=None, exit_point_type=None, entry_point_type=None, tag_type=None, recurse=False, virtual=False)[source]
Helper function for selecting Tag objects from inside a Node.
- Parameters:
tag (Tag) – Tag object to check against the search criteria
source_id (str) – Optional id of the source node to filter by. None by default
dest_id (str) – Optional id of the destination node to filter by. None by default
source_unit_id (int, str) – Optional unit id of the source to filter by. None by default
dest_unit_id (int, str) – Optional unit id of the destination to filter by. None by default
exit_point_id (str) – Optional id of the exit_point node to filter by. None by default
entry_point_id (str) – Optional id of the entry_point node to filter by. None by default
source_node_type (class) – Optional source Node subclass to filter by. None by default
dest_node_type (class) – Optional destination Node subclass to filter by. None by default
exit_point_type (class) – Optional exit_point Node subclass to filter by. None by default
entry_point_type (class) – Optional entry_point Node subclass to filter by. None by default
tag_type (TagType) – Optional tag type to filter by. None by default
recurse (bool) – Whether to search for objects within nodes. False by default
virtual (bool) – True if tag is being queried as part of a VirtualTag. False by default
- Returns:
True if tag meets the filtering criteria
- Return type:
- select_virtual_tags(virtual_tag, source_id=None, dest_id=None, source_unit_id=None, dest_unit_id=None, exit_point_id=None, entry_point_id=None, source_node_type=None, dest_node_type=None, exit_point_type=None, entry_point_type=None, tag_type=None, recurse=False)[source]
Helper function for selecting VirtualTag objects from inside a Node.
- Parameters:
virtual_tag (VirtualTag) – VirtualTag object to check against the search criteria
source_id (str) – Optional id of the source node to filter by. None by default
dest_id (str) – Optional id of the destination node to filter by. None by default
source_unit_id (int, str) – Optional unit id of the source to filter by. None by default
dest_unit_id (int, str) – Optional unit id of the destination to filter by. None by default
exit_point_id (str) – Optional id of the exit_point node to filter by. None by default
entry_point_id (str) – Optional id of the entry_point node to filter by. None by default
source_node_type (class) – Optional source Node subclass to filter by. None by default
dest_node_type (class) – Optional destination Node subclass to filter by. None by default
exit_point_type (class) – Optional exit_point Node subclass to filter by. None by default
entry_point_type (class) – Optional entry_point Node subclass to filter by. None by default
contents_type (ContentsType) – Optional contents to filter by. None by default
tag_type (TagType) – Optional tag type to filter by. None by default
recurse (bool) – Whether to search for objects within nodes. False by default
- Returns:
True if virtual_tag meets the filtering criteria
- Return type:
- set_contents(contents, attribute='input_contents')[source]
Set the input or output contents of a node
- Parameters:
contents (ContentsType or list of ContentsType) – Single value or list of ContentsType entering/exiting the node.
attribute ([“input_contents”, “output_contents”]) – Attribute to set (either input_contents or output_contents)
- set_dosing(dose_rate, mode='rate')[source]
Set the dosing rate of the node
- Parameters:
dose_rate (dict of str:float) – Dosing rate of the chemical in the node
mode (str) – whether or not the dosing is defined as a volumetric ‘rate’ or by ‘area’
- class pype_schema.node.Pump(id, input_contents, output_contents, elevation, min_flow, max_flow, design_flow, power_rating, num_units, pump_type=PumpType.Constant, efficiency=None, tags={})[source]
Bases:
Node
Any kind of pump, such as constant speed, variable frequency drive (VFD), energy recovery device (ERD), and air blower.
- Parameters:
id (str) – Pump ID
input_contents (ContentsType or list of ContentsType) – Contents entering the pump
output_contents (ContentsType or list of ContentsType) – Contents leaving the pump
elevation (pint.Quantity or int) – Elevation of the pump in meters above sea level
power_rating (pint.Quantity or int) – Rated power of a single pump (in horsepower)
num_units (int) – Number of pumps running in parallel
min_flow (pint.Quantity or int) – Minimum flow rate supplied by the pump
max_flow (pint.Quantity or int) – Maximum flow rate supplied by the pump
design_flow (pint.Quantity or int) – Design flow rate supplied by the pump
pump_type (PumpType) – Type of pump (either VFD, ERD, AirBlower or Constant)
efficiency (float) – efficiency of the pump
tags (dict of Tag) – Data tags associated with this pump
- Variables:
id (str) – Pump ID
input_contents (list of ContentsType) – Contents entering the pump
output_contents (list of ContentsType) – Contents leaving the pump
elevation (pint.Quantity or int) – Elevation of the pump in meters above sea level
power_rating (pint.Quantity or int) – Rated power of a single pump (in horsepower)
num_units (int) – Number of pumps running in parallel
min_flow (pint.Quantity or int) – Minimum flow rate supplied by the pump
max_flow (pint.Quantity or int) – Maximum flow rate supplied by the pump
design_flow (pint.Quantity or int) – Design flow rate supplied by the pump
pump_type (PumpType) – Type of pump (either VFD, ERD, AirBlower or Constant)
pump_curve (function) – Function which takes in the current flow rate and returns the energy required to pump at that rate
- property efficiency
- property power_rating
- class pype_schema.node.ROMembrane(id, input_contents, output_contents, min_flow, max_flow, design_flow, num_units, volume, area, permeability, selectivity, dosing_rate={}, settling_time=0.0, tags={})[source]
Bases:
Filtration
A class for representing a reverse osmosis membrane process.
- Parameters:
id (str) – ROMembrane ID
input_contents (ContentsType or list of ContentsType) – Contents entering the RO membrane
output_contents (ContentsType or list of ContentsType) – Contents leaving the RO membrane
min_flow (pint.Quantity or int) – Minimum flow rate of the RO membrane
max_flow (pint.Quantity or int) – Maximum flow rate of the RO membrane
design_flow (pint.Quantity or int) – Design flow rate of a single filter
num_units (int) – Number of RO membranes running in parallel
volume (pint.Quantity or int) – Volume of the RO membrane in cubic meters
area (float) – Area of the RO membrane in square meters
permeability (float) – Permeability of the RO membrane
selectivity (float) – Selectivity of the RO membrane
dosing_rate (dict of DosingType:float) – Dosing information for the RO membrane (key: DosingType, value: rate)
settling_time (float) – time it takes for the filter to reach the desired operation mode
tags (dict of Tag) – Data tags associated with the RO membrane
- Variables:
id (str) – ROMembrane ID
input_contents (list of ContentsType) – Contents entering the RO membrane
output_contents (list of ContentsType) – Contents leaving the RO membrane
num_units (int) – Number of RO membranes running in parallel
volume (pint.Quantity or int) – Volume of a single filter in cubic meters
min_flow (pint.Quantity or int) – Minimum flow rate of a single filter
max_flow (pint.Quantity or int) – Maximum flow rate of a single filter
design_flow (pint.Quantity or int) – Design flow rate of a single filter
area (float) – Area of the RO membrane in square meters
permeability (float) – Permeability of the RO membrane
selectivity (float) – Selectivity of the RO membrane
dosing_rate (dict of DosingType:float) – Dosing information for the RO membrane (key: DosingType, value: rate)
settling_time (float) – time it takes for the filter to reach the desired operation mode
tags (dict of Tag) – Data tags associated with the RO membrane
- class pype_schema.node.Reactor(id, input_contents, output_contents, min_flow, max_flow, design_flow, num_units, volume, residence_time, dosing_rate={}, pH=None, tags={})[source]
Bases:
Node
A reactor modeled as a basic tank with chemical dosing point(s).
- Parameters:
id (str) – Reactor ID
input_contents (ContentsType or list of ContentsType) – Contents entering the reactor
output_contents (ContentsType or list of ContentsType) – Contents leaving the reactor
min_flow (pint.Quantity or int) – Minimum flow rate through the reactor
max_flow (pint.Quantity or int) – Maximum flow rate through the reactor
design_flow (pint.Quantity or int) – Design flow rate through the reactor
num_units (int) – Number of reactor in parallel
volume (pint.Quantity or int) – Volume of the reactor in cubic meters
residence_time (pint.Quantity or float) – Residence time of the reactor
dosing_rate (dict of DosingType:float) – Dosing information for the reactor (key: DosingType, value: rate)
pH (float) – pH value for the reactor
tags (dict of Tag) – Data tags associated with this reactor
- Variables:
id (str) – Reactor ID
input_contents (list of ContentsType) – Contents entering the reactor
output_contents (list of ContentsType) – Contents leaving the reactor
min_flow (pint.Quantity or int) – Minimum flow rate through the reactor
max_flow (pint.Quantity or int) – Maximum flow rate through the reactor
design_flow (pint.Quantity or int) – Design flow rate through the reactor
num_units (int) – Number of reactors
volume (pint.Quantity or int) – Volume of the reactor in cubic meters
residence_time (pint.Quantity or float) – Residence time of the reactor
dosing_rate (dict of DosingType:float) – Dosing information for the reactor (key: DosingType, value: rate)
pH (float) – pH value for the reactor
num_units – Number of reactors in parallel
- property dosing_rate
- class pype_schema.node.Reservoir(id, input_contents, output_contents, elevation, volume, tags={})[source]
Bases:
Node
A generic reservoir used to represent lakes and oceans in addition to manmade bodies of water.
- Parameters:
id (str) – Reservoir ID
input_contents (ContentsType or list of ContentsType) – Contents entering the reservoir.
output_contents (ContentsType or list of ContentsType) – Contents leaving the reservoir.
elevation (pint.Quantity or int) – Elevation of the reservoir in meters above sea level
volume (pint.Quantity or int) – Volume of the reservoir in cubic meters
tags (dict of Tag) – Data tags associated with this reservoir
- Variables:
id (str) – Reservoir ID
input_contents (list of ContentsType) – Contents entering the reservoir.
output_contents (list of ContentsType) – Contents leaving the reservoir.
elevation (pint.Quantity or int) – Elevation of the reservoir in meters above sea level
volume (pint.Quantity or int) – Volume of the reservoir in cubic meters
tags (dict of Tag) – Data tags associated with this reservoir
- class pype_schema.node.Screening(id, input_contents, output_contents, min_flow, max_flow, design_flow, num_units, tags={})[source]
Bases:
Node
A class representing the screening process for removing large solids from the intake of a facility, such as a bar screen.
- Parameters:
id (str) – Screen ID
input_contents (ContentsType or list of ContentsType) – Contents entering the screen
output_contents (ContentsType or list of ContentsType) – Contents leaving the screen
min_flow (pint.Quantity or int) – Minimum flow rate of a single screen
max_flow (pint.Quantity or int) – Maximum flow rate of a single screen
design_flow (pint.Quantity or int) – Design flow rate of a single screen
num_units (int) – Number of screens running in parallel
tags (dict of Tag) – Data tags associated with this screen
- Variables:
id (str) – Screen ID
input_contents (list of ContentsType) – Contents entering the screen
output_contents (list of ContentsType) – Contents leaving the screen
num_units (int) – Number of screens running in parallel
min_flow (pint.Quantity or int) – Minimum flow rate of a single screen
max_flow (pint.Quantity or int) – Maximum flow rate of a single screen
design_flow (pint.Quantity or int) – Design flow rate of a single screen
- class pype_schema.node.StaticMixer(id, input_contents, output_contents, min_flow, max_flow, design_flow, num_units, volume, residence_time, dosing_rate={}, pH=None, tags={})[source]
Bases:
Reactor
A tank containing a static mixer, typically used for coagulation in water treatment.
- Parameters:
id (str) – StaticMixer ID
input_contents (ContentsType or list of ContentsType) – Contents entering the mixer
output_contents (ContentsType or list of ContentsType) – Contents leaving the mixer
min_flow (pint.Quantity or int) – Minimum flow rate through the mixer
max_flow (pint.Quantity or int) – Maximum flow rate through the mixer
design_flow (pint.Quantity or int) – Design flow rate through the mixer
num_units (int) – Number of mixers in parallel
volume (pint.Quantity or int) – Volume of the mixer in cubic meters
residence_time (pint.Quantity or float) – Residence time of the mixer
dosing_rate (dict of DosingType:float) – Dosing information for the mixer (key: DosingType, value: rate)
pH (float) – pH value for the mixer
tags (dict of Tag) – Data tags associated with this mixer
- Variables:
id (str) – StaticMixer ID
input_contents (list of ContentsType) – Contents entering the mixer
output_contents (list of ContentsType) – Contents leaving the mixer
min_flow (pint.Quantity or int) – Minimum flow rate through the mixer
max_flow (pint.Quantity or int) – Maximum flow rate through the mixer
design_flow (pint.Quantity or int) – Design flow rate through the mixer
num_units (int) – Number of mixers in parallel
volume (pint.Quantity or int) – Volume of the mixer in cubic meters
residence_time (pint.Quantity or float) – Residence time of the mixer
dosing_rate (dict of DosingType:float) – Dosing information for the mixer (key: DosingType, value: rate)
pH (float) – pH value for the mixer
- class pype_schema.node.Tank(id, input_contents, output_contents, elevation, volume, num_units=1, tags={})[source]
Bases:
Node
A generic class to represent a storage tank. Any input_contents and output_contents can be provided and metadata such as volume and elevation can be specified.
- Parameters:
id (str) – Tank ID
input_contents (ContentsType or list of ContentsType) – Contents entering the tank
output_contents (ContentsType or list of ContentsType) – Contents leaving the tank
elevation (pint.Quantity or int) – Elevation of the tank in meters above sea level
volume (pint.Quantity or int) – Volume of the tank in cubic meters
num_units (int) – Number of identical tanks in parallel
tags (dict of Tag) – Data tags associated with this tank
- Variables:
id (str) – Tank ID
input_contents (list of ContentsType) – Contents entering the tank.
output_contents (list of ContentsType) – Contents leaving the tank.
elevation (pint.Quantity or int) – Elevation of the tank in meters above sea level
volume (pint.Quantity or int) – Volume of the tank in cubic meters
num_units (int) – Number of identical tanks in parallel
- property num_units
- class pype_schema.node.Thickening(id, input_contents, output_contents, min_flow, max_flow, design_flow, num_units, volume, tags={})[source]
Bases:
Node
A class to represent a general thickener, such as gravity belt, dissolved air float (DAF), or centrifugal thickening.
- Parameters:
id (str) – Thickener ID
input_contents (ContentsType or list of ContentsType) – Contents entering the thickener
output_contents (ContentsType or list of ContentsType) – Contents leaving the thickener
min_flow (pint.Quantity or int) – Minimum flow rate of a single thickener
max_flow (pint.Quantity or int) – Maximum flow rate of a single thickener
design_flow (pint.Quantity or int) – Design flow rate of a single thickener
num_units (int) – Number of thickeners running in parallel
volume (pint.Quantity or int) – Volume of a single thickener in cubic meters
tags (dict of Tag) – Data tags associated with this thickener
- Variables:
id (str) – Thickener ID
input_contents (list of ContentsType) – Contents entering the thickener
output_contents (list of ContentsType) – Contents leaving the thickener
num_units (int) – Number of thickeners running in parallel
volume (pint.Quantity or int) – Volume of a single thickener in cubic meters
min_flow (pint.Quantity or int) – Minimum flow rate of a single thickener
max_flow (pint.Quantity or int) – Maximum flow rate of a single thickener
design_flow (pint.Quantity or int) – Design flow rate of a single thickener
tags (dict of Tag) – Data tags associated with this thickener
- class pype_schema.node.UVSystem(id, input_contents, output_contents, min_flow, max_flow, design_flow, num_units, volume, residence_time, intensity, area, tags={})[source]
Bases:
Disinfection
- Parameters:
id (str) – UV System ID
input_contents (list of ContentsType) – Contents entering the UV system
output_contents (list of ContentsType) – Contents leaving the UV system
num_units (int) – Number of UV systems running in parallel
residence_time (pint.Quantity or float) – Time in seconds that the water is exposed to UV light
intensity (pint.Quantity or float) – Intensity of the UV light in W/m^2
area (pint.Quantity or float) – Application area of the UV light in m^2
tags (dict of Tag) – Data tags associated with this chlorinator
- Variables:
id (str) – UVSystem ID
num_units (int) – Number of chlorinators running in parallel
residence_time (pint.Quantity or float) – Time in seconds that the water is exposed to UV light
dosing_rate (dict of DosingType:float) – UV intensity in the UV system
dosing_area (dict of DosingType:float) – Area of the UV system that is exposed to UV light
tags (dict of Tag) – Data tags associated with this chlorinator
- property dosing_area
pype_schema.operations module
- pype_schema.operations.get_change(variable, delta_t=1, split=False)[source]
Converts cumulative value to rate-of-change value using finite differences Note: assumes rate of change at time t is equal to the difference between the value at time t+1 and t
- Parameters:
variable (pandas.Series, numpy.ndarray) – variable to convert
delta_t (int) – Time difference between two consecutive values of the variable (default is 1)
split (bool) – Whether to split the variable into a negative change and a positive change
- Returns:
Rate of change variable or tuple of netative, positive rate of change variable
- Return type:
pype_schema.parse_json module
- class pype_schema.parse_json.JSONParser(path)[source]
Bases:
object
A parser to convert a JSON file into a Network object
- Parameters:
path (str) – path to the JSON file to load
- Variables:
- add_virtual_tags(verbose=False)[source]
Adds all virtual tags in an object NOTE: assumes the objects tags have already been added
- Parameters:
obj (Node or Connection) – object to add virtual tags to
verbose (bool) – If True will print informative statements while adding virtual tags. Default is False
- collect_virtual_tags(config, obj_id=None, virtual_tags=None)[source]
Recursively collects all virtual tags in a network’s dictionary representation (i.e. config)
- Parameters:
config (dict) – Dictionary representation of the network
obj_id (str) – Optional “id” of config whose virtual tags are being collected (if None will use “ParentNetwork”)
virtual_tags (dict) – dictionary to store virtual tags in
- Returns:
dictionary of all VirtualTag in network
- Return type:
- static conn_to_dict(conn_obj)[source]
Converts a Connection object to a dictionary that can be parsed into JSON format
- Parameters:
conn_obj (Connection) – object to be converted into a dictionary
- Returns:
conn_obj in dictionary form
- Return type:
- create_connection(connection_id, node_obj, verbose=False)[source]
Converts a dictionary into a Connection object
- Parameters:
connection_id (str) – the string id for the Connection
node_id (str) – the string id for the Node which holds this connection. If None the default ID, ‘ParentNetwork’ is used
verbose (bool) – Whether to print informative messages for debugging. Default is False
- Returns:
a Python object with all the values from key connection_id
- Return type:
- create_node(node_id, verbose=False)[source]
Converts a dictionary into a Node object
- Parameters:
node_id (str) – the string id for the Node
verbose (bool) – Whether to print informative messages for debugging. Default is False
- Returns:
a Python object with all the values from key node_id
- Return type:
- static dosing_to_dict(dosing_dict)[source]
Converts the dosing rate or area dictionary from PyPES to JSON format.
- Parameters:
dosing_dict (dict) –
- dictionary of the form {
DosingTypeA
: float or`pint.Quantity`DosingTypeB
: float or pint.Quantity
}
- Returns:
- Dictionary in JSON-readable format. I.e., {
DosingTypeA
: {value
: floatunits
: str
}
DosingTypeB
: {value
: floatunits
: str
}
}
- Return type:
- extend_node(new_network, target_node_id, connections_path, inplace=False, verbose=False)[source]
Incoporates subnetwork (i.e. the new_network) into a node in a existing network (i.e. the old_network) modifying it in place and returning the modified network
- Parameters:
new_network (str or pype_schema.Network) – JSON file path or Network objet to merge with self
target_node_id (str) – ID of the node to expend, must be in the old_network
connections_path (str) – JSON file path to the connections connecting new_network to old_network.
inplace (bool) – Whether to modify self in place or leave original object unmodified. False by default
verbose (bool) – Whether to print informative messages for debugging. Default is False
- Raises:
- Returns:
Modified network object
- Return type:
- static get_tag_contents(tag_id, tag_info, obj)[source]
Parse tag ID and dictionary of information into Tag object
- Parameters:
tag_id (str) – name of the tag
tag_info (dict) –
- dictionary of the form {
type
: TagTypeunits
: strcontents
: strsource_unit_id
: int or strdest_unit_id
: int or strtotalized
: bool
}
obj (Node or Connection) – object that this tag is associated with, which is used to gather relevant metadata
- Returns:
the contents of this tag
- Return type:
- Raises:
ValueError – If contents are ambiguously defined in JSON. E.g., contents not defined in tag and parent object has a list of contents
- initialize_network(verbose=False)[source]
Converts a dictionary into a Network object
- Parameters:
verbose (bool) – If True will print informative statements while initializing the network
- Returns:
a Python object with all the values from the JSON file stored hierarchically
- Return type:
- merge_network(old_network, inplace=False)[source]
Incorporates nodes/connections (i.e. the new_network) into a network (i.e. old_newtwork) modifying it in place and returning the modified network
- Parameters:
old_network (str or pype_schema.Network) – JSON file path or Network objet to merge with self
- Raises:
TypeError: – When user does not provide a valid path or Network object for old_network
- Returns:
Modified network object
- Return type:
- static min_max_design_to_dict(obj, attribute)[source]
Converts the flow rate tuple of a Node or Connection into a dictionary object
- Parameters:
obj (Node or Connection) – object to get attribute of and convert it to a dictionary
attribute (str) – Either “flow_rate”, “gen_capacity”, or “pressure”
- Returns:
- flow rate in the form {
min
: float or intmax
: float or intdesign
: float or intunits
: str
}
- Return type:
- static node_to_dict(node_obj)[source]
Converts a Node object to a dictionary that can be parsed into JSON format
- static parse_dosing_rate(dosing_dict)[source]
Converts a dictionary into a dictionary of a different format
- Parameters:
heating_vals (dict) –
dictionary of the form {
DosingType
: {rate
: floatunits
: str}
}
- Returns:
Keys are of DosingType or str and values of pint.Quantity or float Given as a float if no units are specified
- Return type:
- static parse_min_max_design(min_max_design)[source]
Converts a dictionary into a tuple of flow rates
- Parameters:
min_max_design (dict) –
- dictionary of the form {
min
: floatmax
: floatdesign
: floatunits
: str
}
- Returns:
(min, max, and average) with the given Pint units as a tuple. If no units given, then returns a tuple of floats.
- Return type:
(pint.Quantity, pint.Quantity, pint.Quantity) or (float, float, float)
- static parse_tag(tag_id, tag_info, obj)[source]
Parse tag ID and dictionary of information into Tag object
- Parameters:
tag_id (str) – name of the tag
tag_info (dict) –
- dictionary of the form {
type
: TagTypeunits
: strcontents
: strsource_unit_id
: int or strdest_unit_id
: int or strtotalized
: bool
}
obj (Node or Connection) – object that this tag is associated with, which is used to gather relevant metadata
- Returns:
a Python object with the given ID and the values from tag_info
- Return type:
- static parse_unit_val_dict(unit_dict)[source]
Converts a dictionary into a Pint Quantity
- Parameters:
unit_dict (dict) –
- dictionary of the form {
value
:float
units
: str
}
- Returns:
Dictionary as a Pint Quantity (or float if no units are specified)
- Return type:
pint.Quantity or float
- static parse_virtual_tag(tag_id, tag_info, obj, parent_network=None)[source]
Parse tag ID and dictionary information into VirtualTag object
- Parameters:
tag_id (str) – name of the tag
tag_info (dict) –
- dictionary of the form {
tags
: dict of Tagoperations
: strtype
: TagTypecontents
: str
}
obj (Node or Connection) – parent object that contains all constituent tags, which is used to gather the tag list for combining data correctly
parent_network (None, Network) – Optional network object the tag is a part of If None will assume obj is parent network and all tags are in obj.tags
parent_network (None, Network) – Optional network object the tag is a part of If None will assume obj is the parent network and all tags are in obj.tags
- Returns:
a Python object with the given ID and the values from tag_info
- Return type:
- static prefix_children(target_node, prefix)[source]
Renames the children nodes and connections of the target_node by prepending their ID with prefix.
- Parameters:
target_node (node.Network) – Network object to rename the children of with a prefix
prefix (str) – String to prepend to the existing node and connection objects
- Returns:
New network object with
- Return type:
- static tag_to_dict(tag_obj)[source]
Converts a Tag or VirtualTag object to a dictionary that can be parsed into JSON format
- static to_json(network, file_path=None, indent=4, verbose=False)[source]
Converts a Network object to a JSON file
- Parameters:
network (node.Network) – Network object to export to JSON
file_path (str) – path to write the configuration in JSON format. Default is None, meaning that no file will be written
indent (int) – number of spaces to indent the JSON file. Default is 4
verbose (bool) – Whether to print informative messages for debugging. Default is False
- Raises:
TypeError – If network is not of type Network
- Returns:
json in dictionary format
- Return type:
pype_schema.tag module
- class pype_schema.tag.DownsampleType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
Enum to represent common methods of downsampling data
- Average = 1
- Decimation = 2
- Reservoir = 3
- 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]
Bases:
object
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.
- property calibration
- check_type_compatibility(other_type)[source]
Check if the given tag_type is compatible with another
- Parameters:
other_type (TagType) – Type of tag to compare against
- Returns:
True if compatible, False otherwise
- Return type:
- property downsample_method
- property manufacturer
- property measure_freq
- property report_freq
- class pype_schema.tag.TagType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
Enum to represent types of SCADA tags
- BOD = 12
- COD = 11
- Concentration = 24
- Conductivity = 14
- Efficiency = 17
- Flow = 1
- Frequency = 23
- InFlow = 19
- Level = 3
- NetFlow = 21
- OutFlow = 20
- Pressure = 4
- Rotation = 16
- RunStatus = 7
- RunTime = 6
- SetPoint = 25
- Speed = 22
- StateOfCharge = 18
- TDS = 10
- TSS = 9
- Temperature = 5
- Turbidity = 15
- VSS = 8
- Volume = 2
- pH = 13
- class pype_schema.tag.VirtualTag(id, tags, operations=None, units=None, tag_type=None, parent_id=None, contents=None)[source]
Bases:
object
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
pype_schema.units module
Module containing global unit registry.
The Pint package supports arithmetic
of physical quantities, which are combinations of numerical values and units of
measurement. The units of a quantity come from Pint’s unit registry. This
module contains a unit registry, named u
, based on Pint’s unit registry.
It also defines a few additional units.
Frequently Used Units and Constants in u
Prefixes for Metric Units
pico- = 1e-12 = p-
nano- = 1e-9 = n-
micro- = 1e-6 = u- = µ-
milli- = 1e-3 = m-
centi- = 1e-2 = c-
deci- = 1e-1 = d-
deca- = 1e+1 = da-
hecto- = 1e2 = h-
kilo- = 1e3 = k-
mega- = 1e6 = M-
giga- = 1e9 = G-
tera- = 1e12 = T-
Units of Length
u.meter
=u.metre
=u.m
u.inch
u.foot
=u.ft
u.yard
=u.yd
u.mile
=u.mi
Units of Mass
u.gram
=u.g
u.metric_ton
=u.tonne
=u.t
u.ounce
=u.oz
u.pound
=u.lb
u.ton
u.atomic_mass_unit
=u.amu
Units of Time
u.second
=u.sec
=u.s
u.minute
=u.min
u.hour
=u.hr
u.day
u.week
u.year
Units of Temperature
u.kelvin
=u.degK
u.celsius
=u.degC
u.fahrenheit
=u.degF
Units of Angle
u.revolution
=u.rev
u.radian
=u.rad
u.degree
=u.deg
Units of Force
u.newton
=u.N
u.gram_force
=u.gf
u.kilogram_force
=u.kgf
u.pound_force
=u.lbf
u.ton_force
u.kip
Units of Frequency
u.hertz
=u.Hz
u.revolutions_per_minute
=u.rpm
Units of Money
u.dollar
=u.USD
u.lempira
=u.HNL
Units of Power
u.watt
=u.W
u.horsepower
=u.hp
Units of Pressure
u.pascal
=u.Pa
u.bar
u.atmosphere
=u.atm
u.torr
u.millimeter_Hg
=u.mmHg
Units of Volume
u.liter
=u.litre
=u.L
u.cubic_centimeter
=u.cc
u.gallon
=u.gal
u.quart
=u.qt
u.pint
=u.pt
u.cup
u.fluid_ounce
=u.floz
u.tablespoon
=u.tbsp
u.teaspoon
=tsp
Other Units
u.joule
=u.J
u.mole
=u.mol
=u.equivalent
=u.eq
u.NTU
= 1.47 * (u.mg
/u.L
)u.BTU
= 1055.056 *u.J
u.LMH
=u.liter
** 2 / (u.hour
*u.meter
** 2)This turbidity-concentration relation applies to kaolinite clay and is obtained from Coagulation behavior of polyaluminum chloride (Wei et al., 2015).
Constants
u.gravity
u.molar_gas_constant
=u.R
u.avogadro_number
u.boltzmann_constant
pype_schema.utils module
- class pype_schema.utils.ContentsType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
Class to represent any possible contents, whether they are sludge, water, or gas
- Air = 30
- Biogas = 9
- Brine = 22
- Chemical = 31
- ChlorinatedSeawater = 41
- Coagulant = 32
- CoagulatedWater = 42
- ControlSignal = 46
- DataTransfer = 47
- Deodorant = 34
- Disinfectant = 33
- DisinfectedEffluent = 37
- DrinkingWater = 6
- Electricity = 21
- FatOilGrease = 12
- FilterBackwash = 43
- Filtrate = 44
- FoodWaste = 18
- GasBlend = 11
- Grease = 29
- Groundwater = 25
- Heat = 27
- IndustrialWastewater = 35
- MunicipalWastewater = 36
- NaturalGas = 10
- NonpotableReuse = 8
- Oil = 28
- PotableReuse = 7
- PretreatedWater = 39
- PrimaryEffluent = 2
- PrimarySludge = 13
- ProductWater = 40
- Scum = 17
- Seawater = 23
- SecondaryEffluent = 3
- SludgeBlend = 19
- SolidWaste = 38
- Stormwater = 26
- SurfaceWater = 24
- TPS = 14
- TWAS = 16
- TertiaryEffluent = 4
- ThickenedSludgeBlend = 20
- TreatedSewage = 5
- UntreatedSewage = 1
- WFBS = 45
- WasteActivatedSludge = 15
- class pype_schema.utils.DigesterType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
Enum to represent types of digesters
- Aerobic = 1
- Anaerobic = 2
- class pype_schema.utils.DosingType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
Enum to represent types of dosing
- Antiscalant = 3
- CO2 = 4
- CaOH2 = 5
- FeCl3 = 2
- NaOCl = 1
- OrthoPolyphosphate = 6
- Polymer = 8
- SBS = 7
- UVLight = 9
- class pype_schema.utils.PumpType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
Enum to represent constant vs. variable drive pumps
- AirBlower = 4
- Constant = 1
- ERD = 3
- VFD = 2
- pype_schema.utils.count_args(func_str)[source]
Count the arguments for a lambda function string
- Parameters:
func_str (str) – A string representation of a lambda function
- Returns:
The lambda function’s number of arguments
- Return type:
- pype_schema.utils.get_tag_sum_lambda_func(unit_ids)[source]
Generate a lambda function string to sum tags
- Parameters:
unit_ids (list) – A list of unit IDs to sum
- Returns:
A string representation of a lambda function that sums tags
- Return type:
- pype_schema.utils.parse_quantity(value, units)[source]
Convert a value and unit string to a Pint quantity
- Parameters:
value (float)
units (str)
- Returns:
a Pint Quantity with the given value and units
- Return type:
pint.Quantity
- pype_schema.utils.parse_units(units)[source]
Convert a unit string to a Pint Unit object
- Parameters:
units (str)
- Returns:
a Pint Unit for the given string
- Return type:
Unit
- pype_schema.utils.recursive_get(key, dict_)[source]
Recursively search a nested dictionary for a key
- Parameters:
key (str) – Key to search
dict_ (dict) – (nested) dictionary to search
Returns (any, None) – Value of the key if found, None otherwise
- pype_schema.utils.select_objs_helper(obj, obj_source_node=None, obj_dest_node=None, obj_source_unit_id=None, obj_dest_unit_id=None, obj_exit_point=None, obj_entry_point=None, source_id=None, dest_id=None, source_unit_id=None, dest_unit_id=None, exit_point_id=None, entry_point_id=None, source_node_type=None, dest_node_type=None, exit_point_type=None, entry_point_type=None, tag_type=None, recurse=False)[source]
Helper to select from objects which match source/destination node class, unit ID, and contents
- Parameters:
obj ([Node, Connection, Tag]) – Object to check if it meets the specified filtering criteria
obj_source_node (Node) – Optional source Node to check the type and id of. None by default
obj_dest_node (Node) – Optional destination Node to check the type and id of. None by default
obj_source_unit_id (int, str) – Object’s source unit ID to match against. None by default
obj_dest_unit_id (int, str) – Object’s destination unit ID to match against. None by default
obj_exit_point (Node) – Optional exit_point Node to check the type and id of. None by default
obj_entry_point (Node) – Optional entry_point Node to check the type and id of. None by default
source_id (str) – Optional id of the source node to filter by. None by default
dest_id (str) – Optional id of the destination node to filter by. None by default
source_unit_id (int, str) – Optional unit id of the source to filter by. None by default
dest_unit_id (int, str) – Optional unit id of the destination to filter by. None by default
source_node_type (class) – Optional source Node subclass to filter by. None by default
dest_node_type (class) – Optional destination Node subclass to filter by. None by default
tag_type (TagType) – Optional tag type to filter by. None by default
recurse (bool) – Whether to search for objects within nodes. False by default
- Raises:
ValueError – When a source/destination node type is provided to subset tags
TypeError – When the objects to select among are not of type {‘pype_schema.Tag’ or pype_schema.Connection}
- Returns:
True if obj fits the filter criteria; False otherwise.
- Return type:
pype_schema.visualize module
- pype_schema.visualize.draw_graph(network, pyvis=False, output_file=None)[source]
Draw all of the nodes and connections in the given network
- Parameters:
network (Network) – Network object to draw
pyvis (bool) – Whether to draw the graph with PyVis or Networkx. False (networkx) by default
output_file (str) – Path to the desired output. Default is None, meaning the file will be saved as networkd.id + extension
Module contents
Main package for PyPES.