Skip to content

MASTR: support refreshing from the open-mastr bulk export#298

Open
MaykThewessen wants to merge 3 commits into
PyPSA:masterfrom
MaykThewessen:feature/mastr-open-mastr-bulk-support
Open

MASTR: support refreshing from the open-mastr bulk export#298
MaykThewessen wants to merge 3 commits into
PyPSA:masterfrom
MaykThewessen:feature/mastr-open-mastr-bulk-support

Conversation

@MaykThewessen

Copy link
Copy Markdown

What

Lets the MASTR source be refreshed from a current open-mastr bulk export instead of only the Zenodo CSV dump (whose last published version is frozen at 2025-02-09, record 14783581 is_last:true, while the registry is months newer).

Changes

  • get_raw_file: a glob fn selects the newest matching local file (ISO-dated names sort chronologically). The newest local dump wins even when update=True - the URL is only a seed and can never be newer than a dated local build, so a forced refresh no longer silently regresses to stale data.
  • MASTR(): match the storage_units CSV by suffix instead of the hardcoded bnetza_open_mastr_2025-02-09/ folder, so any dated dump loads.
  • MASTR(): guard ThermischeNutzleistung, which is present in the Zenodo CSV but absent from the bulk export; CHP detection falls back to KwkMastrNummer alone (previously raised KeyError).
  • config.yaml: MASTR.fn is now a glob (bnetza_open_mastr_*.zip); the Zenodo URL is kept as the fallback seed.
  • scripts/build_mastr_zip_from_open_mastr.py: helper to build the ppm-format zip from an open-mastr SQLite DB (Mastr().download()), so users can produce a current dump.

Why

Zenodo's open-mastr dump is no longer updated frequently, so the German fleet ages. The open-mastr bulk export is current to the day; these changes make ppm able to consume it with no manual path edits, and without a forced refresh quietly falling back to the frozen 2025 file.

Notes / backwards compatibility

  • Default behaviour is unchanged for non-glob fn (every other source).
  • With no local dump present, the glob path falls back to downloading the Zenodo URL basename exactly as before.
  • Verified: both update=False and update=True resolve to the newest local dump; full powerplants() build runs end-to-end on a fresh 2026 export.

Related

There is a companion issue (#295) about the open-mastr bulk download silently dropping the combustion table on a multi-code WeitereBrennstoffe value - relevant when building the dump this PR consumes.

MaykThewessen and others added 2 commits June 17, 2026 15:14
The MASTR source assumes the Zenodo CSV dump, whose last published version
is frozen at 2025-02-09. This adds support for building the source from a
current open-mastr bulk export instead:

- get_raw_file: a glob fn selects the newest matching local file (ISO-dated
  names sort chronologically). The newest local dump wins even on
  update=True, so a forced refresh never regresses to the frozen URL.
- MASTR(): match the storage_units CSV by suffix instead of a hardcoded
  bnetza_open_mastr_2025-02-09/ folder, so any dated dump loads.
- MASTR(): guard ThermischeNutzleistung, which is present in the Zenodo CSV
  but absent from the bulk export (CHP detection falls back to
  KwkMastrNummer alone).
- config: MASTR fn is now a glob (bnetza_open_mastr_*.zip), Zenodo URL kept
  as the fallback seed.
- scripts/build_mastr_zip_from_open_mastr.py: build the ppm-format zip from
  an open-mastr SQLite DB.
The new helper script lacked the REUSE-required SPDX header, failing the
reuse pre-commit.ci check on PyPSA#298. Add the MIT header used across the
package.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant