023 — Field alert report

Contents

023 — Field alert report#

Generate a lightweight HTML report summarising recent QC flags + sensor health, suitable for emailing to field operators. Uses the Jinja2 templates in palmwtc.qc.reporting.

Runs on the bundled synthetic sample.

from palmwtc.config import DataPaths
from palmwtc.qc import build_field_alert_context, render_field_alert_html

paths = DataPaths.resolve()
print(paths.describe())
DataPaths (source=sample (bundled synthetic), site=libz):
  raw_dir       = /home/runner/work/palmwtc/palmwtc/src/palmwtc/data/sample/synthetic
  processed_dir = /home/runner/work/palmwtc/palmwtc/src/palmwtc/data/sample/Data/Integrated_QC_Data
  exports_dir   = /home/runner/work/palmwtc/palmwtc/src/palmwtc/data/sample/exports
  config_dir    = /home/runner/work/palmwtc/palmwtc/src/palmwtc/data/sample/config
  extras        = <none>
# Build minimal context (real reports pull from QC summary + sensor exclusions YAML).
context = {
    "site": paths.site,
    "report_date": "2026-04-20",
    "rec_df": None,
    "sensor_health": [],
    "summary_text": "Synthetic sample: no real alerts.",
}
print("Context keys:", list(context.keys()))
Context keys: ['site', 'report_date', 'rec_df', 'sensor_health', 'summary_text']

Render HTML#

The default template lives at the palmwtc.qc.reporting templates directory (callers may pass an explicit template_dir kwarg to override). Real-data callers should verify the context shape matches the build_field_alert_context signature.

print("Real-data callers: pass template_dir to render_field_alert_html().")
Real-data callers: pass template_dir to render_field_alert_html().