forked from SolarDrew/Cython-Crotate
/
aiaprep_test.py
95 lines (82 loc) · 3.2 KB
/
aiaprep_test.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from scipy.io.idl import readsav as read
from pyrot import rotate_map as rotate
"""
==========
Test the Python rotate_Map() function to see if it looks like it's working.
==========
"""
testarr = np.zeros((101,101))
testarr[40:60, :] = testarr[: ,40:60] = 1.0
fig = plt.figure('Python rotate_map() function')
original = fig.add_subplot(231)
plt.imshow(testarr, cmap=cm.coolwarm)
original.set_title('Original image')
plt.colorbar(orientation='horizontal')
rotmap_test = rotate(testarr, np.radians(360.0), int_method='bicubic', int_param=-0.5)
rotated = fig.add_subplot(232)
plt.imshow(rotmap_test, cmap=cm.coolwarm)
rotated.set_title('Image rotated 360 degrees')
plt.colorbar(orientation='horizontal')
diff_im = testarr - rotmap_test
print 'SunPy full rotation difference range: {!s}.'.format(diff_im.max() - diff_im.min())
diff = fig.add_subplot(233)
plt.imshow(diff_im, cmap=cm.coolwarm)
diff.set_title('Difference between images')
plt.colorbar(orientation='horizontal')
original = fig.add_subplot(234)
plt.imshow(testarr, cmap=cm.coolwarm)
original.set_title('Original image')
plt.colorbar(orientation='horizontal')
rotmap_test = rotate(testarr, np.radians(10.0), int_method='bicubic', int_param=-0.5)
rotmap_test = rotate(rotmap_test, np.radians(-10.0), int_method='bicubic', int_param=-0.5)
rotated = fig.add_subplot(235)
plt.imshow(rotmap_test, cmap=cm.coolwarm)
rotated.set_title('Image rotated and derotated 10 degrees')
plt.colorbar(orientation='horizontal')
diff_im = testarr - rotmap_test
print 'SunPy back rotation difference range: {!s}.'.format(diff_im.max() - diff_im.min())
diff = fig.add_subplot(236)
plt.imshow(diff_im, cmap=cm.coolwarm)
diff.set_title('Difference between images')
plt.colorbar(orientation='horizontal')
plt.show()
"""
==========
Same test for IDL's rot() function.
==========
"""
idl_arrs = read('idl_fullrot_test')
fig = plt.figure('Core IDL rot() function')
original = fig.add_subplot(231)
plt.imshow(idl_arrs['array'], cmap=cm.coolwarm)
original.set_title('Original image')
plt.colorbar(orientation='horizontal')
rotated = fig.add_subplot(232)
plt.imshow(idl_arrs['fullrot'], cmap=cm.coolwarm)
rotated.set_title('Image rotated 360 degrees')
plt.colorbar(orientation='horizontal')
diff = fig.add_subplot(233)
diff_im = idl_arrs['fullrot_diff']
print 'IDL rot() full rotation difference range: {!s}.'.format(diff_im.max()-diff_im.min())
plt.imshow(idl_arrs['fullrot_diff'], cmap=cm.coolwarm)
diff.set_title('Difference between images')
plt.colorbar(orientation='horizontal')
idl_arrs2 = read('idl_backrot_test')
original = fig.add_subplot(234)
plt.imshow(idl_arrs['array'], cmap=cm.coolwarm)
original.set_title('Original image')
plt.colorbar(orientation='horizontal')
rotated = fig.add_subplot(235)
plt.imshow(idl_arrs2['backrot'], cmap=cm.coolwarm)
rotated.set_title('Image rotated and derotated 10 degrees')
plt.colorbar(orientation='horizontal')
diff = fig.add_subplot(236)
diff_im = idl_arrs2['backrot_diff']
print 'IDL rot() back rotation difference range: {!s}.'.format(diff_im.max()-diff_im.min())
plt.imshow(idl_arrs2['backrot_diff'], cmap=cm.coolwarm)
diff.set_title('Difference between images')
plt.colorbar(orientation='horizontal')
plt.show()