Commit 0e276f2006b6016544df53abe5f341fd42b840dc
1 parent
88a86ac733
Exists in
master
new script to pipe adev to stdout
Showing 1 changed file with 42 additions and 0 deletions Side-by-side Diff
dat2allan.m
1 | +#!/usr/bin/octave-cli -q | |
2 | + | |
3 | +# allanplot.m computes Allan deviation from temporal dataset | |
4 | +# | |
5 | +# use : allanplot.m file.dat column_i gain_i ad_opt | |
6 | +# allanplot.m file.dat [column_i,column_j] [gain_i,gain_j] [ad_opt_i,ad_opt_j] | |
7 | +# | |
8 | +# inputs: | |
9 | +# file.dat : [string] file to load | |
10 | +# columns : int or [int] columns to load | |
11 | +# fs : int or [int] sampling frequency | |
12 | +# gains : float or [float] gains to apply | |
13 | +# ad_opt : int or [int] ad options : | |
14 | +# 0 direct allan computation | |
15 | +# 1 drift removed ad | |
16 | +# 2 relative ad | |
17 | +# 3 relative drift removed ad | |
18 | + | |
19 | +filename = argv(){1}; | |
20 | +col = eval(argv(){2}); | |
21 | +fs = eval(argv(){3}); | |
22 | +mult = eval(argv(){4}); | |
23 | +ad_opt = eval(argv(){5}); | |
24 | + | |
25 | +if length(col) == length(mult) | |
26 | + ad_all = []; | |
27 | + for i = [1:length(col)] | |
28 | + data.freq = load(filename)(:,col(i)).*mult(i); | |
29 | + if ad_opt(i) == 1 | |
30 | + data.freq = detrend(data.freq); | |
31 | + elseif ad_opt(i) == 2 | |
32 | + data.freq = data.freq./mean(data.freq); | |
33 | + elseif ad_opt(i) == 3 | |
34 | + data.freq = detrend(data.freq./mean(data.freq)); | |
35 | + end | |
36 | + data.rate = fs(i); | |
37 | + [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); | |
38 | + ad_all = horzcat(ad_all, ad', err'); | |
39 | + end | |
40 | +end | |
41 | +dlmwrite(stdout, horzcat(tau', ad_all), '\t') | |
42 | +exit |