22
33#
44# __init__.py - EPANET output package
5- #
5+ #
66# Date Created: August 15, 2018
77#
88# Author: Michael E. Tryby
1919__credits__ = "Maurizio Cingi"
2020__license__ = "CC0 1.0 Universal"
2121
22- __version__ = "0.1.1 "
22+ __version__ = "0.2.0 "
2323__date__ = "August 15, 2018"
2424
2525__maintainer__ = "Michael Tryby"
2929
3030from enum import Enum , auto
3131
32- from epanet .output import output as oapi
32+ from epanet .output import output as oapi
3333
3434
3535class Units (Enum ):
@@ -41,107 +41,107 @@ class Units(Enum):
4141 HEADLOSS = auto ()
4242 RX_RATE = auto ()
4343 UNITLESS = auto ()
44- NONE = auto ()
44+ NONE = auto ()
4545
4646class RxUnits (Enum ):
47- MGH = auto ()
47+ MGH = auto ()
4848 UGH = auto ()
4949
5050
5151class OutputMetadata ():
5252 '''
5353 Simple attribute name and unit lookup.
5454 '''
55-
55+
5656 _unit_labels_us_ = {
5757 Units .HYD_HEAD : "ft" ,
5858 Units .VELOCITY : "ft/sec" ,
59- Units .HEADLOSS : "ft/1000ft" ,
59+ Units .HEADLOSS : "ft/1000ft" ,
6060 Units .UNITLESS : "unitless" ,
6161 Units .NONE : "" ,
62-
62+
6363 RxUnits .MGH : "mg/hr" ,
6464 RxUnits .UGH : "ug/hr" ,
65-
65+
6666 oapi .FlowUnits .CFS : "cu ft/s" ,
6767 oapi .FlowUnits .GPM : "gal/min" ,
6868 oapi .FlowUnits .MGD : "M gal/day" ,
6969 oapi .FlowUnits .IMGD : "M Imp gal/day" ,
7070 oapi .FlowUnits .AFD : "ac ft/day" ,
71-
72- oapi .PressUnits .PSI : "psi" ,
73-
74- oapi .QualUnits .NONE : "" ,
71+
72+ oapi .PressUnits .PSI : "psi" ,
73+
74+ oapi .QualUnits .NONE : "" ,
7575 oapi .QualUnits .MGL : "mg/L" ,
7676 oapi .QualUnits .UGL : "ug/L" ,
77- oapi .QualUnits .HOURS : "hrs" ,
77+ oapi .QualUnits .HOURS : "hrs" ,
7878 oapi .QualUnits .PRCNT : "%" }
7979
8080 _unit_labels_si_ = {
8181 Units .HYD_HEAD : "m" ,
8282 Units .VELOCITY : "m/sec" ,
83- Units .HEADLOSS : "m/Km" ,
83+ Units .HEADLOSS : "m/Km" ,
8484 Units .UNITLESS : "unitless" ,
8585 Units .NONE : "" ,
86-
86+
8787 RxUnits .MGH : "mg/hr" ,
8888 RxUnits .UGH : "ug/hr" ,
89-
89+
9090 oapi .FlowUnits .LPS : "L/sec" ,
9191 oapi .FlowUnits .LPM : "L/min" ,
9292 oapi .FlowUnits .MLD : "M L/day" ,
9393 oapi .FlowUnits .CMH : "cu m/hr" ,
9494 oapi .FlowUnits .CMD : "cu m/day" ,
95-
95+
9696 oapi .PressUnits .MTR : "meters" ,
9797 oapi .PressUnits .KPA : "kPa" ,
98-
99- oapi .QualUnits .NONE : "" ,
98+
99+ oapi .QualUnits .NONE : "" ,
100100 oapi .QualUnits .MGL : "mg/L" ,
101101 oapi .QualUnits .UGL : "ug/L" ,
102- oapi .QualUnits .HOURS : "hrs" ,
102+ oapi .QualUnits .HOURS : "hrs" ,
103103 oapi .QualUnits .PRCNT : "%" }
104104
105-
105+
106106 def __init__ (self , output_handle ):
107-
107+
108108 self .units = list ()
109109 # If outputhandle not initialized use default settings
110- if output_handle == None :
111- self .units = [oapi .FlowUnits .GPM .value ,
112- oapi .PressUnits .PSI .value ,
110+ if output_handle == None :
111+ self .units = [oapi .FlowUnits .GPM .value ,
112+ oapi .PressUnits .PSI .value ,
113113 oapi .QualUnits .NONE .value ]
114114 # Else quary the output api for unit settings
115115 else :
116- for u in oapi .Units :
116+ for u in oapi .Units :
117117 self .units .append (oapi .getunits (output_handle , u ))
118-
119- # Convert unit settings to enums
118+
119+ # Convert unit settings to enums
120120 self ._flow = oapi .FlowUnits (self .units [0 ])
121121 self ._press = oapi .PressUnits (self .units [1 ])
122122 self ._qual = oapi .QualUnits (self .units [2 ])
123-
123+
124124 # Determine unit system from flow setting
125125 if self ._flow .value <= oapi .FlowUnits .AFD .value :
126126 self ._unit_labels = type (self )._unit_labels_us_
127127 else :
128- self ._unit_labels = type (self )._unit_labels_si_
129-
128+ self ._unit_labels = type (self )._unit_labels_si_
129+
130130 # Determine mass units from quality settings
131131 if self ._qual == oapi .QualUnits .MGL :
132132 self ._rx_rate = RxUnits .MGH
133133 elif self ._qual == oapi .QualUnits .UGL :
134134 self ._rx_rate = RxUnits .UGH
135135 else :
136- self ._rx_rate = Units .NONE
136+ self ._rx_rate = Units .NONE
137137
138138
139139 self ._metadata = {
140140 oapi .NodeAttribute .DEMAND : ("Demand" , self ._unit_labels [self ._flow ]),
141141 oapi .NodeAttribute .HEAD : ("Head" , self ._unit_labels [Units .HYD_HEAD ]),
142142 oapi .NodeAttribute .PRESSURE : ("Pressure" , self ._unit_labels [self ._press ]),
143143 oapi .NodeAttribute .QUALITY : ("Quality" , self ._unit_labels [self ._qual ]),
144-
144+
145145 oapi .LinkAttribute .FLOW : ("Flow" , self ._unit_labels [self ._flow ]),
146146 oapi .LinkAttribute .VELOCITY : ("Velocity" , self ._unit_labels [Units .VELOCITY ]),
147147 oapi .LinkAttribute .HEADLOSS : ("Unit Headloss" , self ._unit_labels [Units .HEADLOSS ]),
@@ -152,7 +152,7 @@ def __init__(self, output_handle):
152152 oapi .LinkAttribute .FRCTN_FCTR : ("Friction Factor" , self ._unit_labels [Units .UNITLESS ])
153153 }
154154
155-
155+
156156 def get_attribute_metadata (self , attribute ):
157157 '''
158158 Takes an attribute enum and returns a tuple with name and units.
0 commit comments