-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_main_bat.m
93 lines (76 loc) · 2.28 KB
/
test_main_bat.m
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
close all
addpath('./common-tf-code');
%bat signal
load -ascii batsig.txt
s = batsig;
s = s(145:end);
s = s(:).';
% s = [s fliplr(s)];
% s = s(1:512);
s = hilbert(s);
% sigma_w = 0.13;
sigma_w = 0.13;
% Lg = 65;
% clwin = 10;
% return;
s_ref = s;
IFs = [0, 512];
Amp = ones(size(s));
s_name = 'bat';
NR = 3;
s_all = s;
Lx = length(s_all);
[STFT, ~] = sstn(s_all, 10^(-6), sigma_w);
N_f = size(STFT, 1);
Nfft = 2*N_f;
Tx = (0:(Lx-1))/Lx;
F_vec = (0:N_f-1)*Lx/Nfft;
xi0 = min(IFs) - 100;
xi1 = max(IFs) + 100;
F2 = F_vec.*(F_vec > xi0).*(F_vec < xi1);
small_TFRsc(Tx, F_vec, abs(STFT));
% return;
gen_fig_TFR(Tx, F2, STFT, s_name);
% return;
%% parameters
% IMPORTANT : L_rep > 2
L_rep = 100;
SNR_vec = [10, 20, 30, 40, 50];
% LD = length(d_vec);
%% window range
[g, Lh] = create_gaussian_window(Lx, Nfft, sigma_w, 10^(-3));
Lh2 = Lh*2;
Xw = Lh2+1:Lx-Lh2;
%% energy without noise
s_modes = zeros(Lx, NR);
sv_modes = zeros(4, Lx, NR);
for RA=1:NR
% EV_i : 4, D, Lx
% sv_i : 4, D, Lx
[EV_i, smax_i, sv_i, pv_i] =...
main(s_all, s_all, inf, Lx, Nfft, sigma_w, [0],NR,RA);
% gen_fig_ridge_energy(Tx(Xw), Amp(Xw), squeeze(EV_i(:, 1, Xw)), [s_name, '_r1']);
s_modes(:, RA) = smax_i;
sv_modes(:, :, RA) = squeeze(sv_i(:, :, :));
end
SR_ord = sum(sv_modes, 3);
SR_max = sum(s_modes, 2);
% [STFT_SR, ~] = sstn(SR_ord(1, :), 10^(-6), sigma_w)
% % gen_fig_TFR(Tx, F2, STFT_SR, [s_name, '_1']);
% [STFT_SR, ~] = sstn(SR_ord(1, :), 10^(-6), sigma_w)
% % gen_fig_TFR(Tx, F2, STFT_SR, [s_name, '_2']);
% [STFT_SR, ~] = sstn(SR_ord(1, :), 10^(-6), sigma_w)
% % gen_fig_TFR(Tx, F2, STFT_SR, [s_name, '_3']);
% [STFT_SR, ~] = sstn(SR_ord(1, :), 10^(-6), sigma_w)
% % gen_fig_TFR(Tx, F2, STFT_SR, [s_name, '_4']);
[STFT_SR, ~] = sstn(SR_max, 10^(-6), sigma_w);
gen_fig_TFR(Tx, F2, STFT_SR, [s_name, '_SR']);
fprintf("SNR SST1 = %f\n", snr(s_ref, s_ref(:) - SR_ord(1, :).'));
fprintf("SNR SST2 = %f\n", snr(s_ref, s_ref(:) - SR_ord(1, :).'));
fprintf("SNR SST3 = %f\n", snr(s_ref, s_ref(:) - SR_ord(1, :).'));
fprintf("SNR SST4 = %f\n", snr(s_ref, s_ref(:) - SR_ord(1, :).'));
fprintf("SNR adaptive = %f\n", snr(s_ref, s_ref(:) - SR_max(:)));
% snr(s_ref, s_ref(:) - SR_ord(2, :).')
% snr(s_ref, s_ref(:) - SR_ord(3, :).')
% snr(s_ref, s_ref(:) - SR_ord(4, :).')
% snr(s_ref, s_ref(:) - SR_max(:))