Home > classes > @ao > ltf_plan.m

ltf_plan

PURPOSE ^

LTF_PLAN computes all input values needed for the LPSD and LTFE algorithms.

SYNOPSIS ^

function varargout = ltf_plan(varargin)

DESCRIPTION ^

 LTF_PLAN computes all input values needed for the LPSD and LTFE algorithms.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: LTF_PLAN computes all input values needed for the LPSD and LTFE
              algorithms.

 CALL:       [f, r, b, L, K] = ltf_plan(Ndata, fs, olap, bmin, Lmin, Jdes, Kdes)

 INPUTS:     Ndata  - the length of the time-series to be processed
             fs     - the sample rate of the time-series to be processed
             olap   - overlap percentage, usually taken from the window function
             bmin   - the minimum bin number to be used. This is usually taken
                      from the window function.
             Lmin   - The minimum segment length.
             Jdes   - the desired number of frequencies.
             Kdes   - The desired number of averages.

 OUTPUTS:    Each output is a vector, one value per frequency:
             f      - the frequency
             r      - frequency resolution (Hz)
             b      - bin number
             L      - segment lengths
             K      - number of averages

 PARAMETER LIST:

 M-FILE INFO: Get information about this methods by calling
              >> ao.getInfo('ltf_plan')

              Get information about a specified set-plist by calling:
              >> ao.getInfo('ltf_plan', 'None')

 VERSION:     $Id: ltf_plan.m,v 1.4 2008/09/05 11:05:29 ingo Exp $

 HISTORY:     19-02-2008 M Hewitson
                 Creation

 REFERENCE:  "lpsd revisited: ltf" / S2-AEI-TN-3052
              2008/02/07  V1.1
              G Heinzel

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % LTF_PLAN computes all input values needed for the LPSD and LTFE algorithms.
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: LTF_PLAN computes all input values needed for the LPSD and LTFE
0005 %              algorithms.
0006 %
0007 % CALL:       [f, r, b, L, K] = ltf_plan(Ndata, fs, olap, bmin, Lmin, Jdes, Kdes)
0008 %
0009 % INPUTS:     Ndata  - the length of the time-series to be processed
0010 %             fs     - the sample rate of the time-series to be processed
0011 %             olap   - overlap percentage, usually taken from the window function
0012 %             bmin   - the minimum bin number to be used. This is usually taken
0013 %                      from the window function.
0014 %             Lmin   - The minimum segment length.
0015 %             Jdes   - the desired number of frequencies.
0016 %             Kdes   - The desired number of averages.
0017 %
0018 % OUTPUTS:    Each output is a vector, one value per frequency:
0019 %             f      - the frequency
0020 %             r      - frequency resolution (Hz)
0021 %             b      - bin number
0022 %             L      - segment lengths
0023 %             K      - number of averages
0024 %
0025 % PARAMETER LIST:
0026 %
0027 % M-FILE INFO: Get information about this methods by calling
0028 %              >> ao.getInfo('ltf_plan')
0029 %
0030 %              Get information about a specified set-plist by calling:
0031 %              >> ao.getInfo('ltf_plan', 'None')
0032 %
0033 % VERSION:     $Id: ltf_plan.m,v 1.4 2008/09/05 11:05:29 ingo Exp $
0034 %
0035 % HISTORY:     19-02-2008 M Hewitson
0036 %                 Creation
0037 %
0038 % REFERENCE:  "lpsd revisited: ltf" / S2-AEI-TN-3052
0039 %              2008/02/07  V1.1
0040 %              G Heinzel
0041 %
0042 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0043 
0044 %       q      - a vector of start indices for the segments
0045 
0046 function varargout = ltf_plan(varargin)
0047 
0048   % Check if this is a call for parameters
0049   if utils.helper.isinfocall(varargin{:})
0050     varargout{1} = getInfo(varargin{3});
0051     return
0052   end
0053 
0054   %% ------ Check inputs     ------------------------------------------------
0055   if nargin ~= 7 || nargout ~= 5
0056     help(mfilename)
0057     error('### Incorrect usage');
0058   end
0059 
0060   Ndata  = varargin{1};
0061   fs     = varargin{2};
0062   olap   = varargin{3};
0063   bmin   = varargin{4};
0064   Lmin   = varargin{5};
0065   Jdes   = varargin{6};
0066   Kdes   = varargin{7};
0067 
0068   %% ------ Set up some variables -------------------------------------------
0069 
0070   xov     = (1 - olap/100);
0071   fmin    = fs / Ndata * bmin;
0072   fmax    = fs/2;
0073   fresmin = fs / Ndata;
0074   freslim = fresmin * (1+xov*(Kdes-1));
0075   logfact = (Ndata/2)^(1/Jdes) - 1;
0076 
0077 
0078 
0079   %% ------ Prepare outputs       -------------------------------------------
0080 
0081   f = [];
0082   r = [];
0083   b = [];
0084   L = [];
0085   K = [];
0086   % q = [];
0087 
0088   %% ------ Loop over frequency   -------------------------------------------
0089   fi = fmin;
0090   while fi < fmax
0091 
0092     fres = fi * logfact;
0093     if fres <= freslim
0094       fres = sqrt(fres*freslim);
0095     end
0096     if fres < fresmin
0097       fres = fresmin;
0098     end
0099 
0100     bin = fi/fres;
0101     if bin < bmin
0102       bin = bmin;
0103       fres = fi/bin;
0104     end
0105 
0106     dftlen = round(fs / fres);
0107     if dftlen > Ndata
0108       dftlen = Ndata;
0109     end
0110     if dftlen < Lmin
0111       dftlen = Lmin;
0112     end
0113 
0114     nseg = round((Ndata - dftlen) / (xov*dftlen) + 1);
0115     if nseg == 1
0116       dftlen = Ndata;
0117     end
0118 
0119     fres = fs / dftlen;
0120     bin  = fi / fres;
0121 
0122     % Store outputs
0123     f = [f fi];
0124     r = [r fres];
0125     b = [b bin];
0126     L = [L dftlen];
0127     K = [K nseg];
0128 
0129     fi = fi + fres;
0130 
0131   end
0132 
0133   %% ------ Set outputs           -------------------------------------------
0134 
0135   varargout{1} = f.';
0136   varargout{2} = r.';
0137   varargout{3} = b.';
0138   varargout{4} = L.';
0139   varargout{5} = K.';
0140 end
0141 
0142 %--------------------------------------------------------------------------
0143 % Get Info Object
0144 %--------------------------------------------------------------------------
0145 function ii = getInfo(varargin)
0146   if nargin == 1 && strcmpi(varargin{1}, 'None')
0147     sets = {};
0148     pl   = [];
0149   else
0150     sets = {'Default'};
0151     pl   = getDefaultPlist();
0152   end
0153   % Build info object
0154   ii = minfo(mfilename, 'ao', '', utils.const.categories.relop, '$Id: ltf_plan.m,v 1.4 2008/09/05 11:05:29 ingo Exp $', sets, pl);
0155 end
0156 
0157 %--------------------------------------------------------------------------
0158 % Get Default Plist
0159 %--------------------------------------------------------------------------
0160 function plo = getDefaultPlist()
0161 
0162   plo = plist(...
0163     'Ndata', 10, ...
0164     'fs',    10, ...
0165     'olap',  50, ...
0166     'bmin',  1, ...
0167     'Lmin',  1e20, ...
0168     'Jdes',  1000, ...
0169     'Kdes',  100 ...
0170     );
0171 end
0172 
0173

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003