% Plot derivatives of timeseries to check against scattering spectrograms
% 
% Using equation 3 from ?Noise
% from scattered light in Virgo's second science run data?
% http://iopscience.iop.org/0264-9381/27/19/194011 (thanks Andy for the
% pointer):
% 
% f_fringe = 2*v_sc/lambda

data = csvread('H1_SUS-OMC_M1_DAMP_L_IN1_DQ_111805004640.csv');

traw = data(:,1);
t = traw-min(traw);

x = data(:,2); % Jeff says that M1 L IN1 should be in microns
step=0.001
v = diff(x)./step; % take derivative
f = abs(2*v/1.064); % equation 3 in microns [(um/s)/um = Hz]

figure;
subplot(2,1,1)
plot(t,x-mean(x),t(1:end-1),v)
ylabel('See legend')
legend('Disp [\mu{m}] - mean','Velocity [\mu{m}/s]')
subplot(2,1,2)
plot(t(1:end-1),f)
xlabel(['Times offset of GPS=', num2str(min(traw))])
ylabel('Frequency [Hz] f_{fringe} = 2v_{sc}/\lambda')