Skip to content

Commit 96da6d0

Browse files
authored
Merge pull request #702 from OpenEnergyPlatform/release-v0.16.1
Release v0.16.1
2 parents 0e87599 + 907978e commit 96da6d0

File tree

10 files changed

+96
-47
lines changed

10 files changed

+96
-47
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.16.0
2+
current_version = 0.16.1
33
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<release>(a|na))+(?P<build>\d+))?
44
serialize =
55
{major}.{minor}.{patch}{release}{build}

.github/workflows/ci-production.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: create package
3434
run: python -m build --sdist
3535
- name: import open-mastr
36-
run: python -m pip install ./dist/open_mastr-0.16.0.tar.gz
36+
run: python -m pip install ./dist/open_mastr-0.16.1.tar.gz
3737
- name: Create credentials file
3838
env:
3939
MASTR_TOKEN: ${{ secrets.MASTR_TOKEN }}

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ For each version important additions, changes and removals are listed here.
66
The format is inspired from [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
77
and the versioning aims to respect [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
88

9+
## [v0.16.1] Hotfix - 2025-12-17
10+
11+
### Changed
12+
- Adapt introduction text in README and docs
13+
[#647](https://github.com/OpenEnergyPlatform/open-MaStR/pull/647)
14+
- Hotfix of date selection and incorporate new url structure
15+
[#699](https://github.com/OpenEnergyPlatform/open-MaStR/pull/699)
16+
17+
18+
919
## [v0.16.0] Partial downloads with open-MaStR PartialPumpkinPull - 2025-11-26
1020
### Added
1121
- Add partial bulk download

CITATION.cff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ authors:
4141
title: "open-MaStR"
4242
type: software
4343
license: AGPL-3.0
44-
version: 0.16.0
44+
version: 0.16.1
4545
doi:
46-
date-released: 2025-11-26
46+
date-released: 2025-12-17
4747
url: "https://github.com/OpenEnergyPlatform/open-MaStR/"

README.rst

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,40 @@ open-mastr
3737
Introduction
3838
============
3939

40-
The `Marktstammdatenregister (MaStR) <https://www.marktstammdatenregister.de/MaStR>`_ is a German register
41-
provided by the German Federal Network Agency (Bundesnetzagentur / BNetza) that keeps track of all power and gas units located in Germany.
40+
The python package ``open-mastr`` provides an interface for accessing the `Marktstammdatenregister (MaStR) <https://www.marktstammdatenregister.de/MaStR>`_ data. The MaStR is a German register provided by the German Federal Network Agency (Bundesnetzagentur / BNetza) that keeps track of all power and gas units located in Germany. It is a daily growing dataset with millions of data points covering electricity and gas production units, electricity and gas consumers, storages, grids, and energy market participants.
4241

43-
The MaStR data can be
44-
45-
#. browsed and filtered `online <https://www.marktstammdatenregister.de/MaStR>`_
46-
#. taken from `daily provided dumps <https://www.marktstammdatenregister.de/MaStR/Datendownload>`_
47-
#. be accessed via the `web service <https://www.marktstammdatenregister.de/MaStRHilfe/subpages/webdienst.html>`_
42+
Generally, and besides the offerings of ``open-mastr``, the MaStR data can be accessed via three main options:
4843

49-
| The python package ``open-mastr`` provides an interface for accessing the data.
50-
| It contains methods to download and parse the xml files (bulk) and the SOAP web service (API).
51-
| In this repository we are developing methods to analyze, validate and enrich the data.
52-
| We want to collect and compile post processing scripts to improve data quality.
44+
#. browse, filter and download `in the browser <https://www.marktstammdatenregister.de/MaStR>`_
45+
#. download `daily provided dumps <https://www.marktstammdatenregister.de/MaStR/Datendownload>`_
46+
#. access via the `web service <https://www.marktstammdatenregister.de/MaStRHilfe/subpages/webdienst.html>`_
47+
48+
These access options, however, are not exactly frictionless. ``open-mastr`` thus provides an interface for and improved developer experience of accessing the data. This project is intended for individuals who wish to "just work" with the MaStR data and who do not want to deal with the idiosyncrasies of the three access options above.
49+
50+
In particular, ``open-mastr`` facilitates access to the daily provided MaStR dumps with download methods (bulk) and by parsing the XML files to a relational database. Furthermore, the software provides a Python wrapper to access the MaStR SOAP web service (API).
51+
52+
53+
**Does open-mastr edit or change the MaStR data?**
54+
No. ``open-mastr`` is a wrapper around the MaStR data and does not edit or change the data. It is intended to be used as a tool for working with the MaStR data.
55+
56+
Benefits provided by ``open-mastr``
57+
==================================
58+
59+
.. list-table::
60+
:widths: 30, 70
61+
:header-rows: 1
62+
63+
* - Benefit
64+
- Description
65+
* - Data download and parsing
66+
- Download, decode, and write data to a local database
67+
* - Translation to English
68+
- Translate table names and columns from German to English as well as an English documentation page of the dataset
69+
* - Data processing
70+
- Merge relevant information about different technologies to single csv files
71+
72+
**Just here for the data?**
73+
We regularly run the whole download and cleansing pipeline and upload the dataset as csv files at `zenodo <https://doi.org/10.5281/zenodo.6807425>`_!
5374

5475

5576
Documentation
@@ -140,7 +161,7 @@ Software
140161
141162
Data
142163
----
143-
| The data has the license **Datenlizenz Deutschland – Namensnennung – Version 2.0** (DL-DE-BY-2.0)
164+
| The original dataset is licensed under the **Datenlizenz Deutschland – Namensnennung – Version 2.0** (DL-DE-BY-2.0)
144165
| Copyright: `Marktstammdatenregister <https://www.marktstammdatenregister.de/MaStR>`_ - © Bundesnetzagentur für Elektrizität, Gas, Telekommunikation, Post und Eisenbahnen | `DL-DE-BY-2.0 <https://www.govdata.de/dl-de/by-2-0>`_
145166
146167

docs/index.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
11
# Introduction
22

3-
The [Marktstammdatenregister (MaStR)](https://www.marktstammdatenregister.de/MaStR) is a German register
4-
provided by the German Federal Network Agency (Bundesnetzagentur / BNetza) that keeps track of all power and gas units located in Germany.
5-
It is a daily growing dataset with more than 8.2 million data points covering electricity and gas production units, electricity and gas consumers, storages, grids, and energy market participants (as of spring 2024).
3+
The python package `open-mastr` provides an interface for accessing the [Marktstammdatenregister (MaStR)](https://www.marktstammdatenregister.de/MaStR) data. The MaStR is a German register provided by the German Federal Network Agency (Bundesnetzagentur / BNetza) that keeps track of all power and gas units located in Germany. It is a daily growing dataset with millions of data points covering electricity and gas production units, electricity and gas consumers, storages, grids, and energy market participants.
64

7-
Generally, the MaStR data can be accessed via various options:
5+
Generally, and besides the offerings of `open-mastr`, the MaStR data can be accessed via three main options:
86

9-
1. browse, filter and download [online](https://www.marktstammdatenregister.de/MaStR)
10-
1. download [daily provided dumps](https://www.marktstammdatenregister.de/MaStR/Datendownload)
11-
1. access via the [web service](https://www.marktstammdatenregister.de/MaStRHilfe/subpages/webdienst.html)
7+
1. browse, filter and download [in the browser](https://www.marktstammdatenregister.de/MaStR)
8+
2. download [daily provided dumps](https://www.marktstammdatenregister.de/MaStR/Datendownload)
9+
3. access via the [web service](https://www.marktstammdatenregister.de/MaStRHilfe/subpages/webdienst.html)
1210

13-
The python package `open-mastr` provides an interface for accessing the data and contributes to improving the
14-
usability of the access options above. This repository is intended for people who wish to simply work with the
15-
MaStR data and do not want to deal with the individual obstacles to data access of the three options above. <br> <br>
16-
It facilitates access to the daily provided MaStR dumps with download methods (bulk) and by
17-
parsing the XML files to a relational database. Furthermore, the software provides a Python wrapper to access the MaStR
18-
SOAP web service (API).
11+
These access options, however, are not exactly frictionless. `open-mastr` thus provides an interface for and improved developer experience of accessing the data. This project is intended for individuals who wish to "just work" with the MaStR data and who do not want to deal with the idiosyncrasies of the three access options above.
12+
13+
In particular, `open-mastr` facilitates access to the daily provided MaStR dumps with download methods (bulk) and by parsing the XML files to a relational database. Furthermore, the software provides a Python wrapper to access the MaStR SOAP web service (API).
14+
15+
!!! info "Does `open-mastr` edit or change the MaStR data?"
16+
No. `open-mastr` is a wrapper around the MaStR data and does not edit or change the data. It is intended to be used as a tool for working with the MaStR data.
1917

2018
## Benefits provided by `open-mastr`
2119

22-
Benefit | Description
23-
------- | ------
24-
Data download and parsing | Download, decode, and write data to a local database
25-
Translation to English | Translate table names and columns from German to English as well as an English documentation page of the dataset
26-
Data processing | Merge relevant information about different technologies to single csv files
20+
| Benefit | Description |
21+
| ------------------------- | ---------------------------------------------------------------------------------------------------------------- |
22+
| Data download and parsing | Download, decode, and write data to a local database |
23+
| Translation to English | Translate table names and columns from German to English as well as an English documentation page of the dataset |
24+
| Data processing | Merge relevant information about different technologies to single csv files |
2725

2826
!!! question "Just here for the data?"
2927
:sparkles: We regularly run the whole download and cleansing pipeline and upload the dataset as csv files at [zenodo](https://doi.org/10.5281/zenodo.6807425)!

open_mastr/mastr.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,9 @@ def download(
247247
xml_folder_path,
248248
)
249249

250-
download_xml_Mastr(zipped_xml_file_path, date, data, xml_folder_path)
250+
download_xml_Mastr(
251+
zipped_xml_file_path, bulk_download_date, data, xml_folder_path
252+
)
251253

252254
log.info(
253255
"\nWould you like to speed up the creation of your MaStR database?\n"

open_mastr/xml_download/utils_cleansing_bulk.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
columns_replace_list,
66
)
77
from zipfile import ZipFile
8+
import io
89

910

1011
def cleanse_bulk_data(df: pd.DataFrame, zipped_xml_file_path: str) -> pd.DataFrame:
@@ -59,8 +60,11 @@ def create_katalogwerte_from_bulk_download(zipped_xml_file_path) -> dict:
5960
"""Creates a dictionary from the id -> value mapping defined in the table
6061
katalogwerte from MaStR."""
6162
with ZipFile(zipped_xml_file_path, "r") as f:
62-
data = f.read("Katalogwerte.xml")
63-
df_katalogwerte = pd.read_xml(data, encoding="UTF-16", compression="zip")
63+
with f.open("Katalogwerte.xml") as xml_bytes_io:
64+
xml_bytes = xml_bytes_io.read()
65+
xml_text = xml_bytes.decode("utf-16")
66+
xml_io = io.StringIO(xml_text)
67+
df_katalogwerte = pd.read_xml(xml_io)
6468
katalogwerte_array = np.array(df_katalogwerte[["Id", "Wert"]])
6569
katalogwerte = dict(
6670
(katalogwerte_array[n][0], katalogwerte_array[n][1])

open_mastr/xml_download/utils_download_bulk.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import shutil
33
import time
4+
from datetime import datetime as dt
45
from importlib.metadata import PackageNotFoundError, version
56
from zipfile import ZipFile
67
from pathlib import Path
@@ -84,7 +85,9 @@ def gen_version(
8485
return f"{year}.{release}"
8586

8687

87-
def gen_url(when: time.struct_time = time.localtime(), use_version="current") -> str:
88+
def gen_url(
89+
when: time.struct_time = time.localtime(), use_version="current", use_stichtag=False
90+
) -> str:
8891
"""Generates the download URL for the specified date.
8992
9093
Note that not all dates are archived on the website.
@@ -112,7 +115,11 @@ def gen_url(when: time.struct_time = time.localtime(), use_version="current") ->
112115
version = gen_version(when, use_version)
113116
date = time.strftime("%Y%m%d", when)
114117

115-
return f"https://download.marktstammdatenregister.de/Gesamtdatenexport_{date}_{version}.zip"
118+
if use_stichtag:
119+
url_str = f"https://download.marktstammdatenregister.de/Stichtag/Gesamtdatenexport_{date}_{version}.zip"
120+
else:
121+
url_str = f"https://download.marktstammdatenregister.de/Gesamtdatenexport_{date}_{version}.zip"
122+
return url_str
116123

117124

118125
def download_xml_Mastr(
@@ -134,9 +141,8 @@ def download_xml_Mastr(
134141

135142
log.info("Starting the Download from marktstammdatenregister.de.")
136143

137-
# TODO this should take bulk_date_string
138-
now = time.localtime()
139-
url = gen_url(now)
144+
url_time = dt.strptime(bulk_date_string, "%Y%m%d").date().timetuple()
145+
url = gen_url(url_time)
140146

141147
time_a = time.perf_counter()
142148
r = requests.get(url, stream=True, headers={"User-Agent": USER_AGENT})
@@ -145,23 +151,31 @@ def download_xml_Mastr(
145151
"Download file was not found. Assuming that the new file was not published yet and retrying with yesterday."
146152
)
147153
now = time.localtime(
148-
time.mktime(now) - (24 * 60 * 60)
154+
time.mktime(url_time) - (24 * 60 * 60)
149155
) # subtract 1 day from the date
150156
url = gen_url(now)
151157
r = requests.get(url, stream=True, headers={"User-Agent": USER_AGENT})
152158
if r.status_code == 404:
153-
url = gen_url(now, use_version="before") # Use lower MaStR Version
159+
url = gen_url(url_time, use_version="before") # Use lower MaStR Version
154160
log.warning(
155161
f"Download file was not found. Assuming that the version of MaStR has changed and retrying with download link: {url}"
156162
)
157163
r = requests.get(url, stream=True, headers={"User-Agent": USER_AGENT})
158164
if r.status_code == 404:
159-
url = gen_url(now, use_version="after") # Use higher MaStR Version
165+
url = gen_url(url_time, use_version="after") # Use higher MaStR Version
160166
log.warning(
161167
f"Download file was not found. Assuming that the version of MaStR has changed and retrying with download link: {url}"
162168
)
163169
r = requests.get(url, stream=True, headers={"User-Agent": USER_AGENT})
164170

171+
if r.status_code == 404:
172+
url = gen_url(
173+
url_time, use_stichtag=True
174+
) # Use different url-structure for older downloads
175+
log.warning(
176+
f"Download file was not found. Assuming that the link structure of MaStR has changed and retrying with download link: {url}"
177+
)
178+
r = requests.get(url, stream=True, headers={"User-Agent": USER_AGENT})
165179
if r.status_code == 404:
166180
log.error("Could not download file: download URL not found")
167181
return

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "open_mastr"
7-
version = "0.16.0"
7+
version = "0.16.1"
88
dependencies = [
99
"pandas>=2.2.2",
1010
"numpy",
@@ -79,4 +79,4 @@ open_mastr = [
7979
include = ["open_mastr", "open_mastr.soap_api", "open_mastr.soap_api.metadata", "open_mastr.utils", "open_mastr.utils.config", "open_mastr.xml_download"] # package names should match these glob patterns (["*"] by default)
8080

8181
# from setup.py - not yet included in here
82-
# download_url="https://github.com/OpenEnergyPlatform/open-MaStR/archive""/refs/tags/v0.16.0.tar.gz",
82+
# download_url="https://github.com/OpenEnergyPlatform/open-MaStR/archive""/refs/tags/v0.16.1.tar.gz",

0 commit comments

Comments
 (0)