%**************************************************************************
%This function reads the long coil data from a file.
%
%Input:
%file_name, name of the measurement data file
%
%Output:
%header, header of the measurement file
%pos, position of the measurement (m)
%integ, field integral (Tm or Tm^2)
%
%Zack Wolf, 9/5/08

function [header, pos, integ] = long_coil_read_meas(file_name)

%Open the data file
fid = fopen(file_name, 'r');
if fid == -1
    disp('long_coil_read_meas: unable to open input file');
end

%Extract the header information
ii = 0;
while 1
    in_line = fgetl(fid);
    ii = ii +1;
    header{ii} = in_line;
    if findstr('    Scan     Position    Raw value   Integral', in_line) > 0
        in_line = fgetl(fid);
        ii = ii +1;
        header{ii} = in_line;
        in_line = fgetl(fid);
        ii = ii +1;
        header{ii} = in_line;
        break;
    end
end

%Read the data
data_array = fscanf(fid, '%f %f %f %f', [4, inf]);
scan_num = data_array(1, :);
pos = data_array(2, :);
integ_volt = data_array(3, :);
integ = data_array(4, :);

%Close the file
fclose(fid);

%Done
