<jupyter_start><jupyter_text>Read VAV AHU Points from CSV files<jupyter_code>vav_dprs = pd.read_csv('./All Air Damper Positions-data-as-seriestocolumns-2021-11-05 12_02_42.csv', index_col='Time', parse_dates=True).fillna(method='ffill').dropna()
vav_htg_vlvs = pd.read_csv('./All Reheat Valve Positions-data-as-seriestocolumns-2021-11-05 12_27_13.csv', index_col='Time', parse_dates=True).fillna(method='ffill').dropna()
vav_total_air = pd.read_csv('./Total VAV Box Air Flow-data-2021-11-05 12_06_37.csv', index_col='Time', parse_dates=True).fillna(method='ffill').dropna()
rtu_cooling_sig = pd.read_csv('./RTU Cooling Compressor Commands-data-2021-11-05 12_05_40.csv', index_col='Time', parse_dates=True).fillna(method='ffill').dropna()
rtu_duct_pressure = pd.read_csv('./RTU Duct Static Pressure-data-as-seriestocolumns-2021-11-06 07_21_53.csv', index_col='Time', parse_dates=True).fillna(method='ffill').dropna()
rtu_fan_speed = pd.read_csv('./RTU Supply Fan Speed-data-2021-11-05 12_06_04.csv', index_col='Time', parse_dates=True).fillna(method='ffill').dropna()
rtu_temps = pd.read_csv('./RTU Temperatures-data-as-seriestocolumns-2021-11-05 12_04_38.csv', index_col='Time', parse_dates=True).fillna(method='ffill').dropna()
rtu_economizer = pd.read_csv('./RTU Economizer-data-as-seriestocolumns-2021-11-05 12_05_18.csv', index_col='Time', parse_dates=True).fillna(method='ffill').dropna()<jupyter_output><empty_output><jupyter_text>VAV Box Air Damper Positions<jupyter_code>print(vav_dprs.columns)<jupyter_output>Index(['slipstream_internal/slipstream_hq/10/DPR-O',
       'slipstream_internal/slipstream_hq/23/DPR-O',
       'slipstream_internal/slipstream_hq/11/DPR-O',
       'slipstream_internal/slipstream_hq/13/DPR-O',
       'slipstream_internal/slipstream_hq/24/DPR-O',
       'slipstream_internal/slipstream_hq/14/DPR-O',
       'slipstream_internal/slipstream_hq/25/DPR-O',
       'slipstream_internal/slipstream_hq/15/DPR-O',
       'slipstream_internal/slipstream_hq/16/DPR-O',
       'slipstream_internal/slipstream_hq/19/DPR-O',
       'slipstream_internal/slipstream_hq/20/DPR-O',
       'slipstream_internal/slipstream_hq/26/DPR-O',
       'slipstream_internal/slipstream_hq/21/DPR-O',
       'slipstream_internal/slipstream_hq/27/DPR-O',
       'slipstream_internal/slipstream_hq/7/DPR-O',
       'slipstream_internal/slipstream_hq/29/DPR-O',
       'slipstream_internal/slipstream_hq/30/DPR-O',
       'slipstream_internal/slipstream_hq/31/DPR-O',
       'slipstream_internal/slipstream_hq/8/DPR[...]<jupyter_text>VAV Box Reheat Valve Positions<jupyter_code>print(vav_htg_vlvs.columns)<jupyter_output>Index(['slipstream_internal/slipstream_hq/10/HTG-O',
       'slipstream_internal/slipstream_hq/23/HTG-O',
       'slipstream_internal/slipstream_hq/11/HTG-O',
       'slipstream_internal/slipstream_hq/13/HTG-O',
       'slipstream_internal/slipstream_hq/24/HTG-O',
       'slipstream_internal/slipstream_hq/14/HTG-O',
       'slipstream_internal/slipstream_hq/25/HTG-O',
       'slipstream_internal/slipstream_hq/15/HTG-O',
       'slipstream_internal/slipstream_hq/16/HTG-O',
       'slipstream_internal/slipstream_hq/19/HTG-O',
       'slipstream_internal/slipstream_hq/20/HTG-O',
       'slipstream_internal/slipstream_hq/26/HTG-O',
       'slipstream_internal/slipstream_hq/21/HTG-O',
       'slipstream_internal/slipstream_hq/27/HTG-O',
       'slipstream_internal/slipstream_hq/7/HTG-O',
       'slipstream_internal/slipstream_hq/29/HTG-O',
       'slipstream_internal/slipstream_hq/30/HTG-O',
       'slipstream_internal/slipstream_hq/31/HTG-O',
       'slipstream_internal/slipstream_hq/8/HTG[...]<jupyter_text>Calculated Total Air Flow From VAV Boxes in SQL prior to Pandas<jupyter_code>print(vav_total_air.columns)<jupyter_output>Index(['Total Air Flow'], dtype='object')<jupyter_text>RTU DX Cooling Signal (stages compressors)<jupyter_code>print(rtu_cooling_sig.columns)<jupyter_output>Index(['slipstream_internal/slipstream_hq/1100/Cooling Capacity Status'], dtype='object')<jupyter_text>RTU Duct Static Pressure<jupyter_code>print(rtu_duct_pressure.columns)<jupyter_output>Index(['slipstream_internal/slipstream_hq/1100/Duct Static Pressure Local', 'slipstream_internal/slipstream_hq/1100/Duct Static Pressure Setpoint Active'], dtype='object')<jupyter_text>RTU Fan Speed % VFD Speed<jupyter_code>print(rtu_fan_speed.columns)<jupyter_output>Index(['slipstream_internal/slipstream_hq/1100/Supply Fan Speed Command'], dtype='object')<jupyter_text>RTU Economizer Points<jupyter_code>print(rtu_economizer.columns)<jupyter_output>Index(['slipstream_internal/slipstream_hq/1100/Outdoor Air Enthalpy Active',
       'slipstream_internal/slipstream_hq/1100/Outdoor Air Relative Humidity Local',
       'slipstream_internal/slipstream_hq/1100/Return Air Temperature',
       'slipstream_internal/slipstream_hq/1100/Return Air Enthalpy Active',
       'slipstream_internal/slipstream_hq/1002/Outside Air Temperature local',
       'slipstream_internal/slipstream_hq/1100/Outdoor Air Damper Command',
       'slipstream_internal/slipstream_hq/1100/Return Air Humidity Local'],
      dtype='object')<jupyter_text>RTU Temps<jupyter_code>print(rtu_temps.columns)<jupyter_output>Index(['slipstream_internal/slipstream_hq/1100/Discharge Air Temperature',
       'slipstream_internal/slipstream_hq/1100/Mixed Air Temperature Local',
       'slipstream_internal/slipstream_hq/1100/Return Air Temperature',
       'slipstream_internal/slipstream_hq/1100/Discharge Air Cooling Setpoint BAS',
       'slipstream_internal/slipstream_hq/1002/Outside Air Temperature local'],
      dtype='object')<jupyter_text>Compute 5 Min Rolling Avg Per G36 Spec<jupyter_code>vav_dprs_avg = vav_dprs.rolling('5T').mean()
