Blame view

allanplot.m 1.68 KB
b197c3fdf   bmarechal   first commit
1
  #!/usr/bin/octave-cli --persist
54ec4ada0   bmarechal   add help header
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  # 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
  #	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
b197c3fdf   bmarechal   first commit
16
17
18
  filename = argv(){1};
  col = eval(argv(){2});
  mult = eval(argv(){3});
54ec4ada0   bmarechal   add help header
19
  ad_opt = eval(argv(){4});
b197c3fdf   bmarechal   first commit
20

2f13b7356   bmarechal   add multiple colu...
21
  if length(col) == length(mult)
1a0e88f0c   bmarechal   replace 4-spaces ...
22
23
24
25
26
27
28
  	figure
  	hold all
  	grid on
  	cc = 'bkcgmry';
  	for i = [1:length(col)]
  		data.freq = load(filename)(:,col(i)).*mult(i);
  		if nargin == 4
54ec4ada0   bmarechal   add help header
29
  			if ad_opt(i) == 1
1a0e88f0c   bmarechal   replace 4-spaces ...
30
31
32
33
  				printf(strcat(filename, ' col', num2str(col(i)), ' drift removed
  
  '))
  				data.freq = detrend(data.freq);
54ec4ada0   bmarechal   add help header
34
  			elseif ad_opt(i) == 2
4a63914c1   bmarechal   add relative ad o...
35
36
37
  				printf(strcat(filename, ' col', num2str(col(i)), ' relative ad : mean=', num2str(mean(data.freq)), '
  
  '))
1a0e88f0c   bmarechal   replace 4-spaces ...
38
                  data.freq = data.freq./mean(data.freq);
54ec4ada0   bmarechal   add help header
39
              elseif ad_opt(i) == 3
1a0e88f0c   bmarechal   replace 4-spaces ...
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
                  printf(strcat(filename, ' col', num2str(col(i)), ' drift removed relative ad
  
  '))
                  data.freq = detrend(data.freq./mean(data.freq));
  			end
  		endif
  		data.rate = 1;
  		[ad, S, err, tau] = allan(data, 2.^[0:nextpow2(length(data.freq))-3]./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...");
2f13b7356   bmarechal   add multiple colu...
55
  end
b197c3fdf   bmarechal   first commit
56
  exit