Passed
Push — develop ( 885684...7d5043 )
by Angeline
01:39
created

test_utils_aacgmv2   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 21
dl 0
loc 34
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A TestUtilsAACGMV2.test_subsol() 0 7 1
A TestUtilsAACGMV2.teardown() 0 3 1
A TestUtilsAACGMV2.setup() 0 4 1
A TestUtilsAACGMV2.test_igrf_dipole_axis() 0 6 1
1
# -*- coding: utf-8 -*-
2
from __future__ import division, absolute_import, unicode_literals
3
4
import datetime as dt
5
import numpy as np
6
import pytest
7
8
from aacgmv2 import utils
9
10
class TestUtilsAACGMV2:
11
    def setup(self):
12
        """Runs before every method to create a clean testing setup"""
13
        self.dtime = dt.datetime(2015, 1, 1, 0, 0, 0)
14
        self.out = None
15
16
    def teardown(self):
17
        """Runs after every method to clean up previous testing"""
18
        del self.dtime, self.out
19
20
    def test_subsol(self):
21
        """Test the subsolar calculation"""
22
        self.out = utils.subsol(self.dtime.year, int(self.dtime.strftime("%j")),
23
                                self.dtime.hour * 3600.0
24
                                + self.dtime.minute * 60.0 + self.dtime.second)
25
26
        np.testing.assert_allclose(self.out, [-179.2004, -23.0431], rtol=1.0e-4)
27
28
    def test_igrf_dipole_axis(self):
29
        """Test the IGRF dipole axis calculation"""
30
        self.out = utils.igrf_dipole_axis(self.dtime)
31
32
        np.testing.assert_allclose(self.out, [0.050281, -0.16057, 0.98574],
33
                                   rtol=1.0e-4)
34