Skip to content

Commit

Permalink
more annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
JrtPec committed Jul 16, 2024
1 parent 6f8187d commit 6b7f831
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 93 deletions.
158 changes: 79 additions & 79 deletions demo_energiedelen.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"outputs": [],
"source": [
"from openenergyid import TimeDataFrame\n",
"from openenergyid.energysharing import EnergySharingInput, EnergySharingOutput, calculate, CalculationMethod"
"from openenergyid.energysharing import EnergySharingInput, EnergySharingOutput, calculate, CalculationMethod, KeyInput"
]
},
{
Expand Down Expand Up @@ -388,10 +388,10 @@
"input = EnergySharingInput.model_construct(\n",
" gross_injection=TimeDataFrame.from_pandas(gross_injection),\n",
" gross_offtake=TimeDataFrame.from_pandas(gross_offtake),\n",
" key=TimeDataFrame.from_pandas(key),\n",
" key=KeyInput.from_pandas(key)\n",
")\n",
"\n",
"df = input.data_frame()"
"df = input.to_pandas()"
]
},
{
Expand Down Expand Up @@ -448,7 +448,7 @@
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2024-01-01 12:00:00+01:00</th>\n",
" <th>2024-01-01 11:00:00+00:00</th>\n",
" <td>70</td>\n",
" <td>10</td>\n",
" <td>20</td>\n",
Expand All @@ -469,7 +469,7 @@
" <td>0.225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2024-01-01 12:15:00+01:00</th>\n",
" <th>2024-01-01 11:15:00+00:00</th>\n",
" <td>20</td>\n",
" <td>10</td>\n",
" <td>30</td>\n",
Expand All @@ -490,7 +490,7 @@
" <td>0.225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2024-01-01 12:30:00+01:00</th>\n",
" <th>2024-01-01 11:30:00+00:00</th>\n",
" <td>100</td>\n",
" <td>10</td>\n",
" <td>40</td>\n",
Expand All @@ -511,7 +511,7 @@
" <td>0.225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2024-01-01 12:45:00+01:00</th>\n",
" <th>2024-01-01 11:45:00+00:00</th>\n",
" <td>0</td>\n",
" <td>10</td>\n",
" <td>50</td>\n",
Expand All @@ -538,24 +538,24 @@
"text/plain": [
" Gross Injection Gross Offtake \\\n",
" P1 P2 P3 P4 P5 P6 P1 P2 \n",
"2024-01-01 12:00:00+01:00 70 10 20 0 0 0 0 30 \n",
"2024-01-01 12:15:00+01:00 20 10 30 0 0 0 0 20 \n",
"2024-01-01 12:30:00+01:00 100 10 40 0 0 0 0 10 \n",
"2024-01-01 12:45:00+01:00 0 10 50 0 0 0 0 0 \n",
"2024-01-01 11:00:00+00:00 70 10 20 0 0 0 0 30 \n",
"2024-01-01 11:15:00+00:00 20 10 30 0 0 0 0 20 \n",
"2024-01-01 11:30:00+00:00 100 10 40 0 0 0 0 10 \n",
"2024-01-01 11:45:00+00:00 0 10 50 0 0 0 0 0 \n",
"\n",
" Key \\\n",
" P3 P4 P5 P6 P1 P2 P3 P4 P5 \n",
"2024-01-01 12:00:00+01:00 22 30 18 20 0.0 0.1 0.225 0.225 0.225 \n",
"2024-01-01 12:15:00+01:00 20 25 17 22 0.0 0.1 0.225 0.225 0.225 \n",
"2024-01-01 12:30:00+01:00 30 35 19 24 0.0 0.1 0.225 0.225 0.225 \n",
"2024-01-01 12:45:00+01:00 40 10 25 26 0.0 0.1 0.225 0.225 0.225 \n",
"2024-01-01 11:00:00+00:00 22 30 18 20 0.0 0.1 0.225 0.225 0.225 \n",
"2024-01-01 11:15:00+00:00 20 25 17 22 0.0 0.1 0.225 0.225 0.225 \n",
"2024-01-01 11:30:00+00:00 30 35 19 24 0.0 0.1 0.225 0.225 0.225 \n",
"2024-01-01 11:45:00+00:00 40 10 25 26 0.0 0.1 0.225 0.225 0.225 \n",
"\n",
" \n",
" P6 \n",
"2024-01-01 12:00:00+01:00 0.225 \n",
"2024-01-01 12:15:00+01:00 0.225 \n",
"2024-01-01 12:30:00+01:00 0.225 \n",
"2024-01-01 12:45:00+01:00 0.225 "
"2024-01-01 11:00:00+00:00 0.225 \n",
"2024-01-01 11:15:00+00:00 0.225 \n",
"2024-01-01 11:30:00+00:00 0.225 \n",
"2024-01-01 11:45:00+00:00 0.225 "
]
},
"execution_count": 9,
Expand Down Expand Up @@ -630,7 +630,7 @@
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2024-01-01 12:00:00+01:00</th>\n",
" <th>2024-01-01 11:00:00+00:00</th>\n",
" <td>4.9</td>\n",
" <td>1.70</td>\n",
" <td>5.90</td>\n",
Expand All @@ -651,7 +651,7 @@
" <td>20.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2024-01-01 12:15:00+01:00</th>\n",
" <th>2024-01-01 11:15:00+00:00</th>\n",
" <td>0.0</td>\n",
" <td>1.00</td>\n",
" <td>6.75</td>\n",
Expand All @@ -672,7 +672,7 @@
" <td>13.5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2024-01-01 12:30:00+01:00</th>\n",
" <th>2024-01-01 11:30:00+00:00</th>\n",
" <td>19.0</td>\n",
" <td>2.90</td>\n",
" <td>16.60</td>\n",
Expand All @@ -693,7 +693,7 @@
" <td>24.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2024-01-01 12:45:00+01:00</th>\n",
" <th>2024-01-01 11:45:00+00:00</th>\n",
" <td>0.0</td>\n",
" <td>2.42</td>\n",
" <td>18.33</td>\n",
Expand All @@ -720,24 +720,24 @@
"text/plain": [
" Net Injection \\\n",
" P1 P2 P3 P4 P5 P6 \n",
"2024-01-01 12:00:00+01:00 4.9 1.70 5.90 0.0 0.0 0.0 \n",
"2024-01-01 12:15:00+01:00 0.0 1.00 6.75 0.0 0.0 0.0 \n",
"2024-01-01 12:30:00+01:00 19.0 2.90 16.60 0.0 0.0 0.0 \n",
"2024-01-01 12:45:00+01:00 0.0 2.42 18.33 0.0 0.0 0.0 \n",
"2024-01-01 11:00:00+00:00 4.9 1.70 5.90 0.0 0.0 0.0 \n",
"2024-01-01 11:15:00+00:00 0.0 1.00 6.75 0.0 0.0 0.0 \n",
"2024-01-01 11:30:00+00:00 19.0 2.90 16.60 0.0 0.0 0.0 \n",
"2024-01-01 11:45:00+00:00 0.0 2.42 18.33 0.0 0.0 0.0 \n",
"\n",
" Net Offtake \\\n",
" P1 P2 P3 P4 P5 P6 \n",
"2024-01-01 12:00:00+01:00 0.0 21.0 4.00 7.50 0.0 0.0 \n",
"2024-01-01 12:15:00+01:00 0.0 15.0 13.25 11.50 3.5 8.5 \n",
"2024-01-01 12:30:00+01:00 0.0 0.0 5.25 1.25 0.0 0.0 \n",
"2024-01-01 12:45:00+01:00 0.0 0.0 37.75 0.00 11.5 12.5 \n",
"2024-01-01 11:00:00+00:00 0.0 21.0 4.00 7.50 0.0 0.0 \n",
"2024-01-01 11:15:00+00:00 0.0 15.0 13.25 11.50 3.5 8.5 \n",
"2024-01-01 11:30:00+00:00 0.0 0.0 5.25 1.25 0.0 0.0 \n",
"2024-01-01 11:45:00+00:00 0.0 0.0 37.75 0.00 11.5 12.5 \n",
"\n",
" Shared Energy \n",
" P1 P2 P3 P4 P5 P6 \n",
"2024-01-01 12:00:00+01:00 0.0 9.0 18.00 22.50 18.0 20.0 \n",
"2024-01-01 12:15:00+01:00 0.0 5.0 6.75 13.50 13.5 13.5 \n",
"2024-01-01 12:30:00+01:00 0.0 10.0 24.75 33.75 19.0 24.0 \n",
"2024-01-01 12:45:00+01:00 0.0 0.0 2.25 10.00 13.5 13.5 "
"2024-01-01 11:00:00+00:00 0.0 9.0 18.00 22.50 18.0 20.0 \n",
"2024-01-01 11:15:00+00:00 0.0 5.0 6.75 13.50 13.5 13.5 \n",
"2024-01-01 11:30:00+00:00 0.0 10.0 24.75 33.75 19.0 24.0 \n",
"2024-01-01 11:45:00+00:00 0.0 0.0 2.25 10.00 13.5 13.5 "
]
},
"execution_count": 10,
Expand Down Expand Up @@ -812,7 +812,7 @@
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2024-01-01 12:00:00+01:00</th>\n",
" <th>2024-01-01 11:00:00+00:00</th>\n",
" <td>7.08</td>\n",
" <td>1.01</td>\n",
" <td>2.02</td>\n",
Expand All @@ -833,7 +833,7 @@
" <td>20.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2024-01-01 12:15:00+01:00</th>\n",
" <th>2024-01-01 11:15:00+00:00</th>\n",
" <td>0.00</td>\n",
" <td>0.00</td>\n",
" <td>-0.00</td>\n",
Expand All @@ -854,7 +854,7 @@
" <td>15.71</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2024-01-01 12:30:00+01:00</th>\n",
" <th>2024-01-01 11:30:00+00:00</th>\n",
" <td>24.67</td>\n",
" <td>2.47</td>\n",
" <td>9.87</td>\n",
Expand All @@ -875,7 +875,7 @@
" <td>24.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2024-01-01 12:45:00+01:00</th>\n",
" <th>2024-01-01 11:45:00+00:00</th>\n",
" <td>0.00</td>\n",
" <td>2.24</td>\n",
" <td>11.22</td>\n",
Expand All @@ -902,24 +902,24 @@
"text/plain": [
" Net Injection \\\n",
" P1 P2 P3 P4 P5 P6 \n",
"2024-01-01 12:00:00+01:00 7.08 1.01 2.02 0.0 0.0 0.0 \n",
"2024-01-01 12:15:00+01:00 0.00 0.00 -0.00 0.0 0.0 0.0 \n",
"2024-01-01 12:30:00+01:00 24.67 2.47 9.87 0.0 0.0 0.0 \n",
"2024-01-01 12:45:00+01:00 0.00 2.24 11.22 0.0 0.0 0.0 \n",
"2024-01-01 11:00:00+00:00 7.08 1.01 2.02 0.0 0.0 0.0 \n",
"2024-01-01 11:15:00+00:00 0.00 0.00 -0.00 0.0 0.0 0.0 \n",
"2024-01-01 11:30:00+00:00 24.67 2.47 9.87 0.0 0.0 0.0 \n",
"2024-01-01 11:45:00+00:00 0.00 2.24 11.22 0.0 0.0 0.0 \n",
"\n",
" Net Offtake \\\n",
" P1 P2 P3 P4 P5 P6 \n",
"2024-01-01 12:00:00+01:00 0.0 20.42 3.75 5.94 0.00 0.00 \n",
"2024-01-01 12:15:00+01:00 0.0 14.13 13.00 9.29 1.29 6.29 \n",
"2024-01-01 12:30:00+01:00 0.0 0.00 5.00 0.00 0.00 0.00 \n",
"2024-01-01 12:45:00+01:00 0.0 0.00 37.50 0.00 7.98 8.98 \n",
"2024-01-01 11:00:00+00:00 0.0 20.42 3.75 5.94 0.00 0.00 \n",
"2024-01-01 11:15:00+00:00 0.0 14.13 13.00 9.29 1.29 6.29 \n",
"2024-01-01 11:30:00+00:00 0.0 0.00 5.00 0.00 0.00 0.00 \n",
"2024-01-01 11:45:00+00:00 0.0 0.00 37.50 0.00 7.98 8.98 \n",
"\n",
" Shared Energy \n",
" P1 P2 P3 P4 P5 P6 \n",
"2024-01-01 12:00:00+01:00 0.0 9.58 18.25 24.06 18.00 20.00 \n",
"2024-01-01 12:15:00+01:00 0.0 5.87 7.00 15.71 15.71 15.71 \n",
"2024-01-01 12:30:00+01:00 0.0 10.00 25.00 35.00 19.00 24.00 \n",
"2024-01-01 12:45:00+01:00 0.0 0.00 2.50 10.00 17.02 17.02 "
"2024-01-01 11:00:00+00:00 0.0 9.58 18.25 24.06 18.00 20.00 \n",
"2024-01-01 11:15:00+00:00 0.0 5.87 7.00 15.71 15.71 15.71 \n",
"2024-01-01 11:30:00+00:00 0.0 10.00 25.00 35.00 19.00 24.00 \n",
"2024-01-01 11:45:00+00:00 0.0 0.00 2.50 10.00 17.02 17.02 "
]
},
"execution_count": 11,
Expand Down Expand Up @@ -1000,7 +1000,7 @@
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2024-01-01 12:00:00+01:00</th>\n",
" <th>2024-01-01 11:00:00+00:00</th>\n",
" <td>0.00</td>\n",
" <td>0.00</td>\n",
" <td>0.00</td>\n",
Expand All @@ -1021,7 +1021,7 @@
" <td>20.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2024-01-01 12:15:00+01:00</th>\n",
" <th>2024-01-01 11:15:00+00:00</th>\n",
" <td>0.00</td>\n",
" <td>0.00</td>\n",
" <td>0.00</td>\n",
Expand All @@ -1042,7 +1042,7 @@
" <td>15.71</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2024-01-01 12:30:00+01:00</th>\n",
" <th>2024-01-01 11:30:00+00:00</th>\n",
" <td>14.76</td>\n",
" <td>1.48</td>\n",
" <td>15.77</td>\n",
Expand All @@ -1063,7 +1063,7 @@
" <td>24.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2024-01-01 12:45:00+01:00</th>\n",
" <th>2024-01-01 11:45:00+00:00</th>\n",
" <td>0.00</td>\n",
" <td>0.00</td>\n",
" <td>0.00</td>\n",
Expand All @@ -1090,24 +1090,24 @@
"text/plain": [
" Net Injection \\\n",
" P1 P2 P3 P4 P5 P6 \n",
"2024-01-01 12:00:00+01:00 0.00 0.00 0.00 0.0 0.0 0.0 \n",
"2024-01-01 12:15:00+01:00 0.00 0.00 0.00 0.0 0.0 0.0 \n",
"2024-01-01 12:30:00+01:00 14.76 1.48 15.77 0.0 0.0 0.0 \n",
"2024-01-01 12:45:00+01:00 0.00 0.00 0.00 0.0 0.0 0.0 \n",
"2024-01-01 11:00:00+00:00 0.00 0.00 0.00 0.0 0.0 0.0 \n",
"2024-01-01 11:15:00+00:00 0.00 0.00 0.00 0.0 0.0 0.0 \n",
"2024-01-01 11:30:00+00:00 14.76 1.48 15.77 0.0 0.0 0.0 \n",
"2024-01-01 11:45:00+00:00 0.00 0.00 0.00 0.0 0.0 0.0 \n",
"\n",
" Net Offtake \\\n",
" P1 P2 P3 P4 P5 P6 \n",
"2024-01-01 12:00:00+01:00 0.0 18.51 0.35 1.14 0.00 0.00 \n",
"2024-01-01 12:15:00+01:00 0.0 14.13 13.00 9.29 1.29 6.29 \n",
"2024-01-01 12:30:00+01:00 0.0 0.00 0.00 0.00 0.00 0.00 \n",
"2024-01-01 12:45:00+01:00 0.0 0.00 36.75 0.00 1.62 2.62 \n",
"2024-01-01 11:00:00+00:00 0.0 18.51 0.35 1.14 0.00 0.00 \n",
"2024-01-01 11:15:00+00:00 0.0 14.13 13.00 9.29 1.29 6.29 \n",
"2024-01-01 11:30:00+00:00 0.0 0.00 0.00 0.00 0.00 0.00 \n",
"2024-01-01 11:45:00+00:00 0.0 0.00 36.75 0.00 1.62 2.62 \n",
"\n",
" Shared Energy \n",
" P1 P2 P3 P4 P5 P6 \n",
"2024-01-01 12:00:00+01:00 0.0 11.49 21.65 28.86 18.00 20.00 \n",
"2024-01-01 12:15:00+01:00 0.0 5.87 7.00 15.71 15.71 15.71 \n",
"2024-01-01 12:30:00+01:00 0.0 10.00 30.00 35.00 19.00 24.00 \n",
"2024-01-01 12:45:00+01:00 0.0 0.00 3.25 10.00 23.38 23.38 "
"2024-01-01 11:00:00+00:00 0.0 11.49 21.65 28.86 18.00 20.00 \n",
"2024-01-01 11:15:00+00:00 0.0 5.87 7.00 15.71 15.71 15.71 \n",
"2024-01-01 11:30:00+00:00 0.0 10.00 30.00 35.00 19.00 24.00 \n",
"2024-01-01 11:45:00+00:00 0.0 0.00 3.25 10.00 23.38 23.38 "
]
},
"execution_count": 12,
Expand Down Expand Up @@ -1156,10 +1156,10 @@
"{\n",
" \"netInjection\": {\n",
" \"index\": [\n",
" \"2024-01-01T12:00:00+01:00\",\n",
" \"2024-01-01T12:15:00+01:00\",\n",
" \"2024-01-01T12:30:00+01:00\",\n",
" \"2024-01-01T12:45:00+01:00\"\n",
" \"2024-01-01T11:00:00Z\",\n",
" \"2024-01-01T11:15:00Z\",\n",
" \"2024-01-01T11:30:00Z\",\n",
" \"2024-01-01T11:45:00Z\"\n",
" ],\n",
" \"columns\": [\n",
" \"P1\",\n",
Expand Down Expand Up @@ -1206,10 +1206,10 @@
" },\n",
" \"netOfftake\": {\n",
" \"index\": [\n",
" \"2024-01-01T12:00:00+01:00\",\n",
" \"2024-01-01T12:15:00+01:00\",\n",
" \"2024-01-01T12:30:00+01:00\",\n",
" \"2024-01-01T12:45:00+01:00\"\n",
" \"2024-01-01T11:00:00Z\",\n",
" \"2024-01-01T11:15:00Z\",\n",
" \"2024-01-01T11:30:00Z\",\n",
" \"2024-01-01T11:45:00Z\"\n",
" ],\n",
" \"columns\": [\n",
" \"P1\",\n",
Expand Down Expand Up @@ -1256,10 +1256,10 @@
" },\n",
" \"sharedEnergy\": {\n",
" \"index\": [\n",
" \"2024-01-01T12:00:00+01:00\",\n",
" \"2024-01-01T12:15:00+01:00\",\n",
" \"2024-01-01T12:30:00+01:00\",\n",
" \"2024-01-01T12:45:00+01:00\"\n",
" \"2024-01-01T11:00:00Z\",\n",
" \"2024-01-01T11:15:00Z\",\n",
" \"2024-01-01T11:30:00Z\",\n",
" \"2024-01-01T11:45:00Z\"\n",
" ],\n",
" \"columns\": [\n",
" \"P1\",\n",
Expand Down
2 changes: 1 addition & 1 deletion openenergyid/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Open Energy ID Python SDK."""

__version__ = "0.1.12"
__version__ = "0.1.13"

from .enums import Granularity
from .models import TimeDataFrame, TimeSeries
Expand Down
10 changes: 8 additions & 2 deletions openenergyid/energysharing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
"""Energy Sharing package."""

from .main import calculate
from .models import CalculationMethod, EnergySharingInput, EnergySharingOutput
from .models import CalculationMethod, EnergySharingInput, EnergySharingOutput, KeyInput

__all__ = ["calculate", "CalculationMethod", "EnergySharingInput", "EnergySharingOutput"]
__all__ = [
"calculate",
"CalculationMethod",
"EnergySharingInput",
"EnergySharingOutput",
"KeyInput",
]
3 changes: 0 additions & 3 deletions openenergyid/energysharing/data_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ def create_multi_index_input_frame(

df = pd.concat([gross_injection, gross_offtake, key], axis=1)

# Do a check that the sum of the keys per timestamp is 1
assert df[KEY].dropna(how="all").sum(axis=1).round(2).eq(1).all()

return df


Expand Down
Loading

0 comments on commit 6b7f831

Please sign in to comment.