Skip to content

Commit 2707a4f

Browse files
authored
Improve README (frequenz-floss#208)
2 parents 4011aae + eb0c8c5 commit 2707a4f

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

README.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ check out the [Contributing Guide](CONTRIBUTING.md).
2828

2929
## Usage
3030

31-
Please also refer to [examples](https://github.com/frequenz-floss/frequenz-client-reporting-python/tree/HEAD/examples) for more detailed usage.
31+
Please also refer to source of the [CLI tool](https://github.com/frequenz-floss/frequenz-client-reporting-python/blob/v0.x.x/src/frequenz/client/reporting/cli/__main__.py)
32+
for a practical example of how to use the client.
3233

3334
### Installation
3435

@@ -43,6 +44,7 @@ pip install frequenz-client-reporting==$VERSION
4344

4445
To use the Reporting API client, you need to initialize it with the server URL and authentication credentials.
4546
The server URL should point to your Frequenz Reporting API instance, and you will need an authentication key and a signing secret.
47+
See [this documentation](https://github.com/frequenz-floss/frequenz-client-base-python/blob/v0.x.x/README.md#authorization-and-signing) for further details.
4648

4749
> **Security Note**
4850
> Always keep your authentication key and signing secret secure. Do not hard-code them in your source code or share them publicly.
@@ -66,10 +68,10 @@ client = ReportingApiClient(server_url=SERVER_URL, auth_key=AUTH_KEY, sign_secre
6668
### Query metrics for a single microgrid and component
6769

6870
This method supports:
69-
- Selecting specific `microgrid_id` and `component_id`
70-
- Choosing one or more `metrics` to retrieve
71-
- Defining a time range with `start_time` and `end_time`
72-
- Optional downsampling using `resampling_period` (e.g., `timedelta(minutes=15)`)
71+
- Selecting specific `microgrid_id` and `component_id`.
72+
- Choosing one or more `metrics` to retrieve. Available metrics are listed [here](https://github.com/frequenz-floss/frequenz-api-common/blob/v0.8.0/proto/frequenz/api/common/v1alpha8/metrics/metrics.proto).
73+
- Defining a time range with `start_time` and `end_time`.
74+
- Optional downsampling using `resampling_period` (e.g., `timedelta(minutes=15)`).
7375

7476
```python
7577
# Asynchronously collect metric data samples into a list
@@ -168,7 +170,29 @@ data = [
168170
]
169171
```
170172

171-
### Optionally convert the data to a pandas DataFrame
173+
## Usage of formulas
174+
175+
Formulas can be used to calculate a metric aggregated over multiple components or sensors.
176+
Note that this endpoint must be used with a `resampling_period`.
177+
Details on the formula syntax can be found [here](https://github.com/frequenz-floss/frequenz-microgrid-formula-engine-rs/tree/v0.x.x?tab=readme-ov-file#formula-syntax-overview).
178+
179+
```python
180+
# Example formula to sum the values of two components.
181+
formula = "#1 + #2"
182+
data = [
183+
sample async for sample in
184+
client.receive_aggregated_data(
185+
microgrid_id=microgrid_id,
186+
metric=Metric.AC_ACTIVE_POWER,
187+
aggregation_formula=formula,
188+
start_time=datetime.fromisoformat("2024-05-01T00:00:00"),
189+
end_time=datetime.fromisoformat("2024-05-02T00:00:00"),
190+
resampling_period=resampling_period,
191+
)
192+
]
193+
```
194+
195+
## Optionally convert the data to a pandas DataFrame
172196

173197
For easier data manipulation and analysis, you can convert the collected data into a pandas DataFrame.
174198

0 commit comments

Comments
 (0)