bbartling / open-fdd

Fault Detection Diagnostics (FDD) for HVAC datasets
MIT License
59 stars 14 forks source link

fault rules to incorporate a "combined check" to initiate a fault #19

Closed bbartling closed 2 months ago

bbartling commented 9 months ago

2024 goal am hoping to overhaul tests and fault rules in this style below that incorporates a combined check before initiating a fault. IE., 5 faults need to come through in a row before the function returns a "true fault" hopefully to cut down any false positives.rolling_sum = df["combined_check"].rolling(window=5).sum(). Chime in with any suggestions this may not apply to every fault rule for the HVAC system at hand and may need to be some adjustable global tuning variable or something...

def apply(self, df: pd.DataFrame) -> pd.DataFrame:
    # Existing checks
    df['static_check_'] = (
        df[self.duct_static_col] < df[self.duct_static_setpoint_col] - self.duct_static_inches_err_thres)
    df['fan_check_'] = (
        df[self.supply_vfd_speed_col] >= self.vfd_speed_percent_max - self.vfd_speed_percent_err_thres)

    # Combined condition check
    df["combined_check"] = df['static_check_'] & df['fan_check_']

    # Rolling sum to count consecutive trues
    rolling_sum = df["combined_check"].rolling(window=5).sum()
    # Set flag to 1 if rolling sum equals the window size (5)
    df["fc1_flag"] = (rolling_sum == 5).astype(int)

    return df
bbartling commented 2 months ago

this is complete and built into the fault equations