function [data] = build_GPS_fields (data)
% build_GPS_fields: build GPS data fields
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% build a list of field names
data.GPS.field_names={};
data.GPS.field_location=[];
data.GPS.field_ranges=[];

if ((strcmp(data.GPS.type,'RT17')==1)|(strcmp(data.GPS.type,'PreRT17')==1)|(strcmp(data.GPS.type,'DAT')==1))
   if (isempty(data.GPS.position)==0)
      % position variables configuration
      data.GPS.field_names(end+1,:)={'lat (°)'}; data.GPS.field_location(end+1,:)=[2 2 0]; data.GPS.field_ranges(end+1,:)=[nan nan nan 5 1 0 data.GPS.rate 0];
      data.GPS.field_names(end+1,:)={'lon (°)'}; data.GPS.field_location(end+1,:)=[2 3 0]; data.GPS.field_ranges(end+1,:)=[nan nan nan 5 1 0 data.GPS.rate 0];
      data.GPS.field_names(end+1,:)={'height (m)'}; data.GPS.field_location(end+1,:)=[2 4 0]; data.GPS.field_ranges(end+1,:)=[nan nan nan 3 1 0 data.GPS.rate 0];
      data.GPS.field_names(end+1,:)={'SV #'}; data.GPS.field_location(end+1,:)=[2 5 0]; data.GPS.field_ranges(end+1,:)=[0 12 3 0 1 0 data.GPS.rate 0];
      data.GPS.field_names(end+1,:)={'PDOP'}; data.GPS.field_location(end+1,:)=[2 6 0]; data.GPS.field_ranges(end+1,:)=[0 10 2.5 2 1 0 data.GPS.rate 0];
      data.GPS.field_names(end+1,:)={'Sol Type'}; data.GPS.field_location(end+1,:)=[2 7 0]; data.GPS.field_ranges(end+1,:)=[0 4 1 0 1 0 data.GPS.rate 0];
      data.GPS.field_names(end+1,:)={'E (m)'}; data.GPS.field_location(end+1,:)=[2 8 0]; data.GPS.field_ranges(end+1,:)=[nan nan nan 3 1 0 data.GPS.rate 0];
      data.GPS.field_names(end+1,:)={'N (m)'}; data.GPS.field_location(end+1,:)=[2 9 0]; data.GPS.field_ranges(end+1,:)=[nan nan nan 3 1 0 data.GPS.rate 0];
      data.GPS.field_names(end+1,:)={'U (m)'}; data.GPS.field_location(end+1,:)=[2 10 0]; data.GPS.field_ranges(end+1,:)=[nan nan nan 3 1 0 data.GPS.rate 0];
      data.GPS.field_names(end+1,:)={'vel E (m/s)'}; data.GPS.field_location(end+1,:)=[2 11 0]; data.GPS.field_ranges(end+1,:)=[-8 8 2 3 1 0 data.GPS.rate 0];
      data.GPS.field_names(end+1,:)={'vel N (m/s)'}; data.GPS.field_location(end+1,:)=[2 12 0]; data.GPS.field_ranges(end+1,:)=[-8 8 2 3 1 0 data.GPS.rate 0];
      data.GPS.field_names(end+1,:)={'vel U (m/s)'}; data.GPS.field_location(end+1,:)=[2 13 0]; data.GPS.field_ranges(end+1,:)=[-8 8 2 3 1 0 data.GPS.rate 0];
      data.GPS.field_names(end+1,:)={'GPS Vel (m/s)'}; data.GPS.field_location(end+1,:)=[2 14 0]; data.GPS.field_ranges(end+1,:)=[0 8 1 3 1 0 data.GPS.rate 0];
      data.GPS.field_names(end+1,:)={'GPS Accel (m/s²)'}; data.GPS.field_location(end+1,:)=[2 15 0]; data.GPS.field_ranges(end+1,:)=[-30 30 10 3 1 0 data.GPS.rate 0];
   end;
   
   if (isempty(data.GPS.observables)==0)
      % cycle slip counts
      data.GPS.field_names(end+1,:)={'L1 Cycle Slip Counts'}; data.GPS.field_location(end+1,:)=[5 1 0]; data.GPS.field_ranges(end+1,:)=[0 12 3 0 1 0 data.GPS.rate 0];
      data.GPS.field_names(end+1,:)={'L2 Cycle Slip Counts'}; data.GPS.field_location(end+1,:)=[5 2 0]; data.GPS.field_ranges(end+1,:)=[0 12 3 0 1 0 data.GPS.rate 0];
      
      % clock bias
      data.GPS.field_names(end+1,:)={'Clock Bias'}; data.GPS.field_location(end+1,:)=[3 2 0]; data.GPS.field_ranges(end+1,:)=[nan nan nan 3 1 0 data.GPS.rate 0];
      
      % SV observable variables configuration
      j=0;
      for (i=1:size(data.GPS.observables.SV,2))
         if (isempty(data.GPS.observables.SV{i})==0)
            j=j+1;
            data.GPS.field_names(end+1,:)={sprintf('SV %.0f Elev',i)}; data.GPS.field_location(end+1,:)=[4 1 i]; data.GPS.field_ranges(end+1,:)=[0 90 10 0 1 0 data.GPS.rate 0];
            data.GPS.field_names(end+1,:)={sprintf('SV %.0f Az',i)}; data.GPS.field_location(end+1,:)=[4 2 i]; data.GPS.field_ranges(end+1,:)=[0 360 45 0 1 0 data.GPS.rate 0];
            data.GPS.field_names(end+1,:)={sprintf('SV %.0f L1 Phase',i)}; data.GPS.field_location(end+1,:)=[4 3 i]; data.GPS.field_ranges(end+1,:)=[nan nan nan 0 1 0 data.GPS.rate 0];
            data.GPS.field_names(end+1,:)={sprintf('SV %.0f L1 Range',i)}; data.GPS.field_location(end+1,:)=[4 4 i]; data.GPS.field_ranges(end+1,:)=[nan nan nan 0 1 0 data.GPS.rate 0];
            data.GPS.field_names(end+1,:)={sprintf('SV %.0f L1 Doppler',i)}; data.GPS.field_location(end+1,:)=[4 5 i]; data.GPS.field_ranges(end+1,:)=[nan nan nan 0 1 0 data.GPS.rate 0];
            data.GPS.field_names(end+1,:)={sprintf('SV %.0f L1 SNR',i)}; data.GPS.field_location(end+1,:)=[4 6 i]; data.GPS.field_ranges(end+1,:)=[nan nan nan 0 1 0 data.GPS.rate 0];
            data.GPS.field_names(end+1,:)={sprintf('SV %.0f L1 Slip',i)}; data.GPS.field_location(end+1,:)=[4 7 i]; data.GPS.field_ranges(end+1,:)=[3 5 1 0 1 0 data.GPS.rate 0];
            data.GPS.field_names(end+1,:)={sprintf('SV %.0f L1 Tracking',i)}; data.GPS.field_location(end+1,:)=[4 8 i]; data.GPS.field_ranges(end+1,:)=[0 1 1 0 1 0 data.GPS.rate 0];
            data.GPS.field_names(end+1,:)={sprintf('SV %.0f L2 Phase',i)}; data.GPS.field_location(end+1,:)=[4 9 i]; data.GPS.field_ranges(end+1,:)=[nan nan nan 0 1 0 data.GPS.rate 0];
            data.GPS.field_names(end+1,:)={sprintf('SV %.0f L2 Range',i)}; data.GPS.field_location(end+1,:)=[4 10 i]; data.GPS.field_ranges(end+1,:)=[nan nan nan 0 1 0 data.GPS.rate 0];
            data.GPS.field_names(end+1,:)={sprintf('SV %.0f L2 SNR',i)}; data.GPS.field_location(end+1,:)=[4 11 i]; data.GPS.field_ranges(end+1,:)=[nan nan nan 0 1 0 data.GPS.rate 0];
            data.GPS.field_names(end+1,:)={sprintf('SV %.0f L2 Slip',i)}; data.GPS.field_location(end+1,:)=[4 12 i]; data.GPS.field_ranges(end+1,:)=[0 1 1 0 1 0 data.GPS.rate 0];
            data.GPS.field_names(end+1,:)={sprintf('SV %.0f L2 Tracking',i)}; data.GPS.field_location(end+1,:)=[4 13 i]; data.GPS.field_ranges(end+1,:)=[0 3 1 0 1 0 data.GPS.rate 0];
         end;
      end;
   end;
else
   return;
end;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
return;
