File: test_satelliteinterpolator.py

package info (click to toggle)
python-geotiepoints 1.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,824 kB
  • sloc: python: 3,124; makefile: 111; sh: 15
file content (168 lines) | stat: -rw-r--r-- 8,553 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
"""Tests for SatelliteInterpolator."""

import unittest
import numpy as np

from geotiepoints import SatelliteInterpolator

TIES_EXP1 = np.array([[6384905.78040055,  6381081.08333225,  6371519.34066148,
                       6328950.00792935,  6253610.69157758,  6145946.19489936,
                       6124413.29556372],
                      [6377591.95940176,  6370997.,  6354509.6014956,
                       6305151.62592155,  6223234.99818839,  6109277.14889072,
                       6086485.57903118],
                      [6359307.40690478,  6345786.79166939,  6311985.2535809,
                       6245655.67090206,  6147295.76471541,  6017604.5338691,
                       5991666.28769983],
                      [6351993.58590599,  6335702.70833714,  6294975.51441502,
                       6221857.28889426,  6116920.07132621,  5980935.48786045,
                       5953738.5711673],
                      [6338032.26190294,  6320348.4990906,  6276139.09205974,
                       6199670.56624433,  6091551.90273768,  5952590.38414781,
                       5924798.08042984],
                      [6290665.5946295,  6270385.16249031,  6219684.08214232,
                       6137100.75832981,  6023313.2794414,  5879194.72399075,
                       5850371.01290062],
                      [6172248.92644589,  6145476.82098957,  6078546.55734877,
                       5980676.23854351,  5852716.72120069,  5695705.57359808,
                       5664303.34407756],
                      [6124882.25917245,  6095513.48438928,  6022091.54743135,
                       5918106.430629,  5784478.09790441,  5622309.91344102,
                       5589876.27654834]])

TIES_EXP2 = np.array([[6372937.31273379,  6370997.,  6366146.21816553,
                       6351605.98629588,  6327412.61244969,  6293626.50067273,
                       6286869.27831734],
                      [6353136.46335726,  6345786.79166939,  6327412.61244969,
                       6299445.69529922,  6261968.60390423,  6215087.60607344,
                       6205711.40650728]])

TIES_EXP3 = np.array([[6372937.31273379,  6370997.,  6366146.21816553,
                       6351605.98629588,  6327412.61244969,  6293626.50067273,
                       6286869.27831734],
                      [6353136.46335726,  6345786.79166939,  6327412.61244969,
                       6299445.69529922,  6261968.60390423,  6215087.60607344,
                       6205711.40650728]])

TIES_EXP4 = np.array([[6381081.08333225,  6381639.66045187,  6372470.10269454,
                       6353590.21586788,  6325042.05851245],
                      [6370997.,  6366146.21816553,  6351605.98629588,
                       6327412.61244969,  6293626.50067273],
                      [6345786.79166939,  6327412.61244969,  6299445.69529922,
                       6261968.60390423,  6215087.60607344],
                      [6335702.70833714,  6311919.17016336,  6278581.57890056,
                       6235791.00048604,  6183672.04823372]])

TIES_EXP5 = np.array([[6381081.08333225,  6371519.34066148,  6328950.00792935,
                       6253610.69157758,  6145946.19489936],
                      [6370997.,  6354509.6014956,  6305151.62592155,
                       6223234.99818839,  6109277.14889072],
                      [6345786.79166939,  6311985.2535809,  6245655.67090206,
                       6147295.76471541,  6017604.5338691],
                      [6270385.16249031,  6219684.08214232,  6137100.75832981,
                       6023313.2794414,  5879194.72399075],
                      [6145476.82098957,  6078546.55734877,  5980676.23854351,
                       5852716.72120069,  5695705.57359808],
                      [6095513.48438928,  6022091.54743135,  5918106.430629,
                       5784478.09790441,  5622309.91344102]])

TIES_EXP6 = np.array([[6381081.08333225,  6371519.34066148,  6328950.00792935,
                       6253610.69157758,  6145946.19489936],
                      [6370997.,  6354509.6014956,  6305151.62592155,
                       6223234.99818839,  6109277.14889072],
                      [6345786.79166939,  6311985.2535809,  6245655.67090206,
                       6147295.76471541,  6017604.5338691],
                      [6335702.70833714,  6294975.51441502,  6221857.28889426,
                       6116920.07132621,  5980935.48786045],
                      [6320348.4990906,  6276139.09205974,  6199670.56624433,
                       6091551.90273768,  5952590.38414781],
                      [6270385.16249031,  6219684.08214232,  6137100.75832981,
                       6023313.2794414,  5879194.72399075],
                      [6145476.82098957,  6078546.55734877,  5980676.23854351,
                       5852716.72120069,  5695705.57359808],
                      [6095513.48438928,  6022091.54743135,  5918106.430629,
                       5784478.09790441,  5622309.91344102]])


