Skip to content

Commit

Permalink
WMM2025 World Magnetic Model
Browse files Browse the repository at this point in the history
  • Loading branch information
olehz committed Dec 18, 2024
1 parent db7be2c commit 197902d
Show file tree
Hide file tree
Showing 24 changed files with 126 additions and 126 deletions.
6 changes: 3 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include src/wmm2020/meson.build src/wmm2020/CMakeLists.txt src/wmm2020/setup.cmake src/wmm2020/test_input.asc src/wmm2020/WMM.COF
recursive-include src/wmm2020/src *.c
recursive-include src/wmm2020/src *.h
include src/wmm2025/meson.build src/wmm2025/CMakeLists.txt src/wmm2025/setup.cmake src/wmm2025/test_input.asc src/wmm2025/WMM.COF
recursive-include src/wmm2025/src *.c
recursive-include src/wmm2025/src *.h
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
# WMM2020
# WMM2025

![Actions Status](https://github.com/space-physics/wmm2020/workflows/ci/badge.svg)
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/space-physics/wmm2020.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/space-physics/wmm2020/context:python)
[![Python versions (PyPI)](https://img.shields.io/pypi/pyversions/wmm2020.svg)](https://pypi.python.org/pypi/wmm2020)
[![Downloads](http://pepy.tech/badge/wmm2020)](http://pepy.tech/project/wmm2020)
![Actions Status](https://github.com/space-physics/wmm2025/workflows/ci/badge.svg)
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/space-physics/wmm2025.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/space-physics/wmm2025/context:python)
[![Python versions (PyPI)](https://img.shields.io/pypi/pyversions/wmm2025.svg)](https://pypi.python.org/pypi/wmm2025)
[![Downloads](http://pepy.tech/badge/wmm2025)](http://pepy.tech/project/wmm2025)


WMM2020 World Magnetic Model...in simple, object-oriented Python.
WMM2025 World Magnetic Model...in simple, object-oriented Python.
[WMM2015](https://github.com/space-physics/wmm2015) is also available.
Tested on Linux, Mac and Windows.
Most C compilers work.
At this time Visual Studio is not supported since MSVC doesn't export function symbols without additional headers,
which is typically done with something like SWIG.

![image](./src/wmm2020/tests/incldecl.png)
![image](./src/wmm2025/tests/incldecl.png)

## Install

for the latest release from PyPi:

```sh
python -m pip install wmm2020
python -m pip install wmm2025
```

Optionally, to get the cutting-edge development version:

```sh
git clone https://github.com/space-physics/wmm2020
git clone https://github.com/space-physics/wmm2025

python -m pip install -e wmm2020
python -m pip install -e wmm2025
```

This Python wrapper of WMM2020 uses our build-on-run technique.
The first time you use WMM2020, you will see messages from the Meson build system and your C compiler.
This Python wrapper of WMM2025 uses our build-on-run technique.
The first time you use WMM2025, you will see messages from the Meson build system and your C compiler.


## Usage

an example script

```sh
python RunWMM2020.py
python RunWMM2025.py
```

or as a Python module:

```python
import wmm2020
import wmm2025

mag = wmm2020.wmm(glat, glon, alt_km, yeardec)
mag = wmm2025.wmm(glat, glon, alt_km, yeardec)
```

## Reference

* WMM2020 [inclination map](https://www.ngdc.noaa.gov/geomag/WMM/data/WMM2020/WMM2020_I_MERC.pdf)
* WMM2020 [declination map](https://www.ngdc.noaa.gov/geomag/WMM/data/WMM2020/WMM2020_D_MERC.pdf)
* WMM2025 [inclination map](https://www.ngdc.noaa.gov/geomag/WMM/data/WMM2025/WMM2025_I_MERC.pdf)
* WMM2025 [declination map](https://www.ngdc.noaa.gov/geomag/WMM/data/WMM2025/WMM2025_D_MERC.pdf)
6 changes: 3 additions & 3 deletions RunWMM2020.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from matplotlib.pyplot import show
import argparse

import wmm2020 as wmm
import wmm2020.plots as plt
import wmm2025 as wmm
import wmm2025.plots as plt


p = argparse.ArgumentParser()
p.add_argument("yeardec", help="decimal year e.g. 2020.62", type=float)
p.add_argument("yeardec", help="decimal year e.g. 2025.62", type=float)
p.add_argument("alt_km", help="altitude (km) default: 0.", type=float, default=0.0)
P = p.parse_args()

Expand Down
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[metadata]
name = wmm2020
name = wmm2025
version = 1.1.1
author = Michael Hirsch, Ph.D.
url = https://github.com/space-physics/wmm2020
description = WMM2020 geomagnetic model with simple object-oriented Python interface
url = https://github.com/space-physics/wmm2025
description = WMM2025 geomagnetic model with simple object-oriented Python interface
keywords =
geomagnetic
classifiers =
Expand Down
93 changes: 0 additions & 93 deletions src/wmm2020/WMM.COF

This file was deleted.

1 change: 0 additions & 1 deletion src/wmm2020/test_input.asc

This file was deleted.

Binary file removed src/wmm2020/tests/incldecl.png
Binary file not shown.
2 changes: 1 addition & 1 deletion src/wmm2020/CMakeLists.txt → src/wmm2025/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ endif()
add_library(wmm20 SHARED src/wmm_point_sub.c)
target_link_libraries(wmm20 PRIVATE geo)

# https://www.ngdc.noaa.gov/geomag/WMM/data/WMM2020/WMM2020testvalues.pdf
# https://www.ngdc.noaa.gov/geomag/WMM/data/WMM2025/WMM2025testvalues.pdf
add_executable(wmm20_file src/wmm_file.c)
target_link_libraries(wmm20_file geo)

Expand Down
93 changes: 93 additions & 0 deletions src/wmm2025/WMM.COF
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
2025.0 WMM-2025 11/13/2024
1 0 -29351.8 0.0 12.0 0.0
1 1 -1410.8 4545.4 9.7 -21.5
2 0 -2556.6 0.0 -11.6 0.0
2 1 2951.1 -3133.6 -5.2 -27.7
2 2 1649.3 -815.1 -8.0 -12.1
3 0 1361.0 0.0 -1.3 0.0
3 1 -2404.1 -56.6 -4.2 4.0
3 2 1243.8 237.5 0.4 -0.3
3 3 453.6 -549.5 -15.6 -4.1
4 0 895.0 0.0 -1.6 0.0
4 1 799.5 278.6 -2.4 -1.1
4 2 55.7 -133.9 -6.0 4.1
4 3 -281.1 212.0 5.6 1.6
4 4 12.1 -375.6 -7.0 -4.4
5 0 -233.2 0.0 0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 8 0.9 -3.8 -0.1 -0.1
10 9 -2.7 0.9 -0.0 0.2
10 10 -3.9 -9.1 -0.0 -0.0
11 0 2.9 0.0 0.0 0.0
11 1 -1.5 0.0 -0.0 -0.0
11 2 -2.5 2.9 0.0 0.1
11 3 2.4 -0.6 0.0 -0.0
11 4 -0.6 0.2 0.0 0.1
11 5 -0.1 0.5 -0.1 -0.0
11 6 -0.6 -0.3 0.0 -0.0
11 7 -0.1 -1.2 -0.0 0.1
11 8 1.1 -1.7 -0.1 -0.0
11 9 -1.0 -2.9 -0.1 0.0
11 10 -0.2 -1.8 -0.1 0.0
11 11 2.6 -2.3 -0.1 0.0
12 0 -2.0 0.0 0.0 0.0
12 1 -0.2 -1.3 0.0 -0.0
12 2 0.3 0.7 -0.0 0.0
12 3 1.2 1.0 -0.0 -0.1
12 4 -1.3 -1.4 -0.0 0.1
12 5 0.6 -0.0 -0.0 -0.0
12 6 0.6 0.6 0.1 -0.0
12 7 0.5 -0.1 -0.0 -0.0
12 8 -0.1 0.8 0.0 0.0
12 9 -0.4 0.1 0.0 -0.0
12 10 -0.2 -1.0 -0.1 -0.0
12 11 -1.3 0.1 -0.0 0.0
12 12 -0.7 0.2 -0.1 -0.1
999999999999999999999999999999999999999999999999
999999999999999999999999999999999999999999999999
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/wmm2020/plots.py → src/wmm2025/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def plotwmm(mag: xarray.Dataset):

fg = figure()
ax = fg.subplots(1, 2, sharey=True)
fg.suptitle("WMM2020 {}".format(mag.time))
fg.suptitle("WMM2025 {}".format(mag.time))
h = ax[0].contour(mag.glon, mag.glat, mag.decl, range(-90, 90 + 20, 20))
ax[0].clabel(h, inline=True, fmt="%0.1f")
ax[0].set_title("Magnetic Declination [degrees]")
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* ABSTRACT
*
* The purpose of Geomagnetism Library is primarily to support the World Magnetic Model (WMM) 2015-2020.
* The purpose of Geomagnetism Library is primarily to support the World Magnetic Model (WMM) 2015-2025.
* It however is built to be used for spherical harmonic models of the Earth's magnetic field
* generally and supports models even with a large (>>12) number of degrees. It is also used in many
* other geomagnetic models distributed by NCEI.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/wmm2025/test_input.asc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2025.5 E F30000 70.3 30.8
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from pytest import approx
import xarray

import wmm2020 as wmm
import wmm2025 as wmm


def test_wmm2020():
def test_wmm2025():
mag = wmm.wmm(65, 85, alt_km=0, yeardec=2012.52868852459)

assert isinstance(mag, xarray.Dataset)
Expand All @@ -18,7 +18,7 @@ def test_wmm2020():
assert mag.decl.item() == approx(15.67178464900435)


def test_wmm2020_point():
def test_wmm2025_point():
mag = wmm.wmm_point(65, 85, alt_km=0, yeardec=2012.52868852459)
assert isinstance(mag, dict)

Expand Down

0 comments on commit 197902d

Please sign in to comment.