Test Setup Failed
Push — develop ( e5d4b6...3e903d )
by Adam
04:05
created

TestAtmCorrection.tearDown()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
# Copyright (c) 2017 Adam.Dybbroe
5
6
# Author(s):
7
8
#   Adam.Dybbroe <[email protected]>
9
10
# This program is free software: you can redistribute it and/or modify
11
# it under the terms of the GNU General Public License as published by
12
# the Free Software Foundation, either version 3 of the License, or
13
# (at your option) any later version.
14
15
# This program is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
# GNU General Public License for more details.
19
20
# You should have received a copy of the GNU General Public License
21
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
23
"""Unit tests of the atmospherical correction in the ir spectral range
24
"""
25
26
27
import sys
28
if sys.version_info < (2, 7):
29
    import unittest2 as unittest
30
else:
31
    import unittest
32
33
import numpy as np
34
from pyspectral.atm_correction_ir import AtmosphericalCorrection
35
#from mock import patch
36
37
from pyspectral.tests.unittest_helpers import assertNumpyArraysEqual
38
39
# Mock some modules, so we don't need them for tests.
40
41
#sys.modules['pyresample'] = MagicMock()
42
43
SATZ = np.ma.array([[48.03,  48.03002,  48.03004,  48.03006,  48.03008,  48.0301,
44
                     48.03012,  48.03014,  48.03016,  48.03018],
45
                    [48.09,  48.09002,  48.09004,  48.09006,  48.09008,  48.0901,
46
                     48.09012,  48.09014,  48.09016,  48.09018],
47
                    [48.15,  48.15002,  48.15004,  48.15006,  48.15008,  48.1501,
48
                     48.15012,  48.15014,  48.15016,  48.15018],
49
                    [48.21,  48.21002,  48.21004,  48.21006,  48.21008,  48.2101,
50
                     48.21012,  48.21014,  48.21016,  48.21018],
51
                    [48.27,  48.27002,  48.27004,  48.27006,  48.27008,  48.2701,
52
                     48.27012,  48.27014,  48.27016,  48.27018],
53
                    [48.33,  48.33002,  48.33004,  48.33006,  48.33008,  48.3301,
54
                     48.33012,  48.33014,  48.33016,  48.33018],
55
                    [48.39,  48.39002,  48.39004,  48.39006,  48.39008,  48.3901,
56
                     48.39012,  48.39014,  48.39016,  48.39018],
57
                    [48.45,  48.45002,  48.45004,  48.45006,  48.45008,  48.4501,
58
                     48.45012,  48.45014,  48.45016,  48.45018],
59
                    [48.51,  48.51002,  48.51004,  48.51006,  48.51008,  48.5101,
60
                     48.51012,  48.51014,  48.51016,  48.51018],
61
                    [48.57,  48.57002,  48.57004,  48.57006,  48.57008,  48.5701,
62
                     48.57012,  48.57014,  48.57016,  48.57018]], mask=False)
63
64
TBS = np.ma.array([[284.04,  284.04002667,  284.04005333,  284.04008,
65
                    284.04010667,  284.04013333,  284.04016,  284.04018667,
66
                    284.04021333,  284.04024],
67
                   [284.12,  284.12002667,  284.12005333,  284.12008,
68
                    284.12010667,  284.12013333,  284.12016,  284.12018667,
69
                    284.12021333,  284.12024],
70
                   [284.2,  284.20002667,  284.20005333,  284.20008,
71
                    284.20010667,  284.20013333,  284.20016,  284.20018667,
72
                    284.20021333,  284.20024],
73
                   [284.28,  284.28002667,  284.28005333,  284.28008,
74
                    284.28010667,  284.28013333,  284.28016,  284.28018667,
75
                    284.28021333,  284.28024],
76
                   [284.36,  284.36002667,  284.36005333,  284.36008,
77
                    284.36010667,  284.36013333,  284.36016,  284.36018667,
78
                    284.36021333,  284.36024],
79
                   [284.44,  284.44002667,  284.44005333,  284.44008,
80
                    284.44010667,  284.44013333,  284.44016,  284.44018667,
81
                    284.44021333,  284.44024],
82
                   [284.52,  284.52002667,  284.52005333,  284.52008,
83
                    284.52010667,  284.52013333,  284.52016,  284.52018667,
84
                    284.52021333,  284.52024],
85
                   [284.6,  284.60002667,  284.60005333,  284.60008,
86
                    284.60010667,  284.60013333,  284.60016,  284.60018667,
87
                    284.60021333,  284.60024],
88
                   [284.68,  284.68002667,  284.68005333,  284.68008,
89
                    284.68010667,  284.68013333,  284.68016,  284.68018667,
90
                    284.68021333,  284.68024],
91
                   [284.76,  284.76002667,  284.76005333,  284.76008,
92
                    284.76010667,  284.76013333,  284.76016,  284.76018667,
93
                    284.76021333,  284.76024]], mask=False)
