load CavityScan3Exp11072013
time = CavityScan3Exp11072013(:,1);
f = CavityScan3Exp11072013(:,2); 
REFLAIR = CavityScan3Exp11072013(:,3);
TR = CavityScan3Exp11072013(:,4);

Offset = 14515;   
f0 = 82;            % Set cavity pole to 82Hz
Peak_REFLAIR = 550; % Peak of REFAIR is about 600 counts (H1:LSC-REFLAIR_A_RF9_I_OUTMON)
Peak_TR = 440;      % Peak of IR transmitted light is about 400 counts (H1:ASC-Y_TR_NSUM_OUT_DQ)

f = (f-Offset)/2;
constTR = 5;
constREFLAIR = 75;


Fit_TR = Peak_TR./ (1 + ((f)/f0).^2) + constTR;
Fit_REFLAIR = 2*Peak_REFLAIR*((f)/f0)./ (1 + ((f)/f0).^2) + constREFLAIR;

gain=f/f0*2*Peak_REFLAIR+constREFLAIR;

figure(1)
clf;
plot(time,f);
grid on;

figure(2)
clf;
plot(time,REFLAIR,time,TR);
grid on;

figure(3)
clf;
plot(f,REFLAIR,f,Fit_REFLAIR,f,gain);
grid on;
xlabel('Frequency (Hz)');
ylabel('Counts');
ylim([-600 700]);
legend('REFL data', 'REFL Calibration', 'Gain Slope', 'Location', 'NorthWest');

figure(4)
clf;
plot(f,TR,f, Fit_TR);
grid on;
xlabel('Frequency (Hz)');
ylabel('Counts');
legend('Trans data', 'Trans Calibration', 'Location', 'NorthWest');