ppigrf 2.1.0__tar.gz → 2.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ppigrf-2.1.0/src/ppigrf.egg-info → ppigrf-2.2.0}/PKG-INFO +3 -3
- {ppigrf-2.1.0 → ppigrf-2.2.0}/pyproject.toml +3 -3
- ppigrf-2.2.0/src/ppigrf/__init__.py +14 -0
- {ppigrf-2.1.0 → ppigrf-2.2.0}/src/ppigrf/ppigrf.py +19 -6
- {ppigrf-2.1.0 → ppigrf-2.2.0/src/ppigrf.egg-info}/PKG-INFO +3 -3
- {ppigrf-2.1.0 → ppigrf-2.2.0}/src/ppigrf.egg-info/SOURCES.txt +2 -0
- ppigrf-2.2.0/test/test_component_scaling.py +19 -0
- ppigrf-2.2.0/test/test_declination_quadrants.py +20 -0
- ppigrf-2.1.0/src/ppigrf/__init__.py +0 -1
- {ppigrf-2.1.0 → ppigrf-2.2.0}/LICENSE +0 -0
- {ppigrf-2.1.0 → ppigrf-2.2.0}/README.md +0 -0
- {ppigrf-2.1.0 → ppigrf-2.2.0}/setup.cfg +0 -0
- {ppigrf-2.1.0 → ppigrf-2.2.0}/src/ppigrf/IGRF13.shc +0 -0
- {ppigrf-2.1.0 → ppigrf-2.2.0}/src/ppigrf/IGRF14.shc +0 -0
- {ppigrf-2.1.0 → ppigrf-2.2.0}/src/ppigrf.egg-info/dependency_links.txt +0 -0
- {ppigrf-2.1.0 → ppigrf-2.2.0}/src/ppigrf.egg-info/requires.txt +0 -0
- {ppigrf-2.1.0 → ppigrf-2.2.0}/src/ppigrf.egg-info/top_level.txt +0 -0
- {ppigrf-2.1.0 → ppigrf-2.2.0}/test/test_igrf.py +0 -0
- {ppigrf-2.1.0 → ppigrf-2.2.0}/test/test_inclination_declination.py +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ppigrf
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Summary: Pure Python IGRF
|
|
5
5
|
Author: Karl Laundal
|
|
6
|
-
Maintainer-email: Ashley Smith <ashley
|
|
6
|
+
Maintainer-email: Ashley Smith <ashley@mag.earth>
|
|
7
7
|
License: MIT License
|
|
8
8
|
|
|
9
9
|
Copyright (c) 2021 Karl M. Laundal
|
|
@@ -35,7 +35,7 @@ Classifier: Operating System :: OS Independent
|
|
|
35
35
|
Classifier: Programming Language :: Python
|
|
36
36
|
Classifier: Programming Language :: Python :: 3
|
|
37
37
|
Classifier: Development Status :: 4 - Beta
|
|
38
|
-
Requires-Python: >=3.6
|
|
38
|
+
Requires-Python: >=3.6.1
|
|
39
39
|
Description-Content-Type: text/markdown
|
|
40
40
|
License-File: LICENSE
|
|
41
41
|
Requires-Dist: numpy>=1.15
|
|
@@ -4,17 +4,17 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "ppigrf"
|
|
7
|
-
version = "2.
|
|
7
|
+
version = "2.2.0"
|
|
8
8
|
authors = [
|
|
9
9
|
{ name = "Karl Laundal" }
|
|
10
10
|
]
|
|
11
11
|
maintainers = [
|
|
12
|
-
{ name = "Ashley Smith", email = "ashley
|
|
12
|
+
{ name = "Ashley Smith", email = "ashley@mag.earth" },
|
|
13
13
|
]
|
|
14
14
|
license = { file = "LICENSE" }
|
|
15
15
|
description = "Pure Python IGRF"
|
|
16
16
|
readme = "README.md"
|
|
17
|
-
requires-python = ">=3.6"
|
|
17
|
+
requires-python = ">=3.6.1"
|
|
18
18
|
classifiers = [
|
|
19
19
|
"License :: OSI Approved :: MIT License",
|
|
20
20
|
"Topic :: Scientific/Engineering",
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from .ppigrf import igrf, igrf_gc, get_inclination_declination
|
|
2
|
+
|
|
3
|
+
try:
|
|
4
|
+
from importlib.metadata import version as _version, PackageNotFoundError
|
|
5
|
+
except ImportError: # Python < 3.8 (requires-python is >=3.6)
|
|
6
|
+
try:
|
|
7
|
+
from importlib_metadata import version as _version, PackageNotFoundError
|
|
8
|
+
except ImportError:
|
|
9
|
+
_version, PackageNotFoundError = None, Exception
|
|
10
|
+
|
|
11
|
+
try:
|
|
12
|
+
__version__ = _version("ppigrf") if _version else "unknown"
|
|
13
|
+
except PackageNotFoundError: # e.g. running from a source checkout without installing
|
|
14
|
+
__version__ = "unknown"
|
|
@@ -545,8 +545,22 @@ def igrf_gc(r, theta, phi, date, coeff_fn = shc_fn, min_degree=1, max_degree=13)
|
|
|
545
545
|
Btheta = G.dot(np.hstack((g.values, h.values)).T).T # shape (n_times, n_coords)
|
|
546
546
|
|
|
547
547
|
# calculate Bphi:
|
|
548
|
-
|
|
549
|
-
|
|
548
|
+
# Need P(n,m) / sin(theta), but this is 0/0 at the poles.
|
|
549
|
+
# Apply L'Hôpital's rule at poles (theta = 0° or 180°):
|
|
550
|
+
# lim P(n,m)/sin(theta) = dP(n,m)/dtheta * cos(theta)
|
|
551
|
+
# See: https://github.com/ancklo/ChaosMagPy/blob/master/chaosmagpy/model_utils.py
|
|
552
|
+
sinth = np.sin(np.radians(theta))
|
|
553
|
+
costh = np.cos(np.radians(theta))
|
|
554
|
+
where_poles = (sinth == 0).flatten()
|
|
555
|
+
|
|
556
|
+
P_over_sinth = np.empty_like(P)
|
|
557
|
+
P_over_sinth[~where_poles] = P[~where_poles] / sinth[~where_poles]
|
|
558
|
+
# At poles: use L'Hôpital limit dP/dtheta * cos(theta)
|
|
559
|
+
P_over_sinth[where_poles] = dP[where_poles] * costh[where_poles]
|
|
560
|
+
|
|
561
|
+
numerator = np.hstack((-P_over_sinth * sinmphi, P_over_sinth * cosmphi))
|
|
562
|
+
G = - N_map * (RE / r) ** (nn + 1) * mm * numerator * RE / r
|
|
563
|
+
|
|
550
564
|
Bphi = G.dot(np.hstack((g.values, h.values)).T).T # shape (n_times, n_coords)
|
|
551
565
|
|
|
552
566
|
# reshape and return
|
|
@@ -736,7 +750,7 @@ def get_inclination_declination(Be, Bn, Bu, degrees=True):
|
|
|
736
750
|
|
|
737
751
|
.. math::
|
|
738
752
|
|
|
739
|
-
D = \
|
|
753
|
+
D = \operatorname{atan2}(B_e, B_n)
|
|
740
754
|
|
|
741
755
|
Parameters
|
|
742
756
|
----------
|
|
@@ -763,12 +777,11 @@ def get_inclination_declination(Be, Bn, Bu, degrees=True):
|
|
|
763
777
|
it's returned in radians.
|
|
764
778
|
"""
|
|
765
779
|
# Compute the horizontal component of B
|
|
766
|
-
H = np.
|
|
780
|
+
H = np.hypot(Be, Bn)
|
|
767
781
|
# Compute the inclination and declination, accounting for special H=0 case
|
|
768
782
|
safe_division = np.divide(-Bu, H, where=H != 0)
|
|
769
783
|
inclination = np.where(H != 0, np.arctan(safe_division), -np.sign(Bu) * np.pi /2)
|
|
770
|
-
|
|
771
|
-
declination = np.where(H != 0, np.arcsin(safe_division), 0)
|
|
784
|
+
declination = np.where(H != 0, np.arctan2(Be, Bn), 0)
|
|
772
785
|
# Convert to degrees if needed
|
|
773
786
|
if degrees:
|
|
774
787
|
inclination = np.degrees(inclination)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ppigrf
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Summary: Pure Python IGRF
|
|
5
5
|
Author: Karl Laundal
|
|
6
|
-
Maintainer-email: Ashley Smith <ashley
|
|
6
|
+
Maintainer-email: Ashley Smith <ashley@mag.earth>
|
|
7
7
|
License: MIT License
|
|
8
8
|
|
|
9
9
|
Copyright (c) 2021 Karl M. Laundal
|
|
@@ -35,7 +35,7 @@ Classifier: Operating System :: OS Independent
|
|
|
35
35
|
Classifier: Programming Language :: Python
|
|
36
36
|
Classifier: Programming Language :: Python :: 3
|
|
37
37
|
Classifier: Development Status :: 4 - Beta
|
|
38
|
-
Requires-Python: >=3.6
|
|
38
|
+
Requires-Python: >=3.6.1
|
|
39
39
|
Description-Content-Type: text/markdown
|
|
40
40
|
License-File: LICENSE
|
|
41
41
|
Requires-Dist: numpy>=1.15
|
|
@@ -10,5 +10,7 @@ src/ppigrf.egg-info/SOURCES.txt
|
|
|
10
10
|
src/ppigrf.egg-info/dependency_links.txt
|
|
11
11
|
src/ppigrf.egg-info/requires.txt
|
|
12
12
|
src/ppigrf.egg-info/top_level.txt
|
|
13
|
+
test/test_component_scaling.py
|
|
14
|
+
test/test_declination_quadrants.py
|
|
13
15
|
test/test_igrf.py
|
|
14
16
|
test/test_inclination_declination.py
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Compute directions without squaring components in their input dtype."""
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
import numpy.testing as npt
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
from ppigrf import get_inclination_declination
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@pytest.mark.parametrize(
|
|
11
|
+
"dtype, scale", [(np.int32, 1), (np.float32, 1e20), (np.float32, 1e-30)]
|
|
12
|
+
)
|
|
13
|
+
def test_horizontal_magnitude_without_overflow(dtype, scale):
|
|
14
|
+
components = [
|
|
15
|
+
np.array([value * scale], dtype=dtype) for value in (30000.0, 40000.0, -50000.0)
|
|
16
|
+
]
|
|
17
|
+
inclination, declination = get_inclination_declination(*components)
|
|
18
|
+
npt.assert_allclose(inclination, [45.0], rtol=2e-7)
|
|
19
|
+
npt.assert_allclose(declination, [36.86989764584402], rtol=2e-7)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Check azimuth quadrants and the zero-horizontal-field convention."""
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
import numpy.testing as npt
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
from ppigrf import get_inclination_declination
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@pytest.mark.parametrize("degrees", (True, False))
|
|
11
|
+
def test_declination_all_quadrants(degrees):
|
|
12
|
+
east = np.array([1.0, -1.0, 0.0, 1.0, -1.0, 0.0, 0.0])
|
|
13
|
+
north = np.array([-1.0, -1.0, -1.0, 1.0, 1.0, 1.0, 0.0])
|
|
14
|
+
expected = np.array([135.0, -135.0, 180.0, 45.0, -45.0, 0.0, 0.0])
|
|
15
|
+
if not degrees:
|
|
16
|
+
expected = np.radians(expected)
|
|
17
|
+
_, declination = get_inclination_declination(
|
|
18
|
+
east, north, np.zeros_like(east), degrees=degrees
|
|
19
|
+
)
|
|
20
|
+
npt.assert_allclose(declination, expected, atol=1e-14)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .ppigrf import igrf, igrf_gc, get_inclination_declination
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|