Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HDL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RTSD
HDL
Commits
e2d60fcb
"git@git.astron.nl:rtsd/hdl.git" did not exist on "b3aa22a5eb9b32672f54fa4a69bf501544cdd8b6"
Commit
e2d60fcb
authored
5 months ago
by
Eric Kooistra
Browse files
Options
Downloads
Patches
Plain Diff
Clarify adjust. Support running reconstruct directly after Gen_filter12.m.
parent
b5d2dcc7
No related branches found
No related tags found
1 merge request
!420
Resolve RTSD-264
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
applications/lofar2/model/pfb_bunton_annotated/reconstruct.m
+25
-20
25 additions, 20 deletions
applications/lofar2/model/pfb_bunton_annotated/reconstruct.m
with
25 additions
and
20 deletions
applications/lofar2/model/pfb_bunton_annotated/reconstruct.m
+
25
−
20
View file @
e2d60fcb
...
@@ -11,14 +11,18 @@
...
@@ -11,14 +11,18 @@
%
%
% Usage from README.txt:
% Usage from README.txt:
% . first run Gen_filter12 to create prototype lowpass filter cl
% . first run Gen_filter12 to create prototype lowpass filter cl
% . then run reconstruct with ImpulseResponse = 1 and Correct = 1 to calculate
% . then run reconstruct with ImpulseResponse = 0 and Correct = 0 to filter
% an impulse response and a correction filter for the analysis PFB and
% the inData
% synthesis PFB transfer function error
% . to correct the overall response, rerun reconstruct with ImpulseResponse =
% . then rerun reconstruct with ImpulseResponse = 0 and Correct = 0 or 1
% 1 and Correct = 1 to calculate an impulse response and a correction filter
% for the analysis PFB and synthesis PFB transfer function error
% . then rerun reconstruct with ImpulseResponse = 0 and Correct = 1 to also
% apply the correction filtering
% . use rng('default') to check SNR results, comment rng() to experiment with
% . use rng('default') to check SNR results, comment rng() to experiment with
% new noise input evry rerun
% new noise input ev
e
ry rerun
close
all
close
all
format
longE
% Uncomment rng() line or run rng() line first in shell, to produce same random
% Uncomment rng() line or run rng() line first in shell, to produce same random
% numbers as with MATLAB restart, to verify the SNR results for Correct = 0, 1.
% numbers as with MATLAB restart, to verify the SNR results for Correct = 0, 1.
...
@@ -57,6 +61,7 @@ k = length(inData); % = len * Nhold
...
@@ -57,6 +61,7 @@ k = length(inData); % = len * Nhold
%inData = cos(((1:k).^2 ) * len / (k)^2);
%inData = cos(((1:k).^2 ) * len / (k)^2);
%inData = cos(2*pi*(1:k) * 0.031 / 16);
%inData = cos(2*pi*(1:k) * 0.031 / 16);
%inData = cos(2*pi*(0:k-1) * 1.5 / Nfft); % use integer for CW at bin
%inData = cos(2*pi*(0:k-1) * 1.5 / Nfft); % use integer for CW at bin
%inData = (0:k-1);
% 4) impulse signal
% 4) impulse signal
if
ImpulseResponse
==
1
if
ImpulseResponse
==
1
...
@@ -74,10 +79,10 @@ outBins = polyphase_analysis(inData, cl, Nfft, Nstep);
...
@@ -74,10 +79,10 @@ outBins = polyphase_analysis(inData, cl, Nfft, Nstep);
outData
=
polyphase_synthesis_b
(
outBins
,
cl
,
Nstep
);
outData
=
polyphase_synthesis_b
(
outBins
,
cl
,
Nstep
);
% adjust gain
% adjust gain
% . unit gain in prototype LPF Gen_filter12.m
% .
assume
unit gain in prototype LPF Gen_filter12.m
adjust
=
Nfft
;
% normalize gain per bin for analysis LPF
% .
adjust
for 1/Nfft in synthesis IFFT and adjust for 1/Nup in synthesis
adjust
=
adjust
/
Ros
;
% compensate for oversampling factor
% interpolation, with analysis Ndown = synthesis Nup = Nstep.
adjust
=
adjust
*
Nfft
;
% normalize gain per bin for synthesis LPF
adjust
=
Nfft
*
Nstep
;
outData
=
adjust
*
outData
;
outData
=
adjust
*
outData
;
if
ImpulseResponse
==
1
if
ImpulseResponse
==
1
...
@@ -86,19 +91,18 @@ if ImpulseResponse == 1
...
@@ -86,19 +91,18 @@ if ImpulseResponse == 1
correct
=
real
(
ifft
(
1.
/
fft
(
outData
)));
correct
=
real
(
ifft
(
1.
/
fft
(
outData
)));
end
end
% Choose parameter k to suit oversampling ratio
% oversampling ratio 32/23 then k=0
% oversampling ratio 32/24 then k=39
% oversampling ratio 32/25 then k=72
% oversampling ratio 32/26 then k=3
% oversampling ratio 32/27 then k=48
k
=
39
;
corr
=
correct
;
% Correct for time shift for transfer function correction filter
corr
(
1
+
k
:
length
(
corr
))
=
corr
(
1
:
length
(
corr
)
-
k
);
% Correct for error in transfer function
% Correct for error in transfer function
if
Correct
==
1
if
Correct
==
1
% Choose parameter k to suit oversampling ratio
% oversampling ratio 32/23 then k=0
% oversampling ratio 32/24 then k=39
% oversampling ratio 32/25 then k=72
% oversampling ratio 32/26 then k=3
% oversampling ratio 32/27 then k=48
k
=
39
;
corr
=
correct
;
% Correct for time shift for transfer function correction filter
corr
(
1
+
k
:
length
(
corr
))
=
corr
(
1
:
length
(
corr
)
-
k
);
outData
=
ifft
(
fft
(
outData
)
.*
fft
(
fftshift
(
corr
)));
outData
=
ifft
(
fft
(
outData
)
.*
fft
(
fftshift
(
corr
)));
end
end
...
@@ -121,6 +125,7 @@ diff = outData - inData(1:length(outData));
...
@@ -121,6 +125,7 @@ diff = outData - inData(1:length(outData));
% With DEVP = 0.005 and W0 = 1 / 15.05 then db(0.005) = -46.0 dB and SNR =
% With DEVP = 0.005 and W0 = 1 / 15.05 then db(0.005) = -46.0 dB and SNR =
% 38.8 dB, so increased.
% 38.8 dB, so increased.
SNR
=
10
*
log10
(
sum
(
abs
(
inData
(
10000
:
70000
)
.^
2
))
/
sum
(
abs
(
diff
(
10000
:
70000
)
.^
2
)));
SNR
=
10
*
log10
(
sum
(
abs
(
inData
(
10000
:
70000
)
.^
2
))
/
sum
(
abs
(
diff
(
10000
:
70000
)
.^
2
)));
SNR
=
20
*
log10
(
std
(
inData
(
10000
:
70000
))
/
std
(
diff
(
10000
:
70000
)));
sprintf
(
'SNR = %.5f [dB]'
,
SNR
)
sprintf
(
'SNR = %.5f [dB]'
,
SNR
)
%plot(diff)
%plot(diff)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment