Commit 267f6d32281e3fcf85a8805ed3615806d8fe240c
1 parent
0e276f2006
Exists in
master
update help header
Showing 1 changed file with 7 additions and 3 deletions Inline Diff
dat2allan.m
#!/usr/bin/octave-cli -q | 1 | 1 | #!/usr/bin/octave-cli -q | |
2 | 2 | |||
# allanplot.m computes Allan deviation from temporal dataset | 3 | 3 | # dat2allan.m computes Allan deviation from temporal dataset and disp the result to stdout (with tab spaced values) | |
# | 4 | 4 | # | |
# use : allanplot.m file.dat column_i gain_i ad_opt | 5 | 5 | # use with gnuplot: | |
# allanplot.m file.dat [column_i,column_j] [gain_i,gain_j] [ad_opt_i,ad_opt_j] | 6 | 6 | # set log xy | |
7 | # set format "%E" | |||
8 | # plot "< dat2allan.m 'file.dat' column_i gain_i ad_opt" u 1:2:3 with yerrorlines | |||
9 | # or | |||
10 | # plot "< dat2allan.m 'file.dat' [column_i,column_j] [gain_i,gain_j] [ad_opt_i,ad_opt_j]" u 1:2:3 with yerrorlines | |||
# | 7 | 11 | # | |
# inputs: | 8 | 12 | # inputs: | |
# file.dat : [string] file to load | 9 | 13 | # file.dat : [string] file to load | |
# columns : int or [int] columns to load | 10 | 14 | # columns : int or [int] columns to load | |
# fs : int or [int] sampling frequency | 11 | 15 | # fs : int or [int] sampling frequency | |
# gains : float or [float] gains to apply | 12 | 16 | # gains : float or [float] gains to apply | |
# ad_opt : int or [int] ad options : | 13 | 17 | # ad_opt : int or [int] ad options : | |
# 0 direct allan computation | 14 | 18 | # 0 direct allan computation | |
# 1 drift removed ad | 15 | 19 | # 1 drift removed ad | |
# 2 relative ad | 16 | 20 | # 2 relative ad | |
# 3 relative drift removed ad | 17 | 21 | # 3 relative drift removed ad | |
18 | 22 | |||
filename = argv(){1}; | 19 | 23 | filename = argv(){1}; | |
col = eval(argv(){2}); | 20 | 24 | col = eval(argv(){2}); | |
fs = eval(argv(){3}); | 21 | 25 | fs = eval(argv(){3}); | |
mult = eval(argv(){4}); | 22 | 26 | mult = eval(argv(){4}); | |
ad_opt = eval(argv(){5}); | 23 | 27 | ad_opt = eval(argv(){5}); | |
24 | 28 | |||
if length(col) == length(mult) | 25 | 29 | if length(col) == length(mult) | |
ad_all = []; | 26 | 30 | ad_all = []; | |
for i = [1:length(col)] | 27 | 31 | for i = [1:length(col)] | |
data.freq = load(filename)(:,col(i)).*mult(i); | 28 | 32 | data.freq = load(filename)(:,col(i)).*mult(i); | |
if ad_opt(i) == 1 | 29 | 33 | if ad_opt(i) == 1 | |
data.freq = detrend(data.freq); | 30 | 34 | data.freq = detrend(data.freq); | |
elseif ad_opt(i) == 2 | 31 | 35 | elseif ad_opt(i) == 2 | |
data.freq = data.freq./mean(data.freq); | 32 | 36 | data.freq = data.freq./mean(data.freq); | |
elseif ad_opt(i) == 3 | 33 | 37 | elseif ad_opt(i) == 3 | |
data.freq = detrend(data.freq./mean(data.freq)); | 34 | 38 | data.freq = detrend(data.freq./mean(data.freq)); | |
end | 35 | 39 | end | |
data.rate = fs(i); | 36 | 40 | data.rate = fs(i); | |
[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); | 37 | 41 | [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); | |
ad_all = horzcat(ad_all, ad', err'); | 38 | 42 | ad_all = horzcat(ad_all, ad', err'); | |
end | 39 | 43 | end | |
end | 40 | 44 | end | |
dlmwrite(stdout, horzcat(tau', ad_all), '\t') | 41 | 45 | dlmwrite(stdout, horzcat(tau', ad_all), '\t') | |
exit | 42 | 46 | exit |