Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Mayer
CircularGreenSimCity
Commits
e789be8a
Commit
e789be8a
authored
Apr 08, 2024
by
Eric Duminil
Browse files
Basic example to calculate heat demand
parent
4a031c3e
Changes
1
Hide whitespace changes
Inline
Side-by-side
python_scripts/run_simstadt_from_python/Parse heat demand csv.ipynb
0 → 100644
View file @
e789be8a
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "d2c68f35",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "66f2a037",
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv(r\"C:\\Users\\eric.duminil\\git\\simstadt2\\TestRepository\\Gruenbuehl.proj\\99_HeatDemand.flow\\04_MonthlyEnergyBalance.step\\Gruenbuehl_LOD2_ALKIS_1010_DIN18599_HEATING.csv\",\n",
" skiprows=list(range(19)) + [20],\n",
" sep=';',\n",
" decimal=','\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "c94d6456",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>GMLId</th>\n",
" <th>ParentGMLId</th>\n",
" <th>Latitude</th>\n",
" <th>Longitude</th>\n",
" <th>X-coordinate</th>\n",
" <th>Y-coordinate</th>\n",
" <th>LOD</th>\n",
" <th>Year of construction</th>\n",
" <th>Year of refurbishment</th>\n",
" <th>Refurbishment Variant</th>\n",
" <th>...</th>\n",
" <th>March Heating demand</th>\n",
" <th>April Heating demand</th>\n",
" <th>May Heating demand</th>\n",
" <th>June Heating demand</th>\n",
" <th>July Heating demand</th>\n",
" <th>August Heating demand</th>\n",
" <th>September Heating demand</th>\n",
" <th>October Heating demand</th>\n",
" <th>November Heating demand</th>\n",
" <th>December Heating demand</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>DEBW_LOD2_1004495</td>\n",
" <td>NaN</td>\n",
" <td>48.87950</td>\n",
" <td>9.21478</td>\n",
" <td>3515829.63</td>\n",
" <td>5415809.40</td>\n",
" <td>LOD_2</td>\n",
" <td>1968</td>\n",
" <td>NaN</td>\n",
" <td>Original</td>\n",
" <td>...</td>\n",
" <td>15987</td>\n",
" <td>4566</td>\n",
" <td>673</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>690</td>\n",
" <td>8449</td>\n",
" <td>19075</td>\n",
" <td>26508</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>DEBW_LOD2_1004496</td>\n",
" <td>NaN</td>\n",
" <td>48.87939</td>\n",
" <td>9.21456</td>\n",
" <td>3515813.56</td>\n",
" <td>5415796.91</td>\n",
" <td>LOD_2</td>\n",
" <td>1968</td>\n",
" <td>NaN</td>\n",
" <td>Original</td>\n",
" <td>...</td>\n",
" <td>3973</td>\n",
" <td>1011</td>\n",
" <td>117</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>120</td>\n",
" <td>2085</td>\n",
" <td>4933</td>\n",
" <td>6905</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>DEBW_LOD2_1003853</td>\n",
" <td>NaN</td>\n",
" <td>48.87800</td>\n",
" <td>9.21559</td>\n",
" <td>3515888.84</td>\n",
" <td>5415642.86</td>\n",
" <td>LOD_2</td>\n",
" <td>1968</td>\n",
" <td>NaN</td>\n",
" <td>Original</td>\n",
" <td>...</td>\n",
" <td>2998</td>\n",
" <td>868</td>\n",
" <td>125</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>120</td>\n",
" <td>1578</td>\n",
" <td>3597</td>\n",
" <td>5006</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>DEBW_LOD2_1003651</td>\n",
" <td>NaN</td>\n",
" <td>48.87778</td>\n",
" <td>9.21467</td>\n",
" <td>3515821.59</td>\n",
" <td>5415617.69</td>\n",
" <td>LOD_2</td>\n",
" <td>1957</td>\n",
" <td>NaN</td>\n",
" <td>Original</td>\n",
" <td>...</td>\n",
" <td>11847</td>\n",
" <td>2785</td>\n",
" <td>333</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>401</td>\n",
" <td>6428</td>\n",
" <td>15161</td>\n",
" <td>21212</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>DEBW_LOD2_1003854</td>\n",
" <td>NaN</td>\n",
" <td>48.87811</td>\n",
" <td>9.21559</td>\n",
" <td>3515889.08</td>\n",
" <td>5415655.22</td>\n",
" <td>LOD_2</td>\n",
" <td>1968</td>\n",
" <td>NaN</td>\n",
" <td>Original</td>\n",
" <td>...</td>\n",
" <td>3669</td>\n",
" <td>1102</td>\n",
" <td>154</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>140</td>\n",
" <td>1938</td>\n",
" <td>4310</td>\n",
" <td>5964</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>100</th>\n",
" <td>DEBW_LOD2_2158</td>\n",
" <td>NaN</td>\n",
" <td>48.87861</td>\n",
" <td>9.21813</td>\n",
" <td>3516075.53</td>\n",
" <td>5415710.81</td>\n",
" <td>LOD_2</td>\n",
" <td>1968</td>\n",
" <td>NaN</td>\n",
" <td>Original</td>\n",
" <td>...</td>\n",
" <td>8581</td>\n",
" <td>2153</td>\n",
" <td>289</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>286</td>\n",
" <td>4447</td>\n",
" <td>10780</td>\n",
" <td>15176</td>\n",
" </tr>\n",
" <tr>\n",
" <th>101</th>\n",
" <td>DEBW_LOD2_2200</td>\n",
" <td>NaN</td>\n",
" <td>48.87856</td>\n",
" <td>9.21908</td>\n",
" <td>3516145.22</td>\n",
" <td>5415705.71</td>\n",
" <td>LOD_2</td>\n",
" <td>1994</td>\n",
" <td>NaN</td>\n",
" <td>Original</td>\n",
" <td>...</td>\n",
" <td>15099</td>\n",
" <td>2708</td>\n",
" <td>207</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>295</td>\n",
" <td>7775</td>\n",
" <td>20013</td>\n",
" <td>28298</td>\n",
" </tr>\n",
" <tr>\n",
" <th>102</th>\n",
" <td>DEBW_LOD2_2147</td>\n",
" <td>NaN</td>\n",
" <td>48.87856</td>\n",
" <td>9.21771</td>\n",
" <td>3516044.74</td>\n",
" <td>5415705.26</td>\n",
" <td>LOD_2</td>\n",
" <td>1968</td>\n",
" <td>NaN</td>\n",
" <td>Original</td>\n",
" <td>...</td>\n",
" <td>8622</td>\n",
" <td>2174</td>\n",
" <td>298</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>292</td>\n",
" <td>4476</td>\n",
" <td>10820</td>\n",
" <td>15219</td>\n",
" </tr>\n",
" <tr>\n",
" <th>103</th>\n",
" <td>DEBW_LOD2_2146</td>\n",
" <td>NaN</td>\n",
" <td>48.87869</td>\n",
" <td>9.21771</td>\n",
" <td>3516044.42</td>\n",
" <td>5415719.66</td>\n",
" <td>LOD_2</td>\n",
" <td>1968</td>\n",
" <td>NaN</td>\n",
" <td>Original</td>\n",
" <td>...</td>\n",
" <td>6895</td>\n",
" <td>1762</td>\n",
" <td>226</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>284</td>\n",
" <td>3871</td>\n",
" <td>8580</td>\n",
" <td>11813</td>\n",
" </tr>\n",
" <tr>\n",
" <th>104</th>\n",
" <td>DEBW_LOD2_1249</td>\n",
" <td>NaN</td>\n",
" <td>48.87922</td>\n",
" <td>9.21722</td>\n",
" <td>3516008.53</td>\n",
" <td>5415779.04</td>\n",
" <td>LOD_2</td>\n",
" <td>1968</td>\n",
" <td>NaN</td>\n",
" <td>Original</td>\n",
" <td>...</td>\n",
" <td>7505</td>\n",
" <td>1981</td>\n",
" <td>254</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>307</td>\n",
" <td>4159</td>\n",
" <td>9307</td>\n",
" <td>12859</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>105 rows × 54 columns</p>\n",
"</div>"
],
"text/plain": [
" GMLId ParentGMLId Latitude Longitude X-coordinate \\\n",
"0 DEBW_LOD2_1004495 NaN 48.87950 9.21478 3515829.63 \n",
"1 DEBW_LOD2_1004496 NaN 48.87939 9.21456 3515813.56 \n",
"2 DEBW_LOD2_1003853 NaN 48.87800 9.21559 3515888.84 \n",
"3 DEBW_LOD2_1003651 NaN 48.87778 9.21467 3515821.59 \n",
"4 DEBW_LOD2_1003854 NaN 48.87811 9.21559 3515889.08 \n",
".. ... ... ... ... ... \n",
"100 DEBW_LOD2_2158 NaN 48.87861 9.21813 3516075.53 \n",
"101 DEBW_LOD2_2200 NaN 48.87856 9.21908 3516145.22 \n",
"102 DEBW_LOD2_2147 NaN 48.87856 9.21771 3516044.74 \n",
"103 DEBW_LOD2_2146 NaN 48.87869 9.21771 3516044.42 \n",
"104 DEBW_LOD2_1249 NaN 48.87922 9.21722 3516008.53 \n",
"\n",
" Y-coordinate LOD Year of construction Year of refurbishment \\\n",
"0 5415809.40 LOD_2 1968 NaN \n",
"1 5415796.91 LOD_2 1968 NaN \n",
"2 5415642.86 LOD_2 1968 NaN \n",
"3 5415617.69 LOD_2 1957 NaN \n",
"4 5415655.22 LOD_2 1968 NaN \n",
".. ... ... ... ... \n",
"100 5415710.81 LOD_2 1968 NaN \n",
"101 5415705.71 LOD_2 1994 NaN \n",
"102 5415705.26 LOD_2 1968 NaN \n",
"103 5415719.66 LOD_2 1968 NaN \n",
"104 5415779.04 LOD_2 1968 NaN \n",
"\n",
" Refurbishment Variant ... March Heating demand April Heating demand \\\n",
"0 Original ... 15987 4566 \n",
"1 Original ... 3973 1011 \n",
"2 Original ... 2998 868 \n",
"3 Original ... 11847 2785 \n",
"4 Original ... 3669 1102 \n",
".. ... ... ... ... \n",
"100 Original ... 8581 2153 \n",
"101 Original ... 15099 2708 \n",
"102 Original ... 8622 2174 \n",
"103 Original ... 6895 1762 \n",
"104 Original ... 7505 1981 \n",
"\n",
" May Heating demand June Heating demand July Heating demand \\\n",
"0 673 2 0 \n",
"1 117 0 0 \n",
"2 125 0 0 \n",
"3 333 1 0 \n",
"4 154 0 0 \n",
".. ... ... ... \n",
"100 289 1 0 \n",
"101 207 1 0 \n",
"102 298 1 0 \n",
"103 226 1 0 \n",
"104 254 0 0 \n",
"\n",
" August Heating demand September Heating demand October Heating demand \\\n",
"0 0 690 8449 \n",
"1 0 120 2085 \n",
"2 0 120 1578 \n",
"3 0 401 6428 \n",
"4 0 140 1938 \n",
".. ... ... ... \n",
"100 0 286 4447 \n",
"101 0 295 7775 \n",
"102 0 292 4476 \n",
"103 0 284 3871 \n",
"104 0 307 4159 \n",
"\n",
" November Heating demand December Heating demand \n",
"0 19075 26508 \n",
"1 4933 6905 \n",
"2 3597 5006 \n",
"3 15161 21212 \n",
"4 4310 5964 \n",
".. ... ... \n",
"100 10780 15176 \n",
"101 20013 28298 \n",
"102 10820 15219 \n",
"103 8580 11813 \n",
"104 9307 12859 \n",
"\n",
"[105 rows x 54 columns]"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "adbf8c7c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"8001948"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df['Yearly Heating demand'].sum()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9c62ba61",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
%% Cell type:code id:d2c68f35 tags:
```
python
import
pandas
as
pd
```
%% Cell type:code id:66f2a037 tags:
```
python
df
=
pd
.
read_csv
(
r
"C:\Users\eric.duminil\git\simstadt2\TestRepository\Gruenbuehl.proj\99_HeatDemand.flow\04_MonthlyEnergyBalance.step\Gruenbuehl_LOD2_ALKIS_1010_DIN18599_HEATING.csv"
,
skiprows
=
list
(
range
(
19
))
+
[
20
],
sep
=
';'
,
decimal
=
','
)
```
%% Cell type:code id:c94d6456 tags:
```
python
df
```
%% Output
GMLId ParentGMLId Latitude Longitude X-coordinate \
0 DEBW_LOD2_1004495 NaN 48.87950 9.21478 3515829.63
1 DEBW_LOD2_1004496 NaN 48.87939 9.21456 3515813.56
2 DEBW_LOD2_1003853 NaN 48.87800 9.21559 3515888.84
3 DEBW_LOD2_1003651 NaN 48.87778 9.21467 3515821.59
4 DEBW_LOD2_1003854 NaN 48.87811 9.21559 3515889.08
.. ... ... ... ... ...
100 DEBW_LOD2_2158 NaN 48.87861 9.21813 3516075.53
101 DEBW_LOD2_2200 NaN 48.87856 9.21908 3516145.22
102 DEBW_LOD2_2147 NaN 48.87856 9.21771 3516044.74
103 DEBW_LOD2_2146 NaN 48.87869 9.21771 3516044.42
104 DEBW_LOD2_1249 NaN 48.87922 9.21722 3516008.53
Y-coordinate LOD Year of construction Year of refurbishment \
0 5415809.40 LOD_2 1968 NaN
1 5415796.91 LOD_2 1968 NaN
2 5415642.86 LOD_2 1968 NaN
3 5415617.69 LOD_2 1957 NaN
4 5415655.22 LOD_2 1968 NaN
.. ... ... ... ...
100 5415710.81 LOD_2 1968 NaN
101 5415705.71 LOD_2 1994 NaN
102 5415705.26 LOD_2 1968 NaN
103 5415719.66 LOD_2 1968 NaN
104 5415779.04 LOD_2 1968 NaN
Refurbishment Variant ... March Heating demand April Heating demand \
0 Original ... 15987 4566
1 Original ... 3973 1011
2 Original ... 2998 868
3 Original ... 11847 2785
4 Original ... 3669 1102
.. ... ... ... ...
100 Original ... 8581 2153
101 Original ... 15099 2708
102 Original ... 8622 2174
103 Original ... 6895 1762
104 Original ... 7505 1981
May Heating demand June Heating demand July Heating demand \
0 673 2 0
1 117 0 0
2 125 0 0
3 333 1 0
4 154 0 0
.. ... ... ...
100 289 1 0
101 207 1 0
102 298 1 0
103 226 1 0
104 254 0 0
August Heating demand September Heating demand October Heating demand \
0 0 690 8449
1 0 120 2085
2 0 120 1578
3 0 401 6428
4 0 140 1938
.. ... ... ...
100 0 286 4447
101 0 295 7775
102 0 292 4476
103 0 284 3871
104 0 307 4159
November Heating demand December Heating demand
0 19075 26508
1 4933 6905
2 3597 5006
3 15161 21212
4 4310 5964
.. ... ...
100 10780 15176
101 20013 28298
102 10820 15219
103 8580 11813
104 9307 12859
[105 rows x 54 columns]
%% Cell type:code id:adbf8c7c tags:
```
python
df
[
'Yearly Heating demand'
].
sum
()
```
%% Output
8001948
%% Cell type:code id:9c62ba61 tags:
```
python
```
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment