# DS 251 Data Dictionary / 資料字典

> **Synthetic teaching data / 合成教學資料.** Building A, meter A01 and every reading in these files were generated for DS 251 (data version `power-demo-v1`). They describe no real building, campus energy use or audit result. The case has no emission factor and no inventory boundary, so it cannot support any Scope 2 figure.
> 建物 A、電表 A01 與這些檔案中的每一筆讀值都是為 DS 251 產生的合成資料（資料版本 `power-demo-v1`），不代表任何真實建物、校園用電或查核結果。本案例沒有排放係數與盤查邊界，因此無法支持任何 Scope 2 數字。

> **Privacy / 隱私.** Use only these synthetic files and your learner code. Do not paste company secrets, client personal data, real meter or tenant data into an AI tool.
> 只使用這些合成檔案與你的學員代碼。請勿將公司機密、客戶個資、真實電表或租戶資料貼入 AI 工具。

## 1. Case, time zone and intervals / 案例、時區與區間

| Item / 項目 | Convention / 慣例 |
|---|---|
| Building and meter / 建物與電表 | Building `A`, one revenue meter `A01` / 建物 `A`，單一計量電表 `A01` |
| Measure / 量測 | Energy used in each 15-minute interval (`electricity_kwh_per_15min_interval`) / 每個 15 分鐘區間的用電量 |
| Time zone / 時區 | `Asia/Taipei` (UTC+08:00). Time stamps are ISO 8601 with offset, e.g. `2026-11-16T00:00:00+08:00` / 帶位移的 ISO 8601 |
| Interval / 區間 | Left-closed, right-open; `interval_start` labels the interval. `01:00` covers 01:00 up to 01:15 / 左閉右開，以起點標示 |
| Alignment / 對齊 | Starts at :00, :15, :30 or :45 / 起點必須在 :00、:15、:30、:45 |
| Day / 日 | Cut at local midnight in Asia/Taipei; 96 intervals per day / 依台北時間午夜切日，每天 96 個區間 |
| Period B (baseline) / 基準期 B | `2026-11-09T00:00:00+08:00` to `2026-11-16T00:00:00+08:00`, 7 days, 672 expected intervals |
| Period C (comparison) / 比較期 C | `2026-11-16T00:00:00+08:00` to `2026-11-23T00:00:00+08:00`, 7 days, 672 expected intervals |
| Units / 單位 | `kWh` or `Wh`; Wh ÷ 1,000 = kWh. kW (power) is never added as energy / kW 是功率，不可當電能加總 |
| Display / 顯示 | kWh and percentages to 2 decimals; thresholds are judged on unrounded values / 顯示到小數第 2 位，門檻以未四捨五入值判斷 |

## 2. Versions / 版本

| Version field / 版本欄位 | Value / 值 | Meaning / 意義 |
|---|---|---|
| `schema_version` | `esg-da-1.0` | Field layout of every file in this dictionary / 本字典所有檔案的欄位結構 |
| `data_version` | `power-demo-v1` (the notebook writes `power-demo-v1-f1`, `-f2` or `-f3`) | Which synthetic dataset and variant / 使用哪一份合成資料與變體 |
| `transform_version` | `kpi-transform-1.0` | The cleaning and KPI rules in section 5 / 第 5 節的清理與 KPI 規則 |
| Comparison method / 比較方法 | `compare-periods-1.0` | Rules for the period change in section 6 / 第 6 節的期間比較規則 |

## 3. Input files / 輸入檔案

### `DS251_Meter_Readings_F1.csv`, `_F2.csv`, `_F3.csv`

Three independent variants of the same base data / 同一份基礎資料的三個獨立變體:
**F1** contains a resent reading and a value reported in Wh / 含一筆重送與一筆以 Wh 回報的值；**F2** has one reading removed from period C / C 期少一筆讀值；**F3** has a second, different value for one interval of period C / C 期某區間多一筆不同數值的讀值。

| Field / 欄位 | Meaning / 意義 | Allowed values / 允許值 |
|---|---|---|
| `reading_id` | Row id from the ingestion log; a resend may carry a new id / 匯入紀錄的列編號，重送可能換新編號 | e.g. `R-B-0001`, `R-B-0101-RESEND` |
| `building_id` | Building the meter serves / 電表所屬建物 | `A` |
| `meter_id` | Meter id; must exist in the registry / 電表編號，須在登錄表中 | `A01` |
| `interval_start` | Start of the 15-minute interval, with offset / 區間起點（帶位移） | ISO 8601 |
| `value` | Energy in the interval / 該區間的用電量 | Finite, non-negative decimal / 有限且非負的十進位數 |
| `unit` | Unit of `value` / `value` 的單位 | `kWh` or `Wh` |
| `received_at` | When ingestion received the message / 匯入服務收到訊息的時間 | ISO 8601 |

**Logical key / 邏輯唯一鍵:** `(meter_id, interval_start)`, compared after normalising the time to one instant. `reading_id` is not the key. / 以正規化後的時間比較；`reading_id` 不是鍵值。

### `DS251_Meter_Registry.csv`

| Field / 欄位 | Meaning / 意義 |
|---|---|
| `meter_id` | Meter id / 電表編號 |
| `building_id` | The one building this meter is assigned to / 此電表對應的唯一建物 |
| `interval_minutes` | Interval length, `15` / 區間長度 |
| `timezone` | `Asia/Taipei` |
| `metric_definition` | `electricity_kwh_per_15min_interval` |

### `DS251_Periods.csv`

| Field / 欄位 | Meaning / 意義 |
|---|---|
| `period_id` | `B` or `C` |
| `start_at` / `end_at` | Period boundaries; start included, end excluded / 期間邊界，含起點、不含終點 |
| `building_id`, `meter_id` | Scope of the period / 期間的範圍 |
| `timezone`, `metric_definition` | Must match the registry for the periods to be comparable / 須與登錄表一致才可比較 |

## 4. Output files (the handoff package) / 輸出檔案（交接包）

### `daily-kpi.csv`

| Field / 欄位 | Meaning / 意義 |
|---|---|
| `kpi_id` | `KPI-A01-YYYY-MM-DD` |
| `building_id`, `meter_id` | `A`, `A01` |
| `date` | Local date in Asia/Taipei / 台北本地日期 |
| `observed_kwh` | Sum of valid, deduplicated, non-conflicting intervals; empty for `blocked` or `no_data` / 有效、已去重、無衝突區間的加總；blocked 或 no_data 時留空 |
| `valid_intervals` | Count of those intervals / 上述區間數 |
| `expected_intervals` | `96` |
| `coverage_ratio` | `valid_intervals / expected_intervals`, 4 decimals / 取 4 位小數 |
| `data_version` | e.g. `power-demo-v1-f1` |
| `quality_status` | `complete` (96/96), `partial` (1–95 valid, no conflict), `blocked` (any conflict), `no_data` (0 valid) |

A valid 0 kWh reading counts towards coverage; a missing interval does not. / 有效的 0 kWh 計入完整率，缺漏區間不計入。

### `quality-log.csv`

| Field / 欄位 | Meaning / 意義 |
|---|---|
| `reading_id` | Row concerned; empty for a gap (Q08) / 相關資料列；缺漏（Q08）時留空 |
| `meter_id`, `interval_start` | Key of the interval / 區間鍵值 |
| `rule_id` | `Q01`–`Q08` (section 5) |
| `severity` | `block`, `warning` or `info` |
| `action` | `exclude`, `deduplicate`, `normalize`, `hold_for_review` or `record_gap` |
| `reason` | Plain-language reason / 白話理由 |

### `evidence-index.csv`

| Field / 欄位 | Meaning / 意義 |
|---|---|
| `evidence_id` | `EV-` + `kpi_id` |
| `data_version` | Data version the KPI was computed from / 計算所用的資料版本 |
| `file_name` | `daily-kpi.csv` |
| `row_key` | The `kpi_id` it supports / 對應的 `kpi_id` |
| `source_reading_ids` | JSON list of every input `reading_id` for that day, including resends and conflicting rows / 當天所有輸入列的 JSON 清單，含重送與衝突列 |
| `transform_version` | `kpi-transform-1.0` |

### `handoff-manifest.json`

| Field / 欄位 | Meaning / 意義 |
|---|---|
| `schema_version` | `esg-da-1.0` |
| `data_version` | e.g. `power-demo-v1-f1` |
| `transform_version` | `kpi-transform-1.0` |
| `package_origin` | `student` (your package) or `teacher` (the DS 252 baseline package) / 學員或教師基準包 |
| `timezone` | `Asia/Taipei` |
| `files` | `["daily-kpi.csv", "quality-log.csv", "evidence-index.csv", "periods.csv"]` |

## 5. Quality rules / 品質規則（`kpi-transform-1.0`）

| Rule / 規則 | Finding / 發現 | Severity / 嚴重度 | Action / 處置 |
|---|---|---|---|
| Q01 | Missing required field, or meter not in the registry for that building / 缺必要欄位，或電表不在該建物的登錄表 | block | exclude |
| Q02 | Value is not a finite, non-negative decimal / 數值不是有限且非負的十進位數 | warning | exclude |
| Q03 | Unit is neither Wh nor kWh / 單位不是 Wh 或 kWh | warning | exclude |
| Q04 | Interval not aligned to 15 minutes, or outside the stated periods / 區間未對齊或不在指定期間 | warning | exclude |
| Q05 | Same key, same value (resend): counted once / 同鍵同值（重送），只算一次 | warning | deduplicate |
| Q06 | Value in Wh, divided by 1,000 / 以 Wh 表示，除以 1,000 | info | normalize |
| Q07 | Same key, different valid values (conflict): the day is blocked until a person decides / 同鍵不同值（衝突），當天阻擋至人工裁決 | block | hold_for_review |
| Q08 | No valid reading for an expected interval (gap) / 預期區間沒有有效讀值（缺漏） | warning | record_gap |

**Warning vs block / 警告與阻擋:** a warning excludes, counts once or notes the row and the day is still reported with its coverage; a block means no rule can decide, so the affected day or batch is not published until a person records a decision, who made it and when. Never fill a gap or settle a conflict by guessing. / 警告：排除、只算一次或註記後，當天仍附完整率回報。阻擋：規則無法判定，受影響的日期或批次不發布，直到有人記錄決定內容、決定者與時間。不要用猜的補洞或裁決衝突。

## 6. Period comparison / 期間比較（`compare-periods-1.0`）

`change_pct = (C − B) ÷ B × 100%` is produced only when / 只在下列條件全部成立時計算:

1. Same building, meter, time zone and metric definition / 同建物、電表、時區與量測口徑
2. Same period length and expected intervals / 期間長度與預期區間數相同
3. No `blocked` or `no_data` day in either period / 兩期都沒有 blocked 或 no_data 的日期
4. Coverage of both periods is 100% / 兩期完整率皆為 100%
5. Baseline B is greater than 0 / 基準期 B 大於 0

Otherwise `change_pct` is empty and the reasons are listed. The change is an arithmetic difference in metered electricity; attributing it to any measure needs separate evidence. / 否則變動率留空並列出理由。變動率是計量用電的算術差，歸因到任何措施都需要另外的證據。