vav_htg_vlvs_avg = vav_htg_vlvs.rolling('5T').mean()
vav_total_air_avg = vav_total_air.rolling('5T').mean()
rtu_cooling_sig_avg = rtu_cooling_sig.rolling('5T').mean()
rtu_duct_pressure_avg = rtu_duct_pressure.rolling('5T').mean()
rtu_fan_speed_avg = rtu_fan_speed.rolling('5T').mean()
rtu_temps_avg = rtu_temps.rolling('5T').mean()
rtu_economizer_avg = rtu_economizer.rolling('5T').mean()
rtu_temps_avg.plot(figsize=(25,8), title='RTU TEMPS')<jupyter_output><empty_output><jupyter_text>Internal VAV AHU AFDD Variables per G36 Spec Imperial Units<jupyter_code>supply_fan_delta_degf = 2
oat_rat_delta_degf_min = 10
supply_degf_err_thres = 2
return_degf_err_thres = 2
mix_degf_err_thres = 5
outdoor_degf_err_thres = 5
air_flow_percent_thres = .3
vfd_speed_percent_err_thres = .05
vfd_speed_percent_max = .99
duct_static_inches_err_thres = .1
delta_os_max = 7
mode_delay = 30
alarm_dely = 30
test_mode_delay = 120 
# https://www.dataquest.io/blog/tutorial-add-column-pandas-dataframe-based-on-if-else-condition/<jupyter_output><empty_output><jupyter_text>FAULT CONDITION 1 SCENORIO, COMPARE THE AHU FAN AND DUCT PRESSURE<jupyter_code>'''
def fault_condition_one(dataframe):
    return (dataframe.duct_static < (dataframe.duct_static_setpoint-dataframe.duct_static_inches_err_thres)).any() & (dataframe.vfd_speed >= (dataframe.vfd_speed_percent_max-dataframe.vfd_speed_percent_err_thres)).any()
'''

import operator

def fault_condition_one(dataframe):
    #return dataframe.iterrows(operator.and_(dataframe.duct_static < (dataframe.duct_static_setpoint-dataframe.duct_static_inches_err_thres)),(dataframe.vfd_speed >= (dataframe.vfd_speed_percent_max-dataframe.vfd_speed_percent_err_thres)))
    return operator.and_(dataframe.duct_static < dataframe.duct_static_setpoint, dataframe.vfd_speed >= dataframe.vfd_speed_percent_max)

# return (dataframe.duct_static < (dataframe.duct_static_setpoint-dataframe.duct_static_inches_err_thres)).any() & (dataframe.vfd_speed >= (dataframe.vfd_speed_percent_max-dataframe.vfd_speed_percent_err_thres)).any()

# combine duct pressure and fan speed datasets

fc1_dataset = rtu_duct_pressure_avg.join(rtu_fan_speed_avg)
# make an entire column out of these params
fc1_dataset['vfd_speed_percent_err_thres'] = vfd_speed_percent_err_thres
fc1_dataset['duct_static_inches_err_thres'] = duct_static_inches_err_thres
fc1_dataset['vfd_speed_percent_max'] = vfd_speed_percent_max
fc1_dataset.columns
fc1_dataset.rename(columns={'slipstream_internal/slipstream_hq/1100/Duct Static Pressure Local': 'duct_static', 
                   'slipstream_internal/slipstream_hq/1100/Duct Static Pressure Setpoint Active': 'duct_static_setpoint',
                   'slipstream_internal/slipstream_hq/1100/Supply Fan Speed Command': 'vfd_speed'}, inplace=True)
fc1_dataset['fc1_flag'] = fault_condition_one(fc1_dataset)
fc1_dataset.head()
fc1_dataset['fc1_flag'].value_counts()
# change boolean column to int for plots

fc1_dataset['fc1_flag'] = fc1_dataset['fc1_flag'].astype(int)

# drop params column for better plot
fc1_dataset = fc1_dataset.drop(['vfd_speed_percent_err_thres',
                  'duct_static_inches_err_thres',
                  'vfd_speed_percent_max'],axis=1)

fdd_plot = fc1_dataset[['fc1_flag','duct_static']]

fdd_plot.plot(figsize=(25,8),title='FC 1 Test')
# https://stackoverflow.com/questions/11640243/pandas-plot-multiple-y-axes<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12220517316966242, 'fraction_numerical': 0.03627794826830338, 'mean_word_length': 6.247815726767276, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '12', 'dir': 'jupyter-structured-clean-dedup', 'id': '643600', 'license': 'MIT', 'n_tokens_mistral': 3776, 'n_tokens_neox': 3464, 'n_words': 370, 'path': 'junk-Copy1.ipynb', 'repo_name': 'bbartling/my-weekend-fdd-hobby', 'size': '9124'}