class TestSatelliteInterpolator(unittest.TestCase):

    """Class for unit testing the ancillary interpolation functions
    """

    def setUp(self):
        pass

    # def test_fillborders(self):
    #     lons = np.arange(20).reshape((4, 5), order="F")
    #     lats = np.arange(20).reshape((4, 5), order="C")
    #     lines = np.array([2, 7, 12, 17])
    #     cols = np.array([2, 7, 12, 17, 22])
    #     hlines = np.arange(20)
    #     hcols = np.arange(24)
    #     satint = SatelliteInterpolator(
    #         (lons, lats), (lines, cols), (hlines, hcols), chunk_size=10)
    #     satint.fill_borders('x', 'y')
    #     self.assertTrue(np.allclose(satint.tie_data[0], TIES_EXP1))
    #     self.assertTrue(
    #         np.allclose(satint.row_indices, np.array([0,  2,  7,  9, 10, 12, 17, 19])))
    #     self.assertTrue(
    # np.allclose(satint.col_indices, np.array([0,  2,  7, 12, 17, 22, 23])))

    def test_extrapolate_cols(self):
        lons = np.arange(10).reshape((2, 5), order="F")
        lats = np.arange(10).reshape((2, 5), order="C")
        lines = np.array([2, 7])
        cols = np.array([2, 7, 12, 17, 22])
        hlines = np.arange(10)
        hcols = np.arange(24)
        satint = SatelliteInterpolator(
            (lons, lats), (lines, cols), (hlines, hcols))

        self.assertTrue(np.allclose(satint._extrapolate_cols(satint.tie_data[0]),
                                    TIES_EXP2))

    def test_fill_col_borders(self):
        lons = np.arange(10).reshape((2, 5), order="F")
        lats = np.arange(10).reshape((2, 5), order="C")
        lines = np.array([2, 7])
        cols = np.array([2, 7, 12, 17, 22])
        hlines = np.arange(10)
        hcols = np.arange(24)
        satint = SatelliteInterpolator(
            (lons, lats), (lines, cols), (hlines, hcols))
        satint._fill_col_borders()
        self.assertTrue(np.allclose(satint.tie_data[0], TIES_EXP3))
        self.assertTrue(np.allclose(satint.col_indices,
                                    np.array([0,  2,  7, 12, 17, 22, 23])))

    # def test_extrapolate_rows(self):
    #     lons = np.arange(10).reshape((2, 5), order="F")
    #     lats = np.arange(10).reshape((2, 5), order="C")
    #     lines = np.array([2, 7])
    #     cols = np.array([2, 7, 12, 17, 22])
    #     hlines = np.arange(10)
    #     hcols = np.arange(24)
    #     satint = SatelliteInterpolator(
    #         (lons, lats), (lines, cols), (hlines, hcols))
    # self.assertTrue(np.allclose(satint._extrapolate_rows(satint.tie_data[0]),
    # TIES_EXP4)

    # def test_fill_row_borders(self):
    #     lons = np.arange(20).reshape((4, 5), order="F")
    #     lats = np.arange(20).reshape((4, 5), order="C")
    #     lines = np.array([2, 7, 12, 17])
    #     cols = np.array([2, 7, 12, 17, 22])
    #     hlines = np.arange(20)
    #     hcols = np.arange(24)
    #     satint = SatelliteInterpolator(
    #         (lons, lats), (lines, cols), (hlines, hcols))
    #     satint._fill_row_borders()
    #     self.assertTrue(np.allclose(satint.tie_data[0], TIES_EXP5))
    #     self.assertTrue(np.allclose(satint.row_indices,
    #                                 np.array([0,  2,  7, 12, 17, 19])))
    #     satint = SatelliteInterpolator((lons, lats), (lines, cols),
    #                                    (hlines, hcols), chunk_size=10)
    #     satint._fill_row_borders()
    #     self.assertTrue(np.allclose(satint.tie_data[0], TIES_EXP6))
    #     self.assertTrue(np.allclose(satint.row_indices,
    # np.array([0,  2,  7,  9, 10, 12, 17, 19])))