94
95
RES = np.ma.array([[286.03159412,  286.03162417,  286.03165421,  286.03168426,
96
                    286.0317143,  286.03174434,  286.03177439,  286.03180443,
97
                    286.03183447,  286.03186452],
98
                   [286.12174723,  286.12177729,  286.12180735,  286.12183741,
99
                    286.12186747,  286.12189752,  286.12192758,  286.12195764,
100
                    286.1219877,  286.12201776],
101
                   [286.21194545,  286.21197552,  286.2120056,  286.21203567,
102
                    286.21206574,  286.21209582,  286.21212589,  286.21215597,
103
                    286.21218604,  286.21221611],
104
                   [286.30218896,  286.30221905,  286.30224913,  286.30227922,
105
                    286.30230931,  286.3023394,  286.30236949,  286.30239958,
106
                    286.30242967,  286.30245976],
107
                   [286.39247793,  286.39250803,  286.39253814,  286.39256824,
108
                    286.39259834,  286.39262845,  286.39265855,  286.39268866,
109
                    286.39271876,  286.39274886],
110
                   [286.48281254,  286.48284266,  286.48287278,  286.4829029,
111
                    286.48293302,  286.48296314,  286.48299325,  286.48302337,
112
                    286.48305349,  286.48308361],
113
                   [286.57319297,  286.5732231,  286.57325324,  286.57328337,
114
                    286.57331351,  286.57334364,  286.57337378,  286.57340391,
115
                    286.57343405,  286.57346418],
116
                   [286.6636194,  286.66364955,  286.6636797,  286.66370985,
117
                    286.66374,  286.66377015,  286.6638003,  286.66383045,
118
                    286.6638606,  286.66389075],
119
                   [286.754092,  286.75412216,  286.75415233,  286.75418249,
120
                    286.75421266,  286.75424283,  286.75427299,  286.75430316,
121
                    286.75433332,  286.75436349],
122
                   [286.84461096,  286.84464114,  286.84467132,  286.8447015,
123
                    286.84473168,  286.84476186,  286.84479204,  286.84482222,
124
                    286.8448524,  286.84488258]], mask=False)
125
126
127
class TestAtmCorrection(unittest.TestCase):
128
129
    """Class for testing pyspectral.atm_correction_ir"""
130
131
    def setUp(self):
132
        """Setup the test"""
133
        pass
134
135
    def test_get_correction(self):
136
        """Test getting the atm correction"""
137
138
        this = AtmosphericalCorrection('EOS-Terra', 'modis')
139
        atm_corr = this.get_correction(SATZ, None, TBS)
140
        assertNumpyArraysEqual(TBS, atm_corr)
141
142
    def tearDown(self):
143
        """Clean up"""
144
        pass
145
146
147
def suite():
148
    """The test suite for test_atm_correction_ir.
149
    """
150
    loader = unittest.TestLoader()
151
    mysuite = unittest.TestSuite()
152
    mysuite.addTest(loader.loadTestsFromTestCase(TestAtmCorrection))
153
154
    return mysuite
155