Skip to main content

Python wrapper for obtaining the current frequency of the Swedish national power grid

Project description

GridFrequency

Python wrapper for obtaining the current frequency of the Swedish national power grid

Sources

https://www.svk.se/drift-av-stamnatet/kontrollrummet/ (Swedish National Grid - Inspiration to this project) http://driftsdata.statnett.no/restapi/ (Norwegian National Grid - data provider)

Installation

This program only has one dependency; the requests module. The dependency can be be installed with pip using

pip install -r requirements.txt

Usage

Below are a few snippets of example usage. For more thorough usage, please see the source code.

Continous measurement

pollGridFrequency()

Polls every 0.5s [default], only printing result [default]. Calls callback only if value changed [default]

 pollGridFrequency(my_callback, 0.1)

Polls with custom callback function my_callback taking ONE argument (frequency). I.e. my_callback(freq) is called. Custom refresh rate.

 pollGridFrequency(None, 2, False)

No callback (prints values only), polling every 2s and returning values regardless of whether they have changed.

Obtain a single frequency measurement

 print("This is freq: " + str(getCurrentFrequency()[1]))

Single-capture frequency.

Callback

The data obtained in the continous polling is passed to a provided callback. The format of the callback is as follows

def my_callback(frequency):
  desired_freq = 50
  print("We differ by {} Hertz".format((desired_freq - frequency))

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gridfrequency-1.0.tar.gz (1.9 kB view hashes)

Uploaded Source

Built Distribution

gridfrequency-1.0-py3-none-any.whl (2.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page