forked from bbartling/open-fdd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fc2.py
86 lines (72 loc) · 2.99 KB
/
fc2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
from datetime import timedelta
import pandas as pd
from faults import FaultConditionTwo
from reports import FaultCodeTwoReport
from utils import custom_arg_parser, save_report, describe_dataset
from utils_brick import query_metadata
# python 3.10 on Windows 10
# py .\fc2.py -i ./ahu_data/MZVAV-1.csv -o MZVAV-1_fc2_report
# py .\fc2.py -i ./ahu_data/MZVAV-2-1.csv -o MZVAV-2-1_fc2_report
# py .\fc2.py -i ./ahu_data/MZVAV-2-2.csv -o MZVAV-2-2_fc2_report
# python 3.9 on macOS
# python ./fc2.py -i ./ahu_data/MZVAV-1.csv -o MZVAV-1_fc2_report
# python ./fc2.py -i ./ahu_data/MZVAV-2-1.csv -o MZVAV-2-1_fc2_report
# python ./fc2.py -i ./ahu_data/MZVAV-2-2.csv -o MZVAV-2-2_fc2_report
if __name__ == '__main__':
args = custom_arg_parser()
# G36 params shouldn't need adjusting
# °F error threshold parameters
OUTDOOR_DEGF_ERR_THRES = 5.
MIX_DEGF_ERR_THRES = 5.
RETURN_DEGF_ERR_THRES = 2.
var_dict = {
"mat_col": "AHU: Mixed Air Temperature",
"rat_col": "AHU: Return Air Temperature",
"oat_col": "AHU: Outdoor Air Temperature",
"fan_vfd_speed_col": "AHU: Supply Air Fan Speed Control Signal"
}
q = """ select
?duct_static_col
?supply_vfd_speed_col
?duct_static_setpoint_col
where {
?duct_static_col rdf:type brick:Supply_Air_Static_Pressure_Sensor .
?supply_vfd_speed_col rdf:type brick:Speed_Setpoint .
bldg:Supply_Air_Fan brick:hasPoint ?supply_vfd_speed_col .
?duct_static_setpoint_col rdf:type brick:Supply_Air_Static_Pressure_Setpoint .
}
"""
var_dict = query_metadata(q)
_fc2 = FaultConditionTwo(
mix_degf_err_thres=MIX_DEGF_ERR_THRES,
return_degf_err_thres=RETURN_DEGF_ERR_THRES,
outdoor_degf_err_thres=OUTDOOR_DEGF_ERR_THRES,
mat_col=var_dict["mat_col"],
rat_col=var_dict["rat_col"],
oat_col=var_dict["oat_col"],
fan_vfd_speed_col=var_dict["fan_vfd_speed_col"]
)
_fc2_report = FaultCodeTwoReport(
mix_degf_err_thres=MIX_DEGF_ERR_THRES,
return_degf_err_thres=RETURN_DEGF_ERR_THRES,
outdoor_degf_err_thres=OUTDOOR_DEGF_ERR_THRES,
mat_col=var_dict["mat_col"],
rat_col=var_dict["rat_col"],
oat_col=var_dict["oat_col"],
fan_vfd_speed_col=var_dict["fan_vfd_speed_col"]
)
df = pd.read_csv(args.input, index_col="Date", parse_dates=True).rolling(timedelta(minutes=5)).mean()
'''
# weather data from a different source
oat = pd.read_csv('./ahu_data/oat.csv', index_col="Date", parse_dates=True).rolling(timedelta(minutes=5)).mean()
df = oat.join(df)
df = df.ffill().bfill()
print(df)
'''
# describe dataset printing some stuff
describe_dataset(df)
# return a whole new dataframe with fault flag as new col
df2 = _fc2.apply(df)
print(df2.head())
print(df2.describe())
save_report(args, df, _fc2_report)