@@ -1,63 +1,63 | |||||
1 | ''' No newline at end of file |
|
1 | ''' | |
2 | Created on May 26, 2014 No newline at end of file |
|
2 | Created on May 26, 2014 | |
3 | No newline at end of file |
|
3 | ||
4 | @author: Yolian Amaro No newline at end of file |
|
4 | @author: Yolian Amaro | |
5 | ''' No newline at end of file |
|
5 | ''' | |
6 |
|
6 | |||
No newline at end of file |
|
7 | #import pywt No newline at end of file | ||
7 | import pywt No newline at end of file |
|
|||
8 | import numpy as np No newline at end of file |
|
8 | import numpy as np | |
9 | No newline at end of file |
|
9 | ||
10 | def FSfarras(): No newline at end of file |
|
10 | def FSfarras(): | |
11 | #function [af, sf] = FSfarras No newline at end of file |
|
11 | #function [af, sf] = FSfarras | |
12 | No newline at end of file |
|
12 | ||
13 | # Farras filters organized for the dual-tree No newline at end of file |
|
13 | # Farras filters organized for the dual-tree | |
14 | # complex DWT. No newline at end of file |
|
14 | # complex DWT. | |
15 | # No newline at end of file |
|
15 | # | |
16 | # USAGE: No newline at end of file |
|
16 | # USAGE: | |
17 | # [af, sf] = FSfarras No newline at end of file |
|
17 | # [af, sf] = FSfarras | |
18 | # OUTPUT: No newline at end of file |
|
18 | # OUTPUT: | |
19 | # af{i}, i = 1,2 - analysis filters for tree i No newline at end of file |
|
19 | # af{i}, i = 1,2 - analysis filters for tree i | |
20 | # sf{i}, i = 1,2 - synthesis filters for tree i No newline at end of file |
|
20 | # sf{i}, i = 1,2 - synthesis filters for tree i | |
21 | # See farras, dualtree, dualfilt1. No newline at end of file |
|
21 | # See farras, dualtree, dualfilt1. | |
22 | # No newline at end of file |
|
22 | # | |
23 | # WAVELET SOFTWARE AT POLYTECHNIC UNIVERSITY, BROOKLYN, NY No newline at end of file |
|
23 | # WAVELET SOFTWARE AT POLYTECHNIC UNIVERSITY, BROOKLYN, NY | |
24 | # http://taco.poly.edu/WaveletSoftware/ No newline at end of file |
|
24 | # http://taco.poly.edu/WaveletSoftware/ | |
25 | # No newline at end of file |
|
25 | # | |
26 | # Translated to Python by Yolian Amaro No newline at end of file |
|
26 | # Translated to Python by Yolian Amaro | |
27 | No newline at end of file |
|
27 | ||
28 | No newline at end of file |
|
28 | ||
29 | a1 = np.array( [ No newline at end of file |
|
29 | a1 = np.array( [ | |
30 | [ 0, 0], No newline at end of file |
|
30 | [ 0, 0], | |
31 | [-0.08838834764832, -0.01122679215254], No newline at end of file |
|
31 | [-0.08838834764832, -0.01122679215254], | |
32 | [ 0.08838834764832, 0.01122679215254], No newline at end of file |
|
32 | [ 0.08838834764832, 0.01122679215254], | |
33 | [ 0.69587998903400, 0.08838834764832], No newline at end of file |
|
33 | [ 0.69587998903400, 0.08838834764832], | |
34 | [ 0.69587998903400, 0.08838834764832], No newline at end of file |
|
34 | [ 0.69587998903400, 0.08838834764832], | |
35 | [ 0.08838834764832, -0.69587998903400], No newline at end of file |
|
35 | [ 0.08838834764832, -0.69587998903400], | |
36 | [-0.08838834764832, 0.69587998903400], No newline at end of file |
|
36 | [-0.08838834764832, 0.69587998903400], | |
37 | [ 0.01122679215254, -0.08838834764832], No newline at end of file |
|
37 | [ 0.01122679215254, -0.08838834764832], | |
38 | [ 0.01122679215254, -0.08838834764832], No newline at end of file |
|
38 | [ 0.01122679215254, -0.08838834764832], | |
39 | [0, 0] No newline at end of file |
|
39 | [0, 0] | |
40 | ] ); No newline at end of file |
|
40 | ] ); | |
41 | No newline at end of file |
|
41 | ||
42 | a2 = np.array([ No newline at end of file |
|
42 | a2 = np.array([ | |
43 | [ 0.01122679215254, 0], No newline at end of file |
|
43 | [ 0.01122679215254, 0], | |
44 | [ 0.01122679215254, 0], No newline at end of file |
|
44 | [ 0.01122679215254, 0], | |
45 | [-0.08838834764832, -0.08838834764832], No newline at end of file |
|
45 | [-0.08838834764832, -0.08838834764832], | |
46 | [ 0.08838834764832, -0.08838834764832], No newline at end of file |
|
46 | [ 0.08838834764832, -0.08838834764832], | |
47 | [ 0.69587998903400, 0.69587998903400], No newline at end of file |
|
47 | [ 0.69587998903400, 0.69587998903400], | |
48 | [ 0.69587998903400, -0.69587998903400], No newline at end of file |
|
48 | [ 0.69587998903400, -0.69587998903400], | |
49 | [ 0.08838834764832, 0.08838834764832], No newline at end of file |
|
49 | [ 0.08838834764832, 0.08838834764832], | |
50 | [-0.08838834764832, 0.08838834764832], No newline at end of file |
|
50 | [-0.08838834764832, 0.08838834764832], | |
51 | [ 0, 0.01122679215254], No newline at end of file |
|
51 | [ 0, 0.01122679215254], | |
52 | [ 0, -0.01122679215254] No newline at end of file |
|
52 | [ 0, -0.01122679215254] | |
53 | ]); No newline at end of file |
|
53 | ]); | |
54 | No newline at end of file |
|
54 | ||
55 | No newline at end of file |
|
55 | ||
56 | af = np.array([ [a1,a2] ], dtype=object) No newline at end of file |
|
56 | af = np.array([ [a1,a2] ], dtype=object) | |
57 | No newline at end of file |
|
57 | ||
58 | s1 = a1[::-1] No newline at end of file |
|
58 | s1 = a1[::-1] | |
59 | s2 = a2[::-1] No newline at end of file |
|
59 | s2 = a2[::-1] | |
60 | No newline at end of file |
|
60 | ||
61 | sf = np.array([ [s1,s2] ], dtype=object) No newline at end of file |
|
61 | sf = np.array([ [s1,s2] ], dtype=object) | |
62 | No newline at end of file |
|
62 | ||
63 | return af, sf No newline at end of file |
|
63 | return af, sf |
@@ -1,526 +1,496 | |||||
1 | #!/usr/bin/env python No newline at end of file |
|
1 | #!/usr/bin/env python | |
2 | No newline at end of file |
|
2 | ||
3 | #---------------------------------------------------------- No newline at end of file |
|
3 | #---------------------------------------------------------- | |
4 | # Original MATLAB code developed by Brian Harding No newline at end of file |
|
4 | # Original MATLAB code developed by Brian Harding | |
5 | # Rewritten in Python by Yolian Amaro No newline at end of file |
|
5 | # Rewritten in Python by Yolian Amaro | |
6 | # Python version 2.7 No newline at end of file |
|
6 | # Python version 2.7 | |
7 | # May 15, 2014 No newline at end of file |
|
7 | # May 15, 2014 | |
8 | # Jicamarca Radio Observatory No newline at end of file |
|
8 | # Jicamarca Radio Observatory | |
9 | #---------------------------------------------------------- No newline at end of file |
|
9 | #---------------------------------------------------------- | |
10 | No newline at end of file |
|
10 | ||
11 | import time No newline at end of file |
|
11 | import time | |
12 | import matplotlib.pyplot as plt No newline at end of file |
|
12 | import matplotlib.pyplot as plt | |
13 | from scipy.optimize import root |
|
13 | from scipy.optimize import root | |
No newline at end of file |
|
14 | from scipy.stats import nanmean | ||
14 |
|
No newline at end of file | |||
No newline at end of file |
|
15 | |||
15 | from y_hysell96 import* No newline at end of file |
|
No newline at end of file | ||
|
16 | from y_hysell96 import * No newline at end of file | |||
16 | from deb4_basis import * No newline at end of file |
|
17 | from deb4_basis import * | |
17 | from modelf import * No newline at end of file |
|
18 | from modelf import * | |
18 | from irls_dn2 import * |
|
19 | from irls_dn2 import * | |
No newline at end of file |
|
||||
19 | #from scipy.optimize import fsolve No newline at end of file |
|
|||
20 | No newline at end of file |
|
20 | ||
21 | No newline at end of file |
|
21 | ||
22 | #------------------------------------------------------------------------------------------------- No newline at end of file |
|
22 | #------------------------------------------------------------------------------------------------- | |
23 | # Set parameters No newline at end of file |
|
23 | # Set parameters | |
24 | #------------------------------------------------------------------------------------------------- No newline at end of file |
|
24 | #------------------------------------------------------------------------------------------------- | |
25 | No newline at end of file |
|
25 | ||
26 | ## Calculate Forward Model No newline at end of file |
|
26 | ## Calculate Forward Model | |
27 | lambda1 = 6.0 No newline at end of file |
|
27 | lambda1 = 6.0 | |
28 | k = 2*np.pi/lambda1 No newline at end of file |
|
28 | k = 2*np.pi/lambda1 | |
29 | No newline at end of file |
|
29 | ||
30 | ## Magnetic Declination No newline at end of file |
|
30 | ## Magnetic Declination | |
31 | dec = -1.24 No newline at end of file |
|
31 | dec = -1.24 | |
32 | No newline at end of file |
|
32 | ||
33 | ## Loads Jicamarca antenna positions No newline at end of file |
|
33 | ## Loads Jicamarca antenna positions | |
34 | antpos = np.loadtxt("antpos.txt", comments="#", delimiter=";", unpack=False) No newline at end of file |
|
34 | antpos = np.loadtxt("antpos.txt", comments="#", delimiter=";", unpack=False) | |
35 | No newline at end of file |
|
35 | ||
36 | ## rx and ry -- for plotting purposes No newline at end of file |
|
36 | ## rx and ry -- for plotting purposes | |
37 | rx = np.array( [[127.5000], [91.5000], [127.5000], [19.5000], [91.5000], [-127.5000], [-55.5000], [-220.8240]] ) No newline at end of file |
|
37 | rx = np.array( [[127.5000], [91.5000], [127.5000], [19.5000], [91.5000], [-127.5000], [-55.5000], [-220.8240]] ) | |
38 | ry = np.array( [[127.5000], [91.5000], [91.5000], [55.5000], [-19.5000], [-127.5000], [-127.5000], [-322.2940]] ) No newline at end of file |
|
38 | ry = np.array( [[127.5000], [91.5000], [91.5000], [55.5000], [-19.5000], [-127.5000], [-127.5000], [-322.2940]] ) | |
39 | No newline at end of file |
|
39 | ||
40 | ## Plot of antenna positions No newline at end of file |
|
40 | ## Plot of antenna positions | |
41 | plt.figure(1) No newline at end of file |
|
41 | plt.figure(1) | |
42 | plt.plot(rx, ry, 'ro') No newline at end of file |
|
42 | plt.plot(rx, ry, 'ro') | |
43 | plt.draw() No newline at end of file |
|
43 | plt.draw() | |
44 | No newline at end of file |
|
44 | ||
45 | ## Jicamarca is nominally at a 45 degree angle No newline at end of file |
|
45 | ## Jicamarca is nominally at a 45 degree angle | |
46 | theta = 45 - dec; No newline at end of file |
|
46 | theta = 45 - dec; | |
47 | No newline at end of file |
|
47 | ||
48 | ## Rotation matrix from antenna coord to magnetic coord (East North) No newline at end of file |
|
48 | ## Rotation matrix from antenna coord to magnetic coord (East North) | |
49 | theta_rad = np.radians(theta) # trig functions take radians as argument No newline at end of file |
|
49 | theta_rad = np.radians(theta) # trig functions take radians as argument | |
50 | val1 = float( np.cos(theta_rad) ) No newline at end of file |
|
50 | val1 = float( np.cos(theta_rad) ) | |
51 | val2 = float( np.sin(theta_rad) ) No newline at end of file |
|
51 | val2 = float( np.sin(theta_rad) ) | |
52 | val3 = float( -1*np.sin(theta_rad)) No newline at end of file |
|
52 | val3 = float( -1*np.sin(theta_rad)) | |
53 | val4 = float( np.cos(theta_rad) ) No newline at end of file |
|
53 | val4 = float( np.cos(theta_rad) ) | |
54 | No newline at end of file |
|
54 | ||
55 | # Rotation matrix from antenna coord to magnetic coord (East North) No newline at end of file |
|
55 | # Rotation matrix from antenna coord to magnetic coord (East North) | |
56 | R = np.array( [[val1, val3], [val2, val4]] ) No newline at end of file |
|
56 | R = np.array( [[val1, val3], [val2, val4]] ) | |
57 | No newline at end of file |
|
57 | ||
58 | # Rotate antenna positions to magnetic coord. No newline at end of file |
|
58 | # Rotate antenna positions to magnetic coord. | |
59 | AR = np.dot(R.T, antpos) No newline at end of file |
|
59 | AR = np.dot(R.T, antpos) | |
60 | No newline at end of file |
|
60 | ||
61 | # Only take the East component No newline at end of file |
|
61 | # Only take the East component | |
62 | r = AR[0,:] No newline at end of file |
|
62 | r = AR[0,:] | |
63 | r.sort() No newline at end of file |
|
63 | r.sort() | |
64 | No newline at end of file |
|
64 | ||
65 | # Truth model (high and low resolution) No newline at end of file |
|
65 | # Truth model (high and low resolution) | |
66 | Nt = (1024.0)*(16.0) # number of pixels in truth image: high resolution No newline at end of file |
|
66 | Nt = (1024.0)*(16.0) # number of pixels in truth image: high resolution | |
67 | thbound = 9.0/180*np.pi # the width of the domain in angle space No newline at end of file |
|
67 | thbound = 9.0/180*np.pi # the width of the domain in angle space | |
68 | thetat = np.linspace(-thbound, thbound,Nt) # image domain No newline at end of file |
|
68 | thetat = np.linspace(-thbound, thbound,Nt) # image domain | |
69 | thetat = thetat.T # transpose No newline at end of file |
|
69 | thetat = thetat.T # transpose | |
70 | Nr = (256.0) # number of pixels in reconstructed image: low res No newline at end of file |
|
70 | Nr = (256.0) # number of pixels in reconstructed image: low res | |
71 | thetar = np.linspace(-thbound, thbound,Nr) # reconstruction domain No newline at end of file |
|
71 | thetar = np.linspace(-thbound, thbound,Nr) # reconstruction domain | |
72 | thetar = thetar.T # transpose No newline at end of file |
|
72 | thetar = thetar.T # transpose | |
73 | No newline at end of file |
|
73 | ||
74 | No newline at end of file |
|
74 | ||
75 | #------------------------------------------------------------------------------------------------- No newline at end of file |
|
75 | #------------------------------------------------------------------------------------------------- | |
76 | # Model for f: Gaussian(s) with amplitudes a, centers mu, widths sig, and background constant b. No newline at end of file |
|
76 | # Model for f: Gaussian(s) with amplitudes a, centers mu, widths sig, and background constant b. | |
77 | #------------------------------------------------------------------------------------------------- No newline at end of file |
|
77 | #------------------------------------------------------------------------------------------------- | |
78 | No newline at end of file |
|
78 | ||
79 | # Triple Gaussian No newline at end of file |
|
79 | # Triple Gaussian | |
80 | # a = np.array([3, 5, 2]); No newline at end of file |
|
80 | # a = np.array([3, 5, 2]); | |
81 | # mu = np.array([-5.0/180*np.pi, 2.0/180*np.pi, 7.0/180*np.pi]); No newline at end of file |
|
81 | # mu = np.array([-5.0/180*np.pi, 2.0/180*np.pi, 7.0/180*np.pi]); | |
82 | # sig = np.array([2.0/180*np.pi, 1.5/180*np.pi, 0.3/180*np.pi]); No newline at end of file |
|
82 | # sig = np.array([2.0/180*np.pi, 1.5/180*np.pi, 0.3/180*np.pi]); | |
83 | # b = 0; # background No newline at end of file |
|
83 | # b = 0; # background | |
84 | No newline at end of file |
|
84 | ||
85 | # Double Gaussian No newline at end of file |
|
85 | # Double Gaussian | |
86 | # a = np.array([3, 5]); No newline at end of file |
|
86 | # a = np.array([3, 5]); | |
87 | # mu = np.array([-5.0/180*np.pi, 2.0/180*np.pi]); No newline at end of file |
|
87 | # mu = np.array([-5.0/180*np.pi, 2.0/180*np.pi]); | |
88 | # sig = np.array([2.0/180*np.pi, 1.5/180*np.pi]); No newline at end of file |
|
88 | # sig = np.array([2.0/180*np.pi, 1.5/180*np.pi]); | |
89 | # b = 0; # background No newline at end of file |
|
89 | # b = 0; # background | |
90 | No newline at end of file |
|
90 | ||
91 | # Single Gaussian No newline at end of file |
|
91 | # Single Gaussian | |
92 | a = np.array( [3] ) No newline at end of file |
|
92 | a = np.array( [3] ) | |
93 | mu = np.array( [-3.0/180*np.pi] ) No newline at end of file |
|
93 | mu = np.array( [-3.0/180*np.pi] ) | |
94 | sig = np.array( [2.0/180*np.pi] ) No newline at end of file |
|
94 | sig = np.array( [2.0/180*np.pi] ) | |
95 | b = 0 No newline at end of file |
|
95 | b = 0 | |
96 | No newline at end of file |
|
96 | ||
97 | # Empty matrices for factors No newline at end of file |
|
97 | # Empty matrices for factors | |
98 | fact = np.zeros(shape=(Nt,1)) No newline at end of file |
|
98 | fact = np.zeros(shape=(Nt,1)) | |
99 | factr = np.zeros(shape=(Nr,1)) No newline at end of file |
|
99 | factr = np.zeros(shape=(Nr,1)) | |
100 | No newline at end of file |
|
100 | ||
101 | # DFT Kernels No newline at end of file |
|
101 | # DFT Kernels | |
102 | for i in range(0, a.size): No newline at end of file |
|
102 | for i in range(0, a.size): | |
103 | temp = (-(thetat-mu[i])**2/(sig[i]**2)) No newline at end of file |
|
103 | temp = (-(thetat-mu[i])**2/(sig[i]**2)) | |
104 | tempr = (-(thetar-mu[i])**2/(sig[i]**2)) No newline at end of file |
|
104 | tempr = (-(thetar-mu[i])**2/(sig[i]**2)) | |
105 | for j in range(0, temp.size): No newline at end of file |
|
105 | for j in range(0, temp.size): | |
106 | fact[j] = fact[j] + a[i]*np.exp(temp[j]); No newline at end of file |
|
106 | fact[j] = fact[j] + a[i]*np.exp(temp[j]); | |
107 | for m in range(0, tempr.size): No newline at end of file |
|
107 | for m in range(0, tempr.size): | |
108 | factr[m] = factr[m] + a[i]*np.exp(tempr[m]); No newline at end of file |
|
108 | factr[m] = factr[m] + a[i]*np.exp(tempr[m]); | |
109 | No newline at end of file |
|
109 | ||
110 | fact = fact + b; No newline at end of file |
|
110 | fact = fact + b; | |
111 | factr = factr + b; No newline at end of file |
|
111 | factr = factr + b; | |
112 | No newline at end of file |
|
112 | ||
113 | # #------------------------------------------------------------------------------------------------- No newline at end of file |
|
113 | # #------------------------------------------------------------------------------------------------- | |
114 | # # Model for f: Square pulse No newline at end of file |
|
114 | # # Model for f: Square pulse | |
115 | # #------------------------------------------------------------------------------------------------- No newline at end of file |
|
115 | # #------------------------------------------------------------------------------------------------- | |
116 | # for j in range(0, fact.size): No newline at end of file |
|
116 | # for j in range(0, fact.size): | |
117 | # if (theta > -5.0/180*np.pi and theta < 2.0/180*np.pi): No newline at end of file |
|
117 | # if (theta > -5.0/180*np.pi and theta < 2.0/180*np.pi): | |
118 | # fact[j] = 0 No newline at end of file |
|
118 | # fact[j] = 0 | |
119 | # else: No newline at end of file |
|
119 | # else: | |
120 | # fact[j] = 1 No newline at end of file |
|
120 | # fact[j] = 1 | |
121 | # for k in range(0, factr.size): No newline at end of file |
|
121 | # for k in range(0, factr.size): | |
122 | # if (thetar[k] > -5.0/180*np.pi and thetar[k] < 2/180*np.pi): No newline at end of file |
|
122 | # if (thetar[k] > -5.0/180*np.pi and thetar[k] < 2/180*np.pi): | |
123 | # factr[k] = 0 No newline at end of file |
|
123 | # factr[k] = 0 | |
124 | # else: No newline at end of file |
|
124 | # else: | |
125 | # factr[k] = 1 No newline at end of file |
|
125 | # factr[k] = 1 | |
126 | No newline at end of file |
|
126 | ||
127 | # #------------------------------------------------------------------------------------------------- No newline at end of file |
|
127 | # #------------------------------------------------------------------------------------------------- | |
128 | # # Model for f: Triangle pulse No newline at end of file |
|
128 | # # Model for f: Triangle pulse | |
129 | # #------------------------------------------------------------------------------------------------- No newline at end of file |
|
129 | # #------------------------------------------------------------------------------------------------- | |
130 | # mu = -1.0/180*np.pi; No newline at end of file |
|
130 | # mu = -1.0/180*np.pi; | |
131 | # sig = 5.0/180*np.pi; No newline at end of file |
|
131 | # sig = 5.0/180*np.pi; | |
132 | # wind1 = theta > mu-sig and theta < mu; No newline at end of file |
|
132 | # wind1 = theta > mu-sig and theta < mu; | |
133 | # wind2 = theta < mu+sig and theta > mu; No newline at end of file |
|
133 | # wind2 = theta < mu+sig and theta > mu; | |
134 | # fact = wind1 * (theta - (mu - sig)); No newline at end of file |
|
134 | # fact = wind1 * (theta - (mu - sig)); | |
135 | # factr = wind1 * (thetar - (mu - sig)); No newline at end of file |
|
135 | # factr = wind1 * (thetar - (mu - sig)); | |
136 | # fact = fact + wind2 * (-(theta-(mu+sig))); No newline at end of file |
|
136 | # fact = fact + wind2 * (-(theta-(mu+sig))); | |
137 | # factr = factr + wind2 * (-(thetar-(mu+sig))); No newline at end of file |
|
137 | # factr = factr + wind2 * (-(thetar-(mu+sig))); | |
138 | No newline at end of file |
|
138 | ||
139 | No newline at end of file |
|
139 | # fact = fact/(sum(fact)[0]*2*thbound/Nt); # normalize to integral(f)==1 | |
140 | # fact = fact/(sum(fact)[0]*2*thbound/Nt); # normalize to integral(f)==1 No newline at end of file |
|
140 | ||
141 | No newline at end of file |
|
141 | ||
142 | I = sum(fact)[0]; No newline at end of file |
|
142 | I = sum(fact)[0]; | |
143 | fact = fact/I; # normalize to sum(f)==1 No newline at end of file |
|
143 | fact = fact/I; # normalize to sum(f)==1 | |
144 | factr = factr/I; # normalize to sum(f)==1 No newline at end of file |
|
144 | factr = factr/I; # normalize to sum(f)==1 | |
145 | No newline at end of file |
|
145 | ||
146 | # Plot Gaussian pulse(s) No newline at end of file |
|
146 | # Plot Gaussian pulse(s) | |
147 | plt.figure(2) No newline at end of file |
|
147 | plt.figure(2) | |
148 | plt.plot(thetat, fact, 'r--') No newline at end of file |
|
148 | plt.plot(thetat, fact, 'r--') | |
149 | plt.plot(thetar, factr, 'ro') No newline at end of file |
|
149 | plt.plot(thetar, factr, 'ro') | |
150 | plt.draw() No newline at end of file |
|
150 | plt.draw() | |
151 | No newline at end of file |
|
151 | ||
152 | No newline at end of file |
|
152 | ||
153 | #------------------------------------------------------------------------------------------------- No newline at end of file |
|
153 | #------------------------------------------------------------------------------------------------- | |
154 | # Control the type and number of inversions with: No newline at end of file |
|
154 | # Control the type and number of inversions with: | |
155 | # SNRdBvec: the SNRs that will be used. No newline at end of file |
|
155 | # SNRdBvec: the SNRs that will be used. | |
156 | # NN: the number of trials for each SNR No newline at end of file |
|
156 | # NN: the number of trials for each SNR | |
157 | #------------------------------------------------------------------------------------------------- No newline at end of file |
|
157 | #------------------------------------------------------------------------------------------------- | |
158 | No newline at end of file |
|
158 | ||
159 | #SNRdBvec = np.linspace(5,20,10); No newline at end of file |
|
159 | #SNRdBvec = np.linspace(5,20,10); | |
160 | SNRdBvec = np.array([15]); # 15 dB No newline at end of file |
|
160 | SNRdBvec = np.array([15]); # 15 dB | |
161 | NN = 1; # number of trials at each SNR No newline at end of file |
|
161 | NN = 1; # number of trials at each SNR | |
162 | No newline at end of file |
|
162 | ||
163 | # Statistics simulation (correlation, root mean square) No newline at end of file |
|
163 | # Statistics simulation (correlation, root mean square) | |
164 | corr = np.zeros(shape=(4,SNRdBvec.size,NN)); # (method, SNR, trial) No newline at end of file |
|
164 | corr = np.zeros(shape=(4,SNRdBvec.size,NN)); # (method, SNR, trial) | |
165 | corrc = np.zeros(shape=(4,SNRdBvec.size,NN)); # (method, SNR, trial) No newline at end of file |
|
165 | corrc = np.zeros(shape=(4,SNRdBvec.size,NN)); # (method, SNR, trial) | |
166 | rmse = np.zeros(shape=(4,SNRdBvec.size,NN)); # (method, SNR, trial) No newline at end of file |
|
166 | rmse = np.zeros(shape=(4,SNRdBvec.size,NN)); # (method, SNR, trial) | |
167 | No newline at end of file |
|
167 | ||
168 | # For each SNR and trial No newline at end of file |
|
168 | # For each SNR and trial | |
169 | for snri in range(0, SNRdBvec.size): No newline at end of file |
|
169 | for snri in range(0, SNRdBvec.size): | |
170 | SNRdB = SNRdBvec[snri]; No newline at end of file |
|
170 | SNRdB = SNRdBvec[snri]; | |
171 | SNR = 10**(SNRdB/10.0); No newline at end of file |
|
171 | SNR = 10**(SNRdB/10.0); | |
172 | No newline at end of file |
|
172 | ||
173 | for Ni in range(0, NN): No newline at end of file |
|
173 | for Ni in range(0, NN): | |
174 | # Calculate cross-correlation matrix (Fourier components of image) No newline at end of file |
|
174 | # Calculate cross-correlation matrix (Fourier components of image) | |
175 | # This is an inefficient way to do this. No newline at end of file |
|
175 | # This is an inefficient way to do this. | |
176 | No newline at end of file |
|
176 | ||
177 | R = np.zeros(shape=(r.size, r.size), dtype=object); No newline at end of file |
|
177 | R = np.zeros(shape=(r.size, r.size), dtype=object); | |
178 | No newline at end of file |
|
178 | ||
179 | for i1 in range(0, r.size): No newline at end of file |
|
179 | for i1 in range(0, r.size): | |
180 | for i2 in range(0,r.size): No newline at end of file |
|
180 | for i2 in range(0,r.size): | |
181 | R[i1,i2] = np.dot(fact.T, np.exp(1j*k*np.dot((r[i1]-r[i2]),np.sin(thetat)))) No newline at end of file |
|
181 | R[i1,i2] = np.dot(fact.T, np.exp(1j*k*np.dot((r[i1]-r[i2]),np.sin(thetat)))) | |
182 | R[i1,i2] = sum(R[i1,i2]) No newline at end of file |
|
182 | R[i1,i2] = sum(R[i1,i2]) | |
183 | No newline at end of file |
|
183 | ||
184 | # Add uncertainty No newline at end of file |
|
184 | # Add uncertainty | |
185 | # This is an ad-hoc way of adding "noise". It models some combination of No newline at end of file |
|
185 | # This is an ad-hoc way of adding "noise". It models some combination of | |
186 | # receiver noise and finite integration times. We could use a more No newline at end of file |
|
186 | # receiver noise and finite integration times. We could use a more | |
187 | # advanced model (like in Yu et al 2000) in the future. No newline at end of file |
|
187 | # advanced model (like in Yu et al 2000) in the future. | |
188 | No newline at end of file |
|
188 | ||
189 | # This is a way of adding noise while maintaining the No newline at end of file |
|
189 | # This is a way of adding noise while maintaining the | |
190 | # positive-semi-definiteness of the matrix. No newline at end of file |
|
190 | # positive-semi-definiteness of the matrix. | |
191 | No newline at end of file |
|
191 | ||
192 | U = linalg.cholesky(R.astype(complex), lower=False); # U'*U = R No newline at end of file |
|
192 | U = linalg.cholesky(R.astype(complex), lower=False); # U'*U = R | |
193 | No newline at end of file |
|
193 | ||
194 | sigma_noise = (np.linalg.norm(U,'fro')/SNR); No newline at end of file |
|
194 | sigma_noise = (np.linalg.norm(U,'fro')/SNR); | |
195 | No newline at end of file |
|
195 | ||
196 | # temp1 = (-2*np.random.rand(U.shape[0], U.shape[1]) + 2) No newline at end of file |
|
196 | # temp1 = (-2*np.random.rand(U.shape[0], U.shape[1]) + 2) | |
197 | # temp2 = 1j*(-2*np.random.rand(U.shape[0], U.shape[1]) + 2) No newline at end of file |
|
197 | # temp2 = 1j*(-2*np.random.rand(U.shape[0], U.shape[1]) + 2) | |
198 | # temp3 = ((abs(U) > 0).astype(float)) # upper triangle of 1's No newline at end of file |
|
198 | # temp3 = ((abs(U) > 0).astype(float)) # upper triangle of 1's | |
199 | # temp4 = (sigma_noise * (temp1 + temp2))/np.sqrt(2.0) No newline at end of file |
|
199 | # temp4 = (sigma_noise * (temp1 + temp2))/np.sqrt(2.0) | |
200 | # No newline at end of file |
|
200 | # | |
201 | # nz = np.multiply(temp4,temp3) No newline at end of file |
|
201 | # nz = np.multiply(temp4,temp3) | |
202 | No newline at end of file |
|
202 | ||
203 | nz = np.multiply( sigma_noise * (np.random.randn(U.shape[0]) + 1j*np.random.randn(U.shape[0]))/np.sqrt(2) , (abs(U) > 0).astype(float)); No newline at end of file |
|
203 | nz = np.multiply( sigma_noise * (np.random.randn(U.shape[0]) + 1j*np.random.randn(U.shape[0]))/np.sqrt(2) , (abs(U) > 0).astype(float)); | |
204 | No newline at end of file |
|
204 | ||
205 | Unz = U + nz; No newline at end of file |
|
205 | Unz = U + nz; | |
206 | Rnz = np.dot(Unz.T.conj(),Unz); # the noisy version of R No newline at end of file |
|
206 | Rnz = np.dot(Unz.T.conj(),Unz); # the noisy version of R | |
207 | plt.figure(3); No newline at end of file |
|
207 | plt.figure(3); | |
208 | plt.pcolor(abs(Rnz)); No newline at end of file |
|
208 | plt.pcolor(abs(Rnz)); | |
209 | plt.colorbar(); No newline at end of file |
|
209 | plt.colorbar(); | |
210 | No newline at end of file |
|
210 | ||
211 | #------------------------------------------------------------------------------------------------- No newline at end of file |
|
211 | #------------------------------------------------------------------------------------------------- | |
212 | # Fourier Inversion No newline at end of file |
|
212 | # Fourier Inversion | |
213 | #------------------------------------------------------------------------------------------------- No newline at end of file |
|
213 | #------------------------------------------------------------------------------------------------- | |
214 | f_fourier = np.zeros(shape=(Nr,1), dtype=complex); No newline at end of file |
|
214 | f_fourier = np.zeros(shape=(Nr,1), dtype=complex); | |
215 | No newline at end of file |
|
215 | ||
216 | for i in range(0, thetar.size): No newline at end of file |
|
216 | for i in range(0, thetar.size): | |
217 | th = thetar[i]; No newline at end of file |
|
217 | th = thetar[i]; | |
218 | w = np.exp(1j*k*np.dot(r,np.sin(th))); No newline at end of file |
|
218 | w = np.exp(1j*k*np.dot(r,np.sin(th))); | |
219 | temp = np.dot(w.T.conj(),U) No newline at end of file |
|
219 | temp = np.dot(w.T.conj(),U) | |
220 | f_fourier[i] = np.dot(temp, w); No newline at end of file |
|
220 | f_fourier[i] = np.dot(temp, w); | |
221 | No newline at end of file |
|
221 | ||
222 | f_fourier = f_fourier.real; # get rid of numerical imaginary noise No newline at end of file |
|
222 | f_fourier = f_fourier.real; # get rid of numerical imaginary noise | |
223 | No newline at end of file |
|
223 | ||
224 | No newline at end of file |
|
224 | ||
225 | #------------------------------------------------------------------------------------------------- No newline at end of file |
|
225 | #------------------------------------------------------------------------------------------------- | |
226 | # Capon Inversion No newline at end of file |
|
226 | # Capon Inversion | |
227 | #------------------------------------------------------------------------------------------------- No newline at end of file |
|
227 | #------------------------------------------------------------------------------------------------- | |
228 | f_capon = np.zeros(shape=(Nr,1)); No newline at end of file |
|
228 | f_capon = np.zeros(shape=(Nr,1)); | |
229 | No newline at end of file |
|
229 | ||
230 | tic_capon = time.time(); No newline at end of file |
|
230 | tic_capon = time.time(); | |
231 | No newline at end of file |
|
231 | ||
232 | for i in range(0, thetar.size): No newline at end of file |
|
232 | for i in range(0, thetar.size): | |
233 | th = thetar[i]; No newline at end of file |
|
233 | th = thetar[i]; | |
234 | w = np.exp(1j*k*np.dot(r,np.sin(th))); |
|
234 | w = np.exp(1j*k*np.dot(r,np.sin(th))); | |
No newline at end of file |
|
235 | f_capon[i] = 1/ ( np.dot( w.T.conj(), (linalg.solve(Rnz,w)) ) ).real No newline at end of file | ||
235 | f_capon[i] = np.divide(1, ( np.dot( w.T.conj(), (linalg.solve(Rnz,w)) ) ).real) No newline at end of file |
|
|||
236 | No newline at end of file |
|
236 | ||
237 | toc_capon = time.time() No newline at end of file |
|
237 | toc_capon = time.time() | |
238 | No newline at end of file |
|
238 | elapsed_time_capon = toc_capon - tic_capon; | |
239 | elapsed_time_capon = toc_capon - tic_capon; No newline at end of file |
|
239 | ||
240 | No newline at end of file |
|
240 | f_capon = f_capon.real; # get rid of numerical imaginary noise | |
241 | f_capon = f_capon.real; # get rid of numerical imaginary noise No newline at end of file |
|
241 | ||
242 | No newline at end of file |
|
242 | ||
243 | No newline at end of file |
|
243 | #------------------------------------------------------------------------------------------------- | |
244 | #------------------------------------------------------------------------------------------------- No newline at end of file |
|
244 | # MaxEnt Inversion | |
245 | # MaxEnt Inversion No newline at end of file |
|
245 | #------------------------------------------------------------------------------------------------- | |
246 | #------------------------------------------------------------------------------------------------- No newline at end of file |
|
246 | ||
247 | No newline at end of file |
|
247 | # Create the appropriate sensing matrix (split into real and imaginary # parts) | |
248 | # Create the appropriate sensing matrix (split into real and imaginary # parts) No newline at end of file |
|
248 | M = (r.size-1)*(r.size); | |
249 | M = (r.size-1)*(r.size); No newline at end of file |
|
249 | Ht = np.zeros(shape=(M,Nt)); # "true" sensing matrix | |
250 |
H |
|
250 | Hr = np.zeros(shape=(M,Nr)); # approximate sensing matrix for reconstruction | |
251 | Hr = np.zeros(shape=(M,Nr)); # approximate sensing matrix for reconstruction No newline at end of file |
|
251 | ||
252 | No newline at end of file |
|
252 | # Need to re-index our measurements from matrix R into vector g | |
253 | # Need to re-index our measurements from matrix R into vector g No newline at end of file |
|
253 | g = np.zeros(shape=(M,1)); | |
254 | g = np.zeros(shape=(M,1)); No newline at end of file |
|
254 | gnz = np.zeros(shape=(M,1)); # noisy version of g | |
255 | gnz = np.zeros(shape=(M,1)); # noisy version of g No newline at end of file |
|
255 | ||
256 | No newline at end of file |
|
256 | # Triangular indexing to perform this re-indexing | |
257 | # Triangular indexing to perform this re-indexing No newline at end of file |
|
257 | T = np.ones(shape=(r.size,r.size)); | |
258 | T = np.ones(shape=(r.size,r.size)); No newline at end of file |
|
258 | [i1v,i2v] = np.where(np.triu(T,1) > 0); # converts linear to triangular indexing | |
259 | [i1v,i2v] = np.where(np.triu(T,1) > 0); # converts linear to triangular indexing No newline at end of file |
|
259 | ||
260 | No newline at end of file |
|
260 | # Build H | |
261 | # Build H No newline at end of file |
|
261 | for i1 in range(0, r.size): | |
262 |
for i |
|
262 | for i2 in range(i1+1, r.size): | |
263 | for i2 in range(i1+1, r.size): No newline at end of file |
|
263 | idx = np.where(np.logical_and((i1==i1v), (i2==i2v)))[0]; # kind of awkward | |
264 | idx = np.where(np.logical_and((i1==i1v), (i2==i2v)))[0]; # kind of awkward No newline at end of file |
|
264 | idx1 = 2*idx; | |
265 |
idx |
|
265 | idx2 = 2*idx+1; | |
266 | idx2 = 2*idx+1; No newline at end of file |
|
266 | Hr[idx1,:] = np.cos(k*(r[i1]-r[i2])*np.sin(thetar)).T.conj(); | |
267 |
Hr[idx |
|
267 | Hr[idx2,:] = np.sin(k*(r[i1]-r[i2])*np.sin(thetar)).T.conj(); | |
268 |
H |
|
268 | Ht[idx1,:] = np.cos(k*(r[i1]-r[i2])*np.sin(thetat)).T.conj()*Nr/Nt; | |
269 |
Ht[idx |
|
269 | Ht[idx2,:] = np.sin(k*(r[i1]-r[i2])*np.sin(thetat)).T.conj()*Nr/Nt; | |
270 |
|
|
270 | g[idx1] = (R[i1,i2]).real*Nr/Nt; | |
271 |
g[idx |
|
271 | g[idx2] = (R[i1,i2]).imag*Nr/Nt; | |
272 |
g[idx |
|
272 | gnz[idx1] = (Rnz[i1,i2]).real*Nr/Nt; | |
273 |
gnz[idx |
|
273 | gnz[idx2] = (Rnz[i1,i2]).imag*Nr/Nt; | |
274 | gnz[idx2] = (Rnz[i1,i2]).imag*Nr/Nt; No newline at end of file |
|
274 | ||
275 | No newline at end of file |
|
275 | # Inversion | |
276 | # Inversion No newline at end of file |
|
276 | F = Nr/Nt; # normalization | |
277 | F = Nr/Nt; # normalization No newline at end of file |
|
277 | sigma = 1; # set to 1 because the difference is accounted for in G | |
278 | sigma = 1; # set to 1 because the difference is accounted for in G No newline at end of file |
|
278 | ||
279 | No newline at end of file |
|
279 | G = np.linalg.norm(g-gnz)**2 ; # pretend we know in advance the actual value of chi^2 | |
280 | G = np.linalg.norm(g-gnz)**2 ; # pretend we know in advance the actual value of chi^2 No newline at end of file |
|
280 | lambda0 = 1e-5*np.ones(shape=(M,1)); # initial condition (can be set to anything) | |
281 | lambda0 = 1e-5*np.ones(shape=(M,1)); # initial condition (can be set to anything) No newline at end of file |
|
281 | ||
282 | No newline at end of file |
|
282 | ||
283 | No newline at end of file |
|
283 | # Whitened solution | |
284 | # Whitened solution No newline at end of file |
|
284 | def myfun(lambda1): | |
285 | def myfun(lambda1): No newline at end of file |
|
285 | return y_hysell96(lambda1,gnz,sigma,F,G,Hr); | |
286 | return y_hysell96(lambda1,gnz,sigma,F,G,Hr); No newline at end of file |
|
286 | ||
287 | No newline at end of file |
|
287 | ||
288 | No newline at end of file |
|
288 | tic_maxEnt = time.time(); # start time maxEnt | |
289 | tic_maxEnt = time.time(); # start time maxEnt No newline at end of file |
|
289 | ||
290 | No newline at end of file |
|
290 | lambda1 = root(myfun,lambda0, method='krylov', tol=1e-14); | |
291 | lambda1 = root(myfun,lambda0, method='krylov', tol=1e-14); No newline at end of file |
|
291 | ||
292 | No newline at end of file |
|
292 | toc_maxEnt = time.time() | |
293 | toc_maxEnt = time.time() No newline at end of file |
|
293 | elapsed_time_maxent = toc_maxEnt - tic_maxEnt; | |
294 | elapsed_time_maxent = toc_maxEnt - tic_maxEnt; No newline at end of file |
|
294 | ||
295 | No newline at end of file |
|
295 | # Solution | |
296 | # Solution No newline at end of file |
|
296 | lambda1 = lambda1.x; | |
297 | lambda1 = lambda1.x; No newline at end of file |
|
297 | ||
298 | No newline at end of file |
|
298 | f_maxent = modelf(lambda1, Hr, F); | |
299 |
|
|
299 | ystar = myfun(lambda1); | |
300 | ystar = myfun(lambda1); No newline at end of file |
|
300 | Lambda = np.sqrt(sum(lambda1**2*sigma**2)/(4*G)); | |
301 |
|
|
301 | ep = np.multiply(-lambda1,sigma**2)/ (2*Lambda); | |
302 | ep = np.multiply(-lambda1,sigma**2)/ (2*Lambda); |
|
302 | es = np.dot(Hr, f_maxent) - gnz; | |
No newline at end of file |
|
303 | chi2 = np.sum((es/sigma)**2); No newline at end of file | ||
303 | es = np.dot(Hr, f_maxent) - gnz; # should be same as ep No newline at end of file |
|
|||
304 | chi2 = np.sum((es/sigma)**2); No newline at end of file |
|
304 | ||
305 | No newline at end of file |
|
305 | ||
306 | No newline at end of file |
|
306 | #------------------------------------------------------------------------------------------------- | |
307 | #------------------------------------------------------------------------------------------------- No newline at end of file |
|
307 | # CS inversion using Iteratively Reweighted Least Squares (IRLS) | |
308 | # CS inversion using Iteratively Reweighted Least Squares (IRLS) No newline at end of file |
|
308 | #------------------------------------------------------------------------------------------------- | |
309 | #------------------------------------------------------------------------------------------------- No newline at end of file |
|
309 | # (Use Nr, thetar, gnz, and Hr from MaxEnt above) | |
310 | # (Use Nr, thetar, gnz, and Hr from MaxEnt above) No newline at end of file |
|
310 | ||
311 | No newline at end of file |
|
311 | Psi = deb4_basis(Nr); | |
312 | Psi = deb4_basis(Nr); |
|
312 | ||
No newline at end of file |
|
||||
313 |
|
||||
No newline at end of file |
|
||||
314 | # ------------Remove this------------------------------------------- |
|
|||
No newline at end of file |
|
||||
315 | # wavelet1 = pywt.Wavelet('db4') |
|
|||
No newline at end of file |
|
||||
316 | # Phi, Psi, x = wavelet1.wavefun(level=3) |
|
|||
No newline at end of file |
|
||||
317 | #------------------------------------------------------------------- No newline at end of file |
|
|||
318 | No newline at end of file |
|
313 | # add "sum to 1" constraint | |
319 | # add "sum to 1" constraint No newline at end of file |
|
314 | H2 = np.concatenate( (Hr, np.ones(shape=(1,Nr))), axis=0 ); | |
320 |
|
|
315 | g2 = np.concatenate( (gnz, np.array([[Nr/Nt]])), axis=0 ); | |
321 | g2 = np.concatenate( (gnz, np.array([[Nr/Nt]])), axis=0 ); No newline at end of file |
|
316 | ||
322 | No newline at end of file |
|
317 | tic_cs = time.time(); | |
323 | tic_cs = time.time(); No newline at end of file |
|
318 | ||
324 |
|
319 | # Inversion | ||
No newline at end of file |
|
||||
325 |
|
||||
No newline at end of file |
|
||||
326 | # plt.figure(4) |
|
|||
No newline at end of file |
|
||||
327 | # plt.imshow(Psi)#, interpolation='nearest') |
|
|||
No newline at end of file |
|
||||
328 | # #plt.xticks([]); plt.yticks([]) |
|
|||
No newline at end of file |
|
||||
329 | # plt.show() |
|
|||
No newline at end of file |
|
||||
330 | No newline at end of file |
|
|||
331 | # Inversion No newline at end of file |
|
320 | s = irls_dn2(np.dot(H2,Psi),g2,0.5,G); | |
332 | s = irls_dn2(np.dot(H2,Psi),g2,0.5,G); No newline at end of file |
|
321 | ||
333 |
|
322 | toc_cs = time.time() | ||
No newline at end of file |
|
323 | elapsed_time_cs = toc_cs - tic_cs; | ||
334 | #print s No newline at end of file |
|
No newline at end of file | ||
|
324 | No newline at end of file | |||
335 | No newline at end of file |
|
325 | # Brightness function | |
336 | # Brightness function No newline at end of file |
|
326 | f_cs = np.dot(Psi,s); | |
337 | f_cs = np.dot(Psi,s); No newline at end of file |
|
327 | ||
338 |
|
328 | |||
No newline at end of file |
|
329 | No newline at end of file | ||
339 | toc_cs = time.time() |
|
|||
No newline at end of file |
|
||||
340 | elapsed_time_cs = toc_cs - tic_cs; No newline at end of file |
|
|||
341 |
|
|
330 | # Plot | |
342 | # Plot No newline at end of file |
|
331 | plt.figure(4) | |
343 | plt.figure(4) No newline at end of file |
|
332 | plt.plot(thetar,f_cs,'r.-'); | |
344 |
plt.plot(theta |
|
333 | plt.plot(thetat,fact,'k-'); | |
345 | plt.plot(thetat,fact,'k-'); No newline at end of file |
|
334 | ||
346 |
|
|
335 | ||
347 | No newline at end of file |
|
336 | #------------------------------------------------------------------------------------------------- | |
348 | #------------------------------------------------------------------------------------------------- No newline at end of file |
|
337 | # Scaling and shifting | |
349 | # Scaling and shifting No newline at end of file |
|
338 | # (Only necessary for Capon solution) | |
350 | # (Only necessary for Capon solution) No newline at end of file |
|
339 | #------------------------------------------------------------------------------------------------- | |
351 | #------------------------------------------------------------------------------------------------- No newline at end of file |
|
340 | f_capon = f_capon/np.max(f_capon)*np.max(fact); | |
352 | f_capon = f_capon/np.max(f_capon)*np.max(fact); No newline at end of file |
|
341 | ||
353 | No newline at end of file |
|
342 | ||
354 | No newline at end of file |
|
343 | #------------------------------------------------------------------------------------------------- | |
355 | #------------------------------------------------------------------------------------------------- No newline at end of file |
|
344 | # Analyze stuff | |
356 | # Analyze stuff No newline at end of file |
|
345 | #------------------------------------------------------------------------------------------------- | |
357 | #------------------------------------------------------------------------------------------------- No newline at end of file |
|
346 | ||
358 | No newline at end of file |
|
347 | # Calculate MSE | |
359 | # Calculate MSE No newline at end of file |
|
348 | rmse_fourier = np.sqrt(np.mean((f_fourier - factr)**2)); | |
360 |
rmse_ |
|
349 | rmse_capon = np.sqrt(np.mean((f_capon - factr)**2)); | |
361 |
rmse_ |
|
350 | rmse_maxent = np.sqrt(np.mean((f_maxent - factr)**2)); | |
362 |
rmse_ |
|
351 | rmse_cs = np.sqrt(np.mean((f_cs - factr)**2)); | |
363 | rmse_cs = np.sqrt(np.mean((f_cs - factr)**2)); No newline at end of file |
|
352 | ||
364 | No newline at end of file |
|
353 | ||
365 | No newline at end of file |
|
354 | relrmse_fourier = rmse_fourier / np.linalg.norm(fact); | |
366 |
relrmse_ |
|
355 | relrmse_capon = rmse_capon / np.linalg.norm(fact); | |
367 |
relrmse_ |
|
356 | relrmse_maxent = rmse_maxent / np.linalg.norm(fact); | |
368 |
relrmse_ |
|
357 | relrmse_cs = rmse_cs / np.linalg.norm(fact); | |
369 | relrmse_cs = rmse_cs / np.linalg.norm(fact); No newline at end of file |
|
358 | ||
370 |
|
|
359 | ||
371 | No newline at end of file |
|
360 | # Calculate correlation | |
372 | # Calculate correlation No newline at end of file |
|
361 | corr_fourier = np.dot(f_fourier.T.conj(),factr) / (np.linalg.norm(f_fourier)*np.linalg.norm(factr)); | |
373 |
corr_ |
|
362 | corr_capon = np.dot(f_capon.T.conj(),factr) / (np.linalg.norm(f_capon)*np.linalg.norm(factr)); | |
374 |
corr_ |
|
363 | corr_maxent = np.dot(f_maxent.T.conj(),factr) / (np.linalg.norm(f_maxent)*np.linalg.norm(factr)); | |
375 |
corr_ |
|
364 | corr_cs = np.dot(f_cs.T.conj(),factr) / (np.linalg.norm(f_cs)*np.linalg.norm(factr)); | |
376 | corr_cs = np.dot(f_cs.T.conj(),factr) / (np.linalg.norm(f_cs)*np.linalg.norm(factr)); No newline at end of file |
|
365 | ||
377 | No newline at end of file |
|
366 | ||
378 | No newline at end of file |
|
367 | # Calculate centered correlation | |
379 | # Calculate centered correlation No newline at end of file |
|
368 | f0 = factr - np.mean(factr); | |
380 |
f |
|
369 | f1 = f_fourier - np.mean(f_fourier); | |
381 | f1 = f_fourier - np.mean(f_fourier); No newline at end of file |
|
370 | ||
382 | No newline at end of file |
|
371 | corrc_fourier = np.dot(f0.T.conj(),f1) / (np.linalg.norm(f0)*np.linalg.norm(f1)); | |
383 | corrc_fourier = np.dot(f0.T.conj(),f1) / (np.linalg.norm(f0)*np.linalg.norm(f1)); No newline at end of file |
|
372 | f1 = f_capon - np.mean(f_capon); | |
384 | f1 = f_capon - np.mean(f_capon); No newline at end of file |
|
373 | corrc_capon = np.dot(f0.T.conj(),f1) / (np.linalg.norm(f0)*np.linalg.norm(f1)); | |
385 | corrc_capon = np.dot(f0.T.conj(),f1) / (np.linalg.norm(f0)*np.linalg.norm(f1)); No newline at end of file |
|
374 | f1 = f_maxent - np.mean(f_maxent); | |
386 | f1 = f_maxent - np.mean(f_maxent); No newline at end of file |
|
375 | corrc_maxent = np.dot(f0.T.conj(),f1) / (np.linalg.norm(f0)*np.linalg.norm(f1)); | |
387 | corrc_maxent = np.dot(f0.T.conj(),f1) / (np.linalg.norm(f0)*np.linalg.norm(f1)); No newline at end of file |
|
376 | f1 = f_cs - np.mean(f_cs); | |
388 | f1 = f_cs - np.mean(f_cs); No newline at end of file |
|
377 | corrc_cs = np.dot(f0.T.conj(),f1) / (np.linalg.norm(f0)*np.linalg.norm(f1)); | |
389 | corrc_cs = np.dot(f0.T.conj(),f1) / (np.linalg.norm(f0)*np.linalg.norm(f1)); No newline at end of file |
|
378 | ||
390 | No newline at end of file |
|
379 | ||
391 | No newline at end of file |
|
380 | #------------------------------------------------------------------------------------------------- | |
392 | #------------------------------------------------------------------------------------------------- No newline at end of file |
|
381 | # Plot stuff | |
393 | # Plot stuff No newline at end of file |
|
382 | #------------------------------------------------------------------------------------------------- | |
394 | #------------------------------------------------------------------------------------------------- No newline at end of file |
|
383 | ||
395 |
|
384 | #---- Capon----# | ||
No newline at end of file |
|
385 | plt.figure(5) No newline at end of file | ||
396 | #---- Capon---- No newline at end of file |
|
|||
397 |
plt. |
|
386 | plt.subplot(3, 1, 1) | |
398 | plt.subplot(3, 1, 1) No newline at end of file |
|
387 | plt.plot(180/np.pi*thetar, f_capon, 'r', label='Capon') | |
399 |
plt.plot(180/np.pi*theta |
|
388 | plt.plot(180/np.pi*thetat,fact, 'k--', label='Truth') | |
400 | plt.plot(180/np.pi*thetat,fact, 'k--', label='Truth') No newline at end of file |
|
389 | plt.ylabel('Power (arbitrary units)') | |
401 | plt.ylabel('Power (arbitrary units)') No newline at end of file |
|
390 | plt.legend(loc='upper right') | |
402 | plt.legend(loc='upper right') No newline at end of file |
|
391 | ||
403 | No newline at end of file |
|
392 | # formatting y-axis | |
404 | # formatting y-axis No newline at end of file |
|
393 | locs,labels = plt.yticks() | |
405 | locs,labels = plt.yticks() No newline at end of file |
|
394 | plt.yticks(locs, map(lambda x: "%.1f" % x, locs*1e4)) | |
406 | plt.yticks(locs, map(lambda x: "%.1f" % x, locs*1e4)) No newline at end of file |
|
395 | plt.text(0.0, 1.01, '1e-4', fontsize=10, transform = plt.gca().transAxes) | |
407 | plt.text(0.0, 1.01, '1e-4', fontsize=10, transform = plt.gca().transAxes) No newline at end of file |
|
396 | ||
408 |
|
|
397 | ||
409 |
|
398 | #---- MaxEnt----# | ||
No newline at end of file |
|
399 | plt.subplot(3, 1, 2) No newline at end of file | ||
410 | #---- MaxEnt---- No newline at end of file |
|
|||
411 | plt.subplot(3, 1, 2) No newline at end of file |
|
400 | plt.plot(180/np.pi*thetar, f_maxent, 'r', label='MaxEnt') | |
412 |
plt.plot(180/np.pi*theta |
|
401 | plt.plot(180/np.pi*thetat,fact, 'k--', label='Truth') | |
413 | plt.plot(180/np.pi*thetat,fact, 'k--', label='Truth') No newline at end of file |
|
402 | plt.ylabel('Power (arbitrary units)') | |
414 | plt.ylabel('Power (arbitrary units)') No newline at end of file |
|
403 | plt.legend(loc='upper right') | |
415 | plt.legend(loc='upper right') No newline at end of file |
|
404 | ||
416 | No newline at end of file |
|
405 | # formatting y-axis | |
417 | # formatting y-axis No newline at end of file |
|
406 | locs,labels = plt.yticks() | |
418 | locs,labels = plt.yticks() No newline at end of file |
|
407 | plt.yticks(locs, map(lambda x: "%.1f" % x, locs*1e4)) | |
419 | plt.yticks(locs, map(lambda x: "%.1f" % x, locs*1e4)) No newline at end of file |
|
408 | plt.text(0.0, 1.01, '1e-4', fontsize=10, transform = plt.gca().transAxes) | |
420 | plt.text(0.0, 1.01, '1e-4', fontsize=10, transform = plt.gca().transAxes) No newline at end of file |
|
409 | ||
421 | No newline at end of file |
|
410 | ||
422 |
|
411 | #---- Compressed Sensing----# | ||
No newline at end of file |
|
412 | plt.subplot(3, 1, 3) No newline at end of file | ||
423 | #---- Compressed Sensing---- No newline at end of file |
|
|||
424 | plt.subplot(3, 1, 3) No newline at end of file |
|
413 | plt.plot(180/np.pi*thetar, f_cs, 'r', label='CS') | |
425 |
plt.plot(180/np.pi*theta |
|
414 | plt.plot(180/np.pi*thetat,fact, 'k--', label='Truth') | |
426 | plt.plot(180/np.pi*thetat,fact, 'k--', label='Truth') No newline at end of file |
|
415 | plt.ylabel('Power (arbitrary units)') | |
427 | plt.ylabel('Power (arbitrary units)') No newline at end of file |
|
416 | plt.legend(loc='upper right') | |
428 | plt.legend(loc='upper right') No newline at end of file |
|
417 | ||
429 | No newline at end of file |
|
418 | # formatting y-axis | |
430 | # formatting y-axis No newline at end of file |
|
419 | locs,labels = plt.yticks() | |
431 | locs,labels = plt.yticks() No newline at end of file |
|
420 | plt.yticks(locs, map(lambda x: "%.1f" % x, locs*1e4)) | |
432 | plt.yticks(locs, map(lambda x: "%.1f" % x, locs*1e4)) No newline at end of file |
|
421 | plt.text(0.0, 1.01, '1e-4', fontsize=10, transform = plt.gca().transAxes) | |
433 | plt.text(0.0, 1.01, '1e-4', fontsize=10, transform = plt.gca().transAxes) No newline at end of file |
|
422 | ||
434 |
|
423 | # # Store Results | ||
No newline at end of file |
|
||||
435 |
|
||||
No newline at end of file |
|
||||
436 | # # PLOT PARA COMPRESSED SENSING |
|
|||
No newline at end of file |
|
||||
437 | # # |
|
|||
No newline at end of file |
|
||||
438 | # # subplot(3,1,3); |
|
|||
No newline at end of file |
|
||||
439 | # # plot(180/pi*thetar,f_cs,'r-'); |
|
|||
No newline at end of file |
|
||||
440 | # # hold on; |
|
|||
No newline at end of file |
|
||||
441 | # # plot(180/pi*thetat,fact,'k--'); |
|
|||
No newline at end of file |
|
||||
442 | # # hold off; |
|
|||
No newline at end of file |
|
||||
443 | # # ylim([min(f_cs) 1.1*max(fact)]); |
|
|||
No newline at end of file |
|
||||
444 | # # # title(sprintf('rel. RMSE: #.2e\tCorr: #.3f Corrc: #.3f', relrmse_cs, corr_cs, corrc_cs)); |
|
|||
No newline at end of file |
|
||||
445 | # # # title 'Compressed Sensing - Debauchies Wavelets' |
|
|||
No newline at end of file |
|
||||
446 | # # xlabel 'Degrees' |
|
|||
No newline at end of file |
|
||||
447 | # # ylabel({'Power';'(arbitrary units)'}) |
|
|||
No newline at end of file |
|
||||
448 | # # legend('Comp. Sens.','Truth'); |
|
|||
No newline at end of file |
|
||||
449 | # # |
|
|||
No newline at end of file |
|
||||
450 | # # # set(gcf,'Position',[749 143 528 881]); # CSL |
|
|||
No newline at end of file |
|
||||
451 | # # # set(gcf,'Position',[885 -21 528 673]); # macbook |
|
|||
No newline at end of file |
|
||||
452 | # # pause(0.01); |
|
|||
No newline at end of file |
|
||||
453 |
|
||||
No newline at end of file |
|
||||
454 | No newline at end of file |
|
|||
455 | # # Store Results No newline at end of file |
|
424 | corr[0, snri, Ni] = corr_fourier; | |
456 |
corr[ |
|
425 | corr[1, snri, Ni] = corr_capon; | |
457 |
corr[ |
|
426 | corr[2, snri, Ni] = corr_maxent; | |
458 |
corr[ |
|
427 | corr[3, snri, Ni] = corr_cs; | |
459 | corr[3, snri, Ni] = corr_cs; No newline at end of file |
|
428 | ||
460 | No newline at end of file |
|
429 | rmse[0,snri,Ni] = relrmse_fourier; | |
461 |
rmse[ |
|
430 | rmse[1,snri,Ni] = relrmse_capon; | |
462 |
rmse[ |
|
431 | rmse[2,snri,Ni] = relrmse_maxent; | |
463 |
rmse[ |
|
432 | rmse[3,snri,Ni] = relrmse_cs; | |
464 | rmse[3,snri,Ni] = relrmse_cs; No newline at end of file |
|
433 | ||
465 | No newline at end of file |
|
434 | corrc[0,snri,Ni] = corrc_fourier; | |
466 |
corrc[ |
|
435 | corrc[1,snri,Ni] = corrc_capon; | |
467 |
corrc[ |
|
436 | corrc[2,snri,Ni] = corrc_maxent; | |
468 |
corrc[ |
|
437 | corrc[3,snri,Ni] = corrc_cs; | |
469 | corrc[3,snri,Ni] = corrc_cs; No newline at end of file |
|
438 | ||
470 |
|
439 | print "--------Time performace--------" | ||
No newline at end of file |
|
440 | print 'Capon:\t', elapsed_time_capon, 'sec'; No newline at end of file | ||
471 | No newline at end of file |
|
|||
472 |
print ' |
|
441 | print 'Maxent:\t',elapsed_time_maxent, 'sec'; | |
473 |
print ' |
|
442 | print 'CS:\t',elapsed_time_cs, 'sec\n'; | |
No newline at end of file |
|
443 | |||
474 | print 'CS:\t',elapsed_time_cs, 'sec'; |
|
No newline at end of file | ||
No newline at end of file |
|
444 | print (NN*(snri+1) + Ni), '/', (SNRdBvec.size*NN), '\n'; | ||
475 |
|
No newline at end of file | |||
No newline at end of file |
|
445 | |||
476 | print (NN*(snri+1) + Ni), '/', (SNRdBvec.size*NN); |
|
No newline at end of file | ||
No newline at end of file |
|
446 | |||
477 |
|
No newline at end of file | |||
No newline at end of file |
|
447 | #------------------------------------------------------------------------------------------------- | ||
478 | print corr |
|
No newline at end of file | ||
No newline at end of file |
|
448 | # Analyze and plot statistics | ||
479 |
|
No newline at end of file | |||
No newline at end of file |
|
449 | #------------------------------------------------------------------------------------------------- | ||
480 | print corr.shape |
|
No newline at end of file | ||
No newline at end of file |
|
450 | No newline at end of file | ||
481 |
|
||||
No newline at end of file |
|
||||
482 |
|
||||
No newline at end of file |
|
||||
483 | ## Analyze and plot statistics No newline at end of file |
|
|||
484 | No newline at end of file |
|
451 | metric = corr; # set this to rmse, corr, or corrc | |
485 | metric = corr; # set this to rmse, corr, or corrc No newline at end of file |
|
452 | ||
486 | No newline at end of file |
|
453 | # Remove outliers (this part was experimental and wasn't used in the paper) | |
487 | # Remove outliers (this part was experimental and wasn't used in the paper) No newline at end of file |
|
454 | # nsig = 3; | |
488 |
# |
|
455 | # for i = 1:4 | |
489 |
# for i = 1: |
|
456 | # for snri = 1:length(SNRdBvec) | |
490 | # for snri = 1:length(SNRdBvec) No newline at end of file |
|
457 | # av = mean(met(i,snri,:)); | |
491 |
# |
|
458 | # s = std(met(i,snri,:)); | |
492 |
# |
|
459 | # idx = abs(met(i,snri,:) - av) > nsig*s; | |
493 |
# |
|
460 | # met(i,snri,idx) = nan; | |
494 |
# |
|
461 | # if sum(idx)>0 | |
495 | # if sum(idx)>0 No newline at end of file |
|
462 | # fprintf('i=%i, snr=%i, %i/%i pts removed\n',... | |
496 | # fprintf('i=%i, snr=%i, %i/%i pts removed\n',... No newline at end of file |
|
463 | # i,round(SNRdBvec(snri)),sum(idx),length(idx)); | |
497 | # i,round(SNRdBvec(snri)),sum(idx),length(idx)); No newline at end of file |
|
464 | # end | |
498 |
# |
|
465 | # end | |
499 |
# |
|
466 | # end | |
500 |
|
|
467 | ||
501 | No newline at end of file |
|
468 | ||
502 |
|
|
469 | # Avg ignoring NaNs | |
No newline at end of file |
|
470 | ave = np.zeros(shape=(4)) | ||
503 | def nanmean(data, **args): |
|
No newline at end of file | ||
No newline at end of file |
|
471 | |||
504 | return numpy.ma.filled(numpy.ma.masked_array(data,numpy.isnan(data)).mean(**args), fill_value=numpy.nan) |
|
No newline at end of file | ||
No newline at end of file |
|
472 | ave[0] = nanmean(metric[0,:,:]); # Fourier | ||
505 |
|
No newline at end of file | |||
No newline at end of file |
|
473 | ave[1] = nanmean(metric[1,:,:]); # Capon | ||
506 | # ave = np.zeros(shape=(4)) |
|
No newline at end of file | ||
No newline at end of file |
|
474 | ave[2] = nanmean(metric[2,:,:]); # MaxEnt | ||
507 | # |
|
No newline at end of file | ||
No newline at end of file |
|
475 | ave[3] = nanmean(metric[3,:,:]); # Compressed Sensing | ||
508 | # ave[0] = nanmean(metric, axis=0); |
|
No newline at end of file | ||
No newline at end of file |
|
476 | |||
509 | # ave[1] = nanmean(metric, axis=1); |
|
No newline at end of file | ||
No newline at end of file |
|
477 | # Plot based on chosen metric No newline at end of file | ||
510 | # ave[2] = nanmean(metric, axis=2); |
|
|||
No newline at end of file |
|
||||
511 | # ave[3] = nanmean(metric, axis=3); |
|
|||
No newline at end of file |
|
||||
512 |
|
||||
No newline at end of file |
|
||||
513 | #print ave No newline at end of file |
|
|||
514 | plt.figure(6); |
|
478 | plt.figure(6); | |
No newline at end of file |
|
479 | f = plt.scatter(SNRdBvec, ave[0], marker='+', color='b', s=60); # Fourier | ||
515 | f = plt.scatter(SNRdBvec, corr[0], marker='+', color='b', s=60); # Fourier |
|
No newline at end of file | ||
No newline at end of file |
|
480 | c = plt.scatter(SNRdBvec, ave[1], marker='o', color= 'g', s=60); # Capon | ||
516 | c = plt.scatter(SNRdBvec, corr[1], marker='o', color= 'c', s=60); # Capon |
|
No newline at end of file | ||
No newline at end of file |
|
481 | me= plt.scatter(SNRdBvec, ave[2], marker='s', color= 'c', s=60); # MaxEnt | ||
517 | me= plt.scatter(SNRdBvec, corr[2], marker='s', color= 'y', s=60); # MaxEnt |
|
No newline at end of file | ||
No newline at end of file |
|
482 | cs= plt.scatter(SNRdBvec, ave[3], marker='*', color='r', s=60); # Compressed Sensing No newline at end of file | ||
518 | cs= plt.scatter(SNRdBvec, corr[3], marker='*', color='r', s=60); # Compressed Sensing |
|
|||
No newline at end of file |
|
||||
519 | No newline at end of file |
|
|||
520 | No newline at end of file |
|
483 | ||
521 | plt.legend((f,c,me,cs),('Fourier','Capon', 'MaxEnt', 'Comp. Sens.'),scatterpoints=1, loc='upper right') No newline at end of file |
|
484 | plt.legend((f,c,me,cs),('Fourier','Capon', 'MaxEnt', 'Comp. Sens.'),scatterpoints=1, loc='upper right') | |
522 | plt.xlabel('SNR') No newline at end of file |
|
485 | plt.xlabel('SNR') | |
523 | plt.ylabel('Correlation with Truth') No newline at end of file |
|
486 | plt.ylabel('Correlation with Truth') | |
524 | No newline at end of file |
|
487 | ||
|
488 | print "--------Correlations--------" | |||
|
No newline at end of file | ||||
|
489 | print "Fourier:", ave[0] | |||
|
No newline at end of file | ||||
|
490 | print "Capon:\t", ave[1] | |||
|
No newline at end of file | ||||
|
491 | print "MaxEnt:\t", ave[2] | |||
|
No newline at end of file | ||||
|
492 | print "CS:\t", ave[3] | |||
|
No newline at end of file | ||||
|
493 | No newline at end of file | |||
525 | plt.show() No newline at end of file |
|
494 | plt.show() | |
526 | No newline at end of file |
|
495 | ||
527 |
|
496 |
@@ -1,41 +1,40 | |||||
1 | ''' No newline at end of file |
|
1 | ''' | |
2 | Created on May 26, 2014 No newline at end of file |
|
2 | Created on May 26, 2014 | |
3 | No newline at end of file |
|
3 | ||
4 | @author: Yolian Amaro No newline at end of file |
|
4 | @author: Yolian Amaro | |
5 | ''' No newline at end of file |
|
5 | ''' | |
6 |
|
6 | |||
No newline at end of file |
|
||||
7 | import numpy as np No newline at end of file |
|
|||
8 | from FSfarras import * No newline at end of file |
|
7 | from FSfarras import * | |
9 | from dualfilt1 import * No newline at end of file |
|
8 | from dualfilt1 import * | |
10 | from dualtree import * No newline at end of file |
|
9 | from dualtree import * | |
11 | from idualtree import * No newline at end of file |
|
10 | from idualtree import * | |
12 | No newline at end of file |
|
11 | ||
13 | # Debauchie 4 Wavelet No newline at end of file |
|
12 | # Debauchie 4 Wavelet | |
14 | def deb4_basis(N): No newline at end of file |
|
13 | def deb4_basis(N): | |
15 | No newline at end of file |
|
14 | ||
16 | Psi = np.zeros(shape=(N,2*N+1)); No newline at end of file |
|
15 | Psi = np.zeros(shape=(N,2*N+1)); | |
17 | idx = 0; No newline at end of file |
|
16 | idx = 0; | |
18 | J = 4; No newline at end of file |
|
17 | J = 4; | |
19 | [Faf, Fsf] = FSfarras(); No newline at end of file |
|
18 | [Faf, Fsf] = FSfarras(); | |
20 | [af, sf] = dualfilt1(); No newline at end of file |
|
19 | [af, sf] = dualfilt1(); | |
21 | No newline at end of file |
|
20 | ||
22 | # compute transform of zero vector No newline at end of file |
|
21 | # compute transform of zero vector | |
23 | x = np.zeros(shape=(1,N)); No newline at end of file |
|
22 | x = np.zeros(shape=(1,N)); | |
24 | w = dualtree(x, J, Faf, af); No newline at end of file |
|
23 | w = dualtree(x, J, Faf, af); | |
25 | No newline at end of file |
|
24 | ||
26 | No newline at end of file |
|
25 | ||
27 | # Uses both real and imaginary wavelets No newline at end of file |
|
26 | # Uses both real and imaginary wavelets | |
28 | for i in range (0, J+1): No newline at end of file |
|
27 | for i in range (0, J+1): | |
29 | for j in range (0, 2): No newline at end of file |
|
28 | for j in range (0, 2): | |
30 | for k in range (0, (w[i][j]).size): No newline at end of file |
|
29 | for k in range (0, (w[i][j]).size): | |
31 | w[i][j][0,k] = 1; No newline at end of file |
|
30 | w[i][j][0,k] = 1; | |
32 | y = idualtree(w, J, Fsf, sf); No newline at end of file |
|
31 | y = idualtree(w, J, Fsf, sf); | |
33 | w[i][j][0,k] = 0; No newline at end of file |
|
32 | w[i][j][0,k] = 0; | |
34 | # store it No newline at end of file |
|
33 | # store it | |
35 | Psi[:,idx] = y.T.conj(); No newline at end of file |
|
34 | Psi[:,idx] = y.T.conj(); | |
36 | idx = idx + 1; No newline at end of file |
|
35 | idx = idx + 1; | |
37 | No newline at end of file |
|
36 | ||
38 | # Add uniform vector (seems to be useful if there's a background No newline at end of file |
|
37 | # Add uniform vector (seems to be useful if there's a background | |
39 | Psi[:,2*N] = 1/np.sqrt(N); No newline at end of file |
|
38 | Psi[:,2*N] = 1/np.sqrt(N); | |
40 | No newline at end of file |
|
39 | ||
41 | return Psi No newline at end of file |
|
40 | return Psi |
@@ -1,94 +1,70 | |||||
1 | ''' No newline at end of file |
|
1 | ''' | |
2 | Created on May 27, 2014 No newline at end of file |
|
2 | Created on May 27, 2014 | |
3 | No newline at end of file |
|
3 | ||
4 | @author: Yolian Amaro No newline at end of file |
|
4 | @author: Yolian Amaro | |
5 | ''' No newline at end of file |
|
5 | ''' | |
6 |
|
6 | |||
No newline at end of file |
|
||||
7 | #from scipy.sparse import eye No newline at end of file |
|
|||
8 | from scipy import linalg No newline at end of file |
|
7 | from scipy import linalg | |
9 | import scipy.sparse as sps No newline at end of file |
|
8 | import scipy.sparse as sps | |
10 | import numpy as np No newline at end of file |
|
9 | import numpy as np | |
11 | from numpy.linalg import norm No newline at end of file |
|
10 | from numpy.linalg import norm | |
12 | No newline at end of file |
|
11 | ||
13 | def irls_dn(A,b,p,lambda1): No newline at end of file |
|
12 | def irls_dn(A,b,p,lambda1): | |
14 | No newline at end of file |
|
13 | ||
15 | No newline at end of file |
|
14 | ||
16 | # Minimize lambda*||u||_p + ||A*u-b||_2, 0 < p <= 1 No newline at end of file |
|
15 | # Minimize lambda*||u||_p + ||A*u-b||_2, 0 < p <= 1 | |
17 | # using Iterative Reweighted Least Squares No newline at end of file |
|
16 | # using Iterative Reweighted Least Squares | |
18 | # (see http://math.lanl.gov/Research/Publications/Docs/chartrand-2008-iteratively.pdf No newline at end of file |
|
17 | # (see http://math.lanl.gov/Research/Publications/Docs/chartrand-2008-iteratively.pdf | |
19 | # and http://web.eecs.umich.edu/~aey/sparse/sparse11.pdf) No newline at end of file |
|
18 | # and http://web.eecs.umich.edu/~aey/sparse/sparse11.pdf) | |
20 | No newline at end of file |
|
19 | ||
21 | # Note to self: I found that "warm-starting" didn't really help too much. No newline at end of file |
|
20 | # Note to self: I found that "warm-starting" didn't really help too much. | |
22 | No newline at end of file |
|
21 | ||
23 | [M,N] = A.shape; No newline at end of file |
|
22 | [M,N] = A.shape; | |
24 | # Initialize and precompute: No newline at end of file |
|
23 | # Initialize and precompute: | |
25 | eps = 1e-2; # damping parameter No newline at end of file |
|
24 | eps = 1e-2; # damping parameter | |
26 | No newline at end of file |
|
25 | ||
27 | [Q,R] = linalg.qr(A.T.conj(), mode='economic'); No newline at end of file |
|
26 | [Q,R] = linalg.qr(A.T.conj(), mode='economic'); | |
28 | No newline at end of file |
|
27 | ||
29 | No newline at end of file |
|
28 | ||
30 | c = linalg.solve(R.T.conj(),b); # will be used later also No newline at end of file |
|
29 | c = linalg.solve(R.T.conj(),b); # will be used later also | |
31 | u = np.dot(Q,c); # minimum 2-norm solution No newline at end of file |
|
30 | u = np.dot(Q,c); # minimum 2-norm solution | |
32 | I = sps.eye(M); No newline at end of file |
|
31 | I = sps.eye(M); | |
33 | No newline at end of file |
|
32 | ||
34 | # Temporary N x N matrix No newline at end of file |
|
33 | # Temporary N x N matrix | |
35 | temp = np.zeros(shape=(N,N)) |
|
34 | temp = np.zeros(shape=(N,N)) | |
No newline at end of file |
|
||||
36 |
|
||||
No newline at end of file |
|
||||
37 | #---------- not needed, defined above-------------- |
|
|||
No newline at end of file |
|
||||
38 | # Spacing of floating point numbers |
|
|||
No newline at end of file |
|
||||
39 | #eps = np.spacing(1) |
|
|||
No newline at end of file |
|
||||
40 | #-------------------------------------------------- No newline at end of file |
|
|||
41 | No newline at end of file |
|
35 | ||
42 | # Loop until damping parameter is small enough No newline at end of file |
|
36 | # Loop until damping parameter is small enough | |
43 | while (eps > 1e-7): No newline at end of file |
|
37 | while (eps > 1e-7): | |
44 | epschange = 0; No newline at end of file |
|
38 | epschange = 0; | |
45 | # Loop until it's time to change eps No newline at end of file |
|
39 | # Loop until it's time to change eps | |
46 | while (not(epschange)): No newline at end of file |
|
40 | while (not(epschange)): | |
47 | # main loop No newline at end of file |
|
41 | # main loop | |
48 | # u_n = W*A'*(A*W*A'+ lambda*I)^-1 * b No newline at end of file |
|
42 | # u_n = W*A'*(A*W*A'+ lambda*I)^-1 * b | |
49 | # where W = diag(1/w) No newline at end of file |
|
43 | # where W = diag(1/w) | |
50 | # where w = (u.^2 + eps).^(p/2-1) No newline at end of file |
|
44 | # where w = (u.^2 + eps).^(p/2-1) | |
51 | No newline at end of file |
|
45 | ||
52 | # Update No newline at end of file |
|
46 | # Update | |
53 | w = (u**2 + eps)**(1-p/2.0); |
|
47 | w = (u**2 + eps)**(1-p/2.0); | |
No newline at end of file |
|
||||
54 |
|
||||
No newline at end of file |
|
||||
55 | # #---- Very inefficient- REMOVE THIS PART------ |
|
|||
No newline at end of file |
|
||||
56 | # k = 0 |
|
|||
No newline at end of file |
|
||||
57 | # # Sparse matrix |
|
|||
No newline at end of file |
|
||||
58 | # for i in range (0, N): |
|
|||
No newline at end of file |
|
||||
59 | # for j in range (0,N): |
|
|||
No newline at end of file |
|
||||
60 | # if(i==j): |
|
|||
No newline at end of file |
|
||||
61 | # temp[i,j] = w[k] |
|
|||
No newline at end of file |
|
||||
62 | # k = k+1 |
|
|||
No newline at end of file |
|
||||
63 | #-------------------------------------------------- |
|
|||
No newline at end of file |
|
||||
64 | No newline at end of file |
|
|||
65 | np.fill_diagonal(temp, w) |
|
48 | np.fill_diagonal(temp, w) | |
No newline at end of file |
|
||||
66 | #----------------------------------------------- No newline at end of file |
|
|||
67 | No newline at end of file |
|
49 | ||
68 | # Compressed Sparse Matrix No newline at end of file |
|
50 | # Compressed Sparse Matrix | |
69 | W = sps.csr_matrix(temp); #Compressed Sparse Row matrix No newline at end of file |
|
51 | W = sps.csr_matrix(temp); #Compressed Sparse Row matrix | |
70 | No newline at end of file |
|
52 | ||
71 | No newline at end of file |
|
53 | WAT = W*A.T.conj(); | |
72 | WAT = W*A.T.conj(); |
|
54 | ||
No newline at end of file |
|
||||
73 |
|
||||
No newline at end of file |
|
||||
74 | #print "WAT", WAT.shape |
|
|||
No newline at end of file |
|
||||
75 | #print "np.dot(A,WAT)", np.dot(A,WAT).shape |
|
|||
No newline at end of file |
|
||||
76 | #print "np.dot(lambda1,I)", np.dot(lambda1,I).shape |
|
|||
No newline at end of file |
|
||||
77 | #print "linalg.solve((np.dot(A,WAT) + np.dot(lambda1,I)), b)", linalg.solve((np.dot(A,WAT) + np.dot(lambda1,I)), b).shape No newline at end of file |
|
|||
78 | No newline at end of file |
|
55 | u_new = np.dot(WAT , linalg.solve((np.dot(A,WAT) + np.dot(lambda1,I)), b)); | |
79 | u_new = np.dot(WAT , linalg.solve((np.dot(A,WAT) + np.dot(lambda1,I)), b)); No newline at end of file |
|
56 | ||
80 | No newline at end of file |
|
57 | # See if this subproblem is converging | |
81 | # See if this subproblem is converging No newline at end of file |
|
58 | delu = norm(u_new-u)/norm(u); | |
82 | delu = norm(u_new-u)/norm(u); No newline at end of file |
|
59 | epschange = delu < (np.sqrt(eps)/100.0); | |
83 | epschange = delu < (np.sqrt(eps)/100.0); No newline at end of file |
|
60 | ||
84 | No newline at end of file |
|
61 | # Make update | |
85 |
|
|
62 | u = u_new; | |
86 |
|
|
63 | ||
87 | No newline at end of file |
|
64 | ||
88 | No newline at end of file |
|
65 | eps = eps/10.0; # decrease eps | |
89 | eps = eps/10.0; # decrease eps No newline at end of file |
|
66 | ||
90 | No newline at end of file |
|
67 | return u | |
91 | return u No newline at end of file |
|
68 | ||
92 | No newline at end of file |
|
69 | ||
93 | No newline at end of file |
|
70 | ||
94 |
|
|
71 |
@@ -1,74 +1,53 | |||||
1 | ''' No newline at end of file |
|
1 | ''' | |
2 | Created on May 30, 2014 No newline at end of file |
|
2 | Created on May 30, 2014 | |
3 | No newline at end of file |
|
3 | ||
4 | @author: Yolian Amaro No newline at end of file |
|
4 | @author: Yolian Amaro | |
5 | ''' No newline at end of file |
|
5 | ''' | |
6 | No newline at end of file |
|
6 | ||
7 | from irls_dn import * |
|
7 | from irls_dn import * | |
No newline at end of file |
|
8 | from scipy.optimize import brentq No newline at end of file | ||
8 | from scipy.optimize import fsolve |
|
|||
No newline at end of file |
|
||||
9 | import numpy as np |
|
|||
No newline at end of file |
|
||||
10 | from scipy.optimize import * |
|
|||
No newline at end of file |
|
||||
11 | from dogleg import * |
|
|||
No newline at end of file |
|
||||
12 | from numpy.linalg import norm |
|
|||
No newline at end of file |
|
||||
13 |
|
||||
No newline at end of file |
|
||||
14 | import matplotlib.pyplot as plt No newline at end of file |
|
|||
15 | No newline at end of file |
|
9 | ||
16 | def irls_dn2(A,b,p,G): No newline at end of file |
|
10 | def irls_dn2(A,b,p,G): | |
17 | No newline at end of file |
|
11 | ||
18 | # Minimize ||u||_p subject to ||A*u-b||_2^2 <= G (0 < p <= 1) No newline at end of file |
|
12 | # Minimize ||u||_p subject to ||A*u-b||_2^2 <= G (0 < p <= 1) | |
19 | No newline at end of file |
|
13 | ||
20 | # What this function actually does is finds the lambda1 so that the solution No newline at end of file |
|
14 | # What this function actually does is finds the lambda1 so that the solution | |
21 | # to the following problem satisfies ||A*u-b||_2^2 <= G: No newline at end of file |
|
15 | # to the following problem satisfies ||A*u-b||_2^2 <= G: | |
22 | # Minimize lambda1*||u||_p + ||A*u-b||_2 No newline at end of file |
|
16 | # Minimize lambda1*||u||_p + ||A*u-b||_2 | |
23 | No newline at end of file |
|
17 | ||
24 | # Start with a large lambda1, and do a line search until fidelity <= G. No newline at end of file |
|
18 | # Start with a large lambda1, and do a line search until fidelity <= G. | |
25 | # (Inversions with large lambda1 are really fast anyway). No newline at end of file |
|
19 | # (Inversions with large lambda1 are really fast anyway). | |
26 | No newline at end of file |
|
20 | ||
27 | # Then spin up fsolve to localize the root even better No newline at end of file |
|
21 | # Then spin up fsolve to localize the root even better | |
28 | No newline at end of file |
|
22 | ||
29 | # Line Search No newline at end of file |
|
23 | # Line Search | |
30 | No newline at end of file |
|
24 | ||
31 | alpha = 2.0; # Line search parameter No newline at end of file |
|
25 | alpha = 2.0; # Line search parameter | |
32 | lambda1 = 1e5; # What's a reasonable but safe initial guess? No newline at end of file |
|
26 | lambda1 = 1e5; # What's a reasonable but safe initial guess? | |
33 | u = irls_dn(A,b,p,lambda1); |
|
27 | u = irls_dn(A,b,p,lambda1); | |
No newline at end of file |
|
28 | No newline at end of file | ||
34 | #print "u\n", u No newline at end of file |
|
|||
35 | No newline at end of file |
|
29 | ||
36 | fid = norm(np.dot(A,u)-b)**2; No newline at end of file |
|
30 | fid = norm(np.dot(A,u)-b)**2; | |
37 | No newline at end of file |
|
31 | ||
38 | print '----------------------------------\n'; No newline at end of file |
|
32 | print '----------------------------------\n'; | |
39 | No newline at end of file |
|
33 | ||
40 | while (fid >= G): No newline at end of file |
|
34 | while (fid >= G): | |
41 | lambda1 = lambda1 / alpha; # Balance between speed and accuracy No newline at end of file |
|
35 | lambda1 = lambda1 / alpha; # Balance between speed and accuracy | |
42 | u = irls_dn(A,b,p,lambda1); No newline at end of file |
|
36 | u = irls_dn(A,b,p,lambda1); | |
43 | fid = norm(np.dot(A,u)-b)**2; |
|
37 | fid = norm(np.dot(A,u)-b)**2; | |
No newline at end of file |
|
38 | print 'lambda = %2e \t' % lambda1, '||A*u-b||^2 = %.1f' % fid; No newline at end of file | ||
44 | print 'lambda = %2e \t' % lambda1, '||A*u-b||^2 = %.1f\n' % fid; |
|
|||
No newline at end of file |
|
||||
45 | #print u No newline at end of file |
|
|||
46 | No newline at end of file |
|
39 | ||
47 | # Refinement using fzero/ brentq |
|
40 | # Refinement using fzero/ brentq | |
No newline at end of file |
|
||||
48 | lambda0 = np.array([lambda1,lambda1*alpha]); # interval with zero-crossing No newline at end of file |
|
|||
49 | No newline at end of file |
|
41 | ||
|
42 | lambda0 = np.array([lambda1,lambda1*alpha]); # interval with zero-crossing No newline at end of file | |||
50 |
|
|
43 | ||
51 | def myfun(lambda1): |
|
44 | def myfun(lambda1): | |
No newline at end of file |
|
45 | return norm(np.dot(A, irls_dn(A,b,p,lambda1)) - b)**2 - G; No newline at end of file | ||
52 | temp1 = np.dot(A, irls_dn(A,b,p,lambda1)) |
|
|||
No newline at end of file |
|
||||
53 | temp2 = norm(temp1-b) |
|
|||
No newline at end of file |
|
||||
54 | temp3 = temp2**2-G |
|
|||
No newline at end of file |
|
||||
55 | #return np.linalg.norm(np.dot(A, irls_dn(A,b,p,lambda1)) - b)**2 - G; |
|
|||
No newline at end of file |
|
||||
56 | return temp3 No newline at end of file |
|
|||
57 |
|
46 | |||
No newline at end of file |
|
47 | # Find zero-crossing at given interval (lambda1, lambda1*alpha) No newline at end of file | ||
58 | print "tolerancia=", 0.01*lambda1 |
|
|||
No newline at end of file |
|
||||
59 |
|
||||
No newline at end of file |
|
||||
60 | #lambda1 = root(myfun, lambda1, method='krylov', tol=0.01*lambda1); |
|
|||
No newline at end of file |
|
||||
61 | #lambda1 = lambda1.x |
|
|||
No newline at end of file |
|
||||
62 |
|
||||
No newline at end of file |
|
||||
63 | print "lambda0[0]", lambda0[0] |
|
|||
No newline at end of file |
|
||||
64 | print "lambda0[1]", lambda0[1] |
|
|||
No newline at end of file |
|
||||
65 | No newline at end of file |
|
|||
66 | lambda1 = brentq(myfun, lambda0[0], lambda0[1], xtol=0.01*lambda1) |
|
48 | lambda1 = brentq(myfun, lambda0[0], lambda0[1], xtol=0.01*lambda1) | |
No newline at end of file |
|
||||
67 |
|
||||
No newline at end of file |
|
||||
68 | print "lambda final=", lambda1 No newline at end of file |
|
|||
69 | No newline at end of file |
|
49 | ||
70 | u = irls_dn(A,b,p,lambda1); No newline at end of file |
|
50 | u = irls_dn(A,b,p,lambda1); | |
71 | No newline at end of file |
|
51 | ||
72 | No newline at end of file |
|
52 | return u; | |
73 | return u; No newline at end of file |
|
53 | ||
74 |
|
|
54 |
@@ -1,64 +1,63 | |||||
1 | ''' No newline at end of file |
|
1 | ''' | |
2 | Created on Jun 5, 2014 No newline at end of file |
|
2 | Created on Jun 5, 2014 | |
3 | No newline at end of file |
|
3 | ||
4 | @author: Yolian Amaro No newline at end of file |
|
4 | @author: Yolian Amaro | |
5 | ''' No newline at end of file |
|
5 | ''' | |
6 |
|
6 | |||
No newline at end of file |
|
7 | from multirate import upfirdn No newline at end of file | ||
7 | from multirate import * |
|
|||
No newline at end of file |
|
||||
8 | import numpy as np No newline at end of file |
|
|||
9 | from cshift import * No newline at end of file |
|
8 | from cshift import * | |
10 | No newline at end of file |
|
9 | ||
11 | def sfb(lo, hi, sf): No newline at end of file |
|
10 | def sfb(lo, hi, sf): | |
12 | No newline at end of file |
|
11 | ||
13 | # Synthesis filter bank No newline at end of file |
|
12 | # Synthesis filter bank | |
14 | # No newline at end of file |
|
13 | # | |
15 | # USAGE: No newline at end of file |
|
14 | # USAGE: | |
16 | # y = sfb(lo, hi, sf) No newline at end of file |
|
15 | # y = sfb(lo, hi, sf) | |
17 | # INPUT: No newline at end of file |
|
16 | # INPUT: | |
18 | # lo - low frqeuency input No newline at end of file |
|
17 | # lo - low frqeuency input | |
19 | # hi - high frequency input No newline at end of file |
|
18 | # hi - high frequency input | |
20 | # sf - synthesis filters No newline at end of file |
|
19 | # sf - synthesis filters | |
21 | # sf(:, 1) - lowpass filter (even length) No newline at end of file |
|
20 | # sf(:, 1) - lowpass filter (even length) | |
22 | # sf(:, 2) - highpass filter (even length) No newline at end of file |
|
21 | # sf(:, 2) - highpass filter (even length) | |
23 | # OUTPUT: No newline at end of file |
|
22 | # OUTPUT: | |
24 | # y - output signal No newline at end of file |
|
23 | # y - output signal | |
25 | # See also afb No newline at end of file |
|
24 | # See also afb | |
26 | # No newline at end of file |
|
25 | # | |
27 | # WAVELET SOFTWARE AT POLYTECHNIC UNIVERSITY, BROOKLYN, NY No newline at end of file |
|
26 | # WAVELET SOFTWARE AT POLYTECHNIC UNIVERSITY, BROOKLYN, NY | |
28 | # http://taco.poly.edu/WaveletSoftware/ No newline at end of file |
|
27 | # http://taco.poly.edu/WaveletSoftware/ | |
29 | No newline at end of file |
|
28 | ||
30 | N = 2*lo.size; No newline at end of file |
|
29 | N = 2*lo.size; | |
31 | L = sf.size/2; No newline at end of file |
|
30 | L = sf.size/2; | |
32 | No newline at end of file |
|
31 | ||
33 | # Need to change format for upfirdn funct: No newline at end of file |
|
32 | # Need to change format for upfirdn funct: | |
34 | lo = lo.T.conj() No newline at end of file |
|
33 | lo = lo.T.conj() | |
35 | lo = lo.reshape(lo.size) No newline at end of file |
|
34 | lo = lo.reshape(lo.size) | |
36 | No newline at end of file |
|
35 | ||
37 | #print 'sfb hi', hi No newline at end of file |
|
36 | #print 'sfb hi', hi | |
38 | No newline at end of file |
|
37 | ||
39 | # Need to change format for upfirdn funct: No newline at end of file |
|
38 | # Need to change format for upfirdn funct: | |
40 | hi = hi.T.conj() No newline at end of file |
|
39 | hi = hi.T.conj() | |
41 | hi = hi.reshape(hi.size) No newline at end of file |
|
40 | hi = hi.reshape(hi.size) | |
42 | No newline at end of file |
|
41 | ||
43 | #hi = hi.reshape(1, hi.size) No newline at end of file |
|
42 | #hi = hi.reshape(1, hi.size) | |
44 | No newline at end of file |
|
43 | ||
45 | No newline at end of file |
|
44 | ||
46 | lo = upfirdn(lo, sf[:,0], 2, 1); No newline at end of file |
|
45 | lo = upfirdn(lo, sf[:,0], 2, 1); | |
47 | hi = upfirdn(hi, sf[:,1], 2, 1); No newline at end of file |
|
46 | hi = upfirdn(hi, sf[:,1], 2, 1); | |
48 | No newline at end of file |
|
47 | ||
49 | lo = lo[0:lo.size-1] No newline at end of file |
|
48 | lo = lo[0:lo.size-1] | |
50 | hi = hi[0:hi.size-1] No newline at end of file |
|
49 | hi = hi[0:hi.size-1] | |
51 | No newline at end of file |
|
50 | ||
52 | y = lo + hi; No newline at end of file |
|
51 | y = lo + hi; | |
53 | y[0:L-2] = y[0:L-2] + y[N+ np.arange(0,L-2)]; #CHECK IF ARANGE IS CORRECT No newline at end of file |
|
52 | y[0:L-2] = y[0:L-2] + y[N+ np.arange(0,L-2)]; #CHECK IF ARANGE IS CORRECT | |
54 | y = y[0:N]; No newline at end of file |
|
53 | y = y[0:N]; | |
55 | No newline at end of file |
|
54 | ||
56 | #print 'y en sbf\n', y.shape No newline at end of file |
|
55 | #print 'y en sbf\n', y.shape | |
57 | No newline at end of file |
|
56 | ||
58 | y = y.reshape(1, y.size) No newline at end of file |
|
57 | y = y.reshape(1, y.size) | |
59 | #print 'y en sbf\n', y.shape No newline at end of file |
|
58 | #print 'y en sbf\n', y.shape | |
60 | No newline at end of file |
|
59 | ||
61 | y = cshift(y, 1-L/2); No newline at end of file |
|
60 | y = cshift(y, 1-L/2); | |
62 | No newline at end of file |
|
61 | ||
63 | return y; No newline at end of file |
|
62 | return y; | |
64 | No newline at end of file |
|
63 |
@@ -1,32 +1,31 | |||||
1 | ''' No newline at end of file |
|
1 | ''' | |
2 | Created on May 22, 2014 No newline at end of file |
|
2 | Created on May 22, 2014 | |
3 | No newline at end of file |
|
3 | ||
4 | @author: Yolian Amaro No newline at end of file |
|
4 | @author: Yolian Amaro | |
5 | ''' No newline at end of file |
|
5 | ''' | |
6 |
|
6 | |||
No newline at end of file |
|
||||
7 | import numpy as np No newline at end of file |
|
|||
8 | from modelf import * No newline at end of file |
|
7 | from modelf import * | |
9 | No newline at end of file |
|
8 | ||
10 | def y_hysell96(lambda1,g,sigma,F,G,H): No newline at end of file |
|
9 | def y_hysell96(lambda1,g,sigma,F,G,H): | |
11 | # Y_HYSELL96 Implements set of nonlinear equations to solve Hysell96 MaxEnt No newline at end of file |
|
10 | # Y_HYSELL96 Implements set of nonlinear equations to solve Hysell96 MaxEnt | |
12 | # y(lambda) = 0 No newline at end of file |
|
11 | # y(lambda) = 0 | |
13 | # decision variables: lambda No newline at end of file |
|
12 | # decision variables: lambda | |
14 | # g: data No newline at end of file |
|
13 | # g: data | |
15 | # sigma: uncertainties (length of g) No newline at end of file |
|
14 | # sigma: uncertainties (length of g) | |
16 | # F: sum(f) No newline at end of file |
|
15 | # F: sum(f) | |
17 | # G: desired value for chi^2 No newline at end of file |
|
16 | # G: desired value for chi^2 | |
18 | # H: linear operator mapping image (f) to data (g) No newline at end of file |
|
17 | # H: linear operator mapping image (f) to data (g) | |
19 | # This function is a helper function that returns 0 when a value of lambda No newline at end of file |
|
18 | # This function is a helper function that returns 0 when a value of lambda | |
20 | # is chosen that satisfies the equations. No newline at end of file |
|
19 | # is chosen that satisfies the equations. | |
21 | No newline at end of file |
|
20 | ||
22 | # model for f No newline at end of file |
|
21 | # model for f | |
23 | f = modelf(lambda1, H,F); No newline at end of file |
|
22 | f = modelf(lambda1, H,F); | |
24 | No newline at end of file |
|
23 | ||
25 | # solve for Lambda and e No newline at end of file |
|
24 | # solve for Lambda and e | |
26 | Lambda = np.sqrt(np.sum(np.multiply(lambda1**2,sigma**2))/(4*G)); # positive root (right?) No newline at end of file |
|
25 | Lambda = np.sqrt(np.sum(np.multiply(lambda1**2,sigma**2))/(4*G)); # positive root (right?) | |
27 | e = np.multiply(-lambda1,sigma**2) / (2*Lambda); No newline at end of file |
|
26 | e = np.multiply(-lambda1,sigma**2) / (2*Lambda); | |
28 | No newline at end of file |
|
27 | ||
29 | # measurement equation No newline at end of file |
|
28 | # measurement equation | |
30 | y = g + e - np.dot(H, f); No newline at end of file |
|
29 | y = g + e - np.dot(H, f); | |
31 | No newline at end of file |
|
30 | ||
32 | return y No newline at end of file |
|
31 | return y |
General Comments 0
You need to be logged in to leave comments.
Login now