-
Notifications
You must be signed in to change notification settings - Fork 34
/
test_covariance.py
75 lines (59 loc) · 2.09 KB
/
test_covariance.py
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
#!/bin/python
import unittest
import numpy as num
import matplotlib.pyplot as plt
from kite import Scene
from . import common
benchmark = common.Benchmark()
common.setLogLevel('DEBUG')
class TestCovariance(unittest.TestCase):
@classmethod
def setUpClass(cls):
file = common.get_test_data('myanmar_alos_dsc_ionocorr.mat')
cls.sc = Scene.import_data(file)
def test_covariance(self):
cov = self.sc.covariance
cov.epsilon = .02
cov.subsampling = 24
d = []
d.append(('Full', cov._calcCovarianceMatrix(method='full',
nthreads=0)))
d.append(('Focal', cov._calcCovarianceMatrix(method='focal')))
for _, c1 in d:
for _, c2 in d:
num.testing.assert_allclose(c1, c2,
rtol=200, atol=2e3, verbose=True)
def test_synthetic_noise(self):
self.sc.covariance.syntheticNoise()
self.sc.covariance.variance
@benchmark
def test_covariance_parallel(self):
cov = self.sc.covariance
cov._calcCovarianceMatrix(method='full', nthreads=0)
@benchmark
def _test_covariance_single_thread(self):
cov = self.sc.covariance
cov._calcCovarianceMatrix(method='full', nthreads=1)
@benchmark
def test_covariance_focal(self):
cov = self.sc.covariance
cov._calcCovarianceMatrix(method='focal')
@unittest.skip('Skip!')
def _test_covariance_visual(self):
cov = self.sc.covariance
cov.epsilon = .02
cov.subsampling = 10
# l = self.sc.quadtree.leaves[0]
d = []
d.append(('Full', cov._calcCovarianceMatrix(method='full',
nthreads=0)))
d.append(('Focal', cov._calcCovarianceMatrix(method='focal')))
fig, _ = plt.subplots(1, len(d))
for i, (title, mat) in enumerate(d):
print '%s Max %f' % (title, num.nanmax(mat)), mat.shape
fig.axes[i].imshow(mat)
fig.axes[i].set_title(title)
plt.show()
if __name__ == '__main__':
unittest.main(exit=False)
print benchmark