ppigrf 2.0.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.0.0/src/ppigrf.egg-info → ppigrf-2.2.0}/PKG-INFO +38 -8
- ppigrf-2.2.0/pyproject.toml +47 -0
- {ppigrf-2.0.0 → ppigrf-2.2.0}/src/ppigrf/IGRF14.shc +2 -2
- ppigrf-2.2.0/src/ppigrf/__init__.py +14 -0
- {ppigrf-2.0.0 → ppigrf-2.2.0}/src/ppigrf/ppigrf.py +61 -18
- {ppigrf-2.0.0 → ppigrf-2.2.0/src/ppigrf.egg-info}/PKG-INFO +38 -8
- {ppigrf-2.0.0 → ppigrf-2.2.0}/src/ppigrf.egg-info/SOURCES.txt +3 -1
- ppigrf-2.2.0/src/ppigrf.egg-info/requires.txt +5 -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.0.0 → ppigrf-2.2.0}/test/test_inclination_declination.py +6 -0
- ppigrf-2.0.0/setup.py +0 -40
- ppigrf-2.0.0/src/ppigrf/__init__.py +0 -1
- ppigrf-2.0.0/src/ppigrf.egg-info/requires.txt +0 -2
- {ppigrf-2.0.0 → ppigrf-2.2.0}/LICENSE +0 -0
- {ppigrf-2.0.0 → ppigrf-2.2.0}/README.md +0 -0
- {ppigrf-2.0.0 → ppigrf-2.2.0}/setup.cfg +0 -0
- {ppigrf-2.0.0 → ppigrf-2.2.0}/src/ppigrf/IGRF13.shc +0 -0
- {ppigrf-2.0.0 → ppigrf-2.2.0}/src/ppigrf.egg-info/dependency_links.txt +0 -0
- {ppigrf-2.0.0 → ppigrf-2.2.0}/src/ppigrf.egg-info/top_level.txt +0 -0
- {ppigrf-2.0.0 → ppigrf-2.2.0}/test/test_igrf.py +0 -0
|
@@ -1,18 +1,48 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
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
|
-
|
|
7
|
-
|
|
6
|
+
Maintainer-email: Ashley Smith <ashley@mag.earth>
|
|
7
|
+
License: MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2021 Karl M. Laundal
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
Project-URL: Homepage, https://github.com/IAGA-VMOD/ppigrf
|
|
30
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
31
|
+
Classifier: Topic :: Scientific/Engineering
|
|
8
32
|
Classifier: Intended Audience :: Science/Research
|
|
9
|
-
Classifier:
|
|
33
|
+
Classifier: Intended Audience :: Developers
|
|
34
|
+
Classifier: Operating System :: OS Independent
|
|
35
|
+
Classifier: Programming Language :: Python
|
|
10
36
|
Classifier: Programming Language :: Python :: 3
|
|
11
|
-
|
|
37
|
+
Classifier: Development Status :: 4 - Beta
|
|
38
|
+
Requires-Python: >=3.6.1
|
|
12
39
|
Description-Content-Type: text/markdown
|
|
13
40
|
License-File: LICENSE
|
|
14
|
-
Requires-Dist: numpy>=
|
|
15
|
-
Requires-Dist: pandas>=1.
|
|
41
|
+
Requires-Dist: numpy>=1.15
|
|
42
|
+
Requires-Dist: pandas>=1.0
|
|
43
|
+
Provides-Extra: dev
|
|
44
|
+
Requires-Dist: pytest; extra == "dev"
|
|
45
|
+
Dynamic: license-file
|
|
16
46
|
|
|
17
47
|
# Pure Python International Geomagnetic Reference Field
|
|
18
48
|
[](https://zenodo.org/badge/latestdoi/352365168)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ppigrf"
|
|
7
|
+
version = "2.2.0"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Karl Laundal" }
|
|
10
|
+
]
|
|
11
|
+
maintainers = [
|
|
12
|
+
{ name = "Ashley Smith", email = "ashley@mag.earth" },
|
|
13
|
+
]
|
|
14
|
+
license = { file = "LICENSE" }
|
|
15
|
+
description = "Pure Python IGRF"
|
|
16
|
+
readme = "README.md"
|
|
17
|
+
requires-python = ">=3.6.1"
|
|
18
|
+
classifiers = [
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Topic :: Scientific/Engineering",
|
|
21
|
+
"Intended Audience :: Science/Research",
|
|
22
|
+
"Intended Audience :: Developers",
|
|
23
|
+
"Operating System :: OS Independent",
|
|
24
|
+
"Programming Language :: Python",
|
|
25
|
+
"Programming Language :: Python :: 3",
|
|
26
|
+
"Development Status :: 4 - Beta",
|
|
27
|
+
]
|
|
28
|
+
dependencies = [
|
|
29
|
+
"numpy >= 1.15",
|
|
30
|
+
"pandas >= 1.0",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.optional-dependencies]
|
|
34
|
+
dev = [
|
|
35
|
+
"pytest"
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "https://github.com/IAGA-VMOD/ppigrf"
|
|
40
|
+
|
|
41
|
+
[tool.setuptools]
|
|
42
|
+
packages = ["ppigrf"]
|
|
43
|
+
package-dir = {"" = "src"}
|
|
44
|
+
include-package-data = true
|
|
45
|
+
|
|
46
|
+
[tool.setuptools.package-data]
|
|
47
|
+
ppigrf = ["*.shc"]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# IGRF 14
|
|
2
2
|
# International Geomagnetic Reference Field -- 14th generation
|
|
3
|
-
# see https://doi.org/10.5281/zenodo.
|
|
4
|
-
1 13
|
|
3
|
+
# see https://doi.org/10.5281/zenodo.14012302 for detailed description
|
|
4
|
+
1 13 27 2 1 1900.0 2030.0
|
|
5
5
|
1900.0 1905.0 1910.0 1915.0 1920.0 1925.0 1930.0 1935.0 1940.0 1945.0 1950.0 1955.0 1960.0 1965.0 1970.0 1975.0 1980.0 1985.0 1990.0 1995.0 2000.0 2005.0 2010.0 2015.0 2020.0 2025.0 2030.0
|
|
6
6
|
1 0 -31543 -31464 -31354 -31212 -31060 -30926 -30805 -30715 -30654 -30594 -30554 -30500 -30421 -30334 -30220 -30100 -29992 -29873 -29775 -29692 -29619.4 -29554.63 -29496.57 -29441.46 -29403.41 -29350.0 -29287.0
|
|
7
7
|
1 1 -2298 -2298 -2297 -2306 -2317 -2318 -2316 -2306 -2292 -2285 -2250 -2215 -2169 -2119 -2068 -2013 -1956 -1905 -1848 -1784 -1728.2 -1669.05 -1586.42 -1501.77 -1451.37 -1410.3 -1360.3
|
|
@@ -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"
|
|
@@ -442,7 +442,7 @@ def geoc2geod(theta, r, B_th, B_r):
|
|
|
442
442
|
|
|
443
443
|
|
|
444
444
|
|
|
445
|
-
def igrf_gc(r, theta, phi, date, coeff_fn = shc_fn):
|
|
445
|
+
def igrf_gc(r, theta, phi, date, coeff_fn = shc_fn, min_degree=1, max_degree=13):
|
|
446
446
|
"""
|
|
447
447
|
Calculate IGRF model components
|
|
448
448
|
|
|
@@ -467,6 +467,10 @@ def igrf_gc(r, theta, phi, date, coeff_fn = shc_fn):
|
|
|
467
467
|
one or more dates to evaluate IGRF coefficients
|
|
468
468
|
coeff_fn : string, optional
|
|
469
469
|
filename of .shc file. Default is latest IGRF
|
|
470
|
+
min_degree : int, optional
|
|
471
|
+
lowest degree of expansion min_degree >= 1
|
|
472
|
+
max_degree : int, optional
|
|
473
|
+
highest degree of expansion, 1 <= max_degree <= 13
|
|
470
474
|
|
|
471
475
|
Return
|
|
472
476
|
------
|
|
@@ -491,6 +495,11 @@ def igrf_gc(r, theta, phi, date, coeff_fn = shc_fn):
|
|
|
491
495
|
print('Warning: You provided date(s) not covered by coefficient file \n({} to {})'.format(
|
|
492
496
|
g.index[0].date(), g.index[-1].date()))
|
|
493
497
|
|
|
498
|
+
if min_degree > max_degree:
|
|
499
|
+
print('Warning: Highest degree of expansion must be larger or equal to lowest degree.')
|
|
500
|
+
print('Reset to original range.')
|
|
501
|
+
min_degree, max_degree = 1, 13
|
|
502
|
+
|
|
494
503
|
# get coordinate arrays to same size and shape
|
|
495
504
|
r, theta, phi = np.broadcast_arrays(r, theta, phi)
|
|
496
505
|
shape = r.shape
|
|
@@ -524,18 +533,34 @@ def igrf_gc(r, theta, phi, date, coeff_fn = shc_fn):
|
|
|
524
533
|
# make versions of n and m that are repeated twice
|
|
525
534
|
nn, mm = np.tile(n, 2), np.tile(m, 2)
|
|
526
535
|
|
|
536
|
+
N_map = ((nn >= min_degree) & (nn <= max_degree)).astype(int)
|
|
537
|
+
|
|
527
538
|
# calculate Br:
|
|
528
|
-
G = (RE / r) ** (nn + 2) * (nn + 1) * np.hstack((P * cosmphi, P * sinmphi))
|
|
539
|
+
G = N_map * (RE / r) ** (nn + 2) * (nn + 1) * np.hstack((P * cosmphi, P * sinmphi))
|
|
529
540
|
Br = G.dot(np.hstack((g.values, h.values)).T).T # shape (n_times, n_coords)
|
|
530
541
|
|
|
531
542
|
# calculate Btheta:
|
|
532
|
-
G = -(RE / r) ** (nn + 1) * np.hstack((dP * cosmphi, dP * sinmphi)) \
|
|
543
|
+
G = - N_map * (RE / r) ** (nn + 1) * np.hstack((dP * cosmphi, dP * sinmphi)) \
|
|
533
544
|
* RE / r
|
|
534
545
|
Btheta = G.dot(np.hstack((g.values, h.values)).T).T # shape (n_times, n_coords)
|
|
535
546
|
|
|
536
547
|
# calculate Bphi:
|
|
537
|
-
|
|
538
|
-
|
|
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
|
+
|
|
539
564
|
Bphi = G.dot(np.hstack((g.values, h.values)).T).T # shape (n_times, n_coords)
|
|
540
565
|
|
|
541
566
|
# reshape and return
|
|
@@ -543,7 +568,7 @@ def igrf_gc(r, theta, phi, date, coeff_fn = shc_fn):
|
|
|
543
568
|
return Br.reshape(outshape), Btheta.reshape(outshape), Bphi.reshape(outshape)
|
|
544
569
|
|
|
545
570
|
|
|
546
|
-
def igrf(lon, lat, h, date, coeff_fn = shc_fn):
|
|
571
|
+
def igrf(lon, lat, h, date, coeff_fn = shc_fn, min_degree=1, max_degree=13):
|
|
547
572
|
"""
|
|
548
573
|
Calculate IGRF model components
|
|
549
574
|
|
|
@@ -568,6 +593,10 @@ def igrf(lon, lat, h, date, coeff_fn = shc_fn):
|
|
|
568
593
|
one or more dates to evaluate IGRF coefficients
|
|
569
594
|
coeff_fn : string, optional
|
|
570
595
|
filename of .shc file. Default is latest IGRF
|
|
596
|
+
min_degree : int, optional
|
|
597
|
+
lowest degree of expansion, min_degree >= 1
|
|
598
|
+
max_degree : int, optional
|
|
599
|
+
highest degree of expansion, 1 <= max_degree <= 13
|
|
571
600
|
|
|
572
601
|
Return
|
|
573
602
|
------
|
|
@@ -581,6 +610,11 @@ def igrf(lon, lat, h, date, coeff_fn = shc_fn):
|
|
|
581
610
|
ellipsoid
|
|
582
611
|
"""
|
|
583
612
|
|
|
613
|
+
if min_degree > max_degree:
|
|
614
|
+
print('Warning: Highest degree of expansion must be larger or equal to lowest degree.')
|
|
615
|
+
print('Reset to original range.')
|
|
616
|
+
min_degree, max_degree = 1, 13
|
|
617
|
+
|
|
584
618
|
# convert input to arrays and cast to same shape:
|
|
585
619
|
lon, lat, h = np.broadcast_arrays(lon, lat, h)
|
|
586
620
|
shape = lon.shape
|
|
@@ -591,7 +625,7 @@ def igrf(lon, lat, h, date, coeff_fn = shc_fn):
|
|
|
591
625
|
phi = lon
|
|
592
626
|
|
|
593
627
|
# calculate geocentric components of IGRF:
|
|
594
|
-
Br, Btheta, Bphi = igrf_gc(r, theta, phi, date, coeff_fn = coeff_fn)
|
|
628
|
+
Br, Btheta, Bphi = igrf_gc(r, theta, phi, date, coeff_fn = coeff_fn, min_degree=min_degree, max_degree=max_degree)
|
|
595
629
|
Be = Bphi
|
|
596
630
|
|
|
597
631
|
# convert output to geodetic
|
|
@@ -602,7 +636,7 @@ def igrf(lon, lat, h, date, coeff_fn = shc_fn):
|
|
|
602
636
|
return Be.reshape(outshape), Bn.reshape(outshape), Bu.reshape(outshape)
|
|
603
637
|
|
|
604
638
|
|
|
605
|
-
def igrf_V(r, theta, phi, date, coeff_fn = shc_fn):
|
|
639
|
+
def igrf_V(r, theta, phi, date, coeff_fn = shc_fn, min_degree=1, max_degree=13):
|
|
606
640
|
"""
|
|
607
641
|
Calculate IGRF magnetic potential
|
|
608
642
|
|
|
@@ -627,6 +661,11 @@ def igrf_V(r, theta, phi, date, coeff_fn = shc_fn):
|
|
|
627
661
|
one or more dates to evaluate IGRF coefficients
|
|
628
662
|
coeff_fn : string, optional
|
|
629
663
|
filename of .shc file. Default is latest IGRF
|
|
664
|
+
min_degree : int, optional
|
|
665
|
+
lowest degree of expansion, min_degree >= 1
|
|
666
|
+
max_degree : int, optional
|
|
667
|
+
highest degree of expansion, 1 <= max_degree <= 13
|
|
668
|
+
|
|
630
669
|
|
|
631
670
|
Return
|
|
632
671
|
------
|
|
@@ -634,6 +673,11 @@ def igrf_V(r, theta, phi, date, coeff_fn = shc_fn):
|
|
|
634
673
|
Magnetic potential (unit nT * km)
|
|
635
674
|
"""
|
|
636
675
|
|
|
676
|
+
if min_degree > max_degree:
|
|
677
|
+
print('Warning: Highest degree of expansion must be larger or equal to lowest degree.')
|
|
678
|
+
print('Reset to original range.')
|
|
679
|
+
min_degree, max_degree = 1, 13
|
|
680
|
+
|
|
637
681
|
# read coefficient file:
|
|
638
682
|
g, h = read_shc(coeff_fn)
|
|
639
683
|
|
|
@@ -678,8 +722,10 @@ def igrf_V(r, theta, phi, date, coeff_fn = shc_fn):
|
|
|
678
722
|
# make versions of n and m that are repeated twice
|
|
679
723
|
nn, mm = np.tile(n, 2), np.tile(m, 2)
|
|
680
724
|
|
|
725
|
+
N_map = ((nn >= min_degree) & (nn <= max_degree)).astype(int)
|
|
726
|
+
|
|
681
727
|
# calculate Br:
|
|
682
|
-
G = RE * (RE / r) ** (nn + 1) * np.hstack((P * cosmphi, P * sinmphi))
|
|
728
|
+
G = N_map * RE * (RE / r) ** (nn + 1) * np.hstack((P * cosmphi, P * sinmphi))
|
|
683
729
|
V = G.dot(np.hstack((g.values, h.values)).T).T # shape (n_times, n_coords)
|
|
684
730
|
|
|
685
731
|
# reshape and return
|
|
@@ -704,7 +750,7 @@ def get_inclination_declination(Be, Bn, Bu, degrees=True):
|
|
|
704
750
|
|
|
705
751
|
.. math::
|
|
706
752
|
|
|
707
|
-
D = \
|
|
753
|
+
D = \operatorname{atan2}(B_e, B_n)
|
|
708
754
|
|
|
709
755
|
Parameters
|
|
710
756
|
----------
|
|
@@ -731,14 +777,11 @@ def get_inclination_declination(Be, Bn, Bu, degrees=True):
|
|
|
731
777
|
it's returned in radians.
|
|
732
778
|
"""
|
|
733
779
|
# Compute the horizontal component of B
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
# Compute the two angles
|
|
740
|
-
inclination = np.arctan(-Bu / horizontal_component)
|
|
741
|
-
declination = np.arcsin(Be / horizontal_component)
|
|
780
|
+
H = np.hypot(Be, Bn)
|
|
781
|
+
# Compute the inclination and declination, accounting for special H=0 case
|
|
782
|
+
safe_division = np.divide(-Bu, H, where=H != 0)
|
|
783
|
+
inclination = np.where(H != 0, np.arctan(safe_division), -np.sign(Bu) * np.pi /2)
|
|
784
|
+
declination = np.where(H != 0, np.arctan2(Be, Bn), 0)
|
|
742
785
|
# Convert to degrees if needed
|
|
743
786
|
if degrees:
|
|
744
787
|
inclination = np.degrees(inclination)
|
|
@@ -1,18 +1,48 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
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
|
-
|
|
7
|
-
|
|
6
|
+
Maintainer-email: Ashley Smith <ashley@mag.earth>
|
|
7
|
+
License: MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2021 Karl M. Laundal
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
Project-URL: Homepage, https://github.com/IAGA-VMOD/ppigrf
|
|
30
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
31
|
+
Classifier: Topic :: Scientific/Engineering
|
|
8
32
|
Classifier: Intended Audience :: Science/Research
|
|
9
|
-
Classifier:
|
|
33
|
+
Classifier: Intended Audience :: Developers
|
|
34
|
+
Classifier: Operating System :: OS Independent
|
|
35
|
+
Classifier: Programming Language :: Python
|
|
10
36
|
Classifier: Programming Language :: Python :: 3
|
|
11
|
-
|
|
37
|
+
Classifier: Development Status :: 4 - Beta
|
|
38
|
+
Requires-Python: >=3.6.1
|
|
12
39
|
Description-Content-Type: text/markdown
|
|
13
40
|
License-File: LICENSE
|
|
14
|
-
Requires-Dist: numpy>=
|
|
15
|
-
Requires-Dist: pandas>=1.
|
|
41
|
+
Requires-Dist: numpy>=1.15
|
|
42
|
+
Requires-Dist: pandas>=1.0
|
|
43
|
+
Provides-Extra: dev
|
|
44
|
+
Requires-Dist: pytest; extra == "dev"
|
|
45
|
+
Dynamic: license-file
|
|
16
46
|
|
|
17
47
|
# Pure Python International Geomagnetic Reference Field
|
|
18
48
|
[](https://zenodo.org/badge/latestdoi/352365168)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
LICENSE
|
|
2
2
|
README.md
|
|
3
|
-
|
|
3
|
+
pyproject.toml
|
|
4
4
|
src/ppigrf/IGRF13.shc
|
|
5
5
|
src/ppigrf/IGRF14.shc
|
|
6
6
|
src/ppigrf/__init__.py
|
|
@@ -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)
|
|
@@ -19,6 +19,12 @@ from ppigrf import get_inclination_declination
|
|
|
19
19
|
[(1, 1, -np.sqrt(2)), 45, 45],
|
|
20
20
|
[(1, 1, np.sqrt(2)), -45, 45],
|
|
21
21
|
[(-2_938.0, 16_308.1, -52_741.9), 72.5582, -10.2126],
|
|
22
|
+
[(np.array([0, 0, 1, -1, 1, 1, -2_938.0]),
|
|
23
|
+
np.array([0, 0, 1, 1, 1, 1, 16_308.1]),
|
|
24
|
+
np.array([-1, 1, 0, 0, -np.sqrt(2), np.sqrt(2), -52_741.9])),
|
|
25
|
+
np.array([90, -90, 0, 0, 45, -45, 72.5582]),
|
|
26
|
+
np.array([0, 0, 45, -45, 45, 45, -10.2126]),
|
|
27
|
+
],
|
|
22
28
|
],
|
|
23
29
|
)
|
|
24
30
|
def test_inclination_declination(degrees, geomagnetic_field, inclination, declination):
|
ppigrf-2.0.0/setup.py
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import setuptools
|
|
2
|
-
|
|
3
|
-
# Howto
|
|
4
|
-
#
|
|
5
|
-
#This is how to upload a project to pipy. This is mainly a note to self, as this is the first project I have uplo#aded to pypi:
|
|
6
|
-
#
|
|
7
|
-
#python3 -m venv /tmp/venv
|
|
8
|
-
#source /tmp/venv/bin/activate
|
|
9
|
-
#pip install build
|
|
10
|
-
#pip install twine
|
|
11
|
-
#python3 -m build
|
|
12
|
-
#python3 -m twine upload dist/ppigrf-1.0.0.tar.gz
|
|
13
|
-
|
|
14
|
-
#Genrate long description using readme file
|
|
15
|
-
with open("README.md", "r", encoding="utf-8") as fh:
|
|
16
|
-
long_description = fh.read()
|
|
17
|
-
|
|
18
|
-
setuptools.setup(
|
|
19
|
-
name="ppigrf",
|
|
20
|
-
version="2.0.0",
|
|
21
|
-
author="Karl Laundal",
|
|
22
|
-
author_email="readme@file.md",
|
|
23
|
-
description="Pure Python IGRF",
|
|
24
|
-
long_description=long_description,
|
|
25
|
-
long_description_content_type="text/markdown",
|
|
26
|
-
classifiers=[
|
|
27
|
-
"Development Status :: 4 - Beta",
|
|
28
|
-
"Intended Audience :: Science/Research",
|
|
29
|
-
"Natural Language :: English",
|
|
30
|
-
"Programming Language :: Python :: 3",
|
|
31
|
-
],
|
|
32
|
-
install_requires=[
|
|
33
|
-
'numpy>=0.13.1',
|
|
34
|
-
'pandas>=1.3.5'
|
|
35
|
-
],
|
|
36
|
-
package_dir={"": "src"},
|
|
37
|
-
package_data={'':['IGRF13.shc', 'IGRF14.shc']},
|
|
38
|
-
packages=setuptools.find_packages(where="src"),
|
|
39
|
-
python_requires=">=3.6",
|
|
40
|
-
)
|
|
@@ -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
|