Commit b12818783c09b8d097332dcc16c344fcfff292a9

Authored by bmarechal
1 parent 601f6548f2
Exists in master

use log repeated tau pattern

Showing 1 changed file with 1 additions and 1 deletions Inline Diff

#!/usr/bin/octave-cli --persist 1 1 #!/usr/bin/octave-cli --persist
2 2
# allanplot.m computes Allan deviation from temporal dataset 3 3 # allanplot.m computes Allan deviation from temporal dataset
# 4 4 #
# use : allanplot.m file.dat column_i gain_i ad_opt 5 5 # use : allanplot.m file.dat column_i gain_i ad_opt
# allanplot.m file.dat [column_i,column_j] [gain_i,gain_j] [ad_opt_i,ad_opt_j] 6 6 # allanplot.m file.dat [column_i,column_j] [gain_i,gain_j] [ad_opt_i,ad_opt_j]
# 7 7 #
# inputs: 8 8 # inputs:
# file.dat : [string] file to load 9 9 # file.dat : [string] file to load
# columns : int or [int] columns to load 10 10 # columns : int or [int] columns to load
# fs : int or [int] sampling frequency 11 11 # fs : int or [int] sampling frequency
# gains : float or [float] gains to apply 12 12 # gains : float or [float] gains to apply
# ad_opt : int or [int] ad options : 13 13 # ad_opt : int or [int] ad options :
# 0 direct allan computation 14 14 # 0 direct allan computation
# 1 drift removed ad 15 15 # 1 drift removed ad
# 2 relative ad 16 16 # 2 relative ad
# 3 relative drift removed ad 17 17 # 3 relative drift removed ad
18 18
filename = argv(){1}; 19 19 filename = argv(){1};
col = eval(argv(){2}); 20 20 col = eval(argv(){2});
fs = eval(argv(){3}); 21 21 fs = eval(argv(){3});
mult = eval(argv(){4}); 22 22 mult = eval(argv(){4});
ad_opt = eval(argv(){5}); 23 23 ad_opt = eval(argv(){5});
24 24
if length(col) == length(mult) 25 25 if length(col) == length(mult)
figure 26 26 figure
hold all 27 27 hold all
grid on 28 28 grid on
cc = 'bkcgmry'; 29 29 cc = 'bkcgmry';
for i = [1:length(col)] 30 30 for i = [1:length(col)]
data.freq = load(filename)(:,col(i)).*mult(i); 31 31 data.freq = load(filename)(:,col(i)).*mult(i);
if nargin == 4 32 32 if nargin == 4
if ad_opt(i) == 1 33 33 if ad_opt(i) == 1
printf(strcat(filename, ' col', num2str(col(i)), ' drift removed\n\n')) 34 34 printf(strcat(filename, ' col', num2str(col(i)), ' drift removed\n\n'))
data.freq = detrend(data.freq); 35 35 data.freq = detrend(data.freq);
elseif ad_opt(i) == 2 36 36 elseif ad_opt(i) == 2
printf(strcat(filename, ' col', num2str(col(i)), ' relative ad : mean=', num2str(mean(data.freq)), '\n\n')) 37 37 printf(strcat(filename, ' col', num2str(col(i)), ' relative ad : mean=', num2str(mean(data.freq)), '\n\n'))
data.freq = data.freq./mean(data.freq); 38 38 data.freq = data.freq./mean(data.freq);
elseif ad_opt(i) == 3 39 39 elseif ad_opt(i) == 3
printf(strcat(filename, ' col', num2str(col(i)), ' drift removed relative ad\n\n')) 40 40 printf(strcat(filename, ' col', num2str(col(i)), ' drift removed relative ad\n\n'))
data.freq = detrend(data.freq./mean(data.freq)); 41 41 data.freq = detrend(data.freq./mean(data.freq));
end 42 42 end
endif 43 43 endif
data.rate = fs(i); 44 44 data.rate = fs(i);
[ad, S, err, tau] = allan(data, 2.^[0:nextpow2(length(data.freq))-3]./data.rate, strcat(strsplit(filename, '/'){end}, num2str(i)), 0); 45 45 [ad, S, err, tau] = allan(data, horzcat(reshape([1:0.1:9]'.*10.^[0:round(log10(length(data.freq)))-1],1,[]), 10^(round(log10(length(data.freq)))-1))./data.rate, strcat(strsplit(filename, '/'){end}, num2str(i)), 0);
loglogerr(tau, ad, err, strcat(cc(mod(i, length(cc))), '-s')) 46 46 loglogerr(tau, ad, err, strcat(cc(mod(i, length(cc))), '-s'))
leg{i} = strcat(filename, ' col', num2str(col(i))); 47 47 leg{i} = strcat(filename, ' col', num2str(col(i)));
axis(10.^ceil(log10([tau(1), tau(end)]))) 48 48 axis(10.^ceil(log10([tau(1), tau(end)])))
hold on 49 49 hold on
end 50 50 end
legend(leg) 51 51 legend(leg)
input("Press to continue..."); 52 52 input("Press to continue...");