Colombia: hourly actual generation with one settlement revision#

Read 72 real plant-hour observations from XM’s SIMEM actual-generation dataset 055A4D. Three resources and one complete Colombian source day are selected from revision TXF. Selecting one revision prevents the same plant-hour from being counted repeatedly across settlement versions.

Source: XM SIMEM Generación real. Download the captured JSON and capture manifest. The example runs entirely offline with source observations, without a key.

import hashlib
import json
from pathlib import Path

import matplotlib.pyplot as plt

from energy_data_retrieval.sources.xm import parse_generation

1. Verify the selected native API response#

Metadata and complete source records are retained. The manifest records the original response hash and documents record selection/JSON reserialization. For a fresh bounded API retrieval, outside the offline gallery:

from datetime import date
from energy_data_retrieval.sources.xm import XM_HOSTS, XMClient
from energy_data_retrieval.transport import HTTPClient
with HTTPClient(XM_HOSTS) as http:
    result = XMClient(http).generation(date(2024, 6, 1), date(2024, 6, 1),
                                      version="TXF", resource_ids=["TPUY"])
directory = Path(globals().get("__file__", Path.cwd() / "plot_generation_xm.py")).resolve().parent
data = directory / "data"
manifest = json.loads((data / "generation_xm_provenance.json").read_text())
raw = (data / manifest["fixture"]).read_bytes()
if hashlib.sha256(raw).hexdigest() != manifest["fixture_sha256"]:
    raise ValueError("XM capture differs from its provenance")
frame = parse_generation(json.loads(raw), version="TXF")
print("Source:", manifest["source_url"])
print("Captured:", manifest["retrieved_at_utc"], "revision:", frame.attrs["selected_version"])
Source: https://www.simem.co/backend-files/api/PublicData?datasetId=055A4D&startDate=2024-06-01&endDate=2024-06-01&columnDestinyName=Version&values=TXF
Captured: 2026-10-30T08:17:12.066811+00:00 revision: TXF

2. Preserve the physical unit and explicit revision#

GReal is energy measured at generation boundaries, supplied as kWh for each hour. The normalized value is MWh; original kWh remains in source_value. Native FechaHora labels use Colombia’s UTC-05 clock and are converted to UTC without shifting the provider’s label convention. Null stays missing.

SIMEM may publish TX1-TX5, TXF and TXR for the same hour. An unavailable TXF raises an error instead of silently selecting a provisional version. The separate dataset E17D25 contains daily estimates/schedules and is not used.

print(
    frame.groupby("unit_id").agg(
        observations=("value", "size"), reported=("value", "count"), energy_mwh=("value", "sum")
    )
)
print("Native unit:", frame["source_unit"].unique(), "normalized unit:", frame["unit"].unique())
         observations  reported  energy_mwh
unit_id
3IRX               24        24   741.59069
GYPO               24        24  1785.48856
TPUY               24        24   766.81929
Native unit: ['kWh'] normalized unit: ['MWh']

3. Plot measured energy for the three generation resources#

Resource identifiers are retained as published. Values are hourly energy; this chart does not relabel them as instantaneous MW or nameplate capacity.

fig, ax = plt.subplots(figsize=(9, 4.8), layout="constrained")
for resource, profile in frame.groupby("unit_id"):
    ax.plot(profile["timestamp"], profile["value"], marker=".", label=resource, linewidth=2)
ax.set(
    title="XM actual generation · 1 June 2024 · revision TXF",
    xlabel="Published source hour label converted to UTC",
    ylabel="Hourly generation (MWh)",
)
ax.grid(alpha=0.2)
ax.legend(title="CodigoPlanta")
plt.show()
XM actual generation · 1 June 2024 · revision TXF

Reuse#

Credit XM / SIMEM and record dataset ID, plant identifiers, retrieval date and settlement revision. Comparing revisions can measure settlement corrections; combining them as additional generation would double count the same period.

Total running time of the script: (0 minutes 0.106 seconds)

Gallery generated by Sphinx-Gallery