Dokumentation · Kom i gang: installation og drift
The validation against Eloverblik's own report (B12b)
make validate compares the product's emission figures with a report "Dit klimaaftryk" that the owner made in the
Eloverblik portal (phase-1.md §9.4; what the report holds: docs/research/L2-validation-against-eloverblik.md; how
Eloverblik computes it: docs/research/R2-energi-data-service.md §3.4). It says, per block of the report, equal or by
how much not, and it never says "equal" about something it could not compare. It is the lead's instrument on the owner's
data: the report, the capture and the snapshot are the owner's and stay in data/ (git-ignored); this file and the code
hold no figure of theirs.
Code: tools/src/elo_devtools/validate/footprint.py (the run and the comparison), targets.py (the target format), the
named query report.footprint (docs/queries.md), calc.footprint (migration 0140), the Python reference
libs/core/src/elo_core/footprint.py. Tests: services/api/tests/test_footprint.py,
tools/tests/test_validate_footprint.py, and for the municipality report (B85, municipality-method.md §7)
tools/tests/test_b85_validation_municipality.py. Both reports of the owner's choice of "Geografisk opdeling" are
validated: "Prisområde" and "Kommune".
What runs
- The target is read from
data/validation/targets.md(format below) and its snapshot is checked: a report is evidence only with the declaration datasets as they were on the day it was made (Energinet restates them, and announced a method change for 24 November 2026). Every month file of the report's period and the snapshot's_meta.jsonmust carry a retrieval time of its own (_request.retrievedAt,_retrievedAt), on the report's day (Danish local date); otherwise the target is refused and nothing else happens. (The loader lends a month file without a time_meta.json's; the validation does not, since the snapshot tool rewrites_meta.jsonat every run.) **A price-area report needsDeclarationGridEmission; a municipality report needs three datasets, each of the report's day:DeclarationTransmissionEmission(TE),DeclarationTransmissionGridmix(TM) andReCoverageMunicipality(RE).** 2. A server of its own:deploy/validatedb.shstarts a PostgreSQL 18 under the Compose project${COMPOSE_PROJECT_NAME:-elo}-validate(data in tmpfs, loopback only, an ephemeral port), **marks itspostgresdatabase for validation** (ALTER DATABASE postgres SET elo.purpose = 'validation', B11's mark) and removes it afterwards, whatever the outcome.make test(and somake check) starts its own under${COMPOSE_PROJECT_NAME:-elo}-validate-test, so a check besidemake validatein the same checkout never shares or removes the validation's server. The tool recognises the server by what it is, not by a name, and refuses it before anything changes unless: the login is a superuser, the database it logs in to carries the mark, the server holds no live database (elo), none of the stack's roles (elo_owner,elo_api,elo_worker: they are the whole server's, and the migrations' bootstrap would reset their passwords) and no database but the system ones. It never readsDATABASE_URL. The live database, and the passwords of any role it did not create, are never touched. 3. A database of its own on that server,elo_validation_<random>, and the three roles, created for the run with random passwords: marked for validation (so the declaration loader takes an older snapshot, B11), migrated, then the capture is replayed (B08b'sload_capture: master data, readings, and the monthly control of §6.4) and the snapshot's months of the period are loaded through the loader's file mode. Factors of one provenance only: a snapshot the loader refuses (generated and real files mixed) is a refusal, exit 3; a generated snapshot is said to be generated. The database and the roles are dropped at the end, whatever the outcome. **A municipality report loads TE, and RE with a filter of the municipalities of the target's metering points** (the roots' current master data): a row of any other municipality in the files is skipped, never a refusal, and a month without a row for one of the filter's is a refusal (exit 3), which names the month and the metering points (bymp_id), never a municipality. TM is checked and not loaded (the sources are B89's). 4. The product's own queryreport.footprintruns through the application (the API's route and runner, in process), with what a user would set: the report's period, its metering points, its method (LB-PA-125,LB-PA-200,LB-MU-125: see the target'sMethod), its data basis, and the GWP set AR5 (CH4 28, N2O 265: Eloverblik's, R2 §3.4); a municipality report asks forblocks=emissions(the sources are B89's). **A method that isreservedinref.method(LB-MU-200until the owner has answered question 2 ofmunicipality-method.md§9) is refused before the capture is replayed: "the method LB-MU-200 is reserved (municipality-method.md §2.1)", exit 3.** OneUPDATEof the row makes it available and nothing in the tool changes. 5. The data basis, in two steps (§7). A report of "Endelige tal" is compared underfinal, as it always was. Eloverblik's "Endelige tal" is every hour's published row, whatever itsVersion(municipality-method.md§2.5), while the product'sfinaltakes only Final rows: where the answer underfinalrests on less than the period because hours of the factor dataset (DeclarationGridEmissionfor a price-area report,DeclarationTransmissionEmissionfor a municipality report; RE has no version) are published Initial or Preliminary, **the tool says how many and of which dataset, names the hours when they are ten or fewer, and compares underbestas well; that comparison decides.** The one underfinalis printed under "Under final (decides nothing)" for what it says ("not compared": no factor under the basis final). A report of "Foreløbige tal" is compared underbest, as it always was. A target whose hours are all Final is compared once, underfinal. 6. The comparison, block by block, and the status.
The target: data/validation/targets.md
One section per report. Copy every figure with every decimal the report shows and no more: the number of printed
decimals is the precision the figure is compared at. Danish numbers only, strictly: a comma before the decimals and
no thousands separator, so the report's 1.234,56 is typed 1234,56; a point anywhere in a figure is refused with its
line, never read as a thousands separator (a point typed for the comma of 0,123 would otherwise read as 123). A section
looks like this (the figures here are invented):
## 2025-price-area-125-final
| Field | Value |
|---|---|
| Made on | 2026-11-15 |
| Snapshot | declarations-2026-11-15 |
| Period | 2025-01-01..2025-12-31 |
| Metering points | 579999000000000001 |
| Geographic split | price area |
| Method | 125 % |
| Data basis | final |
| Block | Printed | Unit |
|---|---|---|
| Consumption | 1234,56 | kWh |
| Emissions excluding losses | 123,45 | kg CO2e |
| Distribution loss | 4,78 | kg CO2e |
| Transmission loss | 1,79 | kg CO2e |
| Biogenic emissions | 56,78 | kg CO2 |
| Renewable share | 80 | % |
| CO2 | 45,67 | g/kWh |
| CH4 | 120,1 | mg/kWh |
| N2O | 1,23 | mg/kWh |
| Field | What | Values |
|---|---|---|
| Made on | the day the report was made, Danish local date | YYYY-MM-DD |
| Snapshot | the snapshot of that day, a folder relative to data/validation/ | e.g. declarations-2026-11-15 |
| Period | the report's period, both days inclusive | YYYY-MM-DD..YYYY-MM-DD |
| Metering points | the report's "included meters": the parent consumption points, 18 digits each, comma-separated | each must be an E17 root in the capture |
| Geographic split | the report's "geografisk opdeling" | price area (prisområde), municipality (kommune) |
| Method | the allocation the report was made with. No report prints it ("Beregningsgrundlag" has Oprettet, Periode, Geografisk opdeling and Datagrundlag): it is what was chosen in the form, 125 % where the form gave no choice. The same for both splits | 125 %, 200 %. A municipality target typed municipality (kommune) before B85 is read as 125 %. A municipality target with 200 % is refused (exit 3) while LB-MU-200 is reserved |
| Data basis | the report's data basis | final (endelige tal), preliminary (foreløbige tal: the product's best) |
The target states its kind and omits nothing. Its kind is its Geographic split: a price-area report or a
municipality report. Every block the report prints is typed, a block printed as 0 typed 0; the renewable share may
be typed or not, it changes nothing (B89 compares it). What is compared is the tool's own table, never what the target
holds or leaves out:
| Block | Units the tool takes | Price-area report | Municipality report |
|---|---|---|---|
| Consumption | kWh, MWh | type it; compared | type it; compared |
| Emissions excluding losses, Distribution loss, Transmission loss | kg CO2e, t CO2e | type them; compared | type them; compared (B85) |
| Biogenic emissions | kg CO2, t CO2 | type it; compared | type it; compared |
| CO2 | g/kWh | type it; compared | type it; compared |
| CH4, N2O | mg/kWh | type them; compared | type them; compared |
| Municipal renewable energy ("Kommunal vedvarende energi") | kWh, MWh | not a line of the report; typed, the target is refused | type it; compared with local_energy of report.footprint |
| Renewable share | % | optional; outside, never compared (B89) | the same |
A target that leaves out a block its kind requires (the eight above the renewable share for a price-area report, the nine for a municipality report) is an incomplete target: the output lists the missing blocks first and it ends NOT VALIDATED, exit 5, whatever else was equal or differed.
Every field is required. An unknown field, block or unit, a block given twice, or a figure that is not a Danish number is
refused (refused: <report>, line n: …), so that a typo never drops a block silently. Only the section of the report
asked for is read, from its ## heading to the next heading of any level (#, ##, ###, …): a table under any other
heading belongs to no report, so keep each report's two tables directly under its own ## heading. A ## Notes heading
or another report still being transcribed does not refuse it, and the section asked for, if unfinished, is refused with
its name. The energy source and origin tables of the report are not transcribed yet: B89 compares them, and until then
they are always listed as outside the comparison.
The runbook
From the repository, on the owner's machine, with the Colima profile elo running:
cd <folder> && cd eloverblik
export DOCKER_CONTEXT=colima-elo
1. On the day a report is made, take the snapshot (it makes one call a minute per dataset; months already on disk are skipped, so take each day's snapshot into a folder of its own):
Run one of these two commands, not both:
# a price-area report: the municipalities do not matter
python3 tools/snapshot_declarations.py data/validation/declarations-YYYY-MM-DD --from 2025-01 --to YYYY-MM
# a municipality report: the municipalities of the report's metering points (it is the one for the owner's)
python3 tools/snapshot_declarations.py data/validation/declarations-YYYY-MM-DD --from 2025-01 --to YYYY-MM \
--municipality <code>,<code>
--municipality takes a list of three-digit codes separated by commas (each once) and filters ReCoverageMunicipality
alone; omitted, it takes all 98 municipalities (a larger file; the validation loads the municipalities of the target's
points and skips the rest, so the first command serves a municipality report too). Either snapshot holds all the datasets
the tool takes, so the three of the municipality method are there. A municipality of a real install is never written in a
file of the repository: type it on the command line.
The snapshot of 15 November 2026 exists (data/validation/declarations-2026-11-15). A snapshot taken across midnight is
of two days and refuses the target whose day it is not.
2. Transcribe the report into a section of data/validation/targets.md (above).
3. Run (needs B08b's replay merged; on a tree without it the tool says so and stops):
make validate TARGET=2025-price-area-125-final CAPTURE=data/capture/<run>
make validate TARGET=2025-price-area-125-final CAPTURE=data/capture/<run> FIGURES=1 # the figures too
TARGETS=<file> names another targets file. The run takes about a minute plus the replay. make prints the tool's exit
status as Error n; the last line of the report says it in words.
| Exit | Status | Meaning |
|---|---|---|
| 0 | VALIDATED | the target is complete and every block (consumption, the monthly control, the seven emission blocks, and for a municipality report Municipal renewable energy) was compared and is equal |
| 7 | EQUAL BUT FOR THE LOSSES | a municipality report only: the target is complete, every block was compared, and all are equal but one or both loss lines (Distribution loss, Transmission loss); the output names both residuals, the equal one too. Never read as VALIDATED: the municipal rule's two loss lines are not found (municipality-method.md §2.7) |
| 4 | DIFFERS | the target is complete and at least one block differs (the output names it; a loss line together with another block that differs is DIFFERS, not exit 7) |
| 5 | NOT VALIDATED | an incomplete target (the missing blocks listed first); or none differs and at least one block was not compared: a figure that rests on less than the period, no figure, a monthly control that compared nothing. The output says first what was not compared and why |
| 3 | refused: … (stderr) | the target, its snapshot, the server or the capture cannot be used, or the loader refused the snapshot; a method that is reserved (LB-MU-200); a month of the municipal shares without a row for a municipality of the target; nothing was compared |
| 1 | failed: <error type> (stderr) | an unexpected error; the validation database was dropped. A database error is not printed, as its text can repeat a value |
Exit 6 was "consumption validated, emissions not" of a municipality report before B85 and is not used again.
4. Record per block "match" or the relative residual, without any of the owner's figures (§9.4 "Record"). After a validation is recorded, the emission footnote "checked against golden cases only" changes (§11.1, B16a).
The four price-area reports §9.4 asks for are 125 % and 200 %, each with final and with preliminary. **A municipality
report is validated like the others** (B85): every block it prints is compared, Method is 125 % (200 % is refused
while LB-MU-200 is reserved), and its first target is the owner's report of 15 November 2026 (2025, "Kommune", "Endelige
tal"), typed with the nine blocks of its kind. By municipality-method.md §2.7 it is expected to say EQUAL BUT FOR THE LOSSES or DIFFERS on the lines named there, with the first snapshot (declarations-2026-11-15); the second target is the
report the owner makes again, with that day's snapshot. The record is per block "match" or the residual, without a figure of
the owner's, in docs/emission.md (and docs/mix.md from B89), with which of the four steps of §2.7 it settled.
| Outcome of a municipality report | When |
|---|---|
VALIDATED, exit 0 | every block equal: the rule of municipality-method.md §2 is the report's |
EQUAL BUT FOR THE LOSSES, exit 7 | every block equal but the two loss lines (§2.7, step 2 is then the next trial) |
DIFFERS, exit 4 | a block differs: a block other than a loss line, or a loss line together with another block that differs (§2.7, steps 1 and 3) |
NOT VALIDATED, exit 5 | a block left out of the target (listed first), or a block not compared (a capture that does not cover 2025 whole; a share missing for an hour) |
refused, exit 3 | the snapshot lacks TE, TM or RE, or one is of another day; RE has no row for a municipality of the target in a month; Method is 200 % while LB-MU-200 is reserved |
What it prints
The report holds no figure of the owner's unless FIGURES=1 is given: per block the verdict, the precision it was
compared at, and the relative residual. Metering points are named by count and mp_id. This is the output on the
demo organisation (generated data, the frozen factor extract; tools/tests/test_validate_footprint.py makes the same
runs):
# Validation of demo-2025: VALIDATED
**Generated factors: this run compares figures made from factors that are not Energinet's. It tests the tool; it is no evidence about the product's figures against Eloverblik.**
- Report: made on 2026-11-13; period 2025-01-01 to 2025-12-31; 2 metering point(s) (mp_id 1, 2); price area, LB-PA-125; data basis final
- Snapshot: snapshot, every month file of the period (2025-01 to 2025-12) and _meta.json of DeclarationGridEmission each retrieved on 2026-11-13 by its own time; generated (not Energinet)
- Database: elo_validation_07fe2935e122, on a server of its own, marked for validation; dropped afterwards
- Query: report.footprint (m=LB-PA-125, gwp=AR5, basis=final): state ok; factor source generated; factor status final 100.0 %, preliminary 0.0 %, initial 0.0 %, pending 0.0 %, noPriceArea 0.0 %
Compared at: half a unit of the last printed digit, both ends included (the printed figure is the exact one rounded to its printed decimals, half up or half to even).
| Block | Verdict | Compared at | Relative residual | Note |
|---|---|---|---:|---|
| Consumption | equal | 2 decimals (±0.005 kWh) | +7.556e-9 | |
| Monthly sums of the E17 root (capture) | equal | - | - | every month equal to its Month value |
| Emissions excluding losses | equal | 2 decimals (±0.005 kg CO2e) | +1.161e-7 | |
| Distribution loss | equal | 2 decimals (±0.005 kg CO2e) | +1.587e-6 | |
| Transmission loss | equal | 2 decimals (±0.005 kg CO2e) | -2.499e-6 | |
| Biogenic emissions | equal | 2 decimals (±0.005 kg CO2) | +3.125e-8 | |
| CO2 | equal | 2 decimals (±0.005 g/kWh) | -1.762e-5 | |
| CH4 | equal | 3 decimals (±0.0005 mg/kWh) | +7.213e-7 | |
| N2O | equal | 3 decimals (±0.0005 mg/kWh) | +6.928e-5 | |
| Renewable share | outside phase 1 | - | - | outside phase 1: needs datasets phase 2 loads |
| Energy sources, origin | outside phase 1 | - | - | outside phase 1: needs datasets phase 2 loads |
Blocks that decide the status: 9; equal 9, differ 0, not compared 0.
STATUS: VALIDATED (exit 0)
## Replay of the capture
<the lines of make load-capture: counts, mp_ids, dates and the monthly control; no quantity>
A block that differs (one figure changed by 0.02, with FIGURES=1: the printed figure as the tool read it, the
product's figure to six more decimals than printed, and the difference product − printed):
| Block | Verdict | Compared at | Relative residual | Printed | Product | Difference | Note |
|---|---|---|---:|---:|---:|---:|---|
| Consumption | equal | 2 decimals (±0.005 kWh) | +7.556e-9 | 397034.15 kWh | 397034.15300000 | 0.00300000 | |
| Distribution loss | differs | 2 decimals (±0.005 kg CO2e) | -1.067e-5 | 1631.68 kg CO2e | 1631.66258936 | -0.01741064 | |
…
Blocks that decide the status: 9; equal 8, differ 1, not compared 0.
STATUS: DIFFERS (exit 4)
What "not validated" looks like (a target that names a third metering point whose readings begin in March). What was not compared comes first, under the headline:
# Validation of demo-2025: NOT VALIDATED
Not compared: 8 of the 9 blocks that decide the status:
- Consumption: rests on 24121 of 26280 hours: 2159 hours of the period have no stored readings
- Emissions excluding losses: rests on 24121 of 26280 hours: 2159 hours of the period have no stored readings
…
| Block | Verdict | Compared at | Relative residual | Note |
|---|---|---|---:|---|
| Consumption | not compared | - | - | rests on 24121 of 26280 hours: 2159 hours of the period have no stored readings |
| Monthly sums of the E17 root (capture) | equal | - | - | every month equal to its Month value |
| Emissions excluding losses | not compared | - | - | rests on 24121 of 26280 hours: 2159 hours of the period have no stored readings |
…
Blocks that decide the status: 9; equal 1, differ 0, not compared 8.
STATUS: NOT VALIDATED (exit 5)
With FIGURES=1 a figure not compared because it rests on less than the period still shows the product's figure (over
the hours that are there), the difference and the residual; its verdict stays "not compared".
A block is outside phase 1 (listed, never compared, never deciding the status, whether the target holds it or not) or not compared, with the reason in its note, when:
| Note | Why |
|---|---|
not in the target | a block phase 1 computes is not transcribed: the target is incomplete |
outside phase 1: needs datasets phase 2 loads | the renewable share, and the energy sources and origin (B89 compares them) |
no figure: nothing is stored for the period | no reading of the report's metering points in the period |
no figure: no hour of the period has a factor under the basis … | the snapshot has no factor for the period (or none Final, with final) |
rests on h of H hours: n hours of the period have no stored readings | the capture lacks hours of the period (an hour of quality A02 is the source's own "missing" and counts as delivered) |
n hours with a quantity have no factor under the basis … | pending hours: with final, every hour whose factor is not yet Final |
n hours with a quantity have no price area | a metering point without a price area on a day of the period |
not complete (no_municipality), not complete (municipality_not_loaded), not complete (pending_share), not complete (no_local_share) | a municipality report's figure that rests on less than the period: a point without a usable municipality, one whose municipality is not loaded, an hour without a municipal share (no count: the query gives the reason of the larger share) |
the monthly control compared nothing | B08b's control found no month with a Month value (exit 5 of make load-capture) |
the query answered … | report.footprint did not answer ok (for instance over the row budget) |
A municipality report that is equal but for the losses (the two loss lines changed by two units of their last digit; the
head names both residuals, relative (computed − report) ÷ report):
# Validation of demo-2025: EQUAL BUT FOR THE LOSSES
Equal but for the two loss lines: every other block is equal; the losses of the municipal rule are not found (municipality-method.md §2.7), so this is never read as validated. Relative residuals (computed - report) / report:
- Distribution loss: +1.234e-5 (differs)
- Transmission loss: +2.468e-6 (equal)
- Report: made on 2026-11-13; …; 2 metering point(s) (mp_id 1, 2); municipality, LB-MU-125; data basis final
- Snapshot: snapshot, every month file of the period (2025-01 to 2025-12) and _meta.json of DeclarationTransmissionEmission, DeclarationTransmissionGridmix, ReCoverageMunicipality each retrieved on 2026-11-13 by its own time; generated (not Energinet)
- Municipal shares: 1 municipality of the target's points, loaded from the snapshot's files; rows of other municipalities in the files skipped
- Query: report.footprint (m=LB-MU-125, gwp=AR5, basis=final): …
| Block | Verdict | Compared at | Relative residual | Note |
|---|---|---|---:|---|
| Consumption | equal | 2 decimals (±0.005 kWh) | +7.556e-9 | |
| Monthly sums of the E17 root (capture) | equal | - | - | every month equal to its Month value |
| Emissions excluding losses | equal | 2 decimals (±0.005 kg CO2e) | +1.161e-7 | |
| Distribution loss | differs | 2 decimals (±0.005 kg CO2e) | +1.234e-5 | |
| Transmission loss | equal | 2 decimals (±0.005 kg CO2e) | +2.468e-6 | |
| … | | | | |
| Municipal renewable energy | equal | 2 decimals (±0.005 kWh) | +… | |
| Renewable share | outside phase 1 | - | - | outside phase 1: needs datasets phase 2 loads |
STATUS: EQUAL BUT FOR THE LOSSES (exit 7)
(The figures above are shaped like a run on the demo organisation, not copied from one.)
A report of "Endelige tal" with an hour that is not Final (one hour of TE published Preliminary): the line "Data basis"
says how many hours, of which dataset, and names them; the table that decides is the one under best; the one under
final follows it and decides nothing:
- Report: …; municipality, LB-MU-125; data basis final, and best, which decides
- Data basis: DeclarationTransmissionEmission: 1 hour published with a version other than Final: 2025-03-12T10:00Z (Preliminary); the report of "Endelige tal" is compared under final (not deciding: it rests on less than the period) and under best, which decides
- Query: report.footprint (m=LB-MU-125, gwp=AR5, basis=final and basis=best, which decides): state ok; …
…
STATUS: VALIDATED (exit 0)
## Under final (decides nothing)
| Block | Verdict | Compared at | Relative residual | Note |
| Consumption | equal | … |
| Emissions excluding losses | not compared | - | - | 1 hours with a quantity have no factor under the basis final |
With more than ten such hours the line counts them and names the first three.
How "equal" is decided
| Rule | Detail |
|---|---|
| The printed figure | the report's exact figure rounded to the decimals it prints. Which rounding rule Eloverblik uses is not documented (R2 §3.4.4: "neither page says anything about rounding"); L2 found consumption equal to the last printed decimal (two, in kWh) and the emission total within 0.02 kg (two decimals, in kg) |
| Equal | the product's exact figure lies within half a unit of the last printed digit of the printed one, both ends included: ±0.005 for two decimals, ±0.0005 for three. That accepts rounding half up and half to even, and nothing coarser (a truncated figure can differ by up to a whole unit and is reported as a difference) |
| The product's figure | exact, never rounded before the comparison: consumption is the sum of the stored kWh (3 decimals); a total in kg is the exact sum in g of §9.2's amounts × 0.001; a figure printed in MWh or t is compared in MWh or t (an exact power of ten) |
| An intensity | Σ amount ÷ Σ kWh over the intervals that have a factor (R2 §3.4.5), decided on the exact sums: ` |
| The residual | (product − printed) ÷ printed, printed in scientific notation with four significant digits (-1.067e-5), so that a difference in the last decimal is never shown as 0.0000 % (B08bv2-02) |
| Blocks | consumption, emissions excluding losses, distribution loss (CO2e × (DFactor − 1)), transmission loss (CO2e × (TFactor − 1)), each loss on the emissions excluding losses, added, never compounded; biogenic CO2 of the consumption ((CO2origin − CO2) × kWh, R2 §3.4.1 step 7); CO2 in g/kWh, CH4 and N2O in mg/kWh |
Kilde: docs/validation.md i løsningens
repository.