Magnetic variation (aka declination) for aviation navigation
Project description
The magvar module
This module provides the function
`magnetic_variation(date, latitude, longitude, elevation)`
date must be a float - the Julian date. Example: 2022.1 is in February.
latitude is in radians, positive for north, negative for south.
longitude is in radians, positive for east, negative for west.
elevation is in meters.
This returns what the geo-scientists would call 'declination' but what aviators call 'magnetic variation'.
The result is in radians, and is negative for EAST "east is least" and positive for WEST.
For example:
>>> from geomag import magnetic_variation
>>> from math import degrees, radians
>>> degrees(magnetic_variation(2022.05,
radians(25.7953611),
radians(-80.2901158),
3)
6.9474...
This shows the magnetic variation for the Miami Internation Airport (KMIA) as 6.9 degrees WEST, which matches what the sectional chart for January 2022.
Building from COF files
This distribution includes WMM2010.COF, WMM2015.COF, and WMM2020.COF.
These files were downloaded from the National Centers for Environmental Information (NCEI), formerly known as the National Geophysical Data Center (NGDC).
[NCEI](https://www.ncei.noaa.gov/products/world-magnetic-model)
The file wmm.c contains static data compiled from these .COF files.
To generate the file from scratch, use the `compile-cof' script:
$ ./compile-cof WMM2010.COF WMM2015.COF WMM2020.COF >wmm.c
This incorporates all models, so you can get the magnetic variation for any latitude and longitude from any date from January 1, 2010.
If you're tight on space, and only need the current magnetic model:
$ ./compile-cof WMM2020.COF >wmm.c
Testing the Software
The test subdirectory has test values from the NCEI.
Test the Python:
$ cd test
$ python3 test_wmm2020_test_values.py
Test the C code:
$ cd test
$ make
$ ./test_geomag
$ make clean
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file magvar-1.0.0.tar.gz.
File metadata
- Download URL: magvar-1.0.0.tar.gz
- Upload date:
- Size: 29.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfba6edabd69087e158449aea3198fdd97eb9dc205646fd9b0b5837548e682d0
|
|
| MD5 |
aefc57077cfba471ee39950ffedfac68
|
|
| BLAKE2b-256 |
fb274683c9256571715aa3be42dc5de7ca50af0ef4c47f15c0fa26a5e24f1e8a
|
File details
Details for the file magvar-1.0.0-cp313-cp313-macosx_15_0_arm64.whl.
File metadata
- Download URL: magvar-1.0.0-cp313-cp313-macosx_15_0_arm64.whl
- Upload date:
- Size: 13.2 kB
- Tags: CPython 3.13, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d392181bf015b763c417f3270ae601e63d615523cb0321a9018ad78366d9e67b
|
|
| MD5 |
af108739fd8f331a29fa0e7e309a0608
|
|
| BLAKE2b-256 |
0751f307966bdeeade0b58481a8716a14bef6e29e7d0baf01b23198ebbd4c545
|
File details
Details for the file magvar-1.0.0-cp39-cp39-macosx_10_9_universal2.whl.
File metadata
- Download URL: magvar-1.0.0-cp39-cp39-macosx_10_9_universal2.whl
- Upload date:
- Size: 18.6 kB
- Tags: CPython 3.9, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36acdfce02c3fec5142c30d3f1d0c509a628ce181f9beb8c608990644e55eca7
|
|
| MD5 |
14a1a5330679a0c7041c7970b697d0eb
|
|
| BLAKE2b-256 |
fc9db89e1601daaa48ac838f8fc14f6b1af7db1de8aa84122b3d54a143501320
|