Commit ac0136cba1ac5792aa6275b6657f1d8050302fbc
1 parent
4b03c7b923
Exists in
master
add overlapping adev scripts
Showing 2 changed files with 90 additions and 0 deletions Inline Diff
oallanplot.m
| File was created | 1 | #!/usr/bin/octave-cli --persist | ||
| 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 | figure | |||
| 27 | hold all | |||
| 28 | grid on | |||
| 29 | cc = 'bkcgmry'; | |||
| 30 | for i = [1:length(col)] | |||
| 31 | data.freq = load(filename)(:,col(i)).*mult(i); | |||
| 32 | if nargin == 5 | |||
| 33 | if ad_opt(i) == 1 | |||
| 34 | printf(strcat(filename, ' col', num2str(col(i)), ' drift removed\n\n')) | |||
| 35 | data.freq = detrend(data.freq); | |||
| 36 | elseif ad_opt(i) == 2 | |||
| 37 | printf(strcat(filename, ' col', num2str(col(i)), ' relative ad : mean=', num2str(mean(data.freq)), '\n\n')) | |||
| 38 | data.freq = data.freq./mean(data.freq); | |||
| 39 | elseif ad_opt(i) == 3 | |||
| 40 | printf(strcat(filename, ' col', num2str(col(i)), ' drift removed relative ad\n\n')) | |||
| 41 | data.freq = detrend(data.freq./mean(data.freq)); | |||
| 42 | end | |||
| 43 | endif | |||
| 44 | data.rate = fs(i); | |||
| 45 | [ad, S, err, tau] = allan_overlap(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); | |||
| 46 | loglogerr(tau, ad, err, strcat(cc(mod(i, length(cc))), '-s')) | |||
| 47 | leg{i} = strcat(filename, ' col', num2str(col(i))); | |||
| 48 | axis(10.^ceil(log10([tau(1), tau(end)]))) | |||
| 49 | hold on | |||
| 50 | end | |||
| 51 | legend(leg) |
temp2oallan.m
| File was created | 1 | #!/usr/bin/octave-cli | ||
| 2 | ||||
| 3 | filename = argv(){1}; | |||
| 4 | col = eval(argv(){2}); | |||
| 5 | mult = eval(argv(){3}); | |||
| 6 | ||||
| 7 | filename = argv(){1}; | |||
| 8 | col = eval(argv(){2}); | |||
| 9 | mult = eval(argv(){3}); | |||
| 10 | ad_opt = eval(argv(){4}); | |||
| 11 | ||||
| 12 | if length(col) == length(mult) | |||
| 13 | for i = [1:length(col)] | |||
| 14 | data.freq = load(filename)(:,col(i)).*mult(i); | |||
| 15 | if nargin == 4 | |||
| 16 | if ad_opt(i) == 1 | |||
| 17 | printf(strcat(filename, ' col', num2str(col(i)), ' drift removed\n\n')) | |||
| 18 | data.freq = detrend(data.freq); | |||
| 19 | elseif ad_opt(i) == 2 | |||
| 20 | printf(strcat(filename, ' col', num2str(col(i)), ' relative ad : mean=', num2str(mean(data.freq)), '\n\n')) | |||
| 21 | data.freq = data.freq./mean(data.freq); | |||
| 22 | elseif ad_opt(i) == 3 | |||
| 23 | printf(strcat(filename, ' col', num2str(col(i)), ' drift removed relative ad\n\n')) | |||
| 24 | data.freq = detrend(data.freq./mean(data.freq)); | |||
| 25 | end | |||
| 26 | endif | |||
| 27 | data.rate = 1; | |||
| 28 | [ad, S, err, tau] = allan_overlap(data, 2.^[0:nextpow2(length(data.freq))-3]./data.rate, strcat(strsplit(filename, '/'){end}, num2str(i)), 0); | |||
| 29 | ad_tosave{i} = vertcat(ad, err)'; | |||
| 30 | end | |||
| 31 | tosave = tau'; | |||
| 32 | for i = [1:length(col)] | |||
| 33 | tosave = horzcat(tosave, ad_tosave{i}); |