% function test_ltpda_mdc1_ifo2control
clear all;

% Test the computation of the control terms 
% 
% M Hewitson 11-04-08
% 
% $Id: test_ltpda_mdc1_ifo2control.m,v 1.1 2008/04/14 15:39:44 hewitson Exp $
% 


% Make a white-noise AO
fs    = 10;
nsecs = 10000;

o1  = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', nsecs));
o12 = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', nsecs));

[a1, a2] = ltpda_mdc1_ifo2control(plist('o1', o1, 'o12', o12));

% Split off transients
spl = plist('split_type', 'times', 'times', [200 nsecs-200]);

a1 = split(a1, spl);
a2 = split(a2, spl);
o1 = split(o1, spl);
o12 = split(o12, spl);

% Spectra
a1xx = ltpda_lpsd(a1);
a2xx = ltpda_lpsd(a2);
iplot(a1xx,a2xx)

% TFs
tf1  = ltpda_tfe(a1,o1);
tf2  = ltpda_tfe(a2,o12);

% Compare to models
f = tf1(1,2).data.x;
cdf  = ltpda_mdc1_C(plist('f', f, 'Controller', 'df'));
csus = ltpda_mdc1_C(plist('f', f, 'Controller', 'sus'));
adf  = ltpda_mdc1_actuator(plist('Actuator', 'df', 'f', f));
asus  = ltpda_mdc1_actuator(plist('Actuator', 'sus', 'f', f));

iplot(tf1(2,1), cdf.*adf);
iplot(tf2(2,1), csus.*asus);


% END