% ATS_shell

clear all;
close all;

% open the option data file
[option.fileinfo] = open_file_GUI('Option File Name', ...
    {'*.opt','Data Files (*.opt)';'*.opt','ASCII Option file (*.opt)'}, ...
        'r');

% open the ATS data file
[ats.fileinfo] = open_file_GUI('ATS Data File Name', ...
    {'*.atspc','Data Files (*.atspc)';'*.atspc','ASCII ATS file (*.atspc)'}, ...
        'r');
% open the ZDA data file
[zda.fileinfo] = open_file_GUI('ZDA Data File Name', ...
    {'*.zdapc','Data Files (*.zdapc)';'*.zdapc','ASCII ZDA file (*.zdapc)'}, ...
        'r');

[option.data] = load_data( option.fileinfo.full_path_and_file, 'opt');

[ats.data] = load_data( ats.fileinfo.full_path_and_file, 'atspc');
[zda.data] = load_data( zda.fileinfo.full_path_and_file, 'zdapc');
    
ats.data.lat_rad  = (option.data.coord.lat.hem)*(option.data.coord.lat.deg + option.data.coord.lat.min/60 + option.data.coord.lat.sec/3600)*pi/180;
ats.data.lon_rad  = (option.data.coord.lon.hem)*(option.data.coord.lon.deg + option.data.coord.lon.min/60 + option.data.coord.lon.sec/3600)*pi/180;
ats.data.IH_ht    = option.data.coord.ht + option.data.coord.IH;
ats.data.v_offset = option.data.coord.v_offset;

[llh, xyz] = compute_ATS_trajectory(ats, zda, option);

print_lph_XYZ(llh(:,1), llh(:,2), llh(:,3), llh(:,4), 'llh');
print_lph_XYZ(xyz(:,1), xyz(:,2), xyz(:,3), xyz(:,4), 'xyz');

[llhvel, xyzvel, nedvel] = compute_ATS_velocity(ats, zda, option);

print_lph_XYZ(xyzvel(:,1), xyzvel(:,2), xyzvel(:,3), xyzvel(:,4), 'xyzvel');
print_lph_XYZ(llhvel(:,1), llhvel(:,2), llhvel(:,3), llhvel(:,4), 'llhvel');
print_lph_XYZ(nedvel(:,1), nedvel(:,2), nedvel(:,3), nedvel(:,4), 'nedvel');

fclose('all');

return;