From ac0136cba1ac5792aa6275b6657f1d8050302fbc Mon Sep 17 00:00:00 2001 From: bma Date: Wed, 30 May 2018 08:48:45 +0200 Subject: [PATCH] add overlapping adev scripts --- oallanplot.m | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ temp2oallan.m | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100755 oallanplot.m create mode 100755 temp2oallan.m diff --git a/oallanplot.m b/oallanplot.m new file mode 100755 index 0000000..7514fd6 --- /dev/null +++ b/oallanplot.m @@ -0,0 +1,54 @@ +#!/usr/bin/octave-cli --persist + +# allanplot.m computes Allan deviation from temporal dataset +# +# 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] +# +# inputs: +# file.dat : [string] file to load +# columns : int or [int] columns to load +# fs : int or [int] sampling frequency +# gains : float or [float] gains to apply +# ad_opt : int or [int] ad options : +# 0 direct allan computation +# 1 drift removed ad +# 2 relative ad +# 3 relative drift removed ad + +filename = argv(){1}; +col = eval(argv(){2}); +fs = eval(argv(){3}); +mult = eval(argv(){4}); +ad_opt = eval(argv(){5}); + +if length(col) == length(mult) + figure + hold all + grid on + cc = 'bkcgmry'; + for i = [1:length(col)] + data.freq = load(filename)(:,col(i)).*mult(i); + if nargin == 5 + if ad_opt(i) == 1 + printf(strcat(filename, ' col', num2str(col(i)), ' drift removed\n\n')) + data.freq = detrend(data.freq); + elseif ad_opt(i) == 2 + printf(strcat(filename, ' col', num2str(col(i)), ' relative ad : mean=', num2str(mean(data.freq)), '\n\n')) + data.freq = data.freq./mean(data.freq); + elseif ad_opt(i) == 3 + printf(strcat(filename, ' col', num2str(col(i)), ' drift removed relative ad\n\n')) + data.freq = detrend(data.freq./mean(data.freq)); + end + endif + data.rate = fs(i); + [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); + loglogerr(tau, ad, err, strcat(cc(mod(i, length(cc))), '-s')) + leg{i} = strcat(filename, ' col', num2str(col(i))); + axis(10.^ceil(log10([tau(1), tau(end)]))) + hold on + end + legend(leg) + input("Press to continue..."); +end +exit diff --git a/temp2oallan.m b/temp2oallan.m new file mode 100755 index 0000000..038c5b0 --- /dev/null +++ b/temp2oallan.m @@ -0,0 +1,36 @@ +#!/usr/bin/octave-cli + +filename = argv(){1}; +col = eval(argv(){2}); +mult = eval(argv(){3}); + +filename = argv(){1}; +col = eval(argv(){2}); +mult = eval(argv(){3}); +ad_opt = eval(argv(){4}); + +if length(col) == length(mult) + for i = [1:length(col)] + data.freq = load(filename)(:,col(i)).*mult(i); + if nargin == 4 + if ad_opt(i) == 1 + printf(strcat(filename, ' col', num2str(col(i)), ' drift removed\n\n')) + data.freq = detrend(data.freq); + elseif ad_opt(i) == 2 + printf(strcat(filename, ' col', num2str(col(i)), ' relative ad : mean=', num2str(mean(data.freq)), '\n\n')) + data.freq = data.freq./mean(data.freq); + elseif ad_opt(i) == 3 + printf(strcat(filename, ' col', num2str(col(i)), ' drift removed relative ad\n\n')) + data.freq = detrend(data.freq./mean(data.freq)); + end + endif + data.rate = 1; + [ad, S, err, tau] = allan_overlap(data, 2.^[0:nextpow2(length(data.freq))-3]./data.rate, strcat(strsplit(filename, '/'){end}, num2str(i)), 0); + ad_tosave{i} = vertcat(ad, err)'; + end +tosave = tau'; +for i = [1:length(col)] + tosave = horzcat(tosave, ad_tosave{i}); +end +save('-ascii', strcat(strsplit(filename, '.'){1}, '_ad.dat'), 'tosave'); +end -- 2.16.4