%filtering in the chandler frequency band with Panteleev filter with or without inversion
%in the frequency domain written by L. Zotov 2016-2018
function [ out_signal ]=PMInversion(year,s,dt,FC,Q)
% INPUT
% year - array of dates - could be any, but expected time steps in MJD
% s - complex array of signal to be smoothed
% dt - time step
% FC, Q - defince frequency and quality of resonance
% out_signal


N=size(s,2);


sigmaC=2*pi*FC*(1+i/2/Q); 
tau=i/sigmaC;

sF=fft(s);
% Sym - обратная передаточная функция уравнений Эйлера-Лиувилля
%для движения полюса

 for(k=1:1:N)
      if (k==1)
          t(k)=0;
          omega(k)=1; 
          Sym(k)=0;
       
          
      elseif(k<=N/2+1)
          t(k)=N*dt/(k-1);
          omega(k)=2*pi/t(k); 
          Sym(k)=(1+tau*i*omega(k));
         
           
      elseif(k>N/2+1)
          t(k)=N*dt/(N-k+1);
          omega(k)=-2*pi/t(k);  
          Sym(k)=(1+tau*i*omega(k));
           
      end;
 end;
 
out_signal_fft=sF.*Sym;


out_signal=ifft(out_signal_fft);


 