@@ -20,3 +20,52 @@ The following platforms are officially supported (tested):
2020
2121If you want to know how to build this project and contribute to it, please
2222check out the [ Contributing Guide] ( CONTRIBUTING.md ) .
23+
24+
25+ ### Installation
26+
27+ ``` bash
28+ # Choose the version you want to install
29+ VERSION=0.1.0
30+ pip install frequenz-reporting-python==$VERSION
31+ ```
32+
33+
34+ ### Initialize the client
35+
36+ ``` python
37+ from datetime import datetime
38+
39+ from frequenz.client.common.metric import Metric
40+ from frequenz.client.reporting import ReportingApiClient
41+ from frequenz.reporting._reporting import cumulative_energy
42+
43+ # Change server address if needed
44+ SERVICE_ADDRESS = " reporting.api.frequenz.com:443"
45+ API_KEY = open (' api_key.txt' ).read().strip()
46+ client = ReportingApiClient(service_address = SERVICE_ADDRESS , key = API_KEY )
47+ ```
48+
49+ ### Calculate cumulative energy for a single microgrid and component:
50+
51+ If the component does not measure ` Metric.AC_ACTIVE_ENERGY ` , set ` use_active_power=True `
52+ to utilize ` Metric.AC_ACTIVE_POWER ` instead.
53+
54+ A resolution can be set that alters how NaNs are handled, resulting in varying
55+ results. NaN values are ignored in sums, which may lead to significant data loss
56+ if many are present in the raw data. There is no universally correct method for
57+ handling NaNs, as their causes can vary.
58+
59+ ``` python
60+ energy_reading = await cumulative_energy(
61+ client = client,
62+ microgrid_id = 1 ,
63+ component_id = 100 ,
64+ start_time = datetime.fromisoformat(" 2024-09-01T00:00:00" ),
65+ end_time = datetime.fromisoformat(" 2024-09-30T00:00:00" ),
66+ use_active_power = True ,
67+ resolution = 10 ,
68+ )
69+
70+ print (energy_reading)
71+ ```
0 commit comments