This repository has been archived by the owner on Jun 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathnf2ff_cylindrical.m
318 lines (266 loc) · 10.9 KB
/
nf2ff_cylindrical.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
%
% NF2FF Conversion using Planar Scanner
%
clear
close all
clc
disp('************************************************')
disp(' Near-To-Far-Field Conversion')
disp(' Cylindrical Scanner')
disp('************************************************')
addpath('misc_functions')
addpath('plot_functions')
addpath('transformation_functions')
%% Load Data
disp('Load Data...')
f = 5e9;
setup = '../measurement/CylindricalScan_HornAntenna/';
% setup = '../measurement/CylindricalScan_HornAntenna_Rotated/';
% setup = '../measurement/CylindricalScan_PatchAntenna/';
data_ff = readtable([setup 'Farfield/farfield (f=' num2str(f*1e-9) ') [1].txt']);
scans = dir(setup);
scan_names = {scans.name};
scan_names(ismember(scan_names,{'.','..','Farfield','Farfield_old','Scan-PhiSamples-ZSpacing-ZSamples_R300.txt'})) = [];
data_nf= cellfun(@(scan_names) readtable([setup,scan_names,'/NearFieldProbeResults' num2str(f*1e-9) 'GHz.txt']),scan_names,'UniformOutput',false);
% Rearrange farfield table
data_ff = table(data_ff.Var1*pi/180,data_ff.Var2*pi/180,data_ff.Var3,data_ff.Var4,data_ff.Var6);
data_ff.Properties.VariableNames = {'theta' 'phi' 'Eabs' 'Ethetaabs' 'Ephiabs'};
% Rearrange nearfield table
data_nf = cellfun(@rearrangeTables,data_nf,'UniformOutput',false);
data_nf = cellfun(@(data_nf) rotateCylindricalNFData(data_nf,'z'),data_nf,'UniformOutput',false);
% Select measurements to process
% data_nf = data_nf([10,6,7]);
% scan_names = scan_names([10,6,7]);
% data_nf = data_nf([8,9,10,11,12]);
% scan_names = scan_names([8,9,10,11,12]);
disp('Done!')
%% NF2FF transformation
disp('NF2FF Transformation...')
delta_theta=1;
theta_range = (0:delta_theta:180-delta_theta)*pi/180;
delta_phi = 1;
phi_range = (0:delta_phi:360-delta_phi)*pi/180;
% data_nf2ff_rect = cellfun(@(data_nf) nf2ff_cylindrical_fft(data_nf,f,theta_range,phi_range,'none'),data_nf,'Uniformoutput',false);
% data_nf2ff_hamming = cellfun(@(data_nf) nf2ff_cylindrical_fft(data_nf,f,theta_range,phi_range,'hamming'),data_nf,'Uniformoutput',false);
% data_nf2ff_tukey = cellfun(@(data_nf) nf2ff_cylindrical_fft(data_nf,f,theta_range,phi_range,'tukey'),data_nf,'Uniformoutput',false);
data_nf2ff_rect = cellfun(@(data_nf) nf2ff_cylindrical_manual(data_nf,f,theta_range,phi_range,'none'),data_nf,'Uniformoutput',false);
data_nf2ff_hamming = cellfun(@(data_nf) nf2ff_cylindrical_manual(data_nf,f,theta_range,phi_range,'hamming'),data_nf,'Uniformoutput',false);
data_nf2ff_tukey = cellfun(@(data_nf) nf2ff_cylindrical_manual(data_nf,f,theta_range,phi_range,'tukey'),data_nf,'Uniformoutput',false);
data_nf2ff = data_nf2ff_rect;
disp('Done!')
%% Plots
disp('Plotting...')
close all
fontsize = 14;
normalized = true;
logarithmic = false;
% Phi=0 cut
phi_cut = 0;
figure('name','Far-Field Cuts,Phi=0°','numbertitle','off',...
'units','normalized','outerposition',[0 0 1 1],...
'DefaultAxesFontSize',fontsize);
plotFFPhiCut(data_ff,phi_cut,normalized,logarithmic)
cellfun(@(data_nf2ff) plotNFPhiCutCylindrical(data_nf2ff,phi_cut,normalized,logarithmic),data_nf2ff)
grid on
xlabel('Theta [°]')
if logarithmic == true
ylim([-50 0])
ylabel('E-Field Pattern [dB]')
elseif normalized == true
ylim([0 1])
ylabel('E-Field Pattern [-]')
end
ylabel('E-Field Pattern [-]')
title('Far-Field Cut Phi=0°')
legend(['Far-Field',scan_names])
figure('name','Far-Field Error,Phi=0°','numbertitle','off',...
'units','normalized','outerposition',[0 0 1 1],...
'DefaultAxesFontSize',fontsize);
cellfun(@(data_nf2ff) plotDiffPhiCutCylindrical(data_nf2ff,data_ff,phi_cut,theta_range),data_nf2ff)
grid on
xlabel('Theta [°]')
ylabel('Difference to Reference Far-Field [dB]')
title('Difference to Reference Far-Field, Phi=0°')
legend(scan_names)
% Theta=90 cut
theta_cut = pi/2;
figure('name','Far-Field Cuts,Theta=90°','numbertitle','off',...
'units','normalized','outerposition',[0 0 1 1],...
'DefaultAxesFontSize',fontsize);
plotFFThetaCut(data_ff,theta_cut,normalized,logarithmic)
cellfun(@(data_nf2ff) plotNFThetaCutCylindrical(data_nf2ff,theta_cut,normalized,logarithmic),data_nf2ff)
grid on
xlabel('Phi [°]')
if logarithmic == true
ylim([-50 0])
ylabel('E-Field Pattern [dB]')
elseif normalized == true
ylim([0 1])
ylabel('E-Field Pattern [-]')
end
ylabel('E-Field Pattern [-]')
title('Far-Field Cut Theta=90°')
legend(['Far-Field',scan_names])
figure('name','Far-Field Error,Theta=90°','numbertitle','off',...
'units','normalized','outerposition',[0 0 1 1],...
'DefaultAxesFontSize',fontsize);
cellfun(@(data_nf2ff) plotDiffThetaCutCylindrical(data_nf2ff,data_ff,theta_cut),data_nf2ff)
grid on
xlabel('Phi [°]')
ylabel('Difference to Reference Far-Field [dB]')
title('Difference to Reference Far-Field, Theta=90°')
legend(scan_names)
disp('Done!')
%% Accumulated Pattern Error Analysis
close all
fontsize = 14;
% Calculate APE
error_rect = cellfun(@(data_nf2ff) ErrorAnalysis(data_ff,data_nf2ff,'cylindrical'),data_nf2ff);
error_hamming = cellfun(@(data_nf2ff) ErrorAnalysis(data_ff,data_nf2ff,'planar'),data_nf2ff_hamming);
error_tukey = cellfun(@(data_nf2ff) ErrorAnalysis(data_ff,data_nf2ff,'planar'),data_nf2ff_tukey);
% Increasing Area
samples=[8,9,10,11,12];
xValues = [30,35,40,45,50];
figure('name','Accumulated Pattern Error, Varying Area','numbertitle','off',...
'units','normalized','outerposition',[0 0 1 1],...
'DefaultAxesFontSize',fontsize);
plot(xValues,100*error_rect(samples),'--*')
hold on
plot(xValues,100*error_hamming(samples),'--*')
plot(xValues,100*error_tukey(samples),'--*')
grid on
xlabel('Number of probes in linear dimension');
ylabel('Accumulated Pattern Error [%]')
title({'Accumulated Pattern Error','Varying Measurement Area, \lambda/2 spacing,'})
legend('Rectangular','Hamming','Tukey')
% Varying Spacing
samples = [10,7,6];
figure('name','Accumulated Pattern Error, Varying Spacing','numbertitle','off',...
'units','normalized','outerposition',[0 0 1 1],...
'DefaultAxesFontSize',fontsize);
plot(100*error_rect(samples),'--*')
hold on
plot(100*error_hamming(samples),'--*')
plot(100*error_tukey(samples),'--*')
grid on
ylabel('Accumulated Pattern Error [%]')
title({'Accumulated Pattern Error','Varying Measurement Spacing'})
xtickangle(45)
xticks(1:3)
xticklabels({'42x40','42x45','42x50'})
legend('Rectangular','Hamming','Tukey')
%% HPBW Error Analysis
close all
fontsize = 14;
% Calculate HPBW error
[~,~, hpbw_err_rect] = cellfun(@(data_nf2ff) HPBWError(data_ff,data_nf2ff,'cylindrical'),data_nf2ff_rect,'UniformOutput',false);
[~,~, hpbw_err_hamming] = cellfun(@(data_nf2ff) HPBWError(data_ff,data_nf2ff,'cylindrical'),data_nf2ff_hamming,'UniformOutput',false);
[~,~, hpbw_err_tukey] = cellfun(@(data_nf2ff) HPBWError(data_ff,data_nf2ff,'cylindrical'),data_nf2ff_tukey,'UniformOutput',false);
hpbw_err_rect = cell2mat(hpbw_err_rect);
hpbw_err_hamming = cell2mat(hpbw_err_hamming);
hpbw_err_tukey = cell2mat(hpbw_err_tukey);
xValues = [30,35,40,45,50];
% Increasing Area / Phi = 0 Cut
samples = [8,9,10,11,12];
figure('name','HPBW Error, Varying Area','numbertitle','off',...
'units','normalized','outerposition',[0 0 1 1],...
'DefaultAxesFontSize',fontsize);
plot(xValues,hpbw_err_rect(1,samples),'-*')
hold on
plot(xValues,hpbw_err_hamming(1,samples),'-*')
plot(xValues,hpbw_err_tukey(1,samples),'-*')
grid on
xlabel('Number of probes in linear dimension');
xticks(xValues)
ylabel('HPBW Error [Degrees]')
title({'HPBW Error','Varying Measurement Area, \lambda/2 spacing, Phi=0 Cut'})
legend('Rectangular','Hamming','Tukey')
% Increasing Area / Theta = 90 Cut
samples = [8,9,10,11,12];
figure('name','HPBW Error, Varying Area','numbertitle','off',...
'units','normalized','outerposition',[0 0 1 1],...
'DefaultAxesFontSize',fontsize);
plot(xValues,hpbw_err_rect(2,samples),'-*')
hold on
plot(xValues,hpbw_err_hamming(2,samples),'-*')
plot(xValues,hpbw_err_tukey(2,samples),'-*')
grid on
xlabel('Number of probes in linear dimension');
xticks(xValues)
ylabel('HPBW Error [Degrees]')
title({'HPBW Error','Varying Measurement Area, \lambda/2 spacing, Theta=90 Cut'})
legend('Rectangular','Hamming','Tukey')
% Varying Spacing Phi=0
samples = [10,7,6];
figure('name','Accumulated Pattern Error, Varying Spacing','numbertitle','off',...
'units','normalized','outerposition',[0 0 1 1],...
'DefaultAxesFontSize',fontsize);
plot(hpbw_err_rect(1,samples),'-*')
hold on
plot(hpbw_err_hamming(1,samples),'-*')
plot(hpbw_err_tukey(1,samples),'-*')
grid on
ylabel('HPBW Error [Degrees]')
title({'HPBW Error','Varying Measurement Spacing, 30\lambda/2 x 30\lambda/2, Phi=0 Cut'})
xtickangle(45)
xticks(1:3)
xticklabels({'42x40','42x45','42x50'})
legend('Rectangular','Hamming','Tukey')
% Varying Spacing Theta=90
samples = [10,7,6];
figure('name','Accumulated Pattern Error, Varying Spacing','numbertitle','off',...
'units','normalized','outerposition',[0 0 1 1],...
'DefaultAxesFontSize',fontsize);
plot(hpbw_err_rect(2,samples),'-*')
hold on
plot(hpbw_err_hamming(2,samples),'-*')
plot(hpbw_err_tukey(2,samples),'-*')
grid on
ylabel('HPBW Error [Degrees]')
title({'HPBW Error','Varying Measurement Spacing, 30\lambda/2 x 30\lambda/2, Theta=90 Cut'})
xtickangle(45)
xticks(1:3)
xticklabels({'42x40','42x45','42x50'})
legend('Rectangular','Hamming','Tukey')
%% Side-Lobe Level Error Analysis
close all
fontsize = 14;
% Calculate Side-Lobe Level error
[~,~, sll_err_rect] = cellfun(@(data_nf2ff) SLLError(data_ff,data_nf2ff,'cylindrical'),data_nf2ff_rect,'UniformOutput',false);
[~,~, sll_err_hamming] = cellfun(@(data_nf2ff) SLLError(data_ff,data_nf2ff,'cylindrical'),data_nf2ff_hamming,'UniformOutput',false);
[~,~, sll_err_tukey] = cellfun(@(data_nf2ff) SLLError(data_ff,data_nf2ff,'cylindrical'),data_nf2ff_tukey,'UniformOutput',false);
sll_err_rect = cell2mat(sll_err_rect);
sll_err_hamming = cell2mat(sll_err_hamming);
sll_err_tukey = cell2mat(sll_err_tukey);
xValues = [30,35,40,45,50];
% Increasing Area / Phi = 0 Cut
samples = [8,9,10,11,12];
figure('name','Side-Lobe-Level Error, Varying Area','numbertitle','off',...
'units','normalized','outerposition',[0 0 1 1],...
'DefaultAxesFontSize',fontsize);
plot(xValues,sll_err_rect(samples),'-*')
hold on
plot(xValues,sll_err_hamming(samples),'-*')
plot(xValues,sll_err_tukey(samples),'-*')
grid on
xlabel('Number of probes in linear dimension');
xticks(xValues)
ylabel('SLL Error [dB]')
title({'Side-Lobe-Level Error','Varying Measurement Area, \lambda/2 spacing'})
legend('Rectangular','Hamming','Tukey')
% Varying Spacing Phi=0
samples = [10,7,6];
figure('name','Side-Lobe-Level Error, Varying Spacing','numbertitle','off',...
'units','normalized','outerposition',[0 0 1 1],...
'DefaultAxesFontSize',fontsize);
plot(sll_err_rect(samples),'-*')
hold on
plot(sll_err_hamming(samples),'-*')
plot(sll_err_tukey(samples),'-*')
grid on
ylabel('SLL Error [Degrees]')
title({'Side-Lobe-Level Error','Varying Measurement Spacing, 30\lambda/2 x 30\lambda/2'})
xtickangle(45)
xticks(1:3)
xticklabels({'42x40','42x45','42x50'})
legend('Rectangular','Hamming','Tukey')