function [x,y,z] = READ_header(Filename) % Function reads the header for the specified RINEX file % and returns the approx x,y,z position % [x,y,z] = READ_header(Filename) % opens file to be read by READ_rinex_sat_all, or READ_rinex_epoch % % Example: [x,y,z] = READ_header('tmgo0010.01o'); % Opens the file tmgo0010.01o and returns the approx x,y,z position % from the header % % uses these global variables: %global fid_rinex Obs_line C1_loc P1_loc P2_loc L1_loc L2_loc num_obs % C1_loc, P1_loc, P2_loc tell you where to find the pseudoranges. % L1_loc and L2_loc where to find the phases. These locations % only make sense in the context of the next function you need, called % READ_rinex_sat_all. % David Benson % 5/18/01 % update 7/1/01 %Filename = 'tmgo0010.01o'; % set global variables for use by READ_rinex files global fid_rinex Obs_line C1_loc P1_loc P2_loc L1_loc L2_loc num_obs fid_rinex = fopen(Filename); if fid_rinex == -1 x = 0; y = 0; z = 0; disp([' Error can not open file']) return end info=fgets(fid_rinex,60); header=fgets(fid_rinex); while strncmp(header,'APPROX POSITION XYZ',19)==0; % find xyz line info=fgets(fid_rinex,60); header=fgets(fid_rinex); end A=sscanf(info,'%g'); % load xyz position x=A(1,1); y=A(2,1); z=A(3,1); % search for types of OBS info=fgets(fid_rinex,60); header=fgets(fid_rinex); while strncmp(header,'# / TYPES OF OBSERV',19)==0; info=fgets(fid_rinex,60); header=fgets(fid_rinex); if eval('info') == -1 x = 0; y = 0; z = 0; disp([' Error, READ_header: can not read OBS types']) return end end Obs_line = info; C1_loc = 0; L1_loc = 0; L2_loc = 0; P1_loc = 0; P2_loc = 0; num_obs = str2num(info(1:6)); for i = 1:num_obs obs = info((6*i+1):(6*i+6)); k = findstr(obs, 'C1'); if length(k) ~= 0 C1_loc = i; %position if File where desired info is end k2 = findstr(obs, 'P1'); if length(k2) ~= 0 P1_loc = i; %position if File where desired info is end k3 = findstr(obs, 'P2'); if length(k3) ~= 0 P2_loc = i; %position if File where desired info is end k4 = findstr(obs, 'L1'); if length(k4) ~= 0 L1_loc = i; %position if File where desired info is end k5 = findstr(obs, 'L2'); if length(k5) ~= 0 L2_loc = i; %position if File where desired info is end end % search for end of header while strncmp(header,'END OF HEADER',13)==0; % find end of header info=fgets(fid_rinex,60); header=fgets(fid_rinex); if eval('info') == -1 x = 0; y = 0; z = 0; disp([' Error, READ_header: can not read end of Header']) return end end