pyCity
A Python package for data handling and scenario generation of city districts and urban energy systems.
https://github.com/RWTH-EBC/pyCity
Category: Consumption
Sub Category: Buildings and Heating
Keywords
city modeling python urban urban-energy-modeling
Keywords from Contributors
buildings multi-energy-systems optimisation-framework power-scheduling-algorithm smart-grid modelica modelica-library
Last synced: about 18 hours ago
JSON representation
Repository metadata
Python package for data handling and scenario generation of city districts
- Host: GitHub
- URL: https://github.com/RWTH-EBC/pyCity
- Owner: RWTH-EBC
- License: mit
- Created: 2015-03-06T14:08:28.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-11-23T13:33:46.000Z (over 1 year ago)
- Last Synced: 2025-04-17T21:26:15.745Z (9 days ago)
- Topics: city, modeling, python, urban, urban-energy-modeling
- Language: Python
- Homepage:
- Size: 49.5 MB
- Stars: 25
- Watchers: 20
- Forks: 3
- Open Issues: 4
- Releases: 7
-
Metadata Files:
- Readme: README.md
- License: License.txt
README.md
pycity_base
Python package for data handling and scenario generation of city districts and urban energy systems.
Contributing
- Clone repository:
git clone [email protected]:RWTH-EBC/pyCity.git
(for SSH usage)
Alternatively: Clone via https:git clone https://github.com/RWTH-EBC/pyCity.git
- Open an issue at https://github.com/RWTH-EBC/pyCity/issues
- Checkout development branch:
git checkout development
- Update local development branch (if necessary):
git pull origin development
- Create your feature branch:
git checkout -b issueXY_explanation
- Commit your changes:
git commit -m "Add some feature #XY"
- Push to the branch:
git push origin issueXY_explanation
- Submit a pull request from issueXY_explanation to development branch via https://github.com/RWTH-EBC/pyCity/pulls
Installation
One important issue at the beginning: Please do NOT confuse pycity_base with
the pycity package on pypi! This (other) pycity package is installable via
pip. However, if you want to install pycity_base, follow this instruction.
pycity_base requires the following Python packages:
- numpy==1.26.0
- matplotlib==3.8.0
- pandas==2.1.1
- Shapely==2.0.1
- openpyxl==3.1.2
- networkx==2.5.1
- pyproj==3.6.1
as well as the EBC Python packages:
- richardsonpy==0.2.1
which is available at https://github.com/RWTH-EBC/richardsonpy
- uesgraphs==0.6.4
(with dependencies to shapely and pyproj)
which is available at https://github.com/RWTH-EBC/uesgraphs
richardsonpy and uesgraphs can be installed via pip.
Installation of pycity_base
The latest version of pycity_base is 0.3.3.
When uesgraph and its dependencies are installed, you should be able to install
pycity_base via pip:
pip install pycity_base
or:
pip install -e '<your_path_to_pycity_setup_folder>'
or:
<path_to_your_python_dist\Python.exe> -m pip install -e '<your_path_to_pycity_setup_folder>'
You can check if installation / adding packages to python has been successful
by adding new .py file and trying to import uesgraphs and pyCity.
import uesgraphs
import pycity_base
Import should be possible without errors.
Example usage
import shapely.geometry.point as point
import matplotlib.pyplot as plt
import uesgraphs.visuals as uesvis
import pycity_base.classes.timer as time
import pycity_base.classes.weather as weath
import pycity_base.classes.prices as price
import pycity_base.classes.environment as env
import pycity_base.classes.demand.apartment as apart
import pycity_base.classes.demand.occupancy as occ
import pycity_base.classes.demand.domestic_hot_water as dhw
import pycity_base.classes.demand.electrical_demand as eldem
import pycity_base.classes.demand.space_heating as spaceheat
import pycity_base.classes.building as build
import pycity_base.classes.city_district as citydist
import pycity_base.classes.supply.building_energy_system as besys
import pycity_base.classes.supply.boiler as boil
import pycity_base.classes.supply.photovoltaic as pvsys
def main():
# Define the time discretization for the timer object
timestep = 3600 # in seconds
# Define the total number of timesteps (in this case for one year)
nb_timesteps = int(365 * 24 * 3600 / timestep)
# Generate environment with timer, weather, and prices objects
# ######################################################################
timer = time.Timer(timeDiscretization=timestep,
timestepsTotal=nb_timesteps)
weather = weath.Weather(timer=timer)
prices = price.Prices()
environment = env.Environment(timer=timer, weather=weather, prices=prices)
# Generate city district object
# ######################################################################
city_district = citydist.CityDistrict(environment=environment)
# Annotations: To prevent some methods of subclasses uesgraph / nx.Graph
# from failing (e.g. '.subgraph()) environment is set as optional input
# parameter. However, it is necessary to use an environment object as
# input parameter to initialize a working cityDistrict object!
# Empty dictionary for building positions
dict_pos = {}
# Generate shapely point positions
dict_pos[0] = point.Point(0, 0) # (x, y)
dict_pos[1] = point.Point(20, 0)
# Use for loop to generate two identical building objects for city
# district
# ######################################################################
for i in range(2):
living_area = 200 # in m^2
spec_sh_dem = 160 # Specific space heating demand in kWh/m^2
number_occupants = 3 # Total number of occupants
# Generate space heating demand object (holding loadcurve attribute
# with space heating power)
heat_demand = spaceheat.SpaceHeating(
environment=environment,
method=1, # Standard load profile
livingArea=living_area, # in m^2
specificDemand=spec_sh_dem) # in kWh/m^2
# Generate occupancy object with stochastic user profile
occupancy = occ.Occupancy(environment=environment,
number_occupants=number_occupants)
# Generate electrical demand object
el_dem_stochastic = eldem.ElectricalDemand(
environment=environment,
method=2, # stochastic Richardson profile (richardsonpy)
total_nb_occupants=number_occupants, # Number of occupants
randomizeAppliances=True, # Random choice of installed appliances
lightConfiguration=10, # Light bulb configuration nb.
occupancy=occupancy.occupancy, # Occupancy profile (600 sec resolution)
prev_heat_dev=True, # Prevent space heating and hot water devices
annualDemand=None, # Annual el. demand in kWh could be used for
do_normalization=False) # rescaling (if do_normalization is True)
# Annotation: The calculation of stochastic electric load profiles
# is time consuming. If you prefer a faster method, you can either
# hand over an own array-like load curve (method=0) or generate a
# standardized load profile (SLP) (method=1)
# Generate domestic hot water demand object
dhw_obj = dhw.DomesticHotWater(
environment=environment,
tFlow=60, # DHW output temperature in degree Celsius
method=2, # Stochastic dhw profile
supplyTemperature=25, # DHW inlet flow temperature in degree C.
occupancy=occupancy.occupancy) # Occupancy profile (600 sec resolution)
# Generate apartment and add demand curves
apartment = apart.Apartment(environment)
apartment.addMultipleEntities([heat_demand,
el_dem_stochastic,
dhw_obj])
# Generate building and add apartment
building = build.Building(environment)
building.addEntity(apartment)
# Add buildings to city district
city_district.addEntity(entity=building,
position=dict_pos[i])
# Access information on city district object instance
# ######################################################################
print('Get number of building entities:')
print(city_district.get_nb_of_building_entities())
print()
print('Get list with node ids of building entities:')
print(city_district.get_list_build_entity_node_ids())
print()
print('Get city district overall space heating power load curve:')
print(city_district.get_aggr_space_heating_power_curve(current_values=True))
print()
print('Get city district overall space cooling power load curve:')
print(city_district.get_aggr_space_cooling_power_curve(current_values=True))
print()
# We can use the Visuals class of uesgraphs to plot the city district
# Generate uesgraphs visuals object instance
uesvisuals = uesvis.Visuals(uesgraph=city_district)
fig = plt.figure()
ax = fig.gca()
ax = uesvisuals.create_plot_simple(ax=ax)
plt.show()
plt.close()
# Access buildings
# ######################################################################
# As city_district is a networkx graph object, we can access the building
# entities with the corresponding building node,
# Pointer to building object with id 1001:
building_1001 = city_district.nodes[1001]['entity']
print('Get building 1001 electric load curve:')
print(building_1001.get_electric_power_curve())
print()
# Add energy systems to buildings
# ######################################################################
# We can also add building energy systems (BES) to each building object
# Generate boiler object
boiler = boil.Boiler(environment=environment,
qNominal=10000, # Boiler thermal power in Watt
eta=0.85) # Boiler efficiency
# Generate PV module object
pv = pvsys.PV(environment=environment,
area=30, # Area in m^2
eta=0.15) # Electrical efficiency at NOCT conditions
# Instantiate BES (container object for all energy systems)
bes = besys.BES(environment)
# Add energy systems to bes
bes.addMultipleDevices([boiler, pv])
# Add bes to building 1001
building_1001.addEntity(entity=bes)
print('Does building 1001 has a building energy system (BES)?')
print(building_1001.hasBes)
# Access boiler nominal thermal power
print('Nominal thermal power of boiler in kW:')
print(building_1001.bes.boiler[0].qNominal / 1000)
if __name__ == '__main__':
# Run program
main()
Tutorial
pycity_base also has also a jupyter notebook tutorial script under pycity/examples/tutorials/...
To open the jupyter notebook, open a command/terminal window and change your directory to the directory,
where tutorial_pycity_calc_1.ipynb is stored. Then type 'jupyter notebook' (without '' signs) and press Enter.
Jupyter notebook should open within your browser (such as Firefox). Click on one notebook to start.
If your Pyhton path does not point at your Python installation, you have to
open jupyter notebook directly, e.g. by looking for the jupyter.exe in your distribution.
How to cite pycity_base
- Schiefelbein, J., Rudnick, J., Scholl, A., Remmen, P., Fuchs, M., Müller, D. (2019),
Automated urban energy system modeling and thermal building simulation based on OpenStreetMap data sets,
Building and Environment,
Volume 149,
Pages 630-639,
ISSN 0360-1323
pdf,
bibtex
If you require a reference in German language:
- Schiefelbein, J. , Javadi, A. , Fuchs, M. , Müller, D. , Monti, A. and Diekerhof, M. (2017), Modellierung und Optimierung von Mischgebieten. Bauphysik, 39: 23-32. doi:10.1002/bapi.201710001
pdf,
bibtex
License
pyCity is released by RWTH Aachen University's E.ON Energy Research Center (E.ON ERC),
Institute for Energy Efficient Buildings and Indoor Climate (EBC) and
Institute for Automation of Complex Power Systems (ACS)
under the MIT License
Acknowledgements
We gratefully acknowledge the financial support by BMWi
(German Federal Ministry for Economic Affairs and Energy)
under promotional references 03ET1138D and 03ET1381A.
Owner metadata
- Name: RWTH Aachen University - E.ON Energy Research Center - Institute for Energy Efficient Buildings and Indoor Climate
- Login: RWTH-EBC
- Email: [email protected]
- Kind: organization
- Description:
- Website: http://www.ebc.eonerc.rwth-aachen.de/
- Location: RWTH Aachen University, Aachen, Germany
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/8121773?v=4
- Repositories: 52
- Last ynced at: 2024-03-27T11:18:30.715Z
- Profile URL: https://github.com/RWTH-EBC
GitHub Events
Total
- Watch event: 1
- Fork event: 1
Last Year
- Watch event: 1
- Fork event: 1
Committers metadata
Last synced: 4 days ago
Total Commits: 307
Total Committers: 12
Avg Commits per committer: 25.583
Development Distribution Score (DDS): 0.316
Commits in past year: 1
Committers in past year: 1
Avg Commits per committer in past year: 1.0
Development Distribution Score (DDS) in past year: 0.0
Name | Commits | |
---|---|---|
JSchiefelbein | j****n@e****e | 210 |
Sebastian Uerlich | S****h@r****e | 25 |
ss391347 | s****1@r****e | 25 |
MichaMans | m****s@h****m | 16 |
tsz | t****z@e****e | 16 |
Sebastian Uerlich | s****h@r****e | 5 |
ssi | s****r@e****e | 3 |
Florian Peterssen | f****n@r****e | 2 |
christoph | c****r@p****e | 2 |
Jan Schiefelbein | j****n@j****l | 1 |
MiLu29 | L****e@e****e | 1 |
mschumacher | m****r@r****e | 1 |
Committer domains:
- rwth-aachen.de: 5
- eonerc.rwth-aachen.de: 4
- posteo.de: 1
Issue and Pull Request metadata
Last synced: 2 days ago
Total issues: 131
Total pull requests: 161
Average time to close issues: 3 months
Average time to close pull requests: 8 days
Total issue authors: 12
Total pull request authors: 9
Average comments per issue: 1.05
Average comments per pull request: 0.11
Merged pull request: 154
Bot issues: 0
Bot pull requests: 1
Past year issues: 0
Past year pull requests: 0
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 0
Past year pull request authors: 0
Past year average comments per issue: 0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- JSchiefelbein (86)
- ThomasSchuetz (13)
- ss391347 (12)
- sebuer (5)
- MichaMans (3)
- mschumacher247 (3)
- Credics (3)
- SebastianStinner (2)
- MiLu29 (1)
- yuwash (1)
- marcusfuchs (1)
- lauraesling (1)
Top Pull Request Authors
- JSchiefelbein (120)
- ThomasSchuetz (14)
- ss391347 (10)
- sebuer (8)
- MichaMans (3)
- Credics (2)
- SebastianStinner (2)
- mschumacher247 (1)
- dependabot[bot] (1)
Top Issue Labels
- enhancement (56)
- bug (24)
- solvedOnDevelopment (10)
- invalid (3)
- question (1)
Top Pull Request Labels
- enhancement (30)
- bug (8)
- solvedOnDevelopment (1)
- dependencies (1)
Package metadata
- Total packages: 3
-
Total downloads:
- pypi: 220 last-month
- Total dependent packages: 1 (may contain duplicates)
- Total dependent repositories: 1 (may contain duplicates)
- Total versions: 16
- Total maintainers: 8
proxy.golang.org: github.com/rwth-ebc/pycity
- Homepage:
- Documentation: https://pkg.go.dev/github.com/rwth-ebc/pycity#section-documentation
- Licenses:
- Latest release: v0.3.3 (published over 1 year ago)
- Last Synced: 2025-04-25T12:09:04.398Z (2 days ago)
- Versions: 5
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent packages count: 6.999%
- Average: 8.173%
- Dependent repos count: 9.346%
proxy.golang.org: github.com/RWTH-EBC/pyCity
- Homepage:
- Documentation: https://pkg.go.dev/github.com/RWTH-EBC/pyCity#section-documentation
- Licenses:
- Latest release: v0.3.3 (published over 1 year ago)
- Last Synced: 2025-04-25T12:09:04.629Z (2 days ago)
- Versions: 5
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent packages count: 6.999%
- Average: 8.173%
- Dependent repos count: 9.346%
pypi.org: pycity-base
Python package for data handling and scenario generation of city districts and urban energy systems.
- Homepage: https://github.com/RWTH-EBC/pyCity
- Documentation: https://pycity-base.readthedocs.io/
- Licenses: MIT License
- Latest release: 0.3.3 (published over 1 year ago)
- Last Synced: 2025-04-25T12:09:04.096Z (2 days ago)
- Versions: 6
- Dependent Packages: 1
- Dependent Repositories: 1
- Downloads: 220 Last month
-
Rankings:
- Dependent packages count: 7.373%
- Stargazers count: 13.364%
- Average: 21.724%
- Dependent repos count: 22.233%
- Forks count: 29.991%
- Downloads: 35.658%
- Maintainers (8)
Dependencies
- Shapely ==1.7.1
- matplotlib ==3.3.4
- networkx ==2.5.1
- numpy ==1.19.5
- pandas ==1.1.5
- pyproj ==3.0.1
- richardsonpy ==0.2.1
- uesgraphs ==0.6.4
- xlrd ==1.2.0
- python 3.7 build
Score: 11.29028178869767