GithubHelp home page GithubHelp logo

00mjk / gridkit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bdw/gridkit

0.0 0.0 0.0 233 KB

GridKit is an power grid extraction toolkit

License: MIT License

Shell 2.66% PLpgSQL 65.40% Python 31.44% R 0.50%

gridkit's Introduction

Code (v1.0): DOI

ENTSO-E extract: DOI

GridKit is a power grid extraction toolkit

GridKit uses spatial and topological analysis to transform map objects from OpenStreetMap into a network model of the electric power system. It has been developed in the context of the SciGRID project at the Next Energy research institute, to investigate the possibility of 'heuristic' analysis to augment the route-based analysis used in SciGRID. This has been implemented as a series of scripts for the PostgreSQL database using the PostGIS spatial extensions.

The network model is intended to be used in power systems analysis applications, for example using the PYPOWER system, or the PyPSA toolkit. In general this will require the following:

  • Careful interpretation of results (e.g. power lines and stations may have multiple voltages).
  • Realistic information on generation and load in the system (electrical supply and demand).
  • Reasonable, possibly location specific assumptions on the impedance of lines, depending on their internal structure. Unlike SciGRID, such assumptions have not yet been applied.

Of note, PyPSA implements several methods of network simplification, which is in many cases essential for ensuring that the power flow computations remain managable.

Data exports

Data exports created at March 14, 2016 for North America and Europe can be downloaded from zenodo. These exports are licensed under the Open Database License because they derive from OpenStreetMap data. They follow the same file structure as SciGRID. The file util/network.py contains a parser for these files.

Requirements

  • Python (2.7 or higher)
  • PostgreSQL (9.4 or higher)
  • PostGIS (2.1 or higher)
  • osm2pgsql (0.88.1 or higher)
  • Optionally psycopg2 (2.6 or higher)
  • Optionally osm-c-tools

How to Use (the simple way)

Download a power extract from enipedia:

wget http://enipedia.tudelft.nl/OpenStreetMap/EuropePower.zip
unzip EuropePower.zip

Ensure you have a user for postgresql with permissions to create databases and modify schemas. For example:

createuser -d gridkit

Run gridkit.py:

python gridkit.py EuropePower.osm

The --pg option takes a series of key=value pairs, which are parsed into database connection options. For example to connect to a host on 10.0.0.160 listening on port 9000:

python gridkit.py --pg host=10.0.0.160 port=9000 EuropePower.osm

The files gridkit-highvoltage-vertices.csv contains a CSV file with all high-voltage stations, and gridkit-highvoltage-edges.csv contains a CSV file with all high-voltage lines. You may use --full-export to export all other lines, too.

How to Use (the hard way)

Download a full-planet dump from planet.openstreetmap.org or a geographically-bounded extract from geofabrik.

Extract the power information

osmconvert my_area.osm.pbf -o=my_area.o5m
osmfilter my_area.o5m --keep='power=*' -o=my_area_power.o5m

Alternatively for extracting a specific region from the planet file (my_area.poly should a polygon filter file, which you can acquire from polygons.openstreetmap.fr):

osmconvert planet-latest.osm.pbf -B=my_area.poly -o=my_area.o5m

PostgreSQL configuration

GridKit assumes that you have the psql and osm2pgsql binaries available. Configuring access to the postgresql server is implemented using standard environment variables. Thus, prior to importing the openstreetmap source data, you should use something like:

export PGUSER=my_username PGDATABASE=my_database PGPASSWORD=my_password

Optionally also:

export PGHOST=server_hostname PGPORT=server_port

For more information, check out the linked documentation.

Extraction process

Import data using the script:

./import-data.sh /path/to/data.o5m database_name

The database_name parameter is optional if the PGDATABASE environment variable has been set. Running the extraction process is just:

./run.sh

You should expect this, depending on your machine and the size of your dataset, to take anywhere from 5 minutes to a few hours. Afterwards, you can extract a copy of the network using:

psql -f export-topology.sql

Which will copy the network to a set of CSV files in /tmp:

  • /tmp/heuristic_vertices.csv and /tmp/heuristic_links.csv contain the complete network at all voltage and frequency levels.

  • /tmp/heuristic_vertices_highvoltage and /tmp/heuristic_links_highvoltage contain the high-voltage network (>220kV) at any frequency which is not 16.7Hz.

Some things to watch out for

This process requires a lot of memory and significant amounts of CPU time. It also makes a lot of copies of the same data. This is very useful for investigating issues and tracking changes by the system. It also means that you should probably not use this on resource-constrained systems, such as docker containers in constrained virtual machines or raspberry pi's.

Queries have been typically optimized to make the best possible use of indices, but whether they are actually used is sensitive to query planner specifics. Depending on the specifics, PostgreSQL tuning may be necessary to run the extraction process efficiently.

The resultant network will in almost all cases be considerably more complex than equivalent networks (e.g. from SciGRID or the Bialek model. For practical applications, it is highly advisable to use simplification.

Analysis Utilities

Aside from the main codebase, some utilities have been implemented to enable analysis of the results. Notably:

  • util/network.py allows for some simple analysis of the network, transformation into a PYPOWER powercase dictionary, and 'patching' of the network to propagate voltage and frequency information from neighbors.
  • util/load_polyfile.py transforms a set of poly files into import statements for PostgreSQL, to allow data statistics per area, among other things.

gridkit's People

Contributors

bdw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.