function [data] = load_data ( full_path_and_file, type, subtype )

%  strip off any extension data, if it exists
[token rem] = strtok(full_path_and_file, '.');
full_path_and_file = token;

if(strcmpi(type,'gga'))
    offset = 13;
else
    offset = 13;
end

argumentlist{2}='';
argumentlist{3}=[-1];
argumentlist{4}='headerlines';
argumentlist{5}=[0];
argumentlist{6}='headercolumns';
argumentlist{7}=[0];

if(strcmpi(type,'opt'))
    argumentlist{1}=strcat(full_path_and_file,'.opt');
    whan=waitbar(.20,'Loading Option file ... please wait ...');
    file=dataread('file',argumentlist{:});
    % subtract 83ms to get the PC time for when the ATS measurements were
    % made (assumes a constant latency, as per ATS spec)
    data.coord.lat.deg     = file(1,1);
    data.coord.lat.min     = file(2,1);
    data.coord.lat.sec     = file(3,1);
    data.coord.lat.hem     = file(4,1);
    data.coord.lon.deg     = file(5,1);
    data.coord.lon.min     = file(6,1);
    data.coord.lon.sec     = file(7,1);
    data.coord.lon.hem     = file(8,1);
    data.coord.ht          = file(9,1);
    data.coord.IH          = file(10,1);
    data.coord.v_offset    = file(11,1);
    data.data_rate         = file(12,1);
    data.GPSday_start      = file(13,1);


    waitbar(1,whan,'Loading Option file ... please wait ...');
    delete(whan);
    return;
end


if(strcmpi(type,'atspc'))
    argumentlist{1}=strcat(full_path_and_file,'.atspc');
    whan=waitbar(.20,'Loading ATS Trajectory file ... please wait ...');
    file=dataread('file',argumentlist{:});
    % subtract 83ms to get the PC time for when the ATS measurements were
    % made (assumes a constant latency, as per ATS spec)
    data.ats_pctime     = file(:,1)-0.083;
    data.ats_state      = file(:,2);
    % convert from radians*1000000 to degrees
    data.ats_hang       = file(:,3)*180/(1000000*pi);
    data.ats_vang       = file(:,4)*180/(1000000*pi);
    % convert range to meters
    data.ats_range      = file(:,5)/1000;
    % find all epochs with synchonized angles and range
    data.ats_sync       = find(data.ats_state==69);

    waitbar(1,whan,'Loading ATS Trajectory file ... please wait ...');
    delete(whan);
    return;
end

if(strcmpi(type,'zdapc'))
    argumentlist{1}=strcat(full_path_and_file,'.zdapc');
    whan=waitbar(.20,'Loading ATS Trajectory file ... please wait ...');
    file=dataread('file',argumentlist{:});
    data.zda_pctime     = file(:,1);
    data.zda_UTC_timeSS = file(:,2);
    % account for difference between UTC and GPS time
    data.zda_GPS_timeSS = data.zda_UTC_timeSS + offset;
    % adjust in case of data collected over the daily rollover so that the
    % time will always be between 0 and 86399
    a = find(data.zda_GPS_timeSS < 0);
    data.zda_GPS_timeSS(a) = data.zda_GPS_timeSS(a) + 86400;
    data.zda_GPS_timeSS = adjust_for_eod_rollover(data.zda_GPS_timeSS);
    
    waitbar(1,whan,'Loading ZDA Time Tag file ... please wait ...');
    delete(whan);
    return;
end

return;
