%this is based loosely on GetA2Lspots in
%userapps/isc/common/scripts/decoup/BeamPositions

datafolder = '/opt/rtcds/userapps/trunk/sus/common/scripts/quad/InLockChargeMeasurements/rec_LHO/';
files = dir([datafolder '*.txt' ]);

optics = {'ITMX','ITMY','ETMX','ETMY'};
Nopt=4;

for ii = 1:Nopt
    newfiles.(optics{ii}) = {};
    numfiles.(optics{ii}) = 0;
end

%stuff for figuring out which files are new (add paths for tconvert)
addpath('/ligo/svncommon/NbSVN/aligonoisebudget/trunk/Externals/SimulinkNb/SimulinkNb');
addpath(genpath('/ligo/apps/linux-x86_64/mDV/extra'))

t0_python = tconvert('1970-01-01 00:00:00'); % python's start time and our gps start time aren't the same... 
t0_a2l    = tconvert('2015-10-10 00:00:00'); % date of first data, for plotting convenience
times = zeros(1,length(files));
which_quad = times;

for kk = 1:4;%:length(files)
    %in the future make some if statement to avoid repeat processing of
    %data files
    disp('new file!')
    QUAD = files(kk).name(1:4);
    drive_freq = files(kk).name(6:7);
    times(kk) = str2num(files(kk).name(12:end-4));
    %which_quad(kk) = QUAD;
    [alpha(kk), beta(kk), beta2(kk), gamma(kk)] = process_single_charge_meas([datafolder, files(kk).name], QUAD, 12,0);
end

Veff=(beta-beta2)./(2.*(alpha-gamma));