0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % LTF_PLAN computes all input values needed for the LPSD and LTFE algorithms.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 % DESCRIPTION: LTF_PLAN computes all input values needed for the LPSD and LTFE
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % algorithms.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 % CALL: [f, r, b, L, K] = ltf_plan(Ndata, fs, olap, bmin, Lmin, Jdes, Kdes)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 % INPUTS: Ndata - the length of the time-series to be processed
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 % fs - the sample rate of the time-series to be processed
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 % olap - overlap percentage, usually taken from the window function
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 % bmin - the minimum bin number to be used. This is usually taken
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 % from the window function.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 % Lmin - The minimum segment length.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 % Jdes - the desired number of frequencies.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 % Kdes - The desired number of averages.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 % OUTPUTS: Each output is a vector, one value per frequency:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 % f - the frequency
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 % r - frequency resolution (Hz)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 % b - bin number
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 % L - segment lengths
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 % K - number of averages
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 % PARAMETER LIST:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 % VERSION: $Id: ltf_plan.m,v 1.6 2009/08/31 17:09:43 ingo Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 % HISTORY: 19-02-2008 M Hewitson
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 % Creation
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 % REFERENCE: "lpsd revisited: ltf" / S2-AEI-TN-3052
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 % 2008/02/07 V1.1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 % G Heinzel
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 % q - a vector of start indices for the segments
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 function varargout = ltf_plan(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 %% ------ Check inputs ------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 if nargin ~= 7 || nargout ~= 5
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 help(mfilename)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 error('### Incorrect usage');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 Ndata = varargin{1};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 fs = varargin{2};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 olap = varargin{3};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 bmin = varargin{4};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 Lmin = varargin{5};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 Jdes = varargin{6};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 Kdes = varargin{7};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 %% ------ Set up some variables -------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 xov = (1 - olap/100);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 fmin = fs / Ndata * bmin;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 fmax = fs/2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 fresmin = fs / Ndata;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 freslim = fresmin * (1+xov*(Kdes-1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 logfact = (Ndata/2)^(1/Jdes) - 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 %% ------ Prepare outputs -------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 f = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 r = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 b = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 L = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 K = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 % q = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 %% ------ Loop over frequency -------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 fi = fmin;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 while fi < fmax
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 fres = fi * logfact;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 if fres <= freslim
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82 fres = sqrt(fres*freslim);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 if fres < fresmin
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 fres = fresmin;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 bin = fi/fres;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 if bin < bmin
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 bin = bmin;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91 fres = fi/bin;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 dftlen = round(fs / fres);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 if dftlen > Ndata
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 dftlen = Ndata;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98 if dftlen < Lmin
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 dftlen = Lmin;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 nseg = round((Ndata - dftlen) / (xov*dftlen) + 1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103 if nseg == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104 dftlen = Ndata;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107 fres = fs / dftlen;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 bin = fi / fres;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110 % Store outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111 f = [f fi];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112 r = [r fres];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113 b = [b bin];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114 L = [L dftlen];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115 K = [K nseg];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117 fi = fi + fres;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121 %% ------ Set outputs -------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 varargout{1} = f.';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 varargout{2} = r.';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125 varargout{3} = b.';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126 varargout{4} = L.';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127 varargout{5} = K.';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129
|