Skip to content

Data Analysis Agent

Role

The Data Analysis Agent is a Phase 1 specialist responsible for retrieving and analysing historical BWTS sensor data from PostgreSQL. When the IOT Manager dispatches a trend-analysis task, this agent runs structured queries against telemetry tables, identifies patterns, correlates parameters, and returns a self-contained report — ready for the Manager’s cross-referencing step.


Analysis Workflow

  1. Recon — Discover Sessions

    Run the recon analysis to identify all operating sessions in the database. This returns session start/end timestamps, durations, and gaps. Every subsequent analysis uses these session boundaries as its time window.

  2. Point-in-Time Checks

    Run snapshot analyses (system_snapshot, uv_compliance) against the most recent data point within the current session to establish the system’s present state.

  3. Trend Analysis — Current Session

    Run trend and health analyses (uv_trend, power_headroom, lamp_health, filter_health, flow_analysis, thermal_status) scoped to the current operating session identified by recon. Look for drift, spikes, oscillations, and threshold breaches.

  4. Compare to Previous Session

    Run baseline_comparison to compare the current session’s metrics against the previous session. Identify degradation, improvement, or sudden shifts between sessions that may indicate maintenance events or progressive wear.

  5. Synthesise

    Combine all analysis outputs into the final DATA ANALYSIS REPORT. Cross-reference correlated parameters (e.g., UV intensity dropping while flow rate increases), flag data gaps, and summarise findings with supporting evidence.


Pre-Built Analyses

The primary tool bwts_analysis.py ships with 13 pre-built analyses, each tuned for a specific aspect of BWTS operations.

#AnalysisDescription
1reconDiscover operating sessions — start/end timestamps, durations, idle gaps. Must run first.
2system_snapshotPoint-in-time snapshot of all key parameters at the most recent reading
3uv_complianceCheck whether UV intensity meets IMO D-2 compliance thresholds
4uv_trendUV intensity trend over the current session — detect drift, decay, or sudden drops
5power_headroomCompare current UV lamp power draw against rated capacity — remaining headroom percentage
6lamp_healthPer-lamp status: intensity, hours run, power draw, failure indicators
7filter_healthFilter differential pressure trend — detect clogging, backwash effectiveness
8flow_analysisFlow rate stability, pump cycling patterns, valve position correlation
9thermal_statusTemperature readings across the treatment train — detect overheating or cooling failures
10cip_statusClean-In-Place cycle history — last CIP timestamp, duration, chemical concentration
11alert_patternsHistorical alert frequency and clustering — recurring alarms, storm detection
12correlated_scanMulti-parameter correlation — identify parameters that move together during anomalies
13baseline_comparisonCompare current session metrics against the previous session to detect degradation

Output Format

Every Data Analysis Agent response follows the DATA ANALYSIS REPORT structure:

SectionContent
Operation ContextVessel, equipment tag, session boundaries from recon, operating mode
TrendTime-series summary for the flagged parameter — direction, rate of change, threshold proximity
Lamp StatusPer-lamp intensity, hours, power draw — only if UV-related alert
Correlated ObservationsOther parameters that moved in sync with the flagged parameter
BaselineComparison against previous session — better, worse, or unchanged
CIP StatusLast CIP cycle details — relevant for fouling or efficiency alerts
Operating ModeWhether the system was in Treatment, Standby, CIP, or Bypass during the anomaly
Evidence SummaryBullet-point list of findings with timestamps and values
Data GapsAny missing readings, sensor dropouts, or incomplete sessions

Tools

graph LR
DA["Data Analysis\nAgent"] --> BW["bwts_analysis.py\nPrimary — 13 analyses"]
DA --> DQ["db_query.py\nRaw SQL fallback"]
BW --> PG[("PostgreSQL")]
DQ --> PG
subgraph "Tables"
T1["bwts_iot_telemetry\n103 columns, ALL-CAPS"]
T2["bwts_iot_predictions\ncamelCase columns"]
end
PG --- T1
PG --- T2
style DA fill:#1a1a2e,stroke:#e94560,stroke-width:3px,color:#fff
style BW fill:#16213e,stroke:#0f3460,stroke-width:2px,color:#fff
style DQ fill:#16213e,stroke:#0f3460,stroke-width:2px,color:#fff
style PG fill:#0d1b2a,stroke:#1b9aaa,stroke-width:2px,color:#fff
style T1 fill:#0d1b2a,stroke:#1b9aaa,stroke-width:1px,color:#fff
style T2 fill:#0d1b2a,stroke:#1b9aaa,stroke-width:1px,color:#fff
ToolPurpose
bwts_analysis.pyPrimary analysis tool. Accepts an analysis name (e.g., recon, uv_trend) and optional parameters. Returns structured output.
db_query.pyRaw SQL fallback for ad-hoc queries not covered by the 13 pre-built analyses. Use sparingly.

What It Does NOT Do

No Maintenance Records

Maintenance history, work orders, and service schedules belong to the PMS Agent. This agent has no access to maintenance tables.

No Manual Search

Equipment manual lookups and documented-cause searches are the Manual Agent’s responsibility. This agent works exclusively with sensor data.

No Report Generation

Produces a structured text report for the IOT Manager’s synthesis step. Never generates HTML, never formats client-facing reports, and never sends emails.

No Email or Notifications

Has no communication tools. Writes its findings to the task system only. All external communication flows through the Report Agent.