Commit a359f803 authored by Maciej Lipinski's avatar Maciej Lipinski

[spll debug data anal tool] cleaning, adding comments and making it work with…

[spll debug data anal tool] cleaning, adding comments and making it work with the newest improvements to spll_dbg_read
parent fa2b759e
......@@ -13,10 +13,10 @@ output = 1;
for i=1:size_t(1)
if input(i,column) == 1
disp(sprintf('Switchover at sample: %d',input(i,1)));
return
else
output=output+1;
% output=output-1;
end
end
......
......@@ -33,7 +33,7 @@ xlabel('time [s]');
ylabel('phase [ps]');
axis tight
clr=['r','g','b','c']
clr=['r','g','b','c'];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subplot(5,1,2)
hold on
......
......@@ -43,7 +43,7 @@ plot(Xaxis,smooth(mpll(start:finish,2),(ceil(length(Xaxis)/10))),'r');
% plot((switchover-start+1)*unitScale,max(mpll(start:finish,2)),'*r' );
% legend(sprintf('raw data','smoothed (span=%d)','switchover','Location','northwest',ceil(length(Xaxis)/10)));
legend(sprintf('smoothed (span=%d)',ceil(length(Xaxis)/10)),'switchover','Location','northwest');
legend(sprintf('smoothed (span=%d)',ceil(length(Xaxis)/10)));
title('Y');
xlabel('time [s]');
ylabel('DAC out');
......@@ -52,7 +52,11 @@ axis tight
subplot(4,1,3)
hold on
samples=5000;
if(length(mpll) < start+samples)
samples = length(mpll) - start;
end
plot(Xaxis(start:(start+samples)),mpll(start:(start+samples),2),'b');
plot(Xaxis(start:(start+samples)),smooth(mpll(start:(start+samples),2),10),'r');
......
......@@ -16,10 +16,9 @@ figure
subplot(4,1,1)
hold on
% plot(Xaxis,mpll(start:finish,3)*to_ps,'b');
plot(Xaxis,smooth(mpll(start:finish,5),10)*to_ps,'k');
% plot(Xaxis,mpll(start:finish,7)*to_ps,'g');
% plot(Xaxis,mpll(start:finish,8)*to_ps,'m');
plot(Xaxis,mpll(start:finish,6)*mean(mpll(start:finish,5)),'r' );
% plot(Xaxis,smooth(mpll(start:finish,5),10)*to_ps,'b');
plot(Xaxis,mpll(start:finish,5)*to_ps,'b');
plot(Xaxis,mpll(start:finish,6)*max(mpll(start:finish,5)),'r' );
legend('err (input to PI)''switchover','Location','northwest');
......@@ -29,8 +28,8 @@ ylabel('phase [ps]');
axis tight
subplot(4,1,2)
hold on
% plot(Xaxis,smooth(bpll(start:finish,5),20)*to_ps,'b');
plot(Xaxis,bpll(start:finish,5)*to_ps,'b');
% plot(Xaxis,bpll(start:finish,7)*to_ps,'g');
plot(Xaxis,bpll(start:finish,6)*max(bpll(start:finish,5)),'r' );
legend('err','switchover','Location','northwest');
title('bPLL');
......@@ -47,9 +46,9 @@ axis tight
subplot(4,1,4)
hold on
% plot(Xaxis,mpll(start:finish,2),'b',switchover,max(mpll(start:finish,2)),'*r' );
plot(Xaxis,mpll(start:finish,2));
plot(Xaxis,mpll(start:finish,4),'g');
plot((switchover-start+1)*unitScale,max(mpll(start:finish,2)),'*r' );
plot(Xaxis,smooth(mpll(start:finish,2),10));
plot(Xaxis,smooth(mpll(start:finish,4),10),'g');
plot((switchover-start+1)*unitScale,mean(mpll(start:finish,2)),'*r' );
legend('Y','long average','switchover','Location','northwest');
title('Y');
......
% Maciej Lipinski / CERN / 2014-10-22
%
% scripts to analyzer debugging messages from the SoftPLL of the switch
% input:
% input - 2-dimentional table
% threshold - vector carring definition of threshold for each column of input table
% if value is zero, don't remove outliers
% WARNING: column 1 & 6 are never checked
% name - string to be printed
%
% average-based : remove stuff outside of [(avg-threshold*ceil(avg)) , (avg+threshold*ceil(avg))]
% if threshold is zero, no outlier removal is performed for the column which
% is far from perfect
%
% outliers are replaced with previous value in the column
function output = outliers(input, threshold_vec, name)
size_t = size(input);
tmp = zeros(size_t);
average = mean(input)
average = ceil(mean(input));
tlength = length(threshold_vec);
threshold=zeros(tlength,1);
for j=1:size_t(2)
if threshold_vec(j) > 0
threshold(j) = average(j)*threshold_vec(j);
threshold(j) = abs(average(j)*threshold_vec(j));
else
threshold(j) = 0;
end
end
disp(threshold);
disp('---------------------------------------------------');
disp(sprintf('removing outliers from %s',name));
% correct first entry
for j=1:size_t(2)
......@@ -41,7 +53,7 @@ for i=2:size_t(1)
for j=1:size_t(2)
if threshold(j) > 0 && ((input(i,j) < (average(j)-threshold(j))) || (input(i,j) > (average(j)+threshold(j))))
% disp(sprintf('i=%d, j=%d: replace %d with %d',i,j,input(i,j),input(i-1,j)));
disp(sprintf('removed sample_id =%d: i=%d, j=%d: replace %d with %d',input(i,1), i,j,input(i,j),input(i-1,j)));
if(input(i-1,j) ~= 0)
tmp(cnt,j) = input(i-1,j);
elseif(i>2 && input(i-2,j) ~= 0)
......@@ -60,4 +72,5 @@ end
output =zeros(cnt-1,size_t(2));
output = tmp(1:cnt-1,:);
disp(sprintf('%s: removed %d outliers',name, counter));
disp('---------------------------------------------------');
return
\ No newline at end of file
% Maciej Lipinski / CERN / 2014-10-22
%
% it is not smart, really
% input:
% input - 2-dimentional table
% threshold - vector carring definition of threshold for each column of input table
% if value is zero, don't remove outliers
% name - string to be printed
%
% average-based : remove stuff outside of [(avg-threshold*ceil(sdev)) , (avg+threshold*ceil(sdev))]
% if threshold is zero, no outlier removal is performed for the column which
%
% outliers are replaced with average value
function output = smartOutliers(input, threshold_vec, name)
size_t = size(input)
size_t = size(input);
output = zeros(size_t);
average = mean(input)
max_in = max(input)
min_in = min(input)
maxmaxmin = max([abs(max(input)-average); abs(average-min(input))])
average = mean(input);
max_in = max(input);
min_in = min(input);
maxmaxmin = max([abs(max(input)-average); abs(average-min(input))]);
stdev = std(input)
stdev = std(input);
tlength = length(threshold_vec);
threshold=zeros(tlength,1);
for j=1:size_t(2)
if threshold_vec(j) > 0
% threshold(j) = maxmaxmin(j)*threshold_vec(j);
threshold(j) = stdev(j)*threshold_vec(j);
else
threshold(j) = 0;
end
end
disp('---------------------------------------------------');
disp(sprintf('removing outliers from %s',name));
% correct all other entries
counter = 0;
cnt=1;
for i=1:size_t(1)
for j=1:size_t(2)
if threshold(j) > 0 && ((input(i,j) < (average(j)-threshold(j))))
output(i,j) = average(j) - threshold(j);
disp(sprintf('[i=%d, j=%d] outlier sample_id =%d replace %d with %d',i,j,input(i,1), input(i,j),ceil(average(j))));
output(i,j) = average(j);% - threshold(j);
counter=counter+1;
elseif threshold(j) > 0 && (input(i,j) > (average(j)+threshold(j)))
output(i,j) = average(j) + threshold(j);
disp(sprintf('[i=%d, j=%d] outlier sample_id =%d replace %d with %d',i,j,input(i,1), input(i,j),ceil(average(j))));
output(i,j) = average(j);% + threshold(j);
counter=counter+1;
else
output(i,j) = input(i,j);
......@@ -42,4 +53,5 @@ for i=1:size_t(1)
end
disp(sprintf('%s: removed %d outliers',name, counter));
disp('---------------------------------------------------');
return
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment