Python project for analyzing alarm data from building monitoring systems. Includes alarm analyzer, plotting, tests, and source data files.
51 lines
2.1 KiB
Python
51 lines
2.1 KiB
Python
#!/usr/bin/env python
|
|
# Test script to check the mapping functionality
|
|
|
|
import pandas as pd
|
|
from alarm_analyzer import AlarmAnalyzer
|
|
|
|
def test_mapping():
|
|
print("Creating analyzer instance...")
|
|
analyzer = AlarmAnalyzer('CardinalAlarmsDec25.csv', 'SensorReport Cardinal 2025-12-23_processed.xlsx')
|
|
|
|
print("Loading data...")
|
|
alarm_data, sensor_data = analyzer.load_data()
|
|
|
|
print(f"Created sensor mapping for {len(analyzer.sensor_mapping)} sensors")
|
|
|
|
# Check if specific IDs from the alarm data are in the mapping
|
|
sample_alarm_ids = [9273, 3817, 8963, 7414, 9092, 9105, 7080, 9455, 9451, 3799]
|
|
print(f"Sample alarm IDs: {sample_alarm_ids}")
|
|
|
|
found_in_mapping = []
|
|
for alarm_id in sample_alarm_ids:
|
|
if alarm_id in analyzer.sensor_mapping:
|
|
found_in_mapping.append(alarm_id)
|
|
print(f" ID {alarm_id}: {analyzer.sensor_mapping[alarm_id]}")
|
|
else:
|
|
print(f" ID {alarm_id}: NOT FOUND")
|
|
|
|
print(f"Found {len(found_in_mapping)} out of {len(sample_alarm_ids)} sample IDs in mapping")
|
|
|
|
# Check alarm data for sensor names and groups
|
|
print(f"\nSensor_Name column in alarm data: {'Sensor_Name' in analyzer.alarm_data.columns}")
|
|
print(f"Sensor_Group column in alarm data: {'Sensor_Group' in analyzer.alarm_data.columns}")
|
|
|
|
if 'Sensor_Name' in analyzer.alarm_data.columns:
|
|
unique_names = analyzer.alarm_data['Sensor_Name'].unique()
|
|
print(f"Unique sensor names: {len(unique_names)} - {unique_names[:10]}")
|
|
|
|
if 'Sensor_Group' in analyzer.alarm_data.columns:
|
|
unique_groups = analyzer.alarm_data['Sensor_Group'].unique()
|
|
print(f"Unique sensor groups: {len(unique_groups)} - {unique_groups[:10]}")
|
|
|
|
# Check a few rows to see the mapping worked
|
|
print("\nFirst 10 rows of alarm data with sensor info:")
|
|
cols_to_show = ['Sensor_Id', 'Sensor_Name', 'Sensor_Group', 'Description']
|
|
if all(col in analyzer.alarm_data.columns for col in cols_to_show):
|
|
print(analyzer.alarm_data[cols_to_show].head(10))
|
|
else:
|
|
print("Some columns not found in alarm data")
|
|
|
|
if __name__ == "__main__":
|
|
test_mapping() |