view m-toolbox/test/test_ao_smoother.m @ 28:01b86b780ba7 database-connection-manager

Remove LTPDARepositoryManager implementation. Java code
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

% TEST_AO_SMOOTHER a test function the AO method smoother.
%
% M Hewitson 02-03-08
%
% $Id: test_ao_smoother.m,v 1.8 2009/02/02 15:20:38 hewitson Exp $
%
function test_ao_smoother


  % ------------- Frequency data smoothing ---------------------------------


  % Make some test data

  nsecs = 5000;
  fs    = 10;

  p1 = pz(0.01, 1);
  z1 = pz(0.2);
  gain =1;

  pzm = pzmodel(gain, p1, z1);
  % calling the noisegenerator
  a1 = fngen(pzm, plist('Nsecs', nsecs));
  a1.setYunits('V');
  a1.setXunits('s');
  a1.setName('noise');
  a2 = ao(plist('tsfcn', '0.003.*sin(2*pi*0.65*t) + 0.001.*sin(2*pi*3*t)', 'fs', a1.data.fs, 'nsecs', nsecs));
  a2.setName('signal');
  a3 = a1 + a2;

  % parameter list for lpsd
  pl = plist(...
    'Kdes', 100, ...
    'Kmin', 2, ...
    'Jdes', 500, ...
    'Win', specwin('Kaiser', 10, 150), ...
    'Order', 1);

  %  Make spectrum
  a3xx = psd(a3, plist('Nfft', 1000*fs));


  % Median Smooth both

  pl = plist('width', 100, 'hc', 0.7, 'method', 'median');
  a3s = smoother(a3, pl);
  pl = plist('width', 30, 'hc', 0.8, 'method', 'median');
  a3xxs = smoother(a3xx, pl);

  % Plot
  pl = plist('Legends', {'', 'median'});
  iplot(a3, a3s, pl)
  iplot(a3xx, a3xxs, pl)

  % Mean smooth


  pl = plist('width', 100, 'hc', 0.7, 'method', 'mean');
  a3s = smoother(a3, pl);
  pl = plist('width', 20, 'hc', 0.8, 'method', 'mean');
  a3xxs = smoother(a3xx, pl);

  % Plot
  pl = plist('Legends', {'', 'mean'});
  iplot(a3, a3s, pl)
  iplot(a3xx, a3xxs, pl)

  % Max smooth

  pl = plist('width', 1000, 'hc', 0.7, 'method', 'max');
  a3s = smoother(a3, pl);
  pl = plist('width', 20, 'hc', 0.8, 'method', 'max');
  a3xxs = smoother(a3xx, pl);

  % Plot
  pl = plist('Legends', {'', 'max'});
  iplot(a3, a3s, pl)
  iplot(a3xx, a3xxs, pl)

  % Min smooth

  pl = plist('width', 1000, 'hc', 0.7, 'method', 'min');
  a3s = smoother(a3, pl);
  pl = plist('width', 20, 'hc', 0.8, 'method', 'min');
  a3xxs = smoother(a3xx, pl);

  % Plot
  pl = plist('Legends', {'', 'min'});
  iplot(a3, a3s, pl)
  iplot(a3xx, a3xxs, pl)

  % Mode smooth

  pl = plist('width', 1000, 'hc', 0.7, 'method', 'mode');
  a3s = smoother(a3, pl);
  pl = plist('width', 20, 'hc', 0.8, 'method', 'mode');
  a3xxs = smoother(a3xx, pl);

  % Plot
  pl = plist('Legends', {'', 'mode'});
  iplot(a3, a3s, pl)
  iplot(a3xx, a3xxs, pl)


end