From eb42ced7c13a46f3433c78e3968b8d55e63613be Mon Sep 17 00:00:00 2001 From: "Mathias L. Baumann" Date: Mon, 16 Feb 2026 13:28:01 +0100 Subject: [PATCH 1/3] Simplify install instructions and add plotting example Remove hardcoded version from pip install command and add a matplotlib plotting example at the end of the README. Signed-off-by: Mathias L. Baumann --- README.md | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e248bc8..aea653c 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,7 @@ for a practical example of how to use the client. ### Installation ```bash -# Choose the version you want to install -VERSION=0.18.0 -pip install frequenz-client-reporting==$VERSION +pip install frequenz-client-reporting ``` @@ -222,3 +220,35 @@ reporting-cli \ --bounds ``` In addition to the default CSV format, individual samples can also be output using the `--format iter` option. + +## Plotting data with matplotlib + +```python +import matplotlib.pyplot as plt +import matplotlib.dates as mdates + +# Fetch data (see examples above) +data = [ + sample async for sample in + client.receive_single_component_data( + microgrid_id=1, + component_id=100, + metrics=[Metric.AC_ACTIVE_POWER], + start_time=datetime.fromisoformat("2024-05-01T00:00:00"), + end_time=datetime.fromisoformat("2024-05-02T00:00:00"), + resampling_period=timedelta(seconds=60), + ) +] + +timestamps = [s.timestamp for s in data] +values = [s.value for s in data] + +fig, ax = plt.subplots(figsize=(14, 5)) +ax.plot(timestamps, values) +ax.set_title("AC Active Power") +ax.set_ylabel("Power (W)") +ax.xaxis.set_major_formatter(mdates.DateFormatter("%H:%M")) +ax.grid(True) +fig.tight_layout() +plt.show() +``` From 906ca905a6082b027019b206a8d6a533f0bdbe89 Mon Sep 17 00:00:00 2001 From: "Mathias L. Baumann" Date: Mon, 16 Feb 2026 13:28:32 +0100 Subject: [PATCH 2/3] Add matplotlib install step to plotting example Signed-off-by: Mathias L. Baumann --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index aea653c..1403958 100644 --- a/README.md +++ b/README.md @@ -223,6 +223,10 @@ In addition to the default CSV format, individual samples can also be output usi ## Plotting data with matplotlib +```bash +pip install matplotlib +``` + ```python import matplotlib.pyplot as plt import matplotlib.dates as mdates From 5bbaa9ddd304b8c7bbe2b56569fb5c89cf303dd9 Mon Sep 17 00:00:00 2001 From: "Mathias L. Baumann" Date: Mon, 16 Feb 2026 14:00:00 +0100 Subject: [PATCH 3/3] Address review: move plotting section, remove repeated fetch, add optional comment Signed-off-by: Mathias L. Baumann --- README.md | 60 ++++++++++++++++++++++++------------------------------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 1403958..c0531b0 100644 --- a/README.md +++ b/README.md @@ -200,59 +200,51 @@ df = pd.DataFrame(data) print(df) ``` -## Command line client tool - -The package contains a command-line tool that can be used to request -microgrid component data from the reporting API. - -```bash -reporting-cli \ - --url localhost:4711 \ - --auth_key=$AUTH_KEY - --sign_secret=$SIGN_SECRET - --mid 42 \ - --cid 23 \ - --metrics AC_ACTIVE_POWER AC_REACTIVE_POWER \ - --start 2024-05-01T00:00:00 \ - --end 2024-05-02T00:00:00 \ - --format csv \ - --states \ - --bounds -``` -In addition to the default CSV format, individual samples can also be output using the `--format iter` option. - ## Plotting data with matplotlib ```bash pip install matplotlib ``` +Using the `data` variable from any of the examples above: + ```python import matplotlib.pyplot as plt import matplotlib.dates as mdates -# Fetch data (see examples above) -data = [ - sample async for sample in - client.receive_single_component_data( - microgrid_id=1, - component_id=100, - metrics=[Metric.AC_ACTIVE_POWER], - start_time=datetime.fromisoformat("2024-05-01T00:00:00"), - end_time=datetime.fromisoformat("2024-05-02T00:00:00"), - resampling_period=timedelta(seconds=60), - ) -] - timestamps = [s.timestamp for s in data] values = [s.value for s in data] fig, ax = plt.subplots(figsize=(14, 5)) ax.plot(timestamps, values) + +# Optional: customize the plot ax.set_title("AC Active Power") ax.set_ylabel("Power (W)") ax.xaxis.set_major_formatter(mdates.DateFormatter("%H:%M")) ax.grid(True) fig.tight_layout() + plt.show() ``` + +## Command line client tool + +The package contains a command-line tool that can be used to request +microgrid component data from the reporting API. + +```bash +reporting-cli \ + --url localhost:4711 \ + --auth_key=$AUTH_KEY + --sign_secret=$SIGN_SECRET + --mid 42 \ + --cid 23 \ + --metrics AC_ACTIVE_POWER AC_REACTIVE_POWER \ + --start 2024-05-01T00:00:00 \ + --end 2024-05-02T00:00:00 \ + --format csv \ + --states \ + --bounds +``` +In addition to the default CSV format, individual samples can also be output using the `--format iter` option.