Python API for British Geological Survey magnetic field calculator

Overview

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.

You might also like...
Official python API for Phish.AI public and private API to detect zero-day phishing websites

phish-ai-api Summary Official python API for Phish.AI public and private API to detect zero-day phishing websites How it Works (TLDR) Essentially we h

Python API wrapper around Trello's API

A wrapper around the Trello API written in Python. Each Trello object is represented by a corresponding Python object. The attributes of these objects

A python to scratch API connector. Can fetch data from the API and send it back in cloud variables.

Scratch2py Scratch2py or S2py is a easy to use, versatile tool to communicate with the Scratch API Based of scratchclient by Raihan142857 Installation

Async ready API wrapper for Revolt API written in Python.

Mutiny Async ready API wrapper for Revolt API written in Python. Installation Python 3.9 or higher is required To install the library, you can just ru

🚀 An asynchronous python API wrapper meant to replace discord.py - Snappy discord api wrapper written with aiohttp & websockets

Pincer An asynchronous python API wrapper meant to replace discord.py ❗ The package is currently within the planning phase 📌 Links |Join the discord

wyscoutapi is an extremely basic API client for the Wyscout API (v2 & v3) for Python

wyscoutapi wyscoutapi is an extremely basic API client for the Wyscout API (v2 & v3). Usage Install with pip install wyscoutapi. To connect to the Wys

Beyonic API Python official client library simplified examples using Flask, Django and Fast API.
Beyonic API Python official client library simplified examples using Flask, Django and Fast API.

Beyonic API Python official client library simplified examples using Flask, Django and Fast API.

A Python API wrapper for the Twitter API!

PyTweet PyTweet is an api wrapper made for twitter using twitter's api version 2! Installation Windows py3 -m pip install PyTweet Linux python -m pip

A new coin listing alert bot using Python, Flask, MongoDB, Telegram API and Binance API
A new coin listing alert bot using Python, Flask, MongoDB, Telegram API and Binance API

Bzzmans New Coin Listing Detection Bot Architecture About Project Work in progress. This bot basically gets new coin listings from Binance using Binan

Comments
  • UnboundLocalError possible in MagneticFieldCalculator.calculate()

    UnboundLocalError possible in MagneticFieldCalculator.calculate()

    Not sure why yet - the issue was flagged by my CI pipeline after the new year (1st Jan 2020), so may be related to API changes?

            request = {
                'latitude': latitude,
                'longitude': longitude,
        
                'altitude': altitude,
                'depth': depth,
                'radius': radius,
        
                'year': year,
                'date': date,
        
                'format': 'json',
            }
        
            parameters = urllib.parse.urlencode({k: v for k, v in request.items() if v is not None})
        
            for base_url in self.custom_url, self.main_url:
                if base_url:
                    try:
                        url = base_url \
                        + '/' + self.model \
                        + '/' + self.revision \
                        + ('v' + self.sub_revision if self.sub_revision else '') \
                        + '?' + parameters
        
                        request = urllib.request.Request(url)
        
                        if username and password:
                            auth = base64.b64encode(b'%s:%s' % (username, password))
                            request.add_header("Authorization", "Basic %s" % auth)
        
                        response = urllib.request.urlopen(url).read()
                        result = json.loads(response.decode('utf-8'))
        
                        break
        
                    except (URLError, ValueError) as err:
                        error = err
        
            try:
    >           return result['geomagnetic-field-model-result']
    E           UnboundLocalError: local variable 'result' referenced before assignment
    
    opened by Liam-Deacon 2
Releases(v1.0.2)
An Telegram Bot By @ZauteKm To Stream Videos In Telegram Voice Chat Of Both Groups & Channels. Supports Live Streams, YouTube Videos & Telegram Media !!

Telegram Video Stream Bot (Py-TgCalls) An Telegram Bot By @ZauteKm To Stream Videos In Telegram Voice Chat Of Both Groups & Channels. Supports Live St

Zaute Km 14 Oct 21, 2022
A Python script to update Spotify Playlist data every 5 minutes.

Spotify Playlist Updater A Python script to update Spotify Playlist data every 5 minutes. Description An automatic playlist updater using Spotify API

6 Nov 24, 2022
Seems Like Everyone Is Posting This, Thought I Should Too, Tokens Get Locked Upon Creation And Im Not Going To Fix For Several Reasons

Member-Booster Seems Like Everyone Is Posting This, Thought I Should Too, Tokens Get Locked Upon Creation And Im Not Going To Fix For Several Reasons

Mintyz 1 Dec 28, 2021
Automatically updates the twitter banner with the images of 5 latest followers, using tweepy python

Auto twitter banner Automatically updates the twitter banner every few seconds with follower profile pics on it Here's how it looks! Installation git

Dhravya Shah 7 Jul 04, 2022
YuuScource - A Discord bot made with Pycord

Yuu A Discord bot made with Pycord Features Not much lol • Easy to use commands

kekda 9 Feb 17, 2022
Change the name and pfp of ur accounts, uses tokens.txt for ur tokens.

Change the name and pfp of ur accounts, uses tokens.txt for ur tokens. Also scrapes the pfps+names from a server chosen by you. For hq tokens go to discord.gg/tokenshop or t.me/praisetelegram

cChimney 36 Dec 09, 2022
An open-source Discord Nuker can be used as a self-bot or a regular bot.

How to use Double click avery.exe, and follow the prompts Features Important! Make sure to use [9] (Scrape Info) before using these, or some things ma

Exortions 3 Jul 03, 2022
This Discord bot is to give timely notifications to Students in the Lakehead CS 2021 Guild

Discord-Bot Goal of Project The purpose of this Discord bot is to give timely notifications to Students in the Lakehead CS 2021 Guild. How can I contr

8 Jan 30, 2022
A pre-attack hacker tool which aims to find out sensitives comments in HTML comment tag and to help on reconnaissance process

Find Out in Comment Find sensetive comment out in HTML ⚈ About This is a pre-attack hacker tool that searches for sensitives words in HTML comments ta

Pablo Emídio S.S 8 Dec 31, 2022
The scope of this project will be to build a data ware house on Google Cloud Platform that will help answer common business questions as well as powering dashboards

The scope of this project will be to build a data ware house on Google Cloud Platform that will help answer common business questions as well as powering dashboards.

Shweta_kumawat 2 Jan 20, 2022
search different Streaming Platforms for movie titles.

Install git clone and cd to directory install Selenium download chromedriver.exe to same directory First Run Use --setup True for the first run. Platf

34 Dec 25, 2022
A Telegram bot for Download songs in mp3 format from YouTube and Extract lyrics from Genius.com ❤️

MeudsaMusic A Telegram bot for Download songs in mp3 format from YouTube and Extract lyrics from Genius.com ❤️ Commands Reach @MedusaMusic on Telegram

Bibee 14 Oct 06, 2022
Battle Pass farming tft bot

Tft bot Bot para farmar pontos do Passe de Batalha do TFT Descrição A cada partida de tft jogada você ganha 100 pontos no passe, porém você não precis

Leonardo Gonçalves 4 Jan 27, 2022
Python Markov Chain chatbot running on Telegram

Hanasubot Hanasubot (Japanese 話すボット, talking bot) is a Python chatbot running on Telegram. The bot is based on Markov Chains so it can learn your word

12 Dec 27, 2022
An Amazon Product Scraper built using scapy module of python

Amazon Product Scraper This is an Amazon Product Scraper built using scapy module of python Features it scrape various things Product Title Product Im

Sudhanshu Jha 1 Dec 13, 2021
A youtube search telegram bot.

YouTube-Search-Bot A youtube search telegram bot. Made with Python3 (C) @FayasNoushad Copyright permission under MIT License License - https://github

Fayas Noushad 22 Nov 12, 2022
Python module and command line script client for http://urbandictionary.com

py-urbandict py-urbandict is a client for urbandictionary.com. Project page on github: https://github.com/novel/py-urbandict PyPI: https://pypi.org/pr

Roman Bogorodskiy 32 Oct 01, 2022
Scrapping malaysianpaygap & Extracting data from the Instagram posts

Scrapping malaysianpaygap & Extracting data from the posts Recently @malaysianpaygap has gotten quite famous as a platform that enables workers throug

Yudhiesh Ravindranath 65 Nov 09, 2022
Code to help me strengthen my bot army

discord-bot-manager an api to help you manage your other bots auth lazy: using the browser dev tools, capture a post call and view the Authorization h

Riley Snyder 2 Mar 18, 2022
A simple python oriented telegram bot to give out creative font style's

Font-Bot A simple python oriented telegram bot to give out creative font style's REQUIREMENTS tgcrypto pyrogram==1.2.9 Installation Fork this reposito

BL4CK H47 4 Jan 30, 2022