% Model and generation



fs = 1;

p1 = pzmodel(1e-8,[pz(1e-3)  pz(0.1, 4)],...
  [ pz(2e-1) pz(3e-1)]);

pl3 = plist();
pl3 = append(pl3, param('pzmodel', p1));
pl3 = append(pl3, param('fs',fs));
pl3 = append(pl3, param('nsecs', 3e3));

a = ao(pl3);
%% psd

pl = plist(...
  'Scale','ASD',...
 ... 'Win',  getappdata(0, 'ltpda_default_spectral_window'), ...
  'Nfft', 1000,...
  'Order', 1);

% pl = plist('Kdes', 100,...
%   'Jdes', 100000, ...
%   'Order', 1, ...
%   'Scale', 'ASD');

ca = psd(a,pl);

%% plot

rp1 = resp(p1,plist('f1',1e-3,'f2',100,'nf',1000));

iplot(rp1,ca)

%% gaps
by = mod((1:length(a.data.y))/10, 20)>19;
b = ao(tsdata(double(~by), 10));
c = a.*b.';


%%
d = c.gapfillingoptim(c, p1);
%%
iplot(psd(a, pl), psd(c, pl), psd(d, pl), resp(p1))
iplot(a,c,d)


