Python project for analyzing alarm data from building monitoring systems. Includes alarm analyzer, plotting, tests, and source data files.
81 lines
3.4 KiB
Python
81 lines
3.4 KiB
Python
#!/usr/bin/env python
|
|
# Script to verify the enhanced group statistics
|
|
|
|
import pandas as pd
|
|
import os
|
|
|
|
def check_enhanced_group_stats():
|
|
print("=== ENHANCED GROUP STATISTICS VERIFICATION ===")
|
|
print()
|
|
|
|
# Check if output directory exists
|
|
if not os.path.exists('output'):
|
|
print("Output directory not found!")
|
|
return
|
|
|
|
# Check if group_statistics.csv exists
|
|
group_stats_path = os.path.join('output', 'group_statistics.csv')
|
|
if not os.path.exists(group_stats_path):
|
|
print(f"Group statistics file not found at {group_stats_path}")
|
|
return
|
|
|
|
# Load the enhanced group statistics
|
|
group_stats_df = pd.read_csv(group_stats_path)
|
|
|
|
print("Enhanced Group Statistics Columns:")
|
|
print(list(group_stats_df.columns))
|
|
print()
|
|
|
|
# Verify the new columns exist
|
|
required_columns = [
|
|
'Total_Sensors_In_Group',
|
|
'Percentage_Monitoring_Points_Alarmed',
|
|
'Alarm_Time_Percentage'
|
|
]
|
|
|
|
missing_columns = [col for col in required_columns if col not in group_stats_df.columns]
|
|
if missing_columns:
|
|
print(f"ERROR: Missing columns: {missing_columns}")
|
|
return
|
|
else:
|
|
print("All required enhanced columns are present")
|
|
print()
|
|
|
|
# Display sample of the enhanced data
|
|
print("Sample of Enhanced Group Statistics (Top 10 by Alarm Count):")
|
|
print(group_stats_df[['Sensor_Group', 'Total_Alarm_Count', 'Unique_Sensors',
|
|
'Total_Sensors_In_Group', 'Percentage_Monitoring_Points_Alarmed',
|
|
'Alarm_Time_Percentage']].head(10))
|
|
print()
|
|
|
|
# Show some key statistics
|
|
print("=== ENHANCED ANALYSIS SUMMARY ===")
|
|
|
|
# Groups with highest percentage of monitoring points alarmed
|
|
print("Top 5 groups with highest percentage of monitoring points that experienced alarms:")
|
|
top_alarm_percent = group_stats_df.nlargest(5, 'Percentage_Monitoring_Points_Alarmed')[['Sensor_Group', 'Percentage_Monitoring_Points_Alarmed', 'Unique_Sensors', 'Total_Sensors_In_Group']]
|
|
print(top_alarm_percent)
|
|
print()
|
|
|
|
# Groups with highest alarm time percentage
|
|
print("Top 5 groups with highest percentage of time spent in alarm condition:")
|
|
top_time_percent = group_stats_df.nlargest(5, 'Alarm_Time_Percentage')[['Sensor_Group', 'Alarm_Time_Percentage', 'Total_Duration', 'Total_Sensors_In_Group']]
|
|
print(top_time_percent)
|
|
print()
|
|
|
|
# Groups with the most difference between total sensors and unique sensors that alarmed
|
|
print("Groups with the highest number of total sensors but lower alarm activity:")
|
|
group_stats_df['Sensors_Not_Alarming'] = group_stats_df['Total_Sensors_In_Group'] - group_stats_df['Unique_Sensors']
|
|
top_inactive = group_stats_df.nlargest(5, 'Sensors_Not_Alarming')[['Sensor_Group', 'Sensors_Not_Alarming', 'Total_Sensors_In_Group', 'Unique_Sensors', 'Percentage_Monitoring_Points_Alarmed']]
|
|
print(top_inactive)
|
|
print()
|
|
|
|
print("Enhanced group statistics analysis completed successfully!")
|
|
print()
|
|
print("New metrics added:")
|
|
print("- Total_Sensors_In_Group: Total number of sensors in the group according to sensor report")
|
|
print("- Percentage_Monitoring_Points_Alarmed: Percentage of sensors in the group that experienced alarms")
|
|
print("- Alarm_Time_Percentage: Percentage of total possible sensor-time that was spent in alarm condition")
|
|
|
|
if __name__ == "__main__":
|
|
check_enhanced_group_stats() |