Total Complexity | 4 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Changes | 0 |
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 |