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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file gridfrequency-1.0.tar.gz.

File metadata

  • Download URL: gridfrequency-1.0.tar.gz
  • Upload date:
  • Size: 1.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.4

File hashes

Hashes for gridfrequency-1.0.tar.gz
Algorithm Hash digest
SHA256 bc29f79bbf71838148a12f3136bcb5b627613fd4fe4482a4f4dab6cab11e15e5
MD5 6ae568dee67f9cc58e5797a1d7acd3bb
BLAKE2b-256 3364fbc41f3a01e2bab066e1df128aa1924d5fd89195af1eeb5535bb86a1e779

See more details on using hashes here.

File details

Details for the file gridfrequency-1.0-py3-none-any.whl.

File metadata

  • Download URL: gridfrequency-1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.4

File hashes

Hashes for gridfrequency-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 429a8c11e2c01e68d1f30ca5dcbb02dfd959e7e487c0a949074549d80de37188
MD5 feaa0e43da0af9ddcadbb012ce6c4514
BLAKE2b-256 6301a028c70ace175f2fe8543329ded3374f14a5decc7f26c18efee54a35d8d6

See more details on using hashes here.

Supported by

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