Skip to main content

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='2020',
    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='2028-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.

Metadata

Release files for magnetic-field-calculator 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for magnetic-field-calculator 1.0.2
File Size Uploaded
magnetic-field-calculator-1.0.2.tar.gz 19.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for magnetic-field-calculator 1.0.2
File Interpreter ABI Platform
magnetic_field_calculator-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 38.4 kB

Release files / magnetic-field-calculator-1.0.2.tar.gz

Download URL magnetic-field-calculator-1.0.2.tar.gz
Size 19.8 kB
Tags Source
SHA-256 checksum
How to use checksums
52d5cfa8df609d5343bc7a761fbcd58cf0ec2ff771b0fe97a1c0b33c84aaae89
BLAKE2b-256 checksum
How to use checksums
63f325fa90ec750d2c969b0e3c5ec2e45f60c98774ad0c67bfb8619ee31530ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.7

Release files / magnetic_field_calculator-1.0.2-py3-none-any.whl

Download URL magnetic_field_calculator-1.0.2-py3-none-any.whl
Size 18.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dfbb23e73369ba18a00c750ebb79ec8190b697b57757ddbf4ebeef0c89700f6f
BLAKE2b-256 checksum
How to use checksums
5e64e102ce910e533895af7f81e07fd56931932720bbc1cc20e4227cbc400eb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.7

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page