Passed
Push — master ( 90643e...9a50c9 )
by Stefan
07:24
created

test_igrf   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 33
dl 0
loc 59
rs 10
c 0
b 0
f 0
wmc 5

1 Function

Rating   Name   Duplication   Size   Complexity  
B test_gmpole() 0 34 5
1
# -*- coding: utf-8 -*-
2
# vim:fileencoding=utf-8
3
#
4
# Copyright (c) 2020 Stefan Bender
5
#
6
# This module is part of sciapy.
7
# sciapy is free software: you can redistribute it or modify
8
# it under the terms of the GNU General Public License as published
9
# by the Free Software Foundation, version 2.
10
# See accompanying LICENSE file or http://www.gnu.org/licenses/gpl-2.0.html.
11
"""Test IGRF geomagnetic CD and ED coordinates
12
13
Centred-iploe (CD) and eccentric-dipole (ED) coordinates
14
according to Fraser-Smith 1987
15
"""
16
import datetime as dt
17
18
import numpy as np
19
import pytest
20
21
from sciapy.level2 import igrf
22
23
24
# From Fraser-Smith 1987 and Laundal and Richmond 2017
25
@pytest.mark.parametrize(
26
	"date, cd_n, cd_s, dr, dR",
27
	[
28
		(
29
			dt.datetime(1980, 1, 1),
30
			(78.81, -70.8), None,
31
			(-385.4, 247.5, 170.2),
32
			None,
33
		),
34
		(
35
			dt.datetime(1985, 1, 1),
36
			# (78.98, 289.1), None,
37
			(78.98, -70.9), None,
38
			(-391.9, 257.7, 178.9),
39
			(-399.1, -286.1, 104.6),
40
		),
41
		(
42
			dt.datetime(2015, 1, 1),
43
			(90 - 9.69, -72.63), (90. - 170.31, 107.37),
44
			None,
45
			None,
46
		),
47
	]
48
)
49
def test_gmpole(date, cd_n, cd_s, dr, dR):
50
	cd_np, cd_sp, drp, dRp, B0sqp = igrf.gmpole(date)
51
	if cd_n is not None:
52
		np.testing.assert_allclose(cd_np, cd_n, atol=0.05)
53
	if cd_s is not None:
54
		np.testing.assert_allclose(cd_sp, cd_s, atol=0.05)
55
	if dr is not None:
56
		np.testing.assert_allclose(drp, dr, atol=0.81)
57
	if dR is not None:
58
		np.testing.assert_allclose(dRp, dR, atol=0.71)
59