pyCity

Python package for data handling and scenario generation of city districts

https://github.com/RWTH-EBC/pyCity

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 5 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
    10 of 13 committers (76.9%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.0%) to scientific vocabulary

Keywords

city modeling python urban urban-energy-modeling

Keywords from Contributors

maintained buildings
Last synced: 6 months ago · JSON representation

Repository

Python package for data handling and scenario generation of city districts

Basic Info
  • Host: GitHub
  • Owner: RWTH-EBC
  • License: mit
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 49.5 MB
Statistics
  • Stars: 27
  • Watchers: 20
  • Forks: 3
  • Open Issues: 5
  • Releases: 7
Topics
city modeling python urban urban-energy-modeling
Created almost 11 years ago · Last pushed about 2 years ago
Metadata Files
Readme License

README.md

E.ON EBC RWTH Aachen University

Build Status Coverage Status License

pycity_base

Python package for data handling and scenario generation of city districts and urban energy systems.

Contributing

  1. Clone repository: git clone git@github.com:RWTH-EBC/pyCity.git (for SSH usage) Alternatively: Clone via https: git clone https://github.com/RWTH-EBC/pyCity.git
  2. Open an issue at https://github.com/RWTH-EBC/pyCity/issues
  3. Checkout development branch: git checkout development
  4. Update local development branch (if necessary): git pull origin development
  5. Create your feature branch: git checkout -b issueXY_explanation
  6. Commit your changes: git commit -m "Add some feature #XY"
  7. Push to the branch: git push origin issueXY_explanation
  8. 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 pycitybase with the pycity package on pypi! This (other) pycity package is installable via pip. However, if you want to install pycitybase, 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

```Python import shapely.geometry.point as point import matplotlib.pyplot as plt

import uesgraphs.visuals as uesvis

import pycitybase.classes.timer as time import pycitybase.classes.weather as weath import pycitybase.classes.prices as price import pycitybase.classes.environment as env import pycitybase.classes.demand.apartment as apart import pycitybase.classes.demand.occupancy as occ import pycitybase.classes.demand.domestichotwater as dhw import pycitybase.classes.demand.electricaldemand as eldem import pycitybase.classes.demand.spaceheating as spaceheat import pycitybase.classes.building as build import pycitybase.classes.citydistrict as citydist import pycitybase.classes.supply.buildingenergysystem as besys import pycitybase.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

pycitybase 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 tutorialpycitycalc1.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

  • Name: RWTH Aachen University - E.ON Energy Research Center - Institute for Energy Efficient Buildings and Indoor Climate
  • Login: RWTH-EBC
  • Kind: organization
  • Email: david.jansen@eonerc.rwth-aachen.de
  • Location: RWTH Aachen University, Aachen, Germany

GitHub Events

Total
  • Issues event: 1
  • Watch event: 2
  • Fork event: 1
Last Year
  • Issues event: 1
  • Watch event: 2
  • Fork event: 1

Committers

Last synced: 6 months ago

All Time
  • Total Commits: 307
  • Total Committers: 13
  • Avg Commits per committer: 23.615
  • Development Distribution Score (DDS): 0.316
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
JSchiefelbein j****n@e****e 210
Sebastian Uerlich S****h@r****e 25
ss391347 s****1@r****e 24
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
Sebastian Schwarz S****z@e****e 1
mschumacher m****r@r****e 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 132
  • Total pull requests: 161
  • Average time to close issues: 3 months
  • Average time to close pull requests: 8 days
  • Total issue authors: 13
  • Total pull request authors: 9
  • Average comments per issue: 1.05
  • Average comments per pull request: 0.11
  • Merged pull requests: 154
  • Bot issues: 0
  • Bot pull requests: 1
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • JSchiefelbein (86)
  • ThomasSchuetz (13)
  • ss391347 (12)
  • sebuer (5)
  • MichaMans (3)
  • mschumacher247 (3)
  • Credics (3)
  • SebastianStinner (2)
  • MiLu29 (1)
  • yuwash (1)
  • marvin-kluge (1)
  • marcusfuchs (1)
  • lauraesling (1)
Pull Request Authors
  • JSchiefelbein (120)
  • ThomasSchuetz (14)
  • ss391347 (10)
  • sebuer (8)
  • MichaMans (3)
  • Credics (2)
  • SebastianStinner (2)
  • mschumacher247 (1)
  • dependabot[bot] (1)
Top Labels
Issue Labels
enhancement (56) bug (24) solvedOnDevelopment (10) invalid (3) question (1)
Pull Request Labels
enhancement (30) bug (8) solvedOnDevelopment (1) dependencies (1)

Packages

  • Total packages: 3
  • Total downloads:
    • pypi 146 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
  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 7.0%
Average: 8.2%
Dependent repos count: 9.3%
Last synced: 6 months ago
proxy.golang.org: github.com/rwth-ebc/pycity
  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 7.0%
Average: 8.2%
Dependent repos count: 9.3%
Last synced: 6 months ago
pypi.org: pycity-base

Python package for data handling and scenario generation of city districts and urban energy systems.

  • Versions: 6
  • Dependent Packages: 1
  • Dependent Repositories: 1
  • Downloads: 146 Last month
Rankings
Dependent packages count: 7.4%
Stargazers count: 13.4%
Average: 21.7%
Dependent repos count: 22.2%
Forks count: 30.0%
Downloads: 35.7%
Last synced: 6 months ago

Dependencies

setup.py pypi
  • 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
doc/Dockerfile docker
  • python 3.7 build