%**************************************************************************
%This function reads the data from a file.
%
%Input:
%file_name, tooling ball data file name
%
%Output:
%dat_vals, structure containing the data values
%
%Zack Wolf, 4/14/09

function [dat_vals] = ref_dipole_read_data(file_name)

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

%Read the data
fgetl(fid);  %header
fgetl(fid);  %header
ii = 0;
while 1
    data_str = fgetl(fid);
    if data_str == -1
        break
    end
    data_array = sscanf(data_str, '%i/%i/%i %f %f %f %f %f %*s', [1, 8]);
    ii = ii + 1;
    dat_vals.mm(ii) = data_array(1);
    dat_vals.dd(ii) = data_array(2);
    dat_vals.yy(ii) = data_array(3);
    dat_vals.v(ii) = data_array(4);
    dat_vals.v0(ii) = data_array(5);
    dat_vals.b_hall(ii) = data_array(6);
    dat_vals.b_nmr(ii) = data_array(7);
    dat_vals.b_delta(ii) = data_array(8);
end

%Close the file
fclose(fid);

%Done
