-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from santisoler/inclination-declination
Add function to get inclination and declination
- Loading branch information
Showing
3 changed files
with
93 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from .ppigrf import igrf, igrf_gc | ||
from .ppigrf import igrf, igrf_gc, get_inclination_declination |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
""" | ||
Test function to compute inclination and declination. | ||
""" | ||
import pytest | ||
import numpy as np | ||
import numpy.testing as npt | ||
|
||
from ppigrf import get_inclination_declination | ||
|
||
|
||
@pytest.mark.parametrize("degrees", (True, False)) | ||
@pytest.mark.parametrize( | ||
"geomagnetic_field, inclination, declination", | ||
[ | ||
[(0, 0, -1), 90, 0], | ||
[(0, 0, 1), -90, 0], | ||
[(1, 1, 0), 0, 45], | ||
[(-1, 1, 0), 0, -45], | ||
[(1, 1, -np.sqrt(2)), 45, 45], | ||
[(1, 1, np.sqrt(2)), -45, 45], | ||
[(-2_938.0, 16_308.1, -52_741.9), 72.5582, -10.2126], | ||
], | ||
) | ||
def test_inclination_declination(degrees, geomagnetic_field, inclination, declination): | ||
""" | ||
Test inclination and declination with known values. | ||
The last values were obtained by one of the online calculators. | ||
""" | ||
if not degrees: | ||
inclination = np.radians(inclination) | ||
declination = np.radians(declination) | ||
inc, dec = get_inclination_declination(*geomagnetic_field, degrees=degrees) | ||
npt.assert_allclose([inc, dec], [inclination, declination], rtol=5e-5) |