Magnetism Models
Earth magnetic field models and computations.
Magnetism models module.
This module provides implementations of geomagnetic field models including the World Magnetic Model (WMM), International Geomagnetic Reference Field (IGRF), and high-resolution models (EMM, WMMHR).
Examples
>>> from pytcl.magnetism import wmm, magnetic_declination
>>> import numpy as np
>>> # Magnetic field at a location
>>> result = wmm(np.radians(40), np.radians(-105), 1.0, 2023.0)
>>> print(f"Declination: {np.degrees(result.D):.2f}°")
>>> print(f"Total intensity: {result.F:.0f} nT")
>>> # Just the declination
>>> D = magnetic_declination(np.radians(40), np.radians(-105))
>>> print(f"Declination: {np.degrees(D):.2f}°")
>>> # High-resolution models (require external coefficient files)
>>> from pytcl.magnetism import emm, wmmhr, create_emm_test_coefficients
>>> # Create test coefficients for demonstration
>>> coef = create_emm_test_coefficients(n_max=36)
- class pytcl.magnetism.MagneticResult(X, Y, Z, H, F, I, D)[source]
Bases:
NamedTupleResult of magnetic field computation.
- class pytcl.magnetism.MagneticCoefficients(g, h, g_dot, h_dot, epoch, n_max)[source]
Bases:
NamedTupleSpherical harmonic coefficients for magnetic model.
- g
Main field cosine coefficients (nT).
- Type:
ndarray
- h
Main field sine coefficients (nT).
- Type:
ndarray
- g_dot
Secular variation of g (nT/year).
- Type:
ndarray
- h_dot
Secular variation of h (nT/year).
- Type:
ndarray
- class pytcl.magnetism.IGRFModel(epoch, coeffs, valid_from, valid_to)[source]
Bases:
NamedTupleIGRF model for a specific epoch.
- coeffs
Spherical harmonic coefficients.
- Type:
- coeffs: MagneticCoefficients
Alias for field number 1
- pytcl.magnetism.create_wmm2020_coefficients()[source]
Create WMM2020 model coefficients.
- Returns:
coeffs – WMM2020 spherical harmonic coefficients.
- Return type:
Examples
>>> coeffs = create_wmm2020_coefficients() >>> coeffs.epoch 2020.0 >>> coeffs.n_max 12
Notes
These are the official WMM2020 coefficients valid from 2020.0 to 2025.0. For use beyond 2025, updated coefficients should be obtained from NOAA.
- pytcl.magnetism.magnetic_field_spherical(lat, lon, r, year, coeffs=(array([[0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.94045e+04, -1.45070e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.50000e+03, 2.98200e+03, 1.67680e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [1.36390e+03, -2.38100e+03, 1.23620e+03, 5.25700e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [9.03100e+02, 8.09400e+02, 8.62000e+01, -3.09400e+02, 4.79000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.34400e+02, 3.63100e+02, 4.77000e+01, 1.87800e+02, -1.40700e+02, -1.51200e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [6.56000e+01, 6.55000e+01, -1.91000e+01, 7.30000e+01, -6.27000e+01, 6.00000e-01, -2.42000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [8.06000e+01, -7.67000e+01, -8.20000e+00, -2.66000e+01, 3.00000e+00, -1.49000e+01, 1.04000e+01, -1.83000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [2.44000e+01, 6.00000e+00, -2.00000e+00, -5.80000e+00, 1.00000e-01, 1.09000e+01, -1.30000e+00, -6.50000e+00, -2.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [5.00000e+00, 8.40000e+00, 3.00000e+00, -1.50000e+00, 1.00000e-01, -3.80000e+00, 4.30000e+00, -1.40000e+00, -2.40000e+00, -6.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-1.80000e+00, -7.00000e-01, 2.10000e+00, 2.10000e+00, -2.40000e+00, -1.80000e+00, -5.00000e-01, 6.00000e-01, 9.00000e-01, -8.00000e-01, -2.00000e-01, 0.00000e+00, 0.00000e+00], [3.00000e+00, -1.50000e+00, -2.00000e-01, -3.00000e-01, 5.00000e-01, 1.30000e+00, -1.20000e+00, 7.00000e-01, 4.00000e-01, 0.00000e+00, 6.00000e-01, -5.00000e-01, 0.00000e+00], [-2.00000e-01, -2.00000e-01, -1.00000e-01, 1.00000e-01, 5.00000e-01, 1.10000e+00, -3.00000e-01, -4.00000e-01, -3.00000e-01, 2.00000e-01, -5.00000e-01, 4.00000e-01, -2.00000e-01]]), array([[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6529e+03, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.9916e+03, -7.3480e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -8.2200e+01, 2.4180e+02, -5.4290e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.8200e+02, -1.5840e+02, 1.9980e+02, -3.5010e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6700e+01, 1.9690e+02, -1.1940e+02, 1.6000e+01, 1.0010e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -7.6700e+01, 2.5400e+01, -9.2000e+00, 5.5900e+01, -1.7000e+01, 8.4000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.0000e-01, -2.1500e+01, 1.5500e+01, 1.3800e+01, -1.3500e+01, -1.0000e-01, 8.8000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0400e+01, 1.3400e+01, 1.2100e+01, -6.4000e+00, -8.4000e+00, 8.6000e+00, 2.2000e+00, -7.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 9.0000e-01, -1.4000e+00, 3.8000e+00, -5.3000e+00, -3.0000e-01, 4.0000e-01, 1.7000e+00, -9.0000e-01, 4.6000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 8.0000e-01, -4.0000e-01, -2.0000e-01, 7.0000e-01, 3.0000e-01, 2.2000e+00, -2.5000e+00, 5.0000e-01, 6.0000e-01, -4.0000e-01, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0000e-01, 4.0000e-01, 5.0000e-01, 4.0000e-01, -6.0000e-01, 3.0000e-01, 0.0000e+00, -4.0000e-01, 1.0000e-01, -3.0000e-01, -3.0000e-01, 0.0000e+00], [0.0000e+00, 1.0000e-01, 5.0000e-01, 0.0000e+00, -2.0000e-01, 3.0000e-01, -4.0000e-01, 3.0000e-01, 3.0000e-01, -1.0000e-01, -1.0000e-01, -1.0000e-01, -2.0000e-01]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [6.7, 7.7, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-11.5, -7.1, -2.2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [2.8, -6.2, 3.4, -12.2, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-1.1, -1.6, -6., 5.4, -5.5, 0., 0., 0., 0., 0., 0., 0., 0.], [-0.3, 0.1, -0.6, 0.2, 0.3, 1., 0., 0., 0., 0., 0., 0., 0.], [-0.6, -0.4, 0.5, 1.4, -1.4, 0., 0.8, 0., 0., 0., 0., 0., 0.], [-0.1, -0.3, 0.3, 0.2, -0.5, 0.2, -0.2, 0.6, 0., 0., 0., 0., 0.], [0., 0., 0.1, -0.2, 0.4, 0.3, 0., 0.1, -0.1, 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -25.1, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -30.2, -23.9, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 5.7, -1., 1.1, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0.2, 6.4, 3.1, -12., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -0.4, 2.1, 3.4, -0.9, -1.2, 0., 0., 0., 0., 0., 0., 0.], [0., -0.2, -0.9, 0.3, 0.1, -0.1, 0.4, 0., 0., 0., 0., 0., 0.], [0., -0.5, 0.4, 0.1, 0.4, -0.2, 0.4, 0.3, 0., 0., 0., 0., 0.], [0., 0.1, -0.1, 0.3, 0., 0.2, -0.1, -0.1, 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), 2020.0, 12), use_cache=True)[source]
Compute magnetic field in spherical coordinates.
- Parameters:
lat (float) – Geocentric latitude in radians.
lon (float) – Longitude in radians.
r (float) – Radial distance from Earth’s center in km.
year (float) – Decimal year (e.g., 2023.5 for mid-2023).
coeffs (MagneticCoefficients, optional) – Model coefficients. Default WMM2020.
use_cache (bool, optional) – Whether to use LRU caching for repeated queries. Default True. Set to False for single-use queries or when memory is constrained.
- Returns:
B_r (float) – Radial component (positive outward) in nT.
B_theta (float) – Colatitude component (positive southward) in nT.
B_phi (float) – Longitude component (positive eastward) in nT.
- Return type:
Notes
Results are cached by default using LRU caching. Inputs are quantized to a configurable precision before caching to improve hit rates for nearby queries. Use get_magnetic_cache_info() to check cache statistics and clear_magnetic_cache() to free memory.
Examples
>>> import numpy as np >>> from pytcl.magnetism import magnetic_field_spherical >>> # Compute at Earth's surface (40°N, 105°W, sea level) >>> lat = np.radians(40) >>> lon = np.radians(-105) >>> r = 6371.2 # Earth mean radius in km >>> B_r, B_theta, B_phi = magnetic_field_spherical(lat, lon, r, 2023.0) >>> # All components should be on order of tens to tens of thousands of nT >>> 20000 < (B_r**2 + B_theta**2 + B_phi**2)**0.5 < 70000 True
- pytcl.magnetism.wmm(lat, lon, h=0.0, year=2023.0, coeffs=(array([[0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.94045e+04, -1.45070e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.50000e+03, 2.98200e+03, 1.67680e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [1.36390e+03, -2.38100e+03, 1.23620e+03, 5.25700e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [9.03100e+02, 8.09400e+02, 8.62000e+01, -3.09400e+02, 4.79000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.34400e+02, 3.63100e+02, 4.77000e+01, 1.87800e+02, -1.40700e+02, -1.51200e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [6.56000e+01, 6.55000e+01, -1.91000e+01, 7.30000e+01, -6.27000e+01, 6.00000e-01, -2.42000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [8.06000e+01, -7.67000e+01, -8.20000e+00, -2.66000e+01, 3.00000e+00, -1.49000e+01, 1.04000e+01, -1.83000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [2.44000e+01, 6.00000e+00, -2.00000e+00, -5.80000e+00, 1.00000e-01, 1.09000e+01, -1.30000e+00, -6.50000e+00, -2.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [5.00000e+00, 8.40000e+00, 3.00000e+00, -1.50000e+00, 1.00000e-01, -3.80000e+00, 4.30000e+00, -1.40000e+00, -2.40000e+00, -6.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-1.80000e+00, -7.00000e-01, 2.10000e+00, 2.10000e+00, -2.40000e+00, -1.80000e+00, -5.00000e-01, 6.00000e-01, 9.00000e-01, -8.00000e-01, -2.00000e-01, 0.00000e+00, 0.00000e+00], [3.00000e+00, -1.50000e+00, -2.00000e-01, -3.00000e-01, 5.00000e-01, 1.30000e+00, -1.20000e+00, 7.00000e-01, 4.00000e-01, 0.00000e+00, 6.00000e-01, -5.00000e-01, 0.00000e+00], [-2.00000e-01, -2.00000e-01, -1.00000e-01, 1.00000e-01, 5.00000e-01, 1.10000e+00, -3.00000e-01, -4.00000e-01, -3.00000e-01, 2.00000e-01, -5.00000e-01, 4.00000e-01, -2.00000e-01]]), array([[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6529e+03, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.9916e+03, -7.3480e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -8.2200e+01, 2.4180e+02, -5.4290e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.8200e+02, -1.5840e+02, 1.9980e+02, -3.5010e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6700e+01, 1.9690e+02, -1.1940e+02, 1.6000e+01, 1.0010e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -7.6700e+01, 2.5400e+01, -9.2000e+00, 5.5900e+01, -1.7000e+01, 8.4000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.0000e-01, -2.1500e+01, 1.5500e+01, 1.3800e+01, -1.3500e+01, -1.0000e-01, 8.8000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0400e+01, 1.3400e+01, 1.2100e+01, -6.4000e+00, -8.4000e+00, 8.6000e+00, 2.2000e+00, -7.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 9.0000e-01, -1.4000e+00, 3.8000e+00, -5.3000e+00, -3.0000e-01, 4.0000e-01, 1.7000e+00, -9.0000e-01, 4.6000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 8.0000e-01, -4.0000e-01, -2.0000e-01, 7.0000e-01, 3.0000e-01, 2.2000e+00, -2.5000e+00, 5.0000e-01, 6.0000e-01, -4.0000e-01, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0000e-01, 4.0000e-01, 5.0000e-01, 4.0000e-01, -6.0000e-01, 3.0000e-01, 0.0000e+00, -4.0000e-01, 1.0000e-01, -3.0000e-01, -3.0000e-01, 0.0000e+00], [0.0000e+00, 1.0000e-01, 5.0000e-01, 0.0000e+00, -2.0000e-01, 3.0000e-01, -4.0000e-01, 3.0000e-01, 3.0000e-01, -1.0000e-01, -1.0000e-01, -1.0000e-01, -2.0000e-01]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [6.7, 7.7, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-11.5, -7.1, -2.2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [2.8, -6.2, 3.4, -12.2, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-1.1, -1.6, -6., 5.4, -5.5, 0., 0., 0., 0., 0., 0., 0., 0.], [-0.3, 0.1, -0.6, 0.2, 0.3, 1., 0., 0., 0., 0., 0., 0., 0.], [-0.6, -0.4, 0.5, 1.4, -1.4, 0., 0.8, 0., 0., 0., 0., 0., 0.], [-0.1, -0.3, 0.3, 0.2, -0.5, 0.2, -0.2, 0.6, 0., 0., 0., 0., 0.], [0., 0., 0.1, -0.2, 0.4, 0.3, 0., 0.1, -0.1, 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -25.1, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -30.2, -23.9, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 5.7, -1., 1.1, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0.2, 6.4, 3.1, -12., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -0.4, 2.1, 3.4, -0.9, -1.2, 0., 0., 0., 0., 0., 0., 0.], [0., -0.2, -0.9, 0.3, 0.1, -0.1, 0.4, 0., 0., 0., 0., 0., 0.], [0., -0.5, 0.4, 0.1, 0.4, -0.2, 0.4, 0.3, 0., 0., 0., 0., 0.], [0., 0.1, -0.1, 0.3, 0., 0.2, -0.1, -0.1, 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), 2020.0, 12))[source]
Compute magnetic field using World Magnetic Model.
- Parameters:
lat (float) – Geodetic latitude in radians.
lon (float) – Longitude in radians.
h (float, optional) – Height above WGS84 ellipsoid in km. Default 0.
year (float, optional) – Decimal year. Default 2023.0.
coeffs (MagneticCoefficients, optional) – Model coefficients. Default WMM2020.
- Returns:
result – Magnetic field components and derived quantities.
- Return type:
Examples
>>> import numpy as np >>> result = wmm(np.radians(40), np.radians(-105), 1.0, 2023.0) >>> print(f"Declination: {np.degrees(result.D):.2f}°") >>> print(f"Inclination: {np.degrees(result.I):.2f}°") >>> print(f"Total intensity: {result.F:.0f} nT")
- pytcl.magnetism.magnetic_declination(lat, lon, h=0.0, year=2023.0, coeffs=(array([[0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.94045e+04, -1.45070e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.50000e+03, 2.98200e+03, 1.67680e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [1.36390e+03, -2.38100e+03, 1.23620e+03, 5.25700e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [9.03100e+02, 8.09400e+02, 8.62000e+01, -3.09400e+02, 4.79000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.34400e+02, 3.63100e+02, 4.77000e+01, 1.87800e+02, -1.40700e+02, -1.51200e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [6.56000e+01, 6.55000e+01, -1.91000e+01, 7.30000e+01, -6.27000e+01, 6.00000e-01, -2.42000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [8.06000e+01, -7.67000e+01, -8.20000e+00, -2.66000e+01, 3.00000e+00, -1.49000e+01, 1.04000e+01, -1.83000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [2.44000e+01, 6.00000e+00, -2.00000e+00, -5.80000e+00, 1.00000e-01, 1.09000e+01, -1.30000e+00, -6.50000e+00, -2.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [5.00000e+00, 8.40000e+00, 3.00000e+00, -1.50000e+00, 1.00000e-01, -3.80000e+00, 4.30000e+00, -1.40000e+00, -2.40000e+00, -6.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-1.80000e+00, -7.00000e-01, 2.10000e+00, 2.10000e+00, -2.40000e+00, -1.80000e+00, -5.00000e-01, 6.00000e-01, 9.00000e-01, -8.00000e-01, -2.00000e-01, 0.00000e+00, 0.00000e+00], [3.00000e+00, -1.50000e+00, -2.00000e-01, -3.00000e-01, 5.00000e-01, 1.30000e+00, -1.20000e+00, 7.00000e-01, 4.00000e-01, 0.00000e+00, 6.00000e-01, -5.00000e-01, 0.00000e+00], [-2.00000e-01, -2.00000e-01, -1.00000e-01, 1.00000e-01, 5.00000e-01, 1.10000e+00, -3.00000e-01, -4.00000e-01, -3.00000e-01, 2.00000e-01, -5.00000e-01, 4.00000e-01, -2.00000e-01]]), array([[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6529e+03, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.9916e+03, -7.3480e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -8.2200e+01, 2.4180e+02, -5.4290e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.8200e+02, -1.5840e+02, 1.9980e+02, -3.5010e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6700e+01, 1.9690e+02, -1.1940e+02, 1.6000e+01, 1.0010e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -7.6700e+01, 2.5400e+01, -9.2000e+00, 5.5900e+01, -1.7000e+01, 8.4000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.0000e-01, -2.1500e+01, 1.5500e+01, 1.3800e+01, -1.3500e+01, -1.0000e-01, 8.8000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0400e+01, 1.3400e+01, 1.2100e+01, -6.4000e+00, -8.4000e+00, 8.6000e+00, 2.2000e+00, -7.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 9.0000e-01, -1.4000e+00, 3.8000e+00, -5.3000e+00, -3.0000e-01, 4.0000e-01, 1.7000e+00, -9.0000e-01, 4.6000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 8.0000e-01, -4.0000e-01, -2.0000e-01, 7.0000e-01, 3.0000e-01, 2.2000e+00, -2.5000e+00, 5.0000e-01, 6.0000e-01, -4.0000e-01, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0000e-01, 4.0000e-01, 5.0000e-01, 4.0000e-01, -6.0000e-01, 3.0000e-01, 0.0000e+00, -4.0000e-01, 1.0000e-01, -3.0000e-01, -3.0000e-01, 0.0000e+00], [0.0000e+00, 1.0000e-01, 5.0000e-01, 0.0000e+00, -2.0000e-01, 3.0000e-01, -4.0000e-01, 3.0000e-01, 3.0000e-01, -1.0000e-01, -1.0000e-01, -1.0000e-01, -2.0000e-01]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [6.7, 7.7, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-11.5, -7.1, -2.2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [2.8, -6.2, 3.4, -12.2, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-1.1, -1.6, -6., 5.4, -5.5, 0., 0., 0., 0., 0., 0., 0., 0.], [-0.3, 0.1, -0.6, 0.2, 0.3, 1., 0., 0., 0., 0., 0., 0., 0.], [-0.6, -0.4, 0.5, 1.4, -1.4, 0., 0.8, 0., 0., 0., 0., 0., 0.], [-0.1, -0.3, 0.3, 0.2, -0.5, 0.2, -0.2, 0.6, 0., 0., 0., 0., 0.], [0., 0., 0.1, -0.2, 0.4, 0.3, 0., 0.1, -0.1, 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -25.1, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -30.2, -23.9, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 5.7, -1., 1.1, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0.2, 6.4, 3.1, -12., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -0.4, 2.1, 3.4, -0.9, -1.2, 0., 0., 0., 0., 0., 0., 0.], [0., -0.2, -0.9, 0.3, 0.1, -0.1, 0.4, 0., 0., 0., 0., 0., 0.], [0., -0.5, 0.4, 0.1, 0.4, -0.2, 0.4, 0.3, 0., 0., 0., 0., 0.], [0., 0.1, -0.1, 0.3, 0., 0.2, -0.1, -0.1, 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), 2020.0, 12))[source]
Compute magnetic declination (variation).
- Parameters:
lat (float) – Geodetic latitude in radians.
lon (float) – Longitude in radians.
h (float, optional) – Height above ellipsoid in km. Default 0.
year (float, optional) – Decimal year. Default 2023.0.
coeffs (MagneticCoefficients, optional) – Model coefficients.
- Returns:
D – Magnetic declination in radians. Positive = east of true north. Negative = west of true north.
- Return type:
Examples
>>> import numpy as np >>> # Declination in Denver, CO >>> D = magnetic_declination(np.radians(39.7), np.radians(-105.0)) >>> print(f"Declination: {np.degrees(D):.1f}°")
- pytcl.magnetism.magnetic_inclination(lat, lon, h=0.0, year=2023.0, coeffs=(array([[0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.94045e+04, -1.45070e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.50000e+03, 2.98200e+03, 1.67680e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [1.36390e+03, -2.38100e+03, 1.23620e+03, 5.25700e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [9.03100e+02, 8.09400e+02, 8.62000e+01, -3.09400e+02, 4.79000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.34400e+02, 3.63100e+02, 4.77000e+01, 1.87800e+02, -1.40700e+02, -1.51200e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [6.56000e+01, 6.55000e+01, -1.91000e+01, 7.30000e+01, -6.27000e+01, 6.00000e-01, -2.42000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [8.06000e+01, -7.67000e+01, -8.20000e+00, -2.66000e+01, 3.00000e+00, -1.49000e+01, 1.04000e+01, -1.83000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [2.44000e+01, 6.00000e+00, -2.00000e+00, -5.80000e+00, 1.00000e-01, 1.09000e+01, -1.30000e+00, -6.50000e+00, -2.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [5.00000e+00, 8.40000e+00, 3.00000e+00, -1.50000e+00, 1.00000e-01, -3.80000e+00, 4.30000e+00, -1.40000e+00, -2.40000e+00, -6.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-1.80000e+00, -7.00000e-01, 2.10000e+00, 2.10000e+00, -2.40000e+00, -1.80000e+00, -5.00000e-01, 6.00000e-01, 9.00000e-01, -8.00000e-01, -2.00000e-01, 0.00000e+00, 0.00000e+00], [3.00000e+00, -1.50000e+00, -2.00000e-01, -3.00000e-01, 5.00000e-01, 1.30000e+00, -1.20000e+00, 7.00000e-01, 4.00000e-01, 0.00000e+00, 6.00000e-01, -5.00000e-01, 0.00000e+00], [-2.00000e-01, -2.00000e-01, -1.00000e-01, 1.00000e-01, 5.00000e-01, 1.10000e+00, -3.00000e-01, -4.00000e-01, -3.00000e-01, 2.00000e-01, -5.00000e-01, 4.00000e-01, -2.00000e-01]]), array([[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6529e+03, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.9916e+03, -7.3480e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -8.2200e+01, 2.4180e+02, -5.4290e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.8200e+02, -1.5840e+02, 1.9980e+02, -3.5010e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6700e+01, 1.9690e+02, -1.1940e+02, 1.6000e+01, 1.0010e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -7.6700e+01, 2.5400e+01, -9.2000e+00, 5.5900e+01, -1.7000e+01, 8.4000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.0000e-01, -2.1500e+01, 1.5500e+01, 1.3800e+01, -1.3500e+01, -1.0000e-01, 8.8000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0400e+01, 1.3400e+01, 1.2100e+01, -6.4000e+00, -8.4000e+00, 8.6000e+00, 2.2000e+00, -7.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 9.0000e-01, -1.4000e+00, 3.8000e+00, -5.3000e+00, -3.0000e-01, 4.0000e-01, 1.7000e+00, -9.0000e-01, 4.6000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 8.0000e-01, -4.0000e-01, -2.0000e-01, 7.0000e-01, 3.0000e-01, 2.2000e+00, -2.5000e+00, 5.0000e-01, 6.0000e-01, -4.0000e-01, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0000e-01, 4.0000e-01, 5.0000e-01, 4.0000e-01, -6.0000e-01, 3.0000e-01, 0.0000e+00, -4.0000e-01, 1.0000e-01, -3.0000e-01, -3.0000e-01, 0.0000e+00], [0.0000e+00, 1.0000e-01, 5.0000e-01, 0.0000e+00, -2.0000e-01, 3.0000e-01, -4.0000e-01, 3.0000e-01, 3.0000e-01, -1.0000e-01, -1.0000e-01, -1.0000e-01, -2.0000e-01]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [6.7, 7.7, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-11.5, -7.1, -2.2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [2.8, -6.2, 3.4, -12.2, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-1.1, -1.6, -6., 5.4, -5.5, 0., 0., 0., 0., 0., 0., 0., 0.], [-0.3, 0.1, -0.6, 0.2, 0.3, 1., 0., 0., 0., 0., 0., 0., 0.], [-0.6, -0.4, 0.5, 1.4, -1.4, 0., 0.8, 0., 0., 0., 0., 0., 0.], [-0.1, -0.3, 0.3, 0.2, -0.5, 0.2, -0.2, 0.6, 0., 0., 0., 0., 0.], [0., 0., 0.1, -0.2, 0.4, 0.3, 0., 0.1, -0.1, 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -25.1, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -30.2, -23.9, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 5.7, -1., 1.1, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0.2, 6.4, 3.1, -12., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -0.4, 2.1, 3.4, -0.9, -1.2, 0., 0., 0., 0., 0., 0., 0.], [0., -0.2, -0.9, 0.3, 0.1, -0.1, 0.4, 0., 0., 0., 0., 0., 0.], [0., -0.5, 0.4, 0.1, 0.4, -0.2, 0.4, 0.3, 0., 0., 0., 0., 0.], [0., 0.1, -0.1, 0.3, 0., 0.2, -0.1, -0.1, 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), 2020.0, 12))[source]
Compute magnetic inclination (dip angle).
- Parameters:
lat (float) – Geodetic latitude in radians.
lon (float) – Longitude in radians.
h (float, optional) – Height above ellipsoid in km. Default 0.
year (float, optional) – Decimal year. Default 2023.0.
coeffs (MagneticCoefficients, optional) – Model coefficients.
- Returns:
I – Magnetic inclination in radians. Positive = field points into Earth (Northern hemisphere). Negative = field points out of Earth (Southern hemisphere).
- Return type:
Examples
>>> import numpy as np >>> from pytcl.magnetism import magnetic_inclination >>> # Inclination at 40°N, 105°W (Denver) >>> lat = np.radians(40) >>> lon = np.radians(-105) >>> I = magnetic_inclination(lat, lon, 1.6, 2023.0) >>> # Northern hemisphere: inclination should be positive >>> I > 0 True >>> # Typical values in US are 50-70 degrees >>> 0.8 < I < 1.3 # ~46-74 degrees True
- pytcl.magnetism.magnetic_field_intensity(lat, lon, h=0.0, year=2023.0, coeffs=(array([[0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.94045e+04, -1.45070e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.50000e+03, 2.98200e+03, 1.67680e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [1.36390e+03, -2.38100e+03, 1.23620e+03, 5.25700e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [9.03100e+02, 8.09400e+02, 8.62000e+01, -3.09400e+02, 4.79000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.34400e+02, 3.63100e+02, 4.77000e+01, 1.87800e+02, -1.40700e+02, -1.51200e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [6.56000e+01, 6.55000e+01, -1.91000e+01, 7.30000e+01, -6.27000e+01, 6.00000e-01, -2.42000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [8.06000e+01, -7.67000e+01, -8.20000e+00, -2.66000e+01, 3.00000e+00, -1.49000e+01, 1.04000e+01, -1.83000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [2.44000e+01, 6.00000e+00, -2.00000e+00, -5.80000e+00, 1.00000e-01, 1.09000e+01, -1.30000e+00, -6.50000e+00, -2.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [5.00000e+00, 8.40000e+00, 3.00000e+00, -1.50000e+00, 1.00000e-01, -3.80000e+00, 4.30000e+00, -1.40000e+00, -2.40000e+00, -6.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-1.80000e+00, -7.00000e-01, 2.10000e+00, 2.10000e+00, -2.40000e+00, -1.80000e+00, -5.00000e-01, 6.00000e-01, 9.00000e-01, -8.00000e-01, -2.00000e-01, 0.00000e+00, 0.00000e+00], [3.00000e+00, -1.50000e+00, -2.00000e-01, -3.00000e-01, 5.00000e-01, 1.30000e+00, -1.20000e+00, 7.00000e-01, 4.00000e-01, 0.00000e+00, 6.00000e-01, -5.00000e-01, 0.00000e+00], [-2.00000e-01, -2.00000e-01, -1.00000e-01, 1.00000e-01, 5.00000e-01, 1.10000e+00, -3.00000e-01, -4.00000e-01, -3.00000e-01, 2.00000e-01, -5.00000e-01, 4.00000e-01, -2.00000e-01]]), array([[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6529e+03, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.9916e+03, -7.3480e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -8.2200e+01, 2.4180e+02, -5.4290e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.8200e+02, -1.5840e+02, 1.9980e+02, -3.5010e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6700e+01, 1.9690e+02, -1.1940e+02, 1.6000e+01, 1.0010e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -7.6700e+01, 2.5400e+01, -9.2000e+00, 5.5900e+01, -1.7000e+01, 8.4000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.0000e-01, -2.1500e+01, 1.5500e+01, 1.3800e+01, -1.3500e+01, -1.0000e-01, 8.8000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0400e+01, 1.3400e+01, 1.2100e+01, -6.4000e+00, -8.4000e+00, 8.6000e+00, 2.2000e+00, -7.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 9.0000e-01, -1.4000e+00, 3.8000e+00, -5.3000e+00, -3.0000e-01, 4.0000e-01, 1.7000e+00, -9.0000e-01, 4.6000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 8.0000e-01, -4.0000e-01, -2.0000e-01, 7.0000e-01, 3.0000e-01, 2.2000e+00, -2.5000e+00, 5.0000e-01, 6.0000e-01, -4.0000e-01, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0000e-01, 4.0000e-01, 5.0000e-01, 4.0000e-01, -6.0000e-01, 3.0000e-01, 0.0000e+00, -4.0000e-01, 1.0000e-01, -3.0000e-01, -3.0000e-01, 0.0000e+00], [0.0000e+00, 1.0000e-01, 5.0000e-01, 0.0000e+00, -2.0000e-01, 3.0000e-01, -4.0000e-01, 3.0000e-01, 3.0000e-01, -1.0000e-01, -1.0000e-01, -1.0000e-01, -2.0000e-01]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [6.7, 7.7, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-11.5, -7.1, -2.2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [2.8, -6.2, 3.4, -12.2, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-1.1, -1.6, -6., 5.4, -5.5, 0., 0., 0., 0., 0., 0., 0., 0.], [-0.3, 0.1, -0.6, 0.2, 0.3, 1., 0., 0., 0., 0., 0., 0., 0.], [-0.6, -0.4, 0.5, 1.4, -1.4, 0., 0.8, 0., 0., 0., 0., 0., 0.], [-0.1, -0.3, 0.3, 0.2, -0.5, 0.2, -0.2, 0.6, 0., 0., 0., 0., 0.], [0., 0., 0.1, -0.2, 0.4, 0.3, 0., 0.1, -0.1, 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -25.1, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -30.2, -23.9, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 5.7, -1., 1.1, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0.2, 6.4, 3.1, -12., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -0.4, 2.1, 3.4, -0.9, -1.2, 0., 0., 0., 0., 0., 0., 0.], [0., -0.2, -0.9, 0.3, 0.1, -0.1, 0.4, 0., 0., 0., 0., 0., 0.], [0., -0.5, 0.4, 0.1, 0.4, -0.2, 0.4, 0.3, 0., 0., 0., 0., 0.], [0., 0.1, -0.1, 0.3, 0., 0.2, -0.1, -0.1, 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), 2020.0, 12))[source]
Compute total magnetic field intensity.
- Parameters:
lat (float) – Geodetic latitude in radians.
lon (float) – Longitude in radians.
h (float, optional) – Height above ellipsoid in km. Default 0.
year (float, optional) – Decimal year. Default 2023.0.
coeffs (MagneticCoefficients, optional) – Model coefficients.
- Returns:
F – Total magnetic field intensity in nT.
- Return type:
Examples
>>> import numpy as np >>> from pytcl.magnetism import magnetic_field_intensity >>> # Field intensity at magnetic equator vs pole >>> F_eq = magnetic_field_intensity(0, 0, 0, 2023.0) # Equator >>> F_pole = magnetic_field_intensity(np.radians(80), 0, 0, 2023.0) # Near pole >>> # Field is stronger at poles >>> F_pole > F_eq True >>> # Typical Earth field is 25,000 to 65,000 nT >>> 25000 < F_eq < 35000 # Equatorial field is weaker True >>> 55000 < F_pole < 65000 # Polar field is stronger True
- pytcl.magnetism.get_magnetic_cache_info()[source]
Get information about the magnetic field computation cache.
- Returns:
info – Dictionary containing cache statistics: - hits: Number of cache hits - misses: Number of cache misses - maxsize: Maximum cache size - currsize: Current number of cached entries - hit_rate: Ratio of hits to total calls (0-1)
- Return type:
Examples
>>> from pytcl.magnetism import get_magnetic_cache_info >>> info = get_magnetic_cache_info() >>> print(f"Cache hit rate: {info['hit_rate']:.1%}")
- pytcl.magnetism.clear_magnetic_cache()[source]
Clear the magnetic field computation cache.
This can be useful when memory is constrained or when switching between different coefficient sets.
Examples
>>> from pytcl.magnetism import clear_magnetic_cache >>> clear_magnetic_cache() # Free cached computations
- pytcl.magnetism.configure_magnetic_cache(maxsize=None, precision=None)[source]
Configure the magnetic field computation cache.
- Parameters:
Notes
Changing cache configuration clears the existing cache.
Examples
>>> from pytcl.magnetism import configure_magnetic_cache >>> # Increase cache size for batch processing >>> configure_magnetic_cache(maxsize=4096) >>> # Reduce precision for more cache hits >>> configure_magnetic_cache(precision={'lat': 4, 'lon': 4, 'r': 2, 'year': 1})
- pytcl.magnetism.create_igrf13_coefficients()[source]
Create IGRF-13 model coefficients for epoch 2020.
- Returns:
coeffs – IGRF-13 spherical harmonic coefficients.
- Return type:
Examples
>>> coeffs = create_igrf13_coefficients() >>> coeffs.epoch 2020.0 >>> coeffs.n_max 13
Notes
IGRF-13 is valid from 1900.0 to 2025.0. This function returns the coefficients for the 2020.0 epoch. For other epochs, the coefficients should be interpolated.
- pytcl.magnetism.igrf(lat, lon, h=0.0, year=2023.0, coeffs=None)[source]
Compute magnetic field using IGRF model.
- Parameters:
lat (float) – Geodetic latitude in radians.
lon (float) – Longitude in radians.
h (float, optional) – Height above WGS84 ellipsoid in km. Default 0.
year (float, optional) – Decimal year. Default 2023.0.
coeffs (MagneticCoefficients, optional) – Model coefficients. Default IGRF13.
- Returns:
result – Magnetic field components and derived quantities.
- Return type:
Examples
>>> import numpy as np >>> result = igrf(np.radians(45), np.radians(-75), 0, 2023.0) >>> print(f"Total field: {result.F:.0f} nT")
- pytcl.magnetism.igrf_declination(lat, lon, h=0.0, year=2023.0)[source]
Compute magnetic declination using IGRF.
- Parameters:
- Returns:
D – Declination in radians.
- Return type:
Examples
>>> import numpy as np >>> from pytcl.magnetism import igrf_declination >>> # Declination at Denver (40°N, 105°W) >>> lat = np.radians(40) >>> lon = np.radians(-105) >>> D = igrf_declination(lat, lon, 1.6, 2023.0) >>> # Eastern US has westerly declination (~10-20° W) >>> -0.35 < D < 0 # West is negative True
- pytcl.magnetism.igrf_inclination(lat, lon, h=0.0, year=2023.0)[source]
Compute magnetic inclination using IGRF.
- Parameters:
- Returns:
I – Inclination in radians.
- Return type:
Examples
>>> import numpy as np >>> from pytcl.magnetism import igrf_inclination >>> # Inclination comparison: equator vs pole >>> I_eq = igrf_inclination(0, 0, 0, 2023.0) # Equator >>> I_pole = igrf_inclination(np.radians(85), 0, 0, 2023.0) # Near pole >>> # At equator, inclination is ~0; at poles it's ~90 degrees >>> abs(I_eq) < 0.2 # ~11 degrees True >>> abs(I_pole) > 1.4 # ~80 degrees True
- pytcl.magnetism.dipole_moment(coeffs=(array([[0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.94048e+04, -1.45090e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.49960e+03, 2.98200e+03, 1.67700e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [1.36320e+03, -2.38120e+03, 1.23620e+03, 5.25700e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [9.03000e+02, 8.09500e+02, 8.63000e+01, -3.09400e+02, 4.80000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.34300e+02, 3.63200e+02, 4.77000e+01, 1.87800e+02, -1.40700e+02, -1.51200e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [6.60000e+01, 6.55000e+01, -1.91000e+01, 7.29000e+01, -6.26000e+01, 6.00000e-01, -2.42000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [8.04000e+01, -7.66000e+01, -8.20000e+00, -2.66000e+01, 3.00000e+00, -1.49000e+01, 1.04000e+01, -1.83000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [2.42000e+01, 5.80000e+00, -2.00000e+00, -5.80000e+00, 1.00000e-01, 1.10000e+01, -1.40000e+00, -6.50000e+00, -2.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [5.00000e+00, 8.40000e+00, 3.00000e+00, -1.50000e+00, 1.00000e-01, -3.80000e+00, 4.30000e+00, -1.40000e+00, -2.40000e+00, -6.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-1.80000e+00, -7.00000e-01, 2.10000e+00, 2.10000e+00, -2.40000e+00, -1.80000e+00, -5.00000e-01, 6.00000e-01, 9.00000e-01, -8.00000e-01, -2.00000e-01, 0.00000e+00, 0.00000e+00, 0.00000e+00], [3.00000e+00, -1.50000e+00, -2.00000e-01, -3.00000e-01, 5.00000e-01, 1.30000e+00, -1.20000e+00, 7.00000e-01, 4.00000e-01, 0.00000e+00, 6.00000e-01, -5.00000e-01, 0.00000e+00, 0.00000e+00], [-2.00000e-01, -2.00000e-01, -1.00000e-01, 1.00000e-01, 5.00000e-01, 1.00000e+00, -3.00000e-01, -4.00000e-01, -3.00000e-01, 2.00000e-01, -5.00000e-01, 4.00000e-01, -2.00000e-01, 0.00000e+00], [-1.00000e-01, -2.00000e-01, 1.00000e-01, 1.00000e-01, 0.00000e+00, 0.00000e+00, 1.00000e-01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00]]), array([[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6525e+03, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.9916e+03, -7.3460e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -8.2100e+01, 2.4190e+02, -5.4340e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.8190e+02, -1.5840e+02, 1.9970e+02, -3.4970e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6900e+01, 1.9690e+02, -1.1930e+02, 1.6000e+01, 1.0020e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -7.6700e+01, 2.5400e+01, -9.2000e+00, 5.5800e+01, -1.7000e+01, 8.4000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.0000e-01, -2.1500e+01, 1.5400e+01, 1.3800e+01, -1.3500e+01, -1.0000e-01, 8.9000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0300e+01, 1.3400e+01, 1.2000e+01, -6.4000e+00, -8.5000e+00, 8.5000e+00, 2.2000e+00, -7.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 9.0000e-01, -1.4000e+00, 3.7000e+00, -5.3000e+00, -3.0000e-01, 4.0000e-01, 1.7000e+00, -9.0000e-01, 4.6000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 8.0000e-01, -4.0000e-01, -2.0000e-01, 7.0000e-01, 3.0000e-01, 2.2000e+00, -2.5000e+00, 5.0000e-01, 6.0000e-01, -4.0000e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0000e-01, 4.0000e-01, 5.0000e-01, 4.0000e-01, -6.0000e-01, 3.0000e-01, 0.0000e+00, -4.0000e-01, 1.0000e-01, -3.0000e-01, -3.0000e-01, 0.0000e+00, 0.0000e+00], [0.0000e+00, 1.0000e-01, 5.0000e-01, 0.0000e+00, -2.0000e-01, 3.0000e-01, -4.0000e-01, 3.0000e-01, 3.0000e-01, -1.0000e-01, -1.0000e-01, -1.0000e-01, -2.0000e-01, 0.0000e+00], [0.0000e+00, 1.0000e-01, 0.0000e+00, 0.0000e+00, 1.0000e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [6.7, 7.7, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-11.5, -7.1, -2.2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [2.8, -6.2, 3.4, -12.2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-1.1, -1.6, -6., 5.4, -5.5, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-0.3, 0.1, -0.6, 0.2, 0.3, 1., 0., 0., 0., 0., 0., 0., 0., 0.], [-0.6, -0.4, 0.5, 1.4, -1.4, 0., 0.8, 0., 0., 0., 0., 0., 0., 0.], [-0.1, -0.3, 0.3, 0.2, -0.5, 0.2, -0.2, 0.6, 0., 0., 0., 0., 0., 0.], [0., 0., 0.1, -0.2, 0.4, 0.3, 0., 0.1, -0.1, 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -25.1, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -30.2, -23.9, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 6., -1.1, 1.1, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0.2, 6.4, 3.1, -12., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -0.4, 2.1, 3.4, -0.9, -1.2, 0., 0., 0., 0., 0., 0., 0., 0.], [0., -0.2, -0.9, 0.3, 0.1, -0.1, 0.4, 0., 0., 0., 0., 0., 0., 0.], [0., -0.5, 0.4, 0.1, 0.4, -0.2, 0.4, 0.3, 0., 0., 0., 0., 0., 0.], [0., 0.1, -0.1, 0.3, 0., 0.2, -0.1, -0.1, 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), 2020.0, 13))[source]
Compute the centered dipole moment.
- Parameters:
coeffs (MagneticCoefficients, optional) – Model coefficients. Default IGRF13.
- Returns:
M – Dipole moment in nT * km^3.
- Return type:
Notes
The dipole moment is computed from the n=1 Gauss coefficients: M = a^3 * sqrt(g10^2 + g11^2 + h11^2)
Examples
>>> from pytcl.magnetism import dipole_moment, IGRF13 >>> # Compute Earth's dipole moment from IGRF-13 >>> M = dipole_moment(IGRF13) >>> # Earth's dipole moment is approximately 7.9 × 10^22 A·m² >>> # In nT·km³ units, this is about 7.9 × 10^15 >>> 7e15 < M < 8.5e15 True
- pytcl.magnetism.dipole_axis(coeffs=(array([[0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.94048e+04, -1.45090e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.49960e+03, 2.98200e+03, 1.67700e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [1.36320e+03, -2.38120e+03, 1.23620e+03, 5.25700e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [9.03000e+02, 8.09500e+02, 8.63000e+01, -3.09400e+02, 4.80000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.34300e+02, 3.63200e+02, 4.77000e+01, 1.87800e+02, -1.40700e+02, -1.51200e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [6.60000e+01, 6.55000e+01, -1.91000e+01, 7.29000e+01, -6.26000e+01, 6.00000e-01, -2.42000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [8.04000e+01, -7.66000e+01, -8.20000e+00, -2.66000e+01, 3.00000e+00, -1.49000e+01, 1.04000e+01, -1.83000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [2.42000e+01, 5.80000e+00, -2.00000e+00, -5.80000e+00, 1.00000e-01, 1.10000e+01, -1.40000e+00, -6.50000e+00, -2.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [5.00000e+00, 8.40000e+00, 3.00000e+00, -1.50000e+00, 1.00000e-01, -3.80000e+00, 4.30000e+00, -1.40000e+00, -2.40000e+00, -6.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-1.80000e+00, -7.00000e-01, 2.10000e+00, 2.10000e+00, -2.40000e+00, -1.80000e+00, -5.00000e-01, 6.00000e-01, 9.00000e-01, -8.00000e-01, -2.00000e-01, 0.00000e+00, 0.00000e+00, 0.00000e+00], [3.00000e+00, -1.50000e+00, -2.00000e-01, -3.00000e-01, 5.00000e-01, 1.30000e+00, -1.20000e+00, 7.00000e-01, 4.00000e-01, 0.00000e+00, 6.00000e-01, -5.00000e-01, 0.00000e+00, 0.00000e+00], [-2.00000e-01, -2.00000e-01, -1.00000e-01, 1.00000e-01, 5.00000e-01, 1.00000e+00, -3.00000e-01, -4.00000e-01, -3.00000e-01, 2.00000e-01, -5.00000e-01, 4.00000e-01, -2.00000e-01, 0.00000e+00], [-1.00000e-01, -2.00000e-01, 1.00000e-01, 1.00000e-01, 0.00000e+00, 0.00000e+00, 1.00000e-01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00]]), array([[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6525e+03, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.9916e+03, -7.3460e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -8.2100e+01, 2.4190e+02, -5.4340e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.8190e+02, -1.5840e+02, 1.9970e+02, -3.4970e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6900e+01, 1.9690e+02, -1.1930e+02, 1.6000e+01, 1.0020e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -7.6700e+01, 2.5400e+01, -9.2000e+00, 5.5800e+01, -1.7000e+01, 8.4000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.0000e-01, -2.1500e+01, 1.5400e+01, 1.3800e+01, -1.3500e+01, -1.0000e-01, 8.9000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0300e+01, 1.3400e+01, 1.2000e+01, -6.4000e+00, -8.5000e+00, 8.5000e+00, 2.2000e+00, -7.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 9.0000e-01, -1.4000e+00, 3.7000e+00, -5.3000e+00, -3.0000e-01, 4.0000e-01, 1.7000e+00, -9.0000e-01, 4.6000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 8.0000e-01, -4.0000e-01, -2.0000e-01, 7.0000e-01, 3.0000e-01, 2.2000e+00, -2.5000e+00, 5.0000e-01, 6.0000e-01, -4.0000e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0000e-01, 4.0000e-01, 5.0000e-01, 4.0000e-01, -6.0000e-01, 3.0000e-01, 0.0000e+00, -4.0000e-01, 1.0000e-01, -3.0000e-01, -3.0000e-01, 0.0000e+00, 0.0000e+00], [0.0000e+00, 1.0000e-01, 5.0000e-01, 0.0000e+00, -2.0000e-01, 3.0000e-01, -4.0000e-01, 3.0000e-01, 3.0000e-01, -1.0000e-01, -1.0000e-01, -1.0000e-01, -2.0000e-01, 0.0000e+00], [0.0000e+00, 1.0000e-01, 0.0000e+00, 0.0000e+00, 1.0000e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [6.7, 7.7, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-11.5, -7.1, -2.2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [2.8, -6.2, 3.4, -12.2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-1.1, -1.6, -6., 5.4, -5.5, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-0.3, 0.1, -0.6, 0.2, 0.3, 1., 0., 0., 0., 0., 0., 0., 0., 0.], [-0.6, -0.4, 0.5, 1.4, -1.4, 0., 0.8, 0., 0., 0., 0., 0., 0., 0.], [-0.1, -0.3, 0.3, 0.2, -0.5, 0.2, -0.2, 0.6, 0., 0., 0., 0., 0., 0.], [0., 0., 0.1, -0.2, 0.4, 0.3, 0., 0.1, -0.1, 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -25.1, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -30.2, -23.9, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 6., -1.1, 1.1, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0.2, 6.4, 3.1, -12., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -0.4, 2.1, 3.4, -0.9, -1.2, 0., 0., 0., 0., 0., 0., 0., 0.], [0., -0.2, -0.9, 0.3, 0.1, -0.1, 0.4, 0., 0., 0., 0., 0., 0., 0.], [0., -0.5, 0.4, 0.1, 0.4, -0.2, 0.4, 0.3, 0., 0., 0., 0., 0., 0.], [0., 0.1, -0.1, 0.3, 0., 0.2, -0.1, -0.1, 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), 2020.0, 13))[source]
Compute the geocentric dipole axis direction.
- Parameters:
coeffs (MagneticCoefficients, optional) – Model coefficients. Default IGRF13.
- Returns:
lat (float) – Latitude of the north geomagnetic pole in radians.
lon (float) – Longitude of the north geomagnetic pole in radians.
- Return type:
Notes
The geomagnetic pole is where the centered dipole axis intersects the Earth’s surface.
Examples
>>> import numpy as np >>> from pytcl.magnetism import dipole_axis, IGRF13 >>> # Compute geomagnetic pole location >>> lat, lon = dipole_axis(IGRF13) >>> # Geomagnetic north pole is around 80°N, 72°W >>> 70 < np.degrees(lat) < 85 True >>> -100 < np.degrees(lon) < -60 True
- pytcl.magnetism.magnetic_north_pole(year=2023.0, coeffs=(array([[0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.94048e+04, -1.45090e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.49960e+03, 2.98200e+03, 1.67700e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [1.36320e+03, -2.38120e+03, 1.23620e+03, 5.25700e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [9.03000e+02, 8.09500e+02, 8.63000e+01, -3.09400e+02, 4.80000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.34300e+02, 3.63200e+02, 4.77000e+01, 1.87800e+02, -1.40700e+02, -1.51200e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [6.60000e+01, 6.55000e+01, -1.91000e+01, 7.29000e+01, -6.26000e+01, 6.00000e-01, -2.42000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [8.04000e+01, -7.66000e+01, -8.20000e+00, -2.66000e+01, 3.00000e+00, -1.49000e+01, 1.04000e+01, -1.83000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [2.42000e+01, 5.80000e+00, -2.00000e+00, -5.80000e+00, 1.00000e-01, 1.10000e+01, -1.40000e+00, -6.50000e+00, -2.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [5.00000e+00, 8.40000e+00, 3.00000e+00, -1.50000e+00, 1.00000e-01, -3.80000e+00, 4.30000e+00, -1.40000e+00, -2.40000e+00, -6.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-1.80000e+00, -7.00000e-01, 2.10000e+00, 2.10000e+00, -2.40000e+00, -1.80000e+00, -5.00000e-01, 6.00000e-01, 9.00000e-01, -8.00000e-01, -2.00000e-01, 0.00000e+00, 0.00000e+00, 0.00000e+00], [3.00000e+00, -1.50000e+00, -2.00000e-01, -3.00000e-01, 5.00000e-01, 1.30000e+00, -1.20000e+00, 7.00000e-01, 4.00000e-01, 0.00000e+00, 6.00000e-01, -5.00000e-01, 0.00000e+00, 0.00000e+00], [-2.00000e-01, -2.00000e-01, -1.00000e-01, 1.00000e-01, 5.00000e-01, 1.00000e+00, -3.00000e-01, -4.00000e-01, -3.00000e-01, 2.00000e-01, -5.00000e-01, 4.00000e-01, -2.00000e-01, 0.00000e+00], [-1.00000e-01, -2.00000e-01, 1.00000e-01, 1.00000e-01, 0.00000e+00, 0.00000e+00, 1.00000e-01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00]]), array([[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6525e+03, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.9916e+03, -7.3460e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -8.2100e+01, 2.4190e+02, -5.4340e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.8190e+02, -1.5840e+02, 1.9970e+02, -3.4970e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6900e+01, 1.9690e+02, -1.1930e+02, 1.6000e+01, 1.0020e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -7.6700e+01, 2.5400e+01, -9.2000e+00, 5.5800e+01, -1.7000e+01, 8.4000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.0000e-01, -2.1500e+01, 1.5400e+01, 1.3800e+01, -1.3500e+01, -1.0000e-01, 8.9000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0300e+01, 1.3400e+01, 1.2000e+01, -6.4000e+00, -8.5000e+00, 8.5000e+00, 2.2000e+00, -7.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 9.0000e-01, -1.4000e+00, 3.7000e+00, -5.3000e+00, -3.0000e-01, 4.0000e-01, 1.7000e+00, -9.0000e-01, 4.6000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 8.0000e-01, -4.0000e-01, -2.0000e-01, 7.0000e-01, 3.0000e-01, 2.2000e+00, -2.5000e+00, 5.0000e-01, 6.0000e-01, -4.0000e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0000e-01, 4.0000e-01, 5.0000e-01, 4.0000e-01, -6.0000e-01, 3.0000e-01, 0.0000e+00, -4.0000e-01, 1.0000e-01, -3.0000e-01, -3.0000e-01, 0.0000e+00, 0.0000e+00], [0.0000e+00, 1.0000e-01, 5.0000e-01, 0.0000e+00, -2.0000e-01, 3.0000e-01, -4.0000e-01, 3.0000e-01, 3.0000e-01, -1.0000e-01, -1.0000e-01, -1.0000e-01, -2.0000e-01, 0.0000e+00], [0.0000e+00, 1.0000e-01, 0.0000e+00, 0.0000e+00, 1.0000e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [6.7, 7.7, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-11.5, -7.1, -2.2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [2.8, -6.2, 3.4, -12.2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-1.1, -1.6, -6., 5.4, -5.5, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-0.3, 0.1, -0.6, 0.2, 0.3, 1., 0., 0., 0., 0., 0., 0., 0., 0.], [-0.6, -0.4, 0.5, 1.4, -1.4, 0., 0.8, 0., 0., 0., 0., 0., 0., 0.], [-0.1, -0.3, 0.3, 0.2, -0.5, 0.2, -0.2, 0.6, 0., 0., 0., 0., 0., 0.], [0., 0., 0.1, -0.2, 0.4, 0.3, 0., 0.1, -0.1, 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -25.1, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -30.2, -23.9, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 6., -1.1, 1.1, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0.2, 6.4, 3.1, -12., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -0.4, 2.1, 3.4, -0.9, -1.2, 0., 0., 0., 0., 0., 0., 0., 0.], [0., -0.2, -0.9, 0.3, 0.1, -0.1, 0.4, 0., 0., 0., 0., 0., 0., 0.], [0., -0.5, 0.4, 0.1, 0.4, -0.2, 0.4, 0.3, 0., 0., 0., 0., 0., 0.], [0., 0.1, -0.1, 0.3, 0., 0.2, -0.1, -0.1, 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), 2020.0, 13))[source]
Compute the location of the magnetic north pole.
The magnetic north pole is where the field is vertical (inclination = 90°). This differs from the geomagnetic pole due to non-dipole field contributions.
- Parameters:
year (float, optional) – Decimal year. Default 2023.0.
coeffs (MagneticCoefficients, optional) – Model coefficients. Default IGRF13.
- Returns:
lat (float) – Latitude of magnetic north pole in radians.
lon (float) – Longitude of magnetic north pole in radians.
- Return type:
Notes
This uses an iterative search starting from the dipole pole. The magnetic pole moves over time.
Examples
>>> import numpy as np >>> from pytcl.magnetism import magnetic_north_pole, dipole_axis >>> # Magnetic north pole location (2023) >>> lat, lon = magnetic_north_pole(2023.0) >>> # Should be in Canadian Arctic, around 80-85°N >>> 75 < np.degrees(lat) < 90 True >>> -150 < np.degrees(lon) < -60 True >>> # Compare with geomagnetic pole >>> geo_lat, geo_lon = dipole_axis() >>> # Magnetic pole differs from geomagnetic pole >>> abs(lat - geo_lat) > 0.01 # Different locations True
- class pytcl.magnetism.HighResCoefficients(g, h, g_dot, h_dot, epoch, n_max, n_max_sv, model_name)[source]
Bases:
NamedTupleHigh-resolution magnetic model coefficients.
Extends MagneticCoefficients with additional metadata for high-degree models like EMM and WMMHR.
- g
Main field cosine coefficients (nT), shape (n_max+1, n_max+1).
- Type:
ndarray
- h
Main field sine coefficients (nT), shape (n_max+1, n_max+1).
- Type:
ndarray
- g_dot
Secular variation of g (nT/year), shape (n_max_sv+1, n_max_sv+1).
- Type:
ndarray
- h_dot
Secular variation of h (nT/year), shape (n_max_sv+1, n_max_sv+1).
- Type:
ndarray
- pytcl.magnetism.get_emm_data_dir()
Get the pytcl data directory for external data files.
The data directory is located at
~/.pytcl/data/by default. Can be overridden by setting thePYTCL_DATA_DIRenvironment variable.- Returns:
Path to the data directory.
- Return type:
Path
- pytcl.magnetism.load_emm_coefficients(model='EMM2017', n_max=None)[source]
Load high-resolution magnetic model coefficients.
- Parameters:
- Returns:
Loaded coefficient structure.
- Return type:
- Raises:
FileNotFoundError – If the coefficient file is not found.
ValueError – If an unknown model is specified.
Examples
>>> coef = load_emm_coefficients("WMMHR2025", n_max=50) >>> coef.n_max 50
- pytcl.magnetism.create_emm_test_coefficients(n_max=36)
Create test coefficients for low-degree testing.
Creates a simplified set of coefficients for testing purposes, using the same low-degree terms as WMM2020 extended with synthetic crustal field terms.
- Parameters:
n_max (int) – Maximum degree (default 36).
- Returns:
Test coefficient set.
- Return type:
- pytcl.magnetism.emm(lat, lon, h=0.0, year=2020.0, model='EMM2017', n_max=None, coefficients=None)[source]
Compute magnetic field using Enhanced Magnetic Model.
The EMM provides higher spatial resolution than WMM by including crustal magnetic field contributions up to degree 790.
- Parameters:
lat (float) – Geodetic latitude in radians.
lon (float) – Longitude in radians.
h (float, optional) – Height above WGS84 ellipsoid in km. Default 0.
year (float, optional) – Decimal year. Default 2020.0.
model (str, optional) – Model name (“EMM2017” or “WMMHR2025”). Default “EMM2017”.
n_max (int, optional) – Maximum degree to evaluate. Default uses full model.
coefficients (HighResCoefficients, optional) – Pre-loaded coefficients. If None, loads from file.
- Returns:
result – Magnetic field components and derived quantities.
- Return type:
Examples
>>> import numpy as np >>> # Use test coefficients for demonstration >>> coef = create_test_coefficients(n_max=36) >>> result = emm(np.radians(40), np.radians(-105), 1.0, 2020.0, coefficients=coef) >>> print(f"Declination: {np.degrees(result.D):.2f}°") >>> print(f"Total intensity: {result.F:.0f} nT")
- pytcl.magnetism.wmmhr(lat, lon, h=0.0, year=2025.0, n_max=None, coefficients=None)[source]
Compute magnetic field using World Magnetic Model High Resolution.
WMMHR2025 extends WMM to degree 133, providing higher spatial resolution for applications requiring more accurate local field values.
- Parameters:
lat (float) – Geodetic latitude in radians.
lon (float) – Longitude in radians.
h (float, optional) – Height above WGS84 ellipsoid in km. Default 0.
year (float, optional) – Decimal year. Default 2025.0.
n_max (int, optional) – Maximum degree to evaluate. Default uses full model (133).
coefficients (HighResCoefficients, optional) – Pre-loaded coefficients. If None, loads from file.
- Returns:
result – Magnetic field components and derived quantities.
- Return type:
Notes
WMMHR2025 is valid for 2025.0 - 2030.0. For dates outside this range, results may be less accurate.
Secular variation is only computed for degrees 1-15. Higher degree terms represent static crustal field.
- pytcl.magnetism.emm_declination(lat, lon, h=0.0, year=2020.0, model='EMM2017', n_max=None, coefficients=None)[source]
Compute magnetic declination using EMM/WMMHR.
- Parameters:
lat (float or ndarray) – Geodetic latitude in radians.
lon (float or ndarray) – Longitude in radians.
h (float or ndarray, optional) – Height above WGS84 ellipsoid in km.
year (float, optional) – Decimal year.
model (str, optional) – Model name.
n_max (int, optional) – Maximum degree to evaluate.
coefficients (HighResCoefficients, optional) – Pre-loaded coefficients.
- Returns:
Magnetic declination in radians.
- Return type:
float or ndarray
- pytcl.magnetism.emm_inclination(lat, lon, h=0.0, year=2020.0, model='EMM2017', n_max=None, coefficients=None)[source]
Compute magnetic inclination using EMM/WMMHR.
- Parameters:
lat (float or ndarray) – Geodetic latitude in radians.
lon (float or ndarray) – Longitude in radians.
h (float or ndarray, optional) – Height above WGS84 ellipsoid in km.
year (float, optional) – Decimal year.
model (str, optional) – Model name.
n_max (int, optional) – Maximum degree to evaluate.
coefficients (HighResCoefficients, optional) – Pre-loaded coefficients.
- Returns:
Magnetic inclination (dip) in radians.
- Return type:
float or ndarray
- pytcl.magnetism.emm_intensity(lat, lon, h=0.0, year=2020.0, model='EMM2017', n_max=None, coefficients=None)[source]
Compute total magnetic field intensity using EMM/WMMHR.
- Parameters:
lat (float or ndarray) – Geodetic latitude in radians.
lon (float or ndarray) – Longitude in radians.
h (float or ndarray, optional) – Height above WGS84 ellipsoid in km.
year (float, optional) – Decimal year.
model (str, optional) – Model name.
n_max (int, optional) – Maximum degree to evaluate.
coefficients (HighResCoefficients, optional) – Pre-loaded coefficients.
- Returns:
Total magnetic field intensity in nT.
- Return type:
float or ndarray
World Magnetic Model (WMM)
World Magnetic Model implementation (WMM2020 epoch, valid 2020-2025).
World Magnetic Model (WMM) implementation.
The WMM is the standard model used by the U.S. Department of Defense, the U.K. Ministry of Defence, NATO, and the International Hydrographic Organization for navigation, attitude, and heading referencing.
References
- class pytcl.magnetism.wmm.MagneticResult(X, Y, Z, H, F, I, D)[source]
Bases:
NamedTupleResult of magnetic field computation.
- class pytcl.magnetism.wmm.MagneticCoefficients(g, h, g_dot, h_dot, epoch, n_max)[source]
Bases:
NamedTupleSpherical harmonic coefficients for magnetic model.
- g
Main field cosine coefficients (nT).
- Type:
ndarray
- h
Main field sine coefficients (nT).
- Type:
ndarray
- g_dot
Secular variation of g (nT/year).
- Type:
ndarray
- h_dot
Secular variation of h (nT/year).
- Type:
ndarray
- pytcl.magnetism.wmm.create_wmm2020_coefficients()[source]
Create WMM2020 model coefficients.
- Returns:
coeffs – WMM2020 spherical harmonic coefficients.
- Return type:
Examples
>>> coeffs = create_wmm2020_coefficients() >>> coeffs.epoch 2020.0 >>> coeffs.n_max 12
Notes
These are the official WMM2020 coefficients valid from 2020.0 to 2025.0. For use beyond 2025, updated coefficients should be obtained from NOAA.
- pytcl.magnetism.wmm.magnetic_field_spherical(lat, lon, r, year, coeffs=(array([[0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.94045e+04, -1.45070e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.50000e+03, 2.98200e+03, 1.67680e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [1.36390e+03, -2.38100e+03, 1.23620e+03, 5.25700e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [9.03100e+02, 8.09400e+02, 8.62000e+01, -3.09400e+02, 4.79000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.34400e+02, 3.63100e+02, 4.77000e+01, 1.87800e+02, -1.40700e+02, -1.51200e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [6.56000e+01, 6.55000e+01, -1.91000e+01, 7.30000e+01, -6.27000e+01, 6.00000e-01, -2.42000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [8.06000e+01, -7.67000e+01, -8.20000e+00, -2.66000e+01, 3.00000e+00, -1.49000e+01, 1.04000e+01, -1.83000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [2.44000e+01, 6.00000e+00, -2.00000e+00, -5.80000e+00, 1.00000e-01, 1.09000e+01, -1.30000e+00, -6.50000e+00, -2.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [5.00000e+00, 8.40000e+00, 3.00000e+00, -1.50000e+00, 1.00000e-01, -3.80000e+00, 4.30000e+00, -1.40000e+00, -2.40000e+00, -6.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-1.80000e+00, -7.00000e-01, 2.10000e+00, 2.10000e+00, -2.40000e+00, -1.80000e+00, -5.00000e-01, 6.00000e-01, 9.00000e-01, -8.00000e-01, -2.00000e-01, 0.00000e+00, 0.00000e+00], [3.00000e+00, -1.50000e+00, -2.00000e-01, -3.00000e-01, 5.00000e-01, 1.30000e+00, -1.20000e+00, 7.00000e-01, 4.00000e-01, 0.00000e+00, 6.00000e-01, -5.00000e-01, 0.00000e+00], [-2.00000e-01, -2.00000e-01, -1.00000e-01, 1.00000e-01, 5.00000e-01, 1.10000e+00, -3.00000e-01, -4.00000e-01, -3.00000e-01, 2.00000e-01, -5.00000e-01, 4.00000e-01, -2.00000e-01]]), array([[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6529e+03, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.9916e+03, -7.3480e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -8.2200e+01, 2.4180e+02, -5.4290e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.8200e+02, -1.5840e+02, 1.9980e+02, -3.5010e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6700e+01, 1.9690e+02, -1.1940e+02, 1.6000e+01, 1.0010e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -7.6700e+01, 2.5400e+01, -9.2000e+00, 5.5900e+01, -1.7000e+01, 8.4000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.0000e-01, -2.1500e+01, 1.5500e+01, 1.3800e+01, -1.3500e+01, -1.0000e-01, 8.8000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0400e+01, 1.3400e+01, 1.2100e+01, -6.4000e+00, -8.4000e+00, 8.6000e+00, 2.2000e+00, -7.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 9.0000e-01, -1.4000e+00, 3.8000e+00, -5.3000e+00, -3.0000e-01, 4.0000e-01, 1.7000e+00, -9.0000e-01, 4.6000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 8.0000e-01, -4.0000e-01, -2.0000e-01, 7.0000e-01, 3.0000e-01, 2.2000e+00, -2.5000e+00, 5.0000e-01, 6.0000e-01, -4.0000e-01, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0000e-01, 4.0000e-01, 5.0000e-01, 4.0000e-01, -6.0000e-01, 3.0000e-01, 0.0000e+00, -4.0000e-01, 1.0000e-01, -3.0000e-01, -3.0000e-01, 0.0000e+00], [0.0000e+00, 1.0000e-01, 5.0000e-01, 0.0000e+00, -2.0000e-01, 3.0000e-01, -4.0000e-01, 3.0000e-01, 3.0000e-01, -1.0000e-01, -1.0000e-01, -1.0000e-01, -2.0000e-01]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [6.7, 7.7, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-11.5, -7.1, -2.2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [2.8, -6.2, 3.4, -12.2, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-1.1, -1.6, -6., 5.4, -5.5, 0., 0., 0., 0., 0., 0., 0., 0.], [-0.3, 0.1, -0.6, 0.2, 0.3, 1., 0., 0., 0., 0., 0., 0., 0.], [-0.6, -0.4, 0.5, 1.4, -1.4, 0., 0.8, 0., 0., 0., 0., 0., 0.], [-0.1, -0.3, 0.3, 0.2, -0.5, 0.2, -0.2, 0.6, 0., 0., 0., 0., 0.], [0., 0., 0.1, -0.2, 0.4, 0.3, 0., 0.1, -0.1, 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -25.1, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -30.2, -23.9, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 5.7, -1., 1.1, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0.2, 6.4, 3.1, -12., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -0.4, 2.1, 3.4, -0.9, -1.2, 0., 0., 0., 0., 0., 0., 0.], [0., -0.2, -0.9, 0.3, 0.1, -0.1, 0.4, 0., 0., 0., 0., 0., 0.], [0., -0.5, 0.4, 0.1, 0.4, -0.2, 0.4, 0.3, 0., 0., 0., 0., 0.], [0., 0.1, -0.1, 0.3, 0., 0.2, -0.1, -0.1, 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), 2020.0, 12), use_cache=True)[source]
Compute magnetic field in spherical coordinates.
- Parameters:
lat (float) – Geocentric latitude in radians.
lon (float) – Longitude in radians.
r (float) – Radial distance from Earth’s center in km.
year (float) – Decimal year (e.g., 2023.5 for mid-2023).
coeffs (MagneticCoefficients, optional) – Model coefficients. Default WMM2020.
use_cache (bool, optional) – Whether to use LRU caching for repeated queries. Default True. Set to False for single-use queries or when memory is constrained.
- Returns:
B_r (float) – Radial component (positive outward) in nT.
B_theta (float) – Colatitude component (positive southward) in nT.
B_phi (float) – Longitude component (positive eastward) in nT.
- Return type:
Notes
Results are cached by default using LRU caching. Inputs are quantized to a configurable precision before caching to improve hit rates for nearby queries. Use get_magnetic_cache_info() to check cache statistics and clear_magnetic_cache() to free memory.
Examples
>>> import numpy as np >>> from pytcl.magnetism import magnetic_field_spherical >>> # Compute at Earth's surface (40°N, 105°W, sea level) >>> lat = np.radians(40) >>> lon = np.radians(-105) >>> r = 6371.2 # Earth mean radius in km >>> B_r, B_theta, B_phi = magnetic_field_spherical(lat, lon, r, 2023.0) >>> # All components should be on order of tens to tens of thousands of nT >>> 20000 < (B_r**2 + B_theta**2 + B_phi**2)**0.5 < 70000 True
- pytcl.magnetism.wmm.wmm(lat, lon, h=0.0, year=2023.0, coeffs=(array([[0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.94045e+04, -1.45070e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.50000e+03, 2.98200e+03, 1.67680e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [1.36390e+03, -2.38100e+03, 1.23620e+03, 5.25700e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [9.03100e+02, 8.09400e+02, 8.62000e+01, -3.09400e+02, 4.79000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.34400e+02, 3.63100e+02, 4.77000e+01, 1.87800e+02, -1.40700e+02, -1.51200e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [6.56000e+01, 6.55000e+01, -1.91000e+01, 7.30000e+01, -6.27000e+01, 6.00000e-01, -2.42000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [8.06000e+01, -7.67000e+01, -8.20000e+00, -2.66000e+01, 3.00000e+00, -1.49000e+01, 1.04000e+01, -1.83000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [2.44000e+01, 6.00000e+00, -2.00000e+00, -5.80000e+00, 1.00000e-01, 1.09000e+01, -1.30000e+00, -6.50000e+00, -2.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [5.00000e+00, 8.40000e+00, 3.00000e+00, -1.50000e+00, 1.00000e-01, -3.80000e+00, 4.30000e+00, -1.40000e+00, -2.40000e+00, -6.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-1.80000e+00, -7.00000e-01, 2.10000e+00, 2.10000e+00, -2.40000e+00, -1.80000e+00, -5.00000e-01, 6.00000e-01, 9.00000e-01, -8.00000e-01, -2.00000e-01, 0.00000e+00, 0.00000e+00], [3.00000e+00, -1.50000e+00, -2.00000e-01, -3.00000e-01, 5.00000e-01, 1.30000e+00, -1.20000e+00, 7.00000e-01, 4.00000e-01, 0.00000e+00, 6.00000e-01, -5.00000e-01, 0.00000e+00], [-2.00000e-01, -2.00000e-01, -1.00000e-01, 1.00000e-01, 5.00000e-01, 1.10000e+00, -3.00000e-01, -4.00000e-01, -3.00000e-01, 2.00000e-01, -5.00000e-01, 4.00000e-01, -2.00000e-01]]), array([[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6529e+03, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.9916e+03, -7.3480e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -8.2200e+01, 2.4180e+02, -5.4290e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.8200e+02, -1.5840e+02, 1.9980e+02, -3.5010e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6700e+01, 1.9690e+02, -1.1940e+02, 1.6000e+01, 1.0010e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -7.6700e+01, 2.5400e+01, -9.2000e+00, 5.5900e+01, -1.7000e+01, 8.4000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.0000e-01, -2.1500e+01, 1.5500e+01, 1.3800e+01, -1.3500e+01, -1.0000e-01, 8.8000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0400e+01, 1.3400e+01, 1.2100e+01, -6.4000e+00, -8.4000e+00, 8.6000e+00, 2.2000e+00, -7.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 9.0000e-01, -1.4000e+00, 3.8000e+00, -5.3000e+00, -3.0000e-01, 4.0000e-01, 1.7000e+00, -9.0000e-01, 4.6000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 8.0000e-01, -4.0000e-01, -2.0000e-01, 7.0000e-01, 3.0000e-01, 2.2000e+00, -2.5000e+00, 5.0000e-01, 6.0000e-01, -4.0000e-01, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0000e-01, 4.0000e-01, 5.0000e-01, 4.0000e-01, -6.0000e-01, 3.0000e-01, 0.0000e+00, -4.0000e-01, 1.0000e-01, -3.0000e-01, -3.0000e-01, 0.0000e+00], [0.0000e+00, 1.0000e-01, 5.0000e-01, 0.0000e+00, -2.0000e-01, 3.0000e-01, -4.0000e-01, 3.0000e-01, 3.0000e-01, -1.0000e-01, -1.0000e-01, -1.0000e-01, -2.0000e-01]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [6.7, 7.7, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-11.5, -7.1, -2.2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [2.8, -6.2, 3.4, -12.2, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-1.1, -1.6, -6., 5.4, -5.5, 0., 0., 0., 0., 0., 0., 0., 0.], [-0.3, 0.1, -0.6, 0.2, 0.3, 1., 0., 0., 0., 0., 0., 0., 0.], [-0.6, -0.4, 0.5, 1.4, -1.4, 0., 0.8, 0., 0., 0., 0., 0., 0.], [-0.1, -0.3, 0.3, 0.2, -0.5, 0.2, -0.2, 0.6, 0., 0., 0., 0., 0.], [0., 0., 0.1, -0.2, 0.4, 0.3, 0., 0.1, -0.1, 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -25.1, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -30.2, -23.9, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 5.7, -1., 1.1, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0.2, 6.4, 3.1, -12., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -0.4, 2.1, 3.4, -0.9, -1.2, 0., 0., 0., 0., 0., 0., 0.], [0., -0.2, -0.9, 0.3, 0.1, -0.1, 0.4, 0., 0., 0., 0., 0., 0.], [0., -0.5, 0.4, 0.1, 0.4, -0.2, 0.4, 0.3, 0., 0., 0., 0., 0.], [0., 0.1, -0.1, 0.3, 0., 0.2, -0.1, -0.1, 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), 2020.0, 12))[source]
Compute magnetic field using World Magnetic Model.
- Parameters:
lat (float) – Geodetic latitude in radians.
lon (float) – Longitude in radians.
h (float, optional) – Height above WGS84 ellipsoid in km. Default 0.
year (float, optional) – Decimal year. Default 2023.0.
coeffs (MagneticCoefficients, optional) – Model coefficients. Default WMM2020.
- Returns:
result – Magnetic field components and derived quantities.
- Return type:
Examples
>>> import numpy as np >>> result = wmm(np.radians(40), np.radians(-105), 1.0, 2023.0) >>> print(f"Declination: {np.degrees(result.D):.2f}°") >>> print(f"Inclination: {np.degrees(result.I):.2f}°") >>> print(f"Total intensity: {result.F:.0f} nT")
- pytcl.magnetism.wmm.magnetic_declination(lat, lon, h=0.0, year=2023.0, coeffs=(array([[0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.94045e+04, -1.45070e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.50000e+03, 2.98200e+03, 1.67680e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [1.36390e+03, -2.38100e+03, 1.23620e+03, 5.25700e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [9.03100e+02, 8.09400e+02, 8.62000e+01, -3.09400e+02, 4.79000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.34400e+02, 3.63100e+02, 4.77000e+01, 1.87800e+02, -1.40700e+02, -1.51200e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [6.56000e+01, 6.55000e+01, -1.91000e+01, 7.30000e+01, -6.27000e+01, 6.00000e-01, -2.42000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [8.06000e+01, -7.67000e+01, -8.20000e+00, -2.66000e+01, 3.00000e+00, -1.49000e+01, 1.04000e+01, -1.83000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [2.44000e+01, 6.00000e+00, -2.00000e+00, -5.80000e+00, 1.00000e-01, 1.09000e+01, -1.30000e+00, -6.50000e+00, -2.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [5.00000e+00, 8.40000e+00, 3.00000e+00, -1.50000e+00, 1.00000e-01, -3.80000e+00, 4.30000e+00, -1.40000e+00, -2.40000e+00, -6.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-1.80000e+00, -7.00000e-01, 2.10000e+00, 2.10000e+00, -2.40000e+00, -1.80000e+00, -5.00000e-01, 6.00000e-01, 9.00000e-01, -8.00000e-01, -2.00000e-01, 0.00000e+00, 0.00000e+00], [3.00000e+00, -1.50000e+00, -2.00000e-01, -3.00000e-01, 5.00000e-01, 1.30000e+00, -1.20000e+00, 7.00000e-01, 4.00000e-01, 0.00000e+00, 6.00000e-01, -5.00000e-01, 0.00000e+00], [-2.00000e-01, -2.00000e-01, -1.00000e-01, 1.00000e-01, 5.00000e-01, 1.10000e+00, -3.00000e-01, -4.00000e-01, -3.00000e-01, 2.00000e-01, -5.00000e-01, 4.00000e-01, -2.00000e-01]]), array([[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6529e+03, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.9916e+03, -7.3480e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -8.2200e+01, 2.4180e+02, -5.4290e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.8200e+02, -1.5840e+02, 1.9980e+02, -3.5010e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6700e+01, 1.9690e+02, -1.1940e+02, 1.6000e+01, 1.0010e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -7.6700e+01, 2.5400e+01, -9.2000e+00, 5.5900e+01, -1.7000e+01, 8.4000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.0000e-01, -2.1500e+01, 1.5500e+01, 1.3800e+01, -1.3500e+01, -1.0000e-01, 8.8000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0400e+01, 1.3400e+01, 1.2100e+01, -6.4000e+00, -8.4000e+00, 8.6000e+00, 2.2000e+00, -7.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 9.0000e-01, -1.4000e+00, 3.8000e+00, -5.3000e+00, -3.0000e-01, 4.0000e-01, 1.7000e+00, -9.0000e-01, 4.6000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 8.0000e-01, -4.0000e-01, -2.0000e-01, 7.0000e-01, 3.0000e-01, 2.2000e+00, -2.5000e+00, 5.0000e-01, 6.0000e-01, -4.0000e-01, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0000e-01, 4.0000e-01, 5.0000e-01, 4.0000e-01, -6.0000e-01, 3.0000e-01, 0.0000e+00, -4.0000e-01, 1.0000e-01, -3.0000e-01, -3.0000e-01, 0.0000e+00], [0.0000e+00, 1.0000e-01, 5.0000e-01, 0.0000e+00, -2.0000e-01, 3.0000e-01, -4.0000e-01, 3.0000e-01, 3.0000e-01, -1.0000e-01, -1.0000e-01, -1.0000e-01, -2.0000e-01]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [6.7, 7.7, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-11.5, -7.1, -2.2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [2.8, -6.2, 3.4, -12.2, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-1.1, -1.6, -6., 5.4, -5.5, 0., 0., 0., 0., 0., 0., 0., 0.], [-0.3, 0.1, -0.6, 0.2, 0.3, 1., 0., 0., 0., 0., 0., 0., 0.], [-0.6, -0.4, 0.5, 1.4, -1.4, 0., 0.8, 0., 0., 0., 0., 0., 0.], [-0.1, -0.3, 0.3, 0.2, -0.5, 0.2, -0.2, 0.6, 0., 0., 0., 0., 0.], [0., 0., 0.1, -0.2, 0.4, 0.3, 0., 0.1, -0.1, 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -25.1, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -30.2, -23.9, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 5.7, -1., 1.1, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0.2, 6.4, 3.1, -12., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -0.4, 2.1, 3.4, -0.9, -1.2, 0., 0., 0., 0., 0., 0., 0.], [0., -0.2, -0.9, 0.3, 0.1, -0.1, 0.4, 0., 0., 0., 0., 0., 0.], [0., -0.5, 0.4, 0.1, 0.4, -0.2, 0.4, 0.3, 0., 0., 0., 0., 0.], [0., 0.1, -0.1, 0.3, 0., 0.2, -0.1, -0.1, 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), 2020.0, 12))[source]
Compute magnetic declination (variation).
- Parameters:
lat (float) – Geodetic latitude in radians.
lon (float) – Longitude in radians.
h (float, optional) – Height above ellipsoid in km. Default 0.
year (float, optional) – Decimal year. Default 2023.0.
coeffs (MagneticCoefficients, optional) – Model coefficients.
- Returns:
D – Magnetic declination in radians. Positive = east of true north. Negative = west of true north.
- Return type:
Examples
>>> import numpy as np >>> # Declination in Denver, CO >>> D = magnetic_declination(np.radians(39.7), np.radians(-105.0)) >>> print(f"Declination: {np.degrees(D):.1f}°")
- pytcl.magnetism.wmm.magnetic_inclination(lat, lon, h=0.0, year=2023.0, coeffs=(array([[0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.94045e+04, -1.45070e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.50000e+03, 2.98200e+03, 1.67680e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [1.36390e+03, -2.38100e+03, 1.23620e+03, 5.25700e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [9.03100e+02, 8.09400e+02, 8.62000e+01, -3.09400e+02, 4.79000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.34400e+02, 3.63100e+02, 4.77000e+01, 1.87800e+02, -1.40700e+02, -1.51200e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [6.56000e+01, 6.55000e+01, -1.91000e+01, 7.30000e+01, -6.27000e+01, 6.00000e-01, -2.42000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [8.06000e+01, -7.67000e+01, -8.20000e+00, -2.66000e+01, 3.00000e+00, -1.49000e+01, 1.04000e+01, -1.83000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [2.44000e+01, 6.00000e+00, -2.00000e+00, -5.80000e+00, 1.00000e-01, 1.09000e+01, -1.30000e+00, -6.50000e+00, -2.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [5.00000e+00, 8.40000e+00, 3.00000e+00, -1.50000e+00, 1.00000e-01, -3.80000e+00, 4.30000e+00, -1.40000e+00, -2.40000e+00, -6.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-1.80000e+00, -7.00000e-01, 2.10000e+00, 2.10000e+00, -2.40000e+00, -1.80000e+00, -5.00000e-01, 6.00000e-01, 9.00000e-01, -8.00000e-01, -2.00000e-01, 0.00000e+00, 0.00000e+00], [3.00000e+00, -1.50000e+00, -2.00000e-01, -3.00000e-01, 5.00000e-01, 1.30000e+00, -1.20000e+00, 7.00000e-01, 4.00000e-01, 0.00000e+00, 6.00000e-01, -5.00000e-01, 0.00000e+00], [-2.00000e-01, -2.00000e-01, -1.00000e-01, 1.00000e-01, 5.00000e-01, 1.10000e+00, -3.00000e-01, -4.00000e-01, -3.00000e-01, 2.00000e-01, -5.00000e-01, 4.00000e-01, -2.00000e-01]]), array([[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6529e+03, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.9916e+03, -7.3480e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -8.2200e+01, 2.4180e+02, -5.4290e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.8200e+02, -1.5840e+02, 1.9980e+02, -3.5010e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6700e+01, 1.9690e+02, -1.1940e+02, 1.6000e+01, 1.0010e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -7.6700e+01, 2.5400e+01, -9.2000e+00, 5.5900e+01, -1.7000e+01, 8.4000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.0000e-01, -2.1500e+01, 1.5500e+01, 1.3800e+01, -1.3500e+01, -1.0000e-01, 8.8000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0400e+01, 1.3400e+01, 1.2100e+01, -6.4000e+00, -8.4000e+00, 8.6000e+00, 2.2000e+00, -7.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 9.0000e-01, -1.4000e+00, 3.8000e+00, -5.3000e+00, -3.0000e-01, 4.0000e-01, 1.7000e+00, -9.0000e-01, 4.6000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 8.0000e-01, -4.0000e-01, -2.0000e-01, 7.0000e-01, 3.0000e-01, 2.2000e+00, -2.5000e+00, 5.0000e-01, 6.0000e-01, -4.0000e-01, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0000e-01, 4.0000e-01, 5.0000e-01, 4.0000e-01, -6.0000e-01, 3.0000e-01, 0.0000e+00, -4.0000e-01, 1.0000e-01, -3.0000e-01, -3.0000e-01, 0.0000e+00], [0.0000e+00, 1.0000e-01, 5.0000e-01, 0.0000e+00, -2.0000e-01, 3.0000e-01, -4.0000e-01, 3.0000e-01, 3.0000e-01, -1.0000e-01, -1.0000e-01, -1.0000e-01, -2.0000e-01]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [6.7, 7.7, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-11.5, -7.1, -2.2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [2.8, -6.2, 3.4, -12.2, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-1.1, -1.6, -6., 5.4, -5.5, 0., 0., 0., 0., 0., 0., 0., 0.], [-0.3, 0.1, -0.6, 0.2, 0.3, 1., 0., 0., 0., 0., 0., 0., 0.], [-0.6, -0.4, 0.5, 1.4, -1.4, 0., 0.8, 0., 0., 0., 0., 0., 0.], [-0.1, -0.3, 0.3, 0.2, -0.5, 0.2, -0.2, 0.6, 0., 0., 0., 0., 0.], [0., 0., 0.1, -0.2, 0.4, 0.3, 0., 0.1, -0.1, 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -25.1, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -30.2, -23.9, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 5.7, -1., 1.1, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0.2, 6.4, 3.1, -12., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -0.4, 2.1, 3.4, -0.9, -1.2, 0., 0., 0., 0., 0., 0., 0.], [0., -0.2, -0.9, 0.3, 0.1, -0.1, 0.4, 0., 0., 0., 0., 0., 0.], [0., -0.5, 0.4, 0.1, 0.4, -0.2, 0.4, 0.3, 0., 0., 0., 0., 0.], [0., 0.1, -0.1, 0.3, 0., 0.2, -0.1, -0.1, 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), 2020.0, 12))[source]
Compute magnetic inclination (dip angle).
- Parameters:
lat (float) – Geodetic latitude in radians.
lon (float) – Longitude in radians.
h (float, optional) – Height above ellipsoid in km. Default 0.
year (float, optional) – Decimal year. Default 2023.0.
coeffs (MagneticCoefficients, optional) – Model coefficients.
- Returns:
I – Magnetic inclination in radians. Positive = field points into Earth (Northern hemisphere). Negative = field points out of Earth (Southern hemisphere).
- Return type:
Examples
>>> import numpy as np >>> from pytcl.magnetism import magnetic_inclination >>> # Inclination at 40°N, 105°W (Denver) >>> lat = np.radians(40) >>> lon = np.radians(-105) >>> I = magnetic_inclination(lat, lon, 1.6, 2023.0) >>> # Northern hemisphere: inclination should be positive >>> I > 0 True >>> # Typical values in US are 50-70 degrees >>> 0.8 < I < 1.3 # ~46-74 degrees True
- pytcl.magnetism.wmm.magnetic_field_intensity(lat, lon, h=0.0, year=2023.0, coeffs=(array([[0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.94045e+04, -1.45070e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.50000e+03, 2.98200e+03, 1.67680e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [1.36390e+03, -2.38100e+03, 1.23620e+03, 5.25700e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [9.03100e+02, 8.09400e+02, 8.62000e+01, -3.09400e+02, 4.79000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.34400e+02, 3.63100e+02, 4.77000e+01, 1.87800e+02, -1.40700e+02, -1.51200e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [6.56000e+01, 6.55000e+01, -1.91000e+01, 7.30000e+01, -6.27000e+01, 6.00000e-01, -2.42000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [8.06000e+01, -7.67000e+01, -8.20000e+00, -2.66000e+01, 3.00000e+00, -1.49000e+01, 1.04000e+01, -1.83000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [2.44000e+01, 6.00000e+00, -2.00000e+00, -5.80000e+00, 1.00000e-01, 1.09000e+01, -1.30000e+00, -6.50000e+00, -2.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [5.00000e+00, 8.40000e+00, 3.00000e+00, -1.50000e+00, 1.00000e-01, -3.80000e+00, 4.30000e+00, -1.40000e+00, -2.40000e+00, -6.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-1.80000e+00, -7.00000e-01, 2.10000e+00, 2.10000e+00, -2.40000e+00, -1.80000e+00, -5.00000e-01, 6.00000e-01, 9.00000e-01, -8.00000e-01, -2.00000e-01, 0.00000e+00, 0.00000e+00], [3.00000e+00, -1.50000e+00, -2.00000e-01, -3.00000e-01, 5.00000e-01, 1.30000e+00, -1.20000e+00, 7.00000e-01, 4.00000e-01, 0.00000e+00, 6.00000e-01, -5.00000e-01, 0.00000e+00], [-2.00000e-01, -2.00000e-01, -1.00000e-01, 1.00000e-01, 5.00000e-01, 1.10000e+00, -3.00000e-01, -4.00000e-01, -3.00000e-01, 2.00000e-01, -5.00000e-01, 4.00000e-01, -2.00000e-01]]), array([[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6529e+03, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.9916e+03, -7.3480e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -8.2200e+01, 2.4180e+02, -5.4290e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.8200e+02, -1.5840e+02, 1.9980e+02, -3.5010e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6700e+01, 1.9690e+02, -1.1940e+02, 1.6000e+01, 1.0010e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -7.6700e+01, 2.5400e+01, -9.2000e+00, 5.5900e+01, -1.7000e+01, 8.4000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.0000e-01, -2.1500e+01, 1.5500e+01, 1.3800e+01, -1.3500e+01, -1.0000e-01, 8.8000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0400e+01, 1.3400e+01, 1.2100e+01, -6.4000e+00, -8.4000e+00, 8.6000e+00, 2.2000e+00, -7.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 9.0000e-01, -1.4000e+00, 3.8000e+00, -5.3000e+00, -3.0000e-01, 4.0000e-01, 1.7000e+00, -9.0000e-01, 4.6000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 8.0000e-01, -4.0000e-01, -2.0000e-01, 7.0000e-01, 3.0000e-01, 2.2000e+00, -2.5000e+00, 5.0000e-01, 6.0000e-01, -4.0000e-01, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0000e-01, 4.0000e-01, 5.0000e-01, 4.0000e-01, -6.0000e-01, 3.0000e-01, 0.0000e+00, -4.0000e-01, 1.0000e-01, -3.0000e-01, -3.0000e-01, 0.0000e+00], [0.0000e+00, 1.0000e-01, 5.0000e-01, 0.0000e+00, -2.0000e-01, 3.0000e-01, -4.0000e-01, 3.0000e-01, 3.0000e-01, -1.0000e-01, -1.0000e-01, -1.0000e-01, -2.0000e-01]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [6.7, 7.7, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-11.5, -7.1, -2.2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [2.8, -6.2, 3.4, -12.2, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-1.1, -1.6, -6., 5.4, -5.5, 0., 0., 0., 0., 0., 0., 0., 0.], [-0.3, 0.1, -0.6, 0.2, 0.3, 1., 0., 0., 0., 0., 0., 0., 0.], [-0.6, -0.4, 0.5, 1.4, -1.4, 0., 0.8, 0., 0., 0., 0., 0., 0.], [-0.1, -0.3, 0.3, 0.2, -0.5, 0.2, -0.2, 0.6, 0., 0., 0., 0., 0.], [0., 0., 0.1, -0.2, 0.4, 0.3, 0., 0.1, -0.1, 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -25.1, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -30.2, -23.9, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 5.7, -1., 1.1, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0.2, 6.4, 3.1, -12., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -0.4, 2.1, 3.4, -0.9, -1.2, 0., 0., 0., 0., 0., 0., 0.], [0., -0.2, -0.9, 0.3, 0.1, -0.1, 0.4, 0., 0., 0., 0., 0., 0.], [0., -0.5, 0.4, 0.1, 0.4, -0.2, 0.4, 0.3, 0., 0., 0., 0., 0.], [0., 0.1, -0.1, 0.3, 0., 0.2, -0.1, -0.1, 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), 2020.0, 12))[source]
Compute total magnetic field intensity.
- Parameters:
lat (float) – Geodetic latitude in radians.
lon (float) – Longitude in radians.
h (float, optional) – Height above ellipsoid in km. Default 0.
year (float, optional) – Decimal year. Default 2023.0.
coeffs (MagneticCoefficients, optional) – Model coefficients.
- Returns:
F – Total magnetic field intensity in nT.
- Return type:
Examples
>>> import numpy as np >>> from pytcl.magnetism import magnetic_field_intensity >>> # Field intensity at magnetic equator vs pole >>> F_eq = magnetic_field_intensity(0, 0, 0, 2023.0) # Equator >>> F_pole = magnetic_field_intensity(np.radians(80), 0, 0, 2023.0) # Near pole >>> # Field is stronger at poles >>> F_pole > F_eq True >>> # Typical Earth field is 25,000 to 65,000 nT >>> 25000 < F_eq < 35000 # Equatorial field is weaker True >>> 55000 < F_pole < 65000 # Polar field is stronger True
- pytcl.magnetism.wmm.get_magnetic_cache_info()[source]
Get information about the magnetic field computation cache.
- Returns:
info – Dictionary containing cache statistics: - hits: Number of cache hits - misses: Number of cache misses - maxsize: Maximum cache size - currsize: Current number of cached entries - hit_rate: Ratio of hits to total calls (0-1)
- Return type:
Examples
>>> from pytcl.magnetism import get_magnetic_cache_info >>> info = get_magnetic_cache_info() >>> print(f"Cache hit rate: {info['hit_rate']:.1%}")
- pytcl.magnetism.wmm.clear_magnetic_cache()[source]
Clear the magnetic field computation cache.
This can be useful when memory is constrained or when switching between different coefficient sets.
Examples
>>> from pytcl.magnetism import clear_magnetic_cache >>> clear_magnetic_cache() # Free cached computations
- pytcl.magnetism.wmm.configure_magnetic_cache(maxsize=None, precision=None)[source]
Configure the magnetic field computation cache.
- Parameters:
Notes
Changing cache configuration clears the existing cache.
Examples
>>> from pytcl.magnetism import configure_magnetic_cache >>> # Increase cache size for batch processing >>> configure_magnetic_cache(maxsize=4096) >>> # Reduce precision for more cache hits >>> configure_magnetic_cache(precision={'lat': 4, 'lon': 4, 'r': 2, 'year': 1})
IGRF Model
International Geomagnetic Reference Field (IGRF-13) implementation.
International Geomagnetic Reference Field (IGRF) implementation.
The IGRF is a standard mathematical description of the Earth’s main magnetic field, used widely in studies of the Earth’s interior, its ionosphere and magnetosphere, and in various applications.
References
Alken et al., “International Geomagnetic Reference Field: the thirteenth generation,” Earth, Planets and Space, 2021.
- class pytcl.magnetism.igrf.IGRFModel(epoch, coeffs, valid_from, valid_to)[source]
Bases:
NamedTupleIGRF model for a specific epoch.
- coeffs
Spherical harmonic coefficients.
- Type:
- coeffs: MagneticCoefficients
Alias for field number 1
- pytcl.magnetism.igrf.create_igrf13_coefficients()[source]
Create IGRF-13 model coefficients for epoch 2020.
- Returns:
coeffs – IGRF-13 spherical harmonic coefficients.
- Return type:
Examples
>>> coeffs = create_igrf13_coefficients() >>> coeffs.epoch 2020.0 >>> coeffs.n_max 13
Notes
IGRF-13 is valid from 1900.0 to 2025.0. This function returns the coefficients for the 2020.0 epoch. For other epochs, the coefficients should be interpolated.
- pytcl.magnetism.igrf.igrf(lat, lon, h=0.0, year=2023.0, coeffs=None)[source]
Compute magnetic field using IGRF model.
- Parameters:
lat (float) – Geodetic latitude in radians.
lon (float) – Longitude in radians.
h (float, optional) – Height above WGS84 ellipsoid in km. Default 0.
year (float, optional) – Decimal year. Default 2023.0.
coeffs (MagneticCoefficients, optional) – Model coefficients. Default IGRF13.
- Returns:
result – Magnetic field components and derived quantities.
- Return type:
Examples
>>> import numpy as np >>> result = igrf(np.radians(45), np.radians(-75), 0, 2023.0) >>> print(f"Total field: {result.F:.0f} nT")
- pytcl.magnetism.igrf.igrf_declination(lat, lon, h=0.0, year=2023.0)[source]
Compute magnetic declination using IGRF.
- Parameters:
- Returns:
D – Declination in radians.
- Return type:
Examples
>>> import numpy as np >>> from pytcl.magnetism import igrf_declination >>> # Declination at Denver (40°N, 105°W) >>> lat = np.radians(40) >>> lon = np.radians(-105) >>> D = igrf_declination(lat, lon, 1.6, 2023.0) >>> # Eastern US has westerly declination (~10-20° W) >>> -0.35 < D < 0 # West is negative True
- pytcl.magnetism.igrf.igrf_inclination(lat, lon, h=0.0, year=2023.0)[source]
Compute magnetic inclination using IGRF.
- Parameters:
- Returns:
I – Inclination in radians.
- Return type:
Examples
>>> import numpy as np >>> from pytcl.magnetism import igrf_inclination >>> # Inclination comparison: equator vs pole >>> I_eq = igrf_inclination(0, 0, 0, 2023.0) # Equator >>> I_pole = igrf_inclination(np.radians(85), 0, 0, 2023.0) # Near pole >>> # At equator, inclination is ~0; at poles it's ~90 degrees >>> abs(I_eq) < 0.2 # ~11 degrees True >>> abs(I_pole) > 1.4 # ~80 degrees True
- pytcl.magnetism.igrf.dipole_moment(coeffs=(array([[0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.94048e+04, -1.45090e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.49960e+03, 2.98200e+03, 1.67700e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [1.36320e+03, -2.38120e+03, 1.23620e+03, 5.25700e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [9.03000e+02, 8.09500e+02, 8.63000e+01, -3.09400e+02, 4.80000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.34300e+02, 3.63200e+02, 4.77000e+01, 1.87800e+02, -1.40700e+02, -1.51200e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [6.60000e+01, 6.55000e+01, -1.91000e+01, 7.29000e+01, -6.26000e+01, 6.00000e-01, -2.42000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [8.04000e+01, -7.66000e+01, -8.20000e+00, -2.66000e+01, 3.00000e+00, -1.49000e+01, 1.04000e+01, -1.83000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [2.42000e+01, 5.80000e+00, -2.00000e+00, -5.80000e+00, 1.00000e-01, 1.10000e+01, -1.40000e+00, -6.50000e+00, -2.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [5.00000e+00, 8.40000e+00, 3.00000e+00, -1.50000e+00, 1.00000e-01, -3.80000e+00, 4.30000e+00, -1.40000e+00, -2.40000e+00, -6.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-1.80000e+00, -7.00000e-01, 2.10000e+00, 2.10000e+00, -2.40000e+00, -1.80000e+00, -5.00000e-01, 6.00000e-01, 9.00000e-01, -8.00000e-01, -2.00000e-01, 0.00000e+00, 0.00000e+00, 0.00000e+00], [3.00000e+00, -1.50000e+00, -2.00000e-01, -3.00000e-01, 5.00000e-01, 1.30000e+00, -1.20000e+00, 7.00000e-01, 4.00000e-01, 0.00000e+00, 6.00000e-01, -5.00000e-01, 0.00000e+00, 0.00000e+00], [-2.00000e-01, -2.00000e-01, -1.00000e-01, 1.00000e-01, 5.00000e-01, 1.00000e+00, -3.00000e-01, -4.00000e-01, -3.00000e-01, 2.00000e-01, -5.00000e-01, 4.00000e-01, -2.00000e-01, 0.00000e+00], [-1.00000e-01, -2.00000e-01, 1.00000e-01, 1.00000e-01, 0.00000e+00, 0.00000e+00, 1.00000e-01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00]]), array([[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6525e+03, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.9916e+03, -7.3460e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -8.2100e+01, 2.4190e+02, -5.4340e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.8190e+02, -1.5840e+02, 1.9970e+02, -3.4970e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6900e+01, 1.9690e+02, -1.1930e+02, 1.6000e+01, 1.0020e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -7.6700e+01, 2.5400e+01, -9.2000e+00, 5.5800e+01, -1.7000e+01, 8.4000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.0000e-01, -2.1500e+01, 1.5400e+01, 1.3800e+01, -1.3500e+01, -1.0000e-01, 8.9000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0300e+01, 1.3400e+01, 1.2000e+01, -6.4000e+00, -8.5000e+00, 8.5000e+00, 2.2000e+00, -7.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 9.0000e-01, -1.4000e+00, 3.7000e+00, -5.3000e+00, -3.0000e-01, 4.0000e-01, 1.7000e+00, -9.0000e-01, 4.6000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 8.0000e-01, -4.0000e-01, -2.0000e-01, 7.0000e-01, 3.0000e-01, 2.2000e+00, -2.5000e+00, 5.0000e-01, 6.0000e-01, -4.0000e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0000e-01, 4.0000e-01, 5.0000e-01, 4.0000e-01, -6.0000e-01, 3.0000e-01, 0.0000e+00, -4.0000e-01, 1.0000e-01, -3.0000e-01, -3.0000e-01, 0.0000e+00, 0.0000e+00], [0.0000e+00, 1.0000e-01, 5.0000e-01, 0.0000e+00, -2.0000e-01, 3.0000e-01, -4.0000e-01, 3.0000e-01, 3.0000e-01, -1.0000e-01, -1.0000e-01, -1.0000e-01, -2.0000e-01, 0.0000e+00], [0.0000e+00, 1.0000e-01, 0.0000e+00, 0.0000e+00, 1.0000e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [6.7, 7.7, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-11.5, -7.1, -2.2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [2.8, -6.2, 3.4, -12.2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-1.1, -1.6, -6., 5.4, -5.5, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-0.3, 0.1, -0.6, 0.2, 0.3, 1., 0., 0., 0., 0., 0., 0., 0., 0.], [-0.6, -0.4, 0.5, 1.4, -1.4, 0., 0.8, 0., 0., 0., 0., 0., 0., 0.], [-0.1, -0.3, 0.3, 0.2, -0.5, 0.2, -0.2, 0.6, 0., 0., 0., 0., 0., 0.], [0., 0., 0.1, -0.2, 0.4, 0.3, 0., 0.1, -0.1, 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -25.1, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -30.2, -23.9, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 6., -1.1, 1.1, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0.2, 6.4, 3.1, -12., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -0.4, 2.1, 3.4, -0.9, -1.2, 0., 0., 0., 0., 0., 0., 0., 0.], [0., -0.2, -0.9, 0.3, 0.1, -0.1, 0.4, 0., 0., 0., 0., 0., 0., 0.], [0., -0.5, 0.4, 0.1, 0.4, -0.2, 0.4, 0.3, 0., 0., 0., 0., 0., 0.], [0., 0.1, -0.1, 0.3, 0., 0.2, -0.1, -0.1, 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), 2020.0, 13))[source]
Compute the centered dipole moment.
- Parameters:
coeffs (MagneticCoefficients, optional) – Model coefficients. Default IGRF13.
- Returns:
M – Dipole moment in nT * km^3.
- Return type:
Notes
The dipole moment is computed from the n=1 Gauss coefficients: M = a^3 * sqrt(g10^2 + g11^2 + h11^2)
Examples
>>> from pytcl.magnetism import dipole_moment, IGRF13 >>> # Compute Earth's dipole moment from IGRF-13 >>> M = dipole_moment(IGRF13) >>> # Earth's dipole moment is approximately 7.9 × 10^22 A·m² >>> # In nT·km³ units, this is about 7.9 × 10^15 >>> 7e15 < M < 8.5e15 True
- pytcl.magnetism.igrf.dipole_axis(coeffs=(array([[0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.94048e+04, -1.45090e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.49960e+03, 2.98200e+03, 1.67700e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [1.36320e+03, -2.38120e+03, 1.23620e+03, 5.25700e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [9.03000e+02, 8.09500e+02, 8.63000e+01, -3.09400e+02, 4.80000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.34300e+02, 3.63200e+02, 4.77000e+01, 1.87800e+02, -1.40700e+02, -1.51200e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [6.60000e+01, 6.55000e+01, -1.91000e+01, 7.29000e+01, -6.26000e+01, 6.00000e-01, -2.42000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [8.04000e+01, -7.66000e+01, -8.20000e+00, -2.66000e+01, 3.00000e+00, -1.49000e+01, 1.04000e+01, -1.83000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [2.42000e+01, 5.80000e+00, -2.00000e+00, -5.80000e+00, 1.00000e-01, 1.10000e+01, -1.40000e+00, -6.50000e+00, -2.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [5.00000e+00, 8.40000e+00, 3.00000e+00, -1.50000e+00, 1.00000e-01, -3.80000e+00, 4.30000e+00, -1.40000e+00, -2.40000e+00, -6.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-1.80000e+00, -7.00000e-01, 2.10000e+00, 2.10000e+00, -2.40000e+00, -1.80000e+00, -5.00000e-01, 6.00000e-01, 9.00000e-01, -8.00000e-01, -2.00000e-01, 0.00000e+00, 0.00000e+00, 0.00000e+00], [3.00000e+00, -1.50000e+00, -2.00000e-01, -3.00000e-01, 5.00000e-01, 1.30000e+00, -1.20000e+00, 7.00000e-01, 4.00000e-01, 0.00000e+00, 6.00000e-01, -5.00000e-01, 0.00000e+00, 0.00000e+00], [-2.00000e-01, -2.00000e-01, -1.00000e-01, 1.00000e-01, 5.00000e-01, 1.00000e+00, -3.00000e-01, -4.00000e-01, -3.00000e-01, 2.00000e-01, -5.00000e-01, 4.00000e-01, -2.00000e-01, 0.00000e+00], [-1.00000e-01, -2.00000e-01, 1.00000e-01, 1.00000e-01, 0.00000e+00, 0.00000e+00, 1.00000e-01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00]]), array([[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6525e+03, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.9916e+03, -7.3460e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -8.2100e+01, 2.4190e+02, -5.4340e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.8190e+02, -1.5840e+02, 1.9970e+02, -3.4970e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6900e+01, 1.9690e+02, -1.1930e+02, 1.6000e+01, 1.0020e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -7.6700e+01, 2.5400e+01, -9.2000e+00, 5.5800e+01, -1.7000e+01, 8.4000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.0000e-01, -2.1500e+01, 1.5400e+01, 1.3800e+01, -1.3500e+01, -1.0000e-01, 8.9000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0300e+01, 1.3400e+01, 1.2000e+01, -6.4000e+00, -8.5000e+00, 8.5000e+00, 2.2000e+00, -7.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 9.0000e-01, -1.4000e+00, 3.7000e+00, -5.3000e+00, -3.0000e-01, 4.0000e-01, 1.7000e+00, -9.0000e-01, 4.6000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 8.0000e-01, -4.0000e-01, -2.0000e-01, 7.0000e-01, 3.0000e-01, 2.2000e+00, -2.5000e+00, 5.0000e-01, 6.0000e-01, -4.0000e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0000e-01, 4.0000e-01, 5.0000e-01, 4.0000e-01, -6.0000e-01, 3.0000e-01, 0.0000e+00, -4.0000e-01, 1.0000e-01, -3.0000e-01, -3.0000e-01, 0.0000e+00, 0.0000e+00], [0.0000e+00, 1.0000e-01, 5.0000e-01, 0.0000e+00, -2.0000e-01, 3.0000e-01, -4.0000e-01, 3.0000e-01, 3.0000e-01, -1.0000e-01, -1.0000e-01, -1.0000e-01, -2.0000e-01, 0.0000e+00], [0.0000e+00, 1.0000e-01, 0.0000e+00, 0.0000e+00, 1.0000e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [6.7, 7.7, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-11.5, -7.1, -2.2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [2.8, -6.2, 3.4, -12.2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-1.1, -1.6, -6., 5.4, -5.5, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-0.3, 0.1, -0.6, 0.2, 0.3, 1., 0., 0., 0., 0., 0., 0., 0., 0.], [-0.6, -0.4, 0.5, 1.4, -1.4, 0., 0.8, 0., 0., 0., 0., 0., 0., 0.], [-0.1, -0.3, 0.3, 0.2, -0.5, 0.2, -0.2, 0.6, 0., 0., 0., 0., 0., 0.], [0., 0., 0.1, -0.2, 0.4, 0.3, 0., 0.1, -0.1, 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -25.1, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -30.2, -23.9, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 6., -1.1, 1.1, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0.2, 6.4, 3.1, -12., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -0.4, 2.1, 3.4, -0.9, -1.2, 0., 0., 0., 0., 0., 0., 0., 0.], [0., -0.2, -0.9, 0.3, 0.1, -0.1, 0.4, 0., 0., 0., 0., 0., 0., 0.], [0., -0.5, 0.4, 0.1, 0.4, -0.2, 0.4, 0.3, 0., 0., 0., 0., 0., 0.], [0., 0.1, -0.1, 0.3, 0., 0.2, -0.1, -0.1, 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), 2020.0, 13))[source]
Compute the geocentric dipole axis direction.
- Parameters:
coeffs (MagneticCoefficients, optional) – Model coefficients. Default IGRF13.
- Returns:
lat (float) – Latitude of the north geomagnetic pole in radians.
lon (float) – Longitude of the north geomagnetic pole in radians.
- Return type:
Notes
The geomagnetic pole is where the centered dipole axis intersects the Earth’s surface.
Examples
>>> import numpy as np >>> from pytcl.magnetism import dipole_axis, IGRF13 >>> # Compute geomagnetic pole location >>> lat, lon = dipole_axis(IGRF13) >>> # Geomagnetic north pole is around 80°N, 72°W >>> 70 < np.degrees(lat) < 85 True >>> -100 < np.degrees(lon) < -60 True
- pytcl.magnetism.igrf.magnetic_north_pole(year=2023.0, coeffs=(array([[0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.94048e+04, -1.45090e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.49960e+03, 2.98200e+03, 1.67700e+03, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [1.36320e+03, -2.38120e+03, 1.23620e+03, 5.25700e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [9.03000e+02, 8.09500e+02, 8.63000e+01, -3.09400e+02, 4.80000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-2.34300e+02, 3.63200e+02, 4.77000e+01, 1.87800e+02, -1.40700e+02, -1.51200e+02, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [6.60000e+01, 6.55000e+01, -1.91000e+01, 7.29000e+01, -6.26000e+01, 6.00000e-01, -2.42000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [8.04000e+01, -7.66000e+01, -8.20000e+00, -2.66000e+01, 3.00000e+00, -1.49000e+01, 1.04000e+01, -1.83000e+01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [2.42000e+01, 5.80000e+00, -2.00000e+00, -5.80000e+00, 1.00000e-01, 1.10000e+01, -1.40000e+00, -6.50000e+00, -2.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [5.00000e+00, 8.40000e+00, 3.00000e+00, -1.50000e+00, 1.00000e-01, -3.80000e+00, 4.30000e+00, -1.40000e+00, -2.40000e+00, -6.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00], [-1.80000e+00, -7.00000e-01, 2.10000e+00, 2.10000e+00, -2.40000e+00, -1.80000e+00, -5.00000e-01, 6.00000e-01, 9.00000e-01, -8.00000e-01, -2.00000e-01, 0.00000e+00, 0.00000e+00, 0.00000e+00], [3.00000e+00, -1.50000e+00, -2.00000e-01, -3.00000e-01, 5.00000e-01, 1.30000e+00, -1.20000e+00, 7.00000e-01, 4.00000e-01, 0.00000e+00, 6.00000e-01, -5.00000e-01, 0.00000e+00, 0.00000e+00], [-2.00000e-01, -2.00000e-01, -1.00000e-01, 1.00000e-01, 5.00000e-01, 1.00000e+00, -3.00000e-01, -4.00000e-01, -3.00000e-01, 2.00000e-01, -5.00000e-01, 4.00000e-01, -2.00000e-01, 0.00000e+00], [-1.00000e-01, -2.00000e-01, 1.00000e-01, 1.00000e-01, 0.00000e+00, 0.00000e+00, 1.00000e-01, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00, 0.00000e+00]]), array([[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6525e+03, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.9916e+03, -7.3460e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -8.2100e+01, 2.4190e+02, -5.4340e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.8190e+02, -1.5840e+02, 1.9970e+02, -3.4970e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 4.6900e+01, 1.9690e+02, -1.1930e+02, 1.6000e+01, 1.0020e+02, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -7.6700e+01, 2.5400e+01, -9.2000e+00, 5.5800e+01, -1.7000e+01, 8.4000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 2.0000e-01, -2.1500e+01, 1.5400e+01, 1.3800e+01, -1.3500e+01, -1.0000e-01, 8.9000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0300e+01, 1.3400e+01, 1.2000e+01, -6.4000e+00, -8.5000e+00, 8.5000e+00, 2.2000e+00, -7.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 9.0000e-01, -1.4000e+00, 3.7000e+00, -5.3000e+00, -3.0000e-01, 4.0000e-01, 1.7000e+00, -9.0000e-01, 4.6000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, 8.0000e-01, -4.0000e-01, -2.0000e-01, 7.0000e-01, 3.0000e-01, 2.2000e+00, -2.5000e+00, 5.0000e-01, 6.0000e-01, -4.0000e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00], [0.0000e+00, -2.0000e-01, 4.0000e-01, 5.0000e-01, 4.0000e-01, -6.0000e-01, 3.0000e-01, 0.0000e+00, -4.0000e-01, 1.0000e-01, -3.0000e-01, -3.0000e-01, 0.0000e+00, 0.0000e+00], [0.0000e+00, 1.0000e-01, 5.0000e-01, 0.0000e+00, -2.0000e-01, 3.0000e-01, -4.0000e-01, 3.0000e-01, 3.0000e-01, -1.0000e-01, -1.0000e-01, -1.0000e-01, -2.0000e-01, 0.0000e+00], [0.0000e+00, 1.0000e-01, 0.0000e+00, 0.0000e+00, 1.0000e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [6.7, 7.7, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-11.5, -7.1, -2.2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [2.8, -6.2, 3.4, -12.2, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-1.1, -1.6, -6., 5.4, -5.5, 0., 0., 0., 0., 0., 0., 0., 0., 0.], [-0.3, 0.1, -0.6, 0.2, 0.3, 1., 0., 0., 0., 0., 0., 0., 0., 0.], [-0.6, -0.4, 0.5, 1.4, -1.4, 0., 0.8, 0., 0., 0., 0., 0., 0., 0.], [-0.1, -0.3, 0.3, 0.2, -0.5, 0.2, -0.2, 0.6, 0., 0., 0., 0., 0., 0.], [0., 0., 0.1, -0.2, 0.4, 0.3, 0., 0.1, -0.1, 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -25.1, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -30.2, -23.9, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 6., -1.1, 1.1, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0.2, 6.4, 3.1, -12., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., -0.4, 2.1, 3.4, -0.9, -1.2, 0., 0., 0., 0., 0., 0., 0., 0.], [0., -0.2, -0.9, 0.3, 0.1, -0.1, 0.4, 0., 0., 0., 0., 0., 0., 0.], [0., -0.5, 0.4, 0.1, 0.4, -0.2, 0.4, 0.3, 0., 0., 0., 0., 0., 0.], [0., 0.1, -0.1, 0.3, 0., 0.2, -0.1, -0.1, 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), 2020.0, 13))[source]
Compute the location of the magnetic north pole.
The magnetic north pole is where the field is vertical (inclination = 90°). This differs from the geomagnetic pole due to non-dipole field contributions.
- Parameters:
year (float, optional) – Decimal year. Default 2023.0.
coeffs (MagneticCoefficients, optional) – Model coefficients. Default IGRF13.
- Returns:
lat (float) – Latitude of magnetic north pole in radians.
lon (float) – Longitude of magnetic north pole in radians.
- Return type:
Notes
This uses an iterative search starting from the dipole pole. The magnetic pole moves over time.
Examples
>>> import numpy as np >>> from pytcl.magnetism import magnetic_north_pole, dipole_axis >>> # Magnetic north pole location (2023) >>> lat, lon = magnetic_north_pole(2023.0) >>> # Should be in Canadian Arctic, around 80-85°N >>> 75 < np.degrees(lat) < 90 True >>> -150 < np.degrees(lon) < -60 True >>> # Compare with geomagnetic pole >>> geo_lat, geo_lon = dipole_axis() >>> # Magnetic pole differs from geomagnetic pole >>> abs(lat - geo_lat) > 0.01 # Different locations True
Enhanced Magnetic Model (EMM) and WMMHR2025
High-resolution magnetic field models: EMM2017 (degree 790) and WMMHR2025 (degree 133). Both support scalar and array inputs for lat/lon/height.
Enhanced Magnetic Model (EMM) and World Magnetic Model High Resolution (WMMHR).
This module provides support for high-degree magnetic field models: - EMM2017: Degree 790, resolves anomalies down to 51 km wavelength - WMMHR2025: Degree 133, resolves anomalies down to ~300 km wavelength
These models provide higher spatial resolution than the standard WMM (degree 12) by including crustal magnetic field contributions.
References
Maus, S., et al. “EMAG2: A 2-arc min resolution Earth Magnetic Anomaly Grid compiled from satellite, airborne, and marine magnetic measurements.” Geochemistry, Geophysics, Geosystems 10.8 (2009).
NOAA National Centers for Environmental Information, “Enhanced Magnetic Model (EMM).” https://www.ncei.noaa.gov/products/enhanced-magnetic-model
NOAA National Centers for Environmental Information, “World Magnetic Model High Resolution (WMMHR).” https://www.ncei.noaa.gov/products/world-magnetic-model-high-resolution
- class pytcl.magnetism.emm.HighResCoefficients(g, h, g_dot, h_dot, epoch, n_max, n_max_sv, model_name)[source]
Bases:
NamedTupleHigh-resolution magnetic model coefficients.
Extends MagneticCoefficients with additional metadata for high-degree models like EMM and WMMHR.
- g
Main field cosine coefficients (nT), shape (n_max+1, n_max+1).
- Type:
ndarray
- h
Main field sine coefficients (nT), shape (n_max+1, n_max+1).
- Type:
ndarray
- g_dot
Secular variation of g (nT/year), shape (n_max_sv+1, n_max_sv+1).
- Type:
ndarray
- h_dot
Secular variation of h (nT/year), shape (n_max_sv+1, n_max_sv+1).
- Type:
ndarray
- pytcl.magnetism.emm.get_data_dir()[source]
Get the pytcl data directory for external data files.
The data directory is located at
~/.pytcl/data/by default. Can be overridden by setting thePYTCL_DATA_DIRenvironment variable.- Returns:
Path to the data directory.
- Return type:
Path
- pytcl.magnetism.emm.parse_emm_file(filepath, n_max=None)[source]
Parse an EMM/WMMHR coefficient file.
- The file format is similar to WMM but with more coefficients:
n m g_nm h_nm g_dot_nm h_dot_nm
- Parameters:
filepath (Path) – Path to the coefficient file.
n_max (int, optional) – Maximum degree to load. If None, loads all coefficients.
- Returns:
g (ndarray) – Cosine coefficients.
h (ndarray) – Sine coefficients.
g_dot (ndarray) – Secular variation of g.
h_dot (ndarray) – Secular variation of h.
epoch (float) – Model epoch.
actual_n_max (int) – Maximum degree loaded.
- Return type:
tuple[ndarray[tuple[Any, …], dtype[floating]], ndarray[tuple[Any, …], dtype[floating]], ndarray[tuple[Any, …], dtype[floating]], ndarray[tuple[Any, …], dtype[floating]], float, int]
- pytcl.magnetism.emm.create_test_coefficients(n_max=36)[source]
Create test coefficients for low-degree testing.
Creates a simplified set of coefficients for testing purposes, using the same low-degree terms as WMM2020 extended with synthetic crustal field terms.
- Parameters:
n_max (int) – Maximum degree (default 36).
- Returns:
Test coefficient set.
- Return type:
- pytcl.magnetism.emm.load_emm_coefficients(model='EMM2017', n_max=None)[source]
Load high-resolution magnetic model coefficients.
- Parameters:
- Returns:
Loaded coefficient structure.
- Return type:
- Raises:
FileNotFoundError – If the coefficient file is not found.
ValueError – If an unknown model is specified.
Examples
>>> coef = load_emm_coefficients("WMMHR2025", n_max=50) >>> coef.n_max 50
- pytcl.magnetism.emm.emm(lat, lon, h=0.0, year=2020.0, model='EMM2017', n_max=None, coefficients=None)[source]
Compute magnetic field using Enhanced Magnetic Model.
The EMM provides higher spatial resolution than WMM by including crustal magnetic field contributions up to degree 790.
- Parameters:
lat (float) – Geodetic latitude in radians.
lon (float) – Longitude in radians.
h (float, optional) – Height above WGS84 ellipsoid in km. Default 0.
year (float, optional) – Decimal year. Default 2020.0.
model (str, optional) – Model name (“EMM2017” or “WMMHR2025”). Default “EMM2017”.
n_max (int, optional) – Maximum degree to evaluate. Default uses full model.
coefficients (HighResCoefficients, optional) – Pre-loaded coefficients. If None, loads from file.
- Returns:
result – Magnetic field components and derived quantities.
- Return type:
Examples
>>> import numpy as np >>> # Use test coefficients for demonstration >>> coef = create_test_coefficients(n_max=36) >>> result = emm(np.radians(40), np.radians(-105), 1.0, 2020.0, coefficients=coef) >>> print(f"Declination: {np.degrees(result.D):.2f}°") >>> print(f"Total intensity: {result.F:.0f} nT")
- pytcl.magnetism.emm.wmmhr(lat, lon, h=0.0, year=2025.0, n_max=None, coefficients=None)[source]
Compute magnetic field using World Magnetic Model High Resolution.
WMMHR2025 extends WMM to degree 133, providing higher spatial resolution for applications requiring more accurate local field values.
- Parameters:
lat (float) – Geodetic latitude in radians.
lon (float) – Longitude in radians.
h (float, optional) – Height above WGS84 ellipsoid in km. Default 0.
year (float, optional) – Decimal year. Default 2025.0.
n_max (int, optional) – Maximum degree to evaluate. Default uses full model (133).
coefficients (HighResCoefficients, optional) – Pre-loaded coefficients. If None, loads from file.
- Returns:
result – Magnetic field components and derived quantities.
- Return type:
Notes
WMMHR2025 is valid for 2025.0 - 2030.0. For dates outside this range, results may be less accurate.
Secular variation is only computed for degrees 1-15. Higher degree terms represent static crustal field.
- pytcl.magnetism.emm.emm_declination(lat, lon, h=0.0, year=2020.0, model='EMM2017', n_max=None, coefficients=None)[source]
Compute magnetic declination using EMM/WMMHR.
- Parameters:
lat (float or ndarray) – Geodetic latitude in radians.
lon (float or ndarray) – Longitude in radians.
h (float or ndarray, optional) – Height above WGS84 ellipsoid in km.
year (float, optional) – Decimal year.
model (str, optional) – Model name.
n_max (int, optional) – Maximum degree to evaluate.
coefficients (HighResCoefficients, optional) – Pre-loaded coefficients.
- Returns:
Magnetic declination in radians.
- Return type:
float or ndarray
- pytcl.magnetism.emm.emm_inclination(lat, lon, h=0.0, year=2020.0, model='EMM2017', n_max=None, coefficients=None)[source]
Compute magnetic inclination using EMM/WMMHR.
- Parameters:
lat (float or ndarray) – Geodetic latitude in radians.
lon (float or ndarray) – Longitude in radians.
h (float or ndarray, optional) – Height above WGS84 ellipsoid in km.
year (float, optional) – Decimal year.
model (str, optional) – Model name.
n_max (int, optional) – Maximum degree to evaluate.
coefficients (HighResCoefficients, optional) – Pre-loaded coefficients.
- Returns:
Magnetic inclination (dip) in radians.
- Return type:
float or ndarray
- pytcl.magnetism.emm.emm_intensity(lat, lon, h=0.0, year=2020.0, model='EMM2017', n_max=None, coefficients=None)[source]
Compute total magnetic field intensity using EMM/WMMHR.
- Parameters:
lat (float or ndarray) – Geodetic latitude in radians.
lon (float or ndarray) – Longitude in radians.
h (float or ndarray, optional) – Height above WGS84 ellipsoid in km.
year (float, optional) – Decimal year.
model (str, optional) – Model name.
n_max (int, optional) – Maximum degree to evaluate.
coefficients (HighResCoefficients, optional) – Pre-loaded coefficients.
- Returns:
Total magnetic field intensity in nT.
- Return type:
float or ndarray