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

test_utils_aacgmv2.TestUtilsAACGMV2.teardown()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nop 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