Skip to main content

Python API for British Geological Survey magnetic field calculator

Project description

Magnetic field calculator

Latest Version Total Downloads License Build Status

Python API for British Geological Survey magnetic field calculator.

Description

This project magnetic field calculator. It uses is British Geological Survey (BGS) API web service for calculation.

The web service makes the World Magnetic Model (WMM), the International Geomagnetic Reference Field (IGRF) and the BGS Global Geomagnetic Model (BGGM) available as a web service. The IGRF and WMM have no restrictions on use, the BGGM is only available to subscribers. The API provides options to select which model and revision to use. Values of the magnetic field at any point around the world can be retrieved for a given date.

The project is not part of the BGS. It is just API client for it, made by community. For any information about BGS, you should use the official website.

Usage

First, you need to import the calculator class:

from magnetic_field_calculator import MagneticFieldCalculator

Then you need to init the calculator client, with default WMM model and it's latest available version:

calculator = MagneticFieldCalculator()

Model, it's revisions and custom URS can be changed with parameters:

calculator = MagneticFieldCalculator(
    model='wmm',
    revision='2015',
    sub_revision='2',
    custom_url='https://example.com'
)

You can then get the calculations for given location:

result = calculator.calculate(
    latitude=-80,
    longitude=140,
    altitude=200,
    date='2018-12-31'
)

The only required parameters are latitude and longitude, but it is reccomended to also set others for best results. Some of them are exclusive and you should not use them at same time. You can also set username and password for HTTP auth for protected models. For more details about parameters, see the official documentation.

Output is returned as dictionary:

field_value = result['field-value']
declination = field_value['declination']
inclination = field_value['inclination']
total_intensity = field_value['total-intensity']
north_intensity = field_value['north-intensity']
east_intensity = field_value['east-intensity']
vertical_intensity = field_value['vertical-intensity']
horizontal_intensity = field_value['horizontal-intensity']

Some output properties will have units and value sub properties. Output format will depend on used input, specially for height and date.

You can also look to example file for more examples.

Versioning

This library uses SemVer for versioning. For the versions available, see the tags on this repository.

License

This library is licensed under the GPLv3+ license. See the LICENSE file for details.

Project details


Download files

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

Source Distribution

magnetic-field-calculator-1.0.1.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

magnetic_field_calculator-1.0.1-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file magnetic-field-calculator-1.0.1.tar.gz.

File metadata

  • Download URL: magnetic-field-calculator-1.0.1.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for magnetic-field-calculator-1.0.1.tar.gz
Algorithm Hash digest
SHA256 076f05a07b7033ac04cf1513d4b6902f67609d776113a266a74dd7720e2b345a
MD5 313d80b5f0feeb4ae8c887dfaab3bd64
BLAKE2b-256 1ab43a38036d906ec4721f2dff838519c0f297d50a30f6e200e6f7c8a444cc69

See more details on using hashes here.

File details

Details for the file magnetic_field_calculator-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: magnetic_field_calculator-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for magnetic_field_calculator-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7ad00cd9c764fdd4e7fcfa87141dec39c3a8f8adc0e4a891b1dcb7579c25b966
MD5 cef2947ab1c06136544067d1ab45fc0b
BLAKE2b-256 173afbea03c8147b2f116b795f86533d1faabe10b4c4525481918986edf4db1b

See more details on using hashes here.

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