The compass is the essential navigation tool pointing explorers, sailors, pilots, and scientists in the right direction since the 11th century. As with any tool, there’s a catch. The compass points to the magnetic North which is not exactly aligned with geographic North. Maps are drawn in the geographic coordinate system, calculations are done geographically for weather models, but often wind observations are given magnetically. To correct for this you need to know the magnetic declination at your location. Luckily it is easy with Python!
What is Magnetic Declination?
Magnetic declination is also termed deviation and is the difference between the magnetic North and true North directions at a location. Since the Earth’s non-aligned magnetic field is not constant the magnetic declination varies both by location on the planet and with time. This makes it especially pesky when working with legacy data. There are a few different models of the Earth’s magnetic field, but commonly we use the World Magnetic Model (WMM), the International Geomagnetic Reference Field (IGRF,) or the BGS Global Geomagnetic Model (BGGM).
Finding the Declination with Python
Luckily finding the declination at a location is pretty easy! If you just have a location or two there are web calculators associated with many of the global field models, but that involves manually typing coordinates, copy and pasting results, and lots of places to induce error. Personally, I’d rather use a Python library that would make doing the calculation at many points, many times, or performing a sensitivity analysis a quick process. Looking around the ecosystem there were a few packages out there, but the one I landed on was the Magnetic Field Calculator by filips123 on GitHub. It interfaces to the three big models and had enough documentation to get going.
from magnetic_field_calculator import MagneticFieldCalculator
calculator = MagneticFieldCalculator()
result = calculator.calculate(
latitude=40.015,
longitude=254.73)
print(result['field-value']['declination'])
Checkout the short video below from Unidata demonstrating this library and a few cautions on how to use it.
So When do I need to Correct Winds?
Wind data is generally corrected to geographic North when provided in textual form. Different networks may operate differently by aligning the sensors to true North or by aligning to magnetic North and correcting the data. There are always exceptions in Earth science though! If you get raw ASOS/ATIS data from airport observation stations they are referenced to magnetic North. Some field projects may also reference their data to magnetic North due to the use of magnetometers to align their instruments. Be sure you know how the data you are using are reported as it can make significant differences in the wind direction!
How to Correct for Deviation
There is an old saying in the navigation world to remember how to do the correction “east is least, but west is best”. This means to go from true courses to magnetic courses (as one needs to do when steering a boat or aircraft using a magnetic compass) you subtract east deviations and add west variations. To go from magnetic to true it is just the opposite!
Understanding the Earth’s 3D Field
Earth’s magnetic field is really a very complex and three-dimensional structure. These 3D potential fields can be difficult to understand of visualize. Be sure to checkout our 3D Compass Kit that lets you build a compass to show the true direction of the magnetic field vector where you stand and even get quantitative data!
- GEARS 2023 Now in November! - September 5, 2023
- Unraveling RTD Sensor Mysteries: The Ultimate Guide to 2, 3, and 4 Wire Variants - June 27, 2023
- In Experts We Trust: The Importance of Trusting Fellow Experts - June 6, 2023