%script gUhrGeoEelGeomR02;
%{'SU_Set'};gUhrGeoEelGeomR02; %>> Load Setup
%{'ML_Set'};gUhrGeoEelGeomR02; %>> define "Map layers"
%{'Main_Load'};gUhrGeoEelGeomR02; %>> PR & ML variables Load or Create PR-structure
%{'PR_Set','0006_C_L_HR_29',26,1};gUhrGeoEelGeomR02; %>> Create dataset for single line
%{'Fix&Shot_QC',1};gUhrGeoEelGeomR02; %>> Find MissShots
%{'Time_QC','StTp','Gps',1,1:1};gUhrGeoEelGeomR02; %>> delete spike&smooth Time
%{'Coord_QC','StTp','Gps',10,1};gUhrGeoEelGeomR02; %>> delete spike&smooth Coord
%{'PR_CreateSet',1};gUhrGeoEelGeomR02;
%{'OutPromaxGunGeom',1};gUhrGeoEelGeomR02; %>> create file for PROMAX with Gun
%{'OutP190Geom','Gun',2018,1,10,'S'};gUhrGeoEelGeomR02; %>> create file P190 and AutoCad-script for Gun
%{'OutP190Geom','Cmp1',2018,1,10,'C'};gUhrGeoEelGeomR02; %>> create file P190 and AutoCad-script for Cmp1
%{'SgyTextural',1};gUhrGeoEelGeomR02;
%{'OutSgyGeom',1};gUhrGeoEelGeomR02; %>> save geometry to Sgy fields
%{'Main_Save'};gUhrGeoEelGeomR02; %>> ML & PR variables Save

gKey=ans;clear ans;
if strcmp(gKey{1},'SU_Set'), %define Setup values // {'SU_Set'};gUhrGeoEelGeomR02;
    try clear SU;catch,end;
    SU.RootDir='d:\UHR_GeoEel\';
    SU.LPlan=1; %MapLayers's cell number with default Line Planning for drawing
    SU.NavS=struct('EllipParam',[6378137 0.0818191908426215],'TargCode',2);
    SU.NavP=struct('EllipParam',[6378137 0.0818191908426215],'ProjParam',[0 141 0.9996 500000 0],'ProjForvFunc','gNavGeog2ProjUtm','ProjRevFunc','gNavProjUtm2Geog','TargCode',6);
    SU.CompTimeLocShift=11*3600; %local time shift in seconds
    SU.SgyFormatForced=1; %Forced sgy format. If empty, than no forced.
    SU.SgyReelPos=1:4; %prefix char position in LineName (sequence or Reel for Sgy, contained as a prefix in LineName)
    SU.Job=25; %Job identification number (JIN).
    %values saved to PR{..}
    SU.WaterVelocity=1470; %water velocity in m/s
    SU.NameP190GunHead='P190_GunHeader.txt';SU.NameP190Cmp1Head='P190_Cmp1Header.txt';SU.NameSgyTxt='Sgy_TextHeader.txt';
    SU.SpInterval=6.25; %Shotpoint interval
    SU.GunTpNod=[]; %Gun towpoint position relative vessel's CRP
    SU.GunDist=54; %Length of gun towcable (from towpoint to "acoustic center")
    SU.StTpNod=[]; %Streamer's towpoint position relative vessel's CRP
    SU.StBuoyDist=1418.4; SU.StBuoyNum=numel(SU.StBuoyDist); %Streamer length from towpoint to tail buoy // number of tail for streamer
    SU.StBirdDist=[62.2 162.2 262.2 362.2 462.2 562.2 662.2 762.2 862.2 962.2 1062.2 1162.2 1262.2]; SU.StBirdNum=numel(SU.StBirdDist); %distance to birds from towpoint, calculated by section length // number of birds for streamer
    SU.StChDist=(0:192-1).*6.25+64.3;SU.StChNum=numel(SU.StChDist); %distance to Channels from towpoint, calculated by section length // number of data channels for streamer
    SU.StAuxIdenitifactionCode=[9 3 3 3];SU.StAuxNum=numel(SU.StAuxIdenitifactionCode); %Sgy Bytes29-30; TraceIdenitifactionCode: -1=Other; 0=Unknown; 1=Seismic data; 2=Dead; 3=Dummy; 4=Time break; 5=Uphole; 6=Sweep; 7=Timing; 8=Waterbreak; 9=Near-field gun signature; 10=Far-field gun signature; 11=Seismic pressure sensor; 12=Multicomponent seismic sensor - Vertical component; 13=Multicomponent seismic sensor - Cross-line component; 14=Multicomponent seismic sensor - In-line component; 15=Rotated multicomponent seismic sensor - Vertical component; 16=Rotated multicomponent seismic sensor - Transverse component; 17=Rotated multicomponent seismic sensor - Radial component; 18=Vibrator reaction mass; 19=Vibrator baseplate; 20=Vibrator estimated ground force; 21=Vibrator reference; 22=Time-velocity pairs; 23 … N=optional use,  (maximum N = 32,767).
    SU.StAllNum=SU.StChNum+SU.StAuxNum; %number of all channels
    SU.StAllGain=[zeros(size(SU.StChDist))+8 16 16 16 16]; %gain for data channels and aux channels
end;
if strcmp(gKey{1},'ML_Set'), %define "Map layers" // {'ML_Set'};gUhrGeoEelGeomR02;
    try clear ML;catch,end;
    n=SU.LPlan;ML{n}.fRec='LPlan_2DHR.txt';ML{n}.fRecFormat='LinePlan';ML{n}.NDraw=2;ML{n}.LP=gMapPLReadTxt([SU.RootDir ML{n}.fRec],1,'-b'); %LinePlanning and ZoneBorder file, path to file in Root
    figure('Name','Line Plan','NumberTitle','off');gMapPLDraw([],ML{n}.LP);axis equal;gMapPL2AcadExport([SU.RootDir 'LPlan_2DHR.scr'],ML{n}.LP,[7 0],[5 100000],[6 0 1000000 0],3,1,0);%gMapPL2AcadExport(fName,PL,PLNameAttr,CircleAttr,KPNameAttr,DigitNum,PointsStep,flLayers)
    disp(['ML{' num2str(n) '}=' ML{n}.fRec '; Format: ' ML{n}.fRecFormat ' - LinePlaning Loaded; AutoCad file created']);
    clearvars n
end;
if strcmp(gKey{1},'Main_Load'), %ML & PR variables Load // {'Main_Load'};gUhrGeoEelGeomR02;
    try load([SU.RootDir '\MAIN_GEOM.mat']);disp('MAIN_GEOM.mat - PR & ML variables Loaded'); %create/load Survey Lines variable
    catch, PR=cell(input('SurveyLines Numbers for PR variable:'),1);end;
end;
if strcmp(gKey{1},'Main_Save'), %ML & PR variables Save // {'Main_Save'};gUhrGeoEelGeomR02;
    save([SU.RootDir '\MAIN_GEOM.mat'],'PR','ML');disp('MAIN_GEOM.mat - PR & ML variables Saved');
end;
if strcmp(gKey{1},'PR_Set'), %Load data from all logs // {'PR_Set','0006_C_L_HR_29',26,1};gUhrGeoEelGeomR02;
    %======= Begin PR{..} set fields description ===================================
    %LLog >> Survey Line information
    %   WaterVelocity                                               -water velosity in m/s;
    %   NameP190GunHead, NameSgyTxt                                 -files containe P190; SgyText headers;
    %   SpInterval                                                  -shotpoint interval;
    %   GunTpNod, GunDist                                           -cluster's towpoint nod; clusters distance from towpoint;
    %   StTpNod, StBuoyDist, StBuoyNum, StBirdDist, StBirdsNum      -streamer's towpoint nod; distance form towpoint to buoys; buoys number; distance from towpoint to birds; birds number;
    %   StChDist, StChNum                                           -streamer's distance from towpoint to data channels; data channels number;
    %   StAuxNum, StAllNum, StAllGain                               -streamer's aux channels number; data+aux channels number; data+aux channels gain;
    %   LName, LHead, ShotNum                                       -survey line name; survey line direction; 
    %   CompDay, CompTime, GpsDay, GpsTime                          -time mark, taken from gLog computer or NaN; time mark, taken from GunLog-file.
    %ProcLog >> creating processing log for each PR{..}
    %Bathy >> MBES belt by Pings (Qinsy exported)
    %   GpsE, GpsN, Depth                                           -point coordinates by QPS preprocessing; point depth for current sea level by QPS preprocessing.
    %StTp >> Streamer towpoin by 1-second (Qinsy exported)
    %   GpsDay, GpsTime, GpsE, GpsN, Head                           -time mark and streamer towpoint coordinates, exported by Qinsy; vessel's heading; 
    %   add: QMask, GpsDayRaw, GpsTimeRaw, GpsERaw, GpsNRaw         -fields raw-copies; added when QC, using 'Time_QC' and 'Coord_QC'.
    %StBuoy >> Buoy position by 1-second (Qinsy exported)
    %   GpsDay, GpsTime, GpsE, GpsN                                 -time mark and tailbuoy coordinates, exported by Qinsy;;
    %   add: QMask, GpsDayRaw, GpsTimeRaw, GpsERaw, GpsNRaw         -fields raw-copies; added when QC, using 'Time_QC' and 'Coord_QC'.
    %StNav >> GeoEel "navigational log" by ShotID
    %   CompTime, GpsDay, GpsTime, GpsE, GpsN                       -GeoEel computer time; time mark for shot and streamer towpoint coordinates from "start-of-second when shot", generated by Qinsy;
    %   Fix, ShotID                                                 -navigation fix-number, generated by Qinsy; shot and file ID-number generated by GeoEel.
    %StDpt >> GeoEel "depth log" by ShotID
    %   ShotID, SensID, Depth                                       -shot and file ID-number generated by GeoEel; depth sensor's ID; depth value measured by SensID-sensor.
    %StTens >> GeoEel "tension log" by time (about 0.5-second)
    %   CompDay, CompTime, Tens                                     -time mark by GeoEel computer time; streamer's tension.
    %GunTp >> Gun towpoint by 1-second (Qinsy exported)
    %   GpsDay, GpsTime, GpsE, GpsN, Head                           -time mark and gun's towpoint coordinates, generated by Qinsy; vessel's heading;
    %   add: QMask, GpsDayRaw, GpsTimeRaw, GpsERaw, GpsNRaw         -fields raw-copies; added when QC, using 'Time_QC' and 'Coord_QC'.
    %GunLog >> GunLog2000 "guns log" by ShotID
    %   ShotID, GpsDay, GpsTime                                     -shot ID generated by GunLog2000; time mark for shot, generated by GunLog2000 (best for Mark using);
    %   dTGun, Atmosferic, Depth, Manifold, Volume                  -shot error in microseconds; atmosferic pressure in psi; guns cluster depth in meters; manifold pressure in psi; guns volume;
    %BirdLog >> Birds log by 1-second (Qinsy exported)
    %   GpsDay, GpsTime -time mark for birds, generated by Qinsy;
    %   Head, Depth, Angle, Temper                                  -compass heading for each bird (nan is not avalible); depth for each bird (nan is not avalible); wings angle each bird (nan is not avalible); temperature each bird (nan is not avalible).
    %SgyHead >> Segy header (binary, textural, extended textural) by GeoEel, link to tmp-file with Data (SgyHead.fNameTmp)
    %Head >> Segy trace headers by GeoEel
    %add: Z >> raw sensors interpolated to Fix; added using 'PR_CreateSet'.
    %======= End PR{..} set fields description =====================================
    try LName=gKey{2};catch,LName=input('FileNames Main part=');end; try LHead=gKey{3};catch,LHead=input('Survey Line Direction=');end; try n=gKey{4};catch,n=input('Survey Line Number=');end;
    disp(['Current settings: FileNamesMainPart=' LName '; LineDirection=' num2str(LHead) '; LineNumber=' num2str(n)]);
    PR{n}=struct('LLog',[],'ProcLog',[],'Bathy',[],'StTp',[],'StBuoy',[],'StNav',[],'StDpt',[],'StTens',[],'GunTp',[],'GunLog',[],'BirdLog',[],'SgyHead',[],'Head',[]);
    %Bathy
    tmp=gFieldsXYZFileRead([SU.RootDir '\' LName '\' LName '_Bathy.txt'],char([13 10]),{'GpsE','GpsN','Depth','Ping','Ray'},'%f%f%f%f%f');                      tmp{1}.GpsE=tmp{1}.GpsE-131206;tmp{1}.GpsN=tmp{1}.GpsN-131206;
    PR{n}.Bathy=rmfield(tmp{1},{'LName','Ping','Ray'}); PR{n}.Bathy.Depth=-PR{n}.Bathy.Depth;
    disp('-- Bathy belt get;');
    %Streamer
    tmp=gFieldsXYZFileRead([SU.RootDir '\' LName '\' LName '_StTp.txt'],char([13 10]),{'GpsDay','GpsTime','Fix','GpsE','GpsN','Head'},'%f%f%f%f%f%f');          tmp{1}.GpsE=tmp{1}.GpsE-131206;tmp{1}.GpsN=tmp{1}.GpsN-131206;
    tmp{1}.GpsDay=gNavTime2Time('YMD2Dx',tmp{1}.GpsDay);tmp{1}.GpsTime=gNavTime2Time('HMS2Sd',tmp{1}.GpsTime);PR{n}.StTp=rmfield(tmp{1},{'LName','Fix'});
    tmp=gFieldsXYZFileRead([SU.RootDir '\' LName '\' LName '_StBuoy.txt'],char([13 10]),{'GpsDay','GpsTime','Fix','GpsE','GpsN','Head'},'%f%f%f%f%f%f');        tmp{1}.GpsE=tmp{1}.GpsE-131206;tmp{1}.GpsN=tmp{1}.GpsN-131206;
    tmp{1}.GpsDay=gNavTime2Time('YMD2Dx',tmp{1}.GpsDay);tmp{1}.GpsTime=gNavTime2Time('HMS2Sd',tmp{1}.GpsTime);PR{n}.StBuoy=rmfield(tmp{1},{'LName','Head'});
    PR{n}.StNav=gUhrGeoEel_NavLogRead([SU.RootDir '\' LName '\' LName '_StNav.txt'],2);PR{n}.StNav=rmfield(PR{n}.StNav,{'fName','Head'});
    tmp=gFieldsXYZFileRead([SU.RootDir '\' LName '\' LName '_StDpt.txt'],char([13 10]),{'ShotID','SensID','Depth'},'File: %f, Depths: %f: %fm');PR{n}.StDpt=rmfield(tmp{1},'LName');
    tmp=gFieldsXYZFileRead([SU.RootDir '\' LName '\' LName '_StTens.txt'],char([13 10]),{'CompDay(1)','CompDay(2)','CompDay(3)','CompTime(1)','CompTime(2)','CompTime(3)','Tens'},'%f/%f/%f %f:%f:%f %f');
    tmp{1}.CompDay=gNavTime2Time('YMD3z2Dx',tmp{1}.CompDay);tmp{1}.CompTime=gNavTime2Time('HMS3z2Sd',tmp{1}.CompTime);PR{n}.StTens=rmfield(tmp{1},'LName');
    disp('-- Streamer logs get: TowPoint, Buoy, Log, RepeaterDepth, Tension;');
    %Gun
    tmp=gFieldsXYZFileRead([SU.RootDir '\' LName '\' LName '_GunTp.txt'],char([13 10]),{'GpsDay','GpsTime','Fix','GpsE','GpsN','Head'},'%f%f%f%f%f%f');         tmp{1}.GpsE=tmp{1}.GpsE-131206;tmp{1}.GpsN=tmp{1}.GpsN-131206;
    tmp{1}.GpsDay=gNavTime2Time('YMD2Dx',tmp{1}.GpsDay);tmp{1}.GpsTime=gNavTime2Time('HMS2Sd',tmp{1}.GpsTime);PR{n}.GunTp=rmfield(tmp{1},{'LName','Fix'});
    tmp=gFieldsXYZFileRead([SU.RootDir '\' LName '\' LName '_GunLog.txt'],char(10),{'ShotID','GpsDay(1)','GpsDay(2)','GpsDay(3)','GpsTime(1)','GpsTime(2)','GpsTime(3)','dTGun(1)','dTGun(2)','dTGun(3)','dTGun(4)','Atmosferic','Depth','Manifold','Volume'},'%f%f-%f-%f_%f:%f:%f%f%f%f%f%f%f%f%f');
    tmp{1}.GpsDay=gNavTime2Time('YMD3z2Dx',tmp{1}.GpsDay);tmp{1}.GpsTime=gNavTime2Time('HMS3z2Sd',tmp{1}.GpsTime);PR{n}.GunLog=rmfield(tmp{1},'LName');
    disp('-- Gun logs get: TowPoint, Log;');
    %Birds
    tmp=gFieldsXYZFileRead([SU.RootDir '\' LName '\' LName '_BirdLog.txt'],char([13 10]),{'GpsDay','GpsTime','Fix','Head(1)','Head(2)','Head(5)','Head(6)','Head(8)','Head(9)','Head(11)','Head(12)','Depth(1)','Depth(2)','Depth(3)','Depth(4)','Depth(5)','Depth(6)','Depth(7)','Depth(8)','Depth(9)','Depth(10)','Depth(11)','Depth(12)','Depth(13)',...
        'Angle(1)','Angle(2)','Angle(3)','Angle(4)','Angle(5)','Angle(6)','Angle(7)','Angle(8)','Angle(9)','Angle(10)','Angle(11)','Angle(12)','Angle(13)','Temper(1)','Temper(2)','Temper(3)','Temper(4)','Temper(5)','Temper(6)','Temper(7)','Temper(8)','Temper(9)','Temper(10)','Temper(11)','Temper(12)','Temper(13)'},...
        '%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f');
    if size(tmp{1}.Head,1)~=SU.StBirdNum,tmp{1}.Head(SU.StBirdNum,:)=0;end;tmp{1}.Head(all(tmp{1}.Head'==0),:)=nan; if size(tmp{1}.Depth,1)~=SU.StBirdNum,tmp{1}.Depth(SU.StBirdNum,:)=0;end;tmp{1}.Depth(all(tmp{1}.Depth'==0),:)=nan;
    if size(tmp{1}.Angle,1)~=SU.StBirdNum,tmp{1}.Angle(SU.StBirdNum,:)=0;end;tmp{1}.Angle(all(tmp{1}.Angle'==0),:)=nan; if size(tmp{1}.Temper,1)~=SU.StBirdNum,tmp{1}.Temper(SU.StBirdNum,:)=0;end;tmp{1}.Temper(all(tmp{1}.Temper'==0),:)=nan;
    tmp{1}.GpsDay=gNavTime2Time('YMD2Dx',tmp{1}.GpsDay);tmp{1}.GpsTime=gNavTime2Time('HMS2Sd',tmp{1}.GpsTime);PR{n}.BirdLog=rmfield(tmp{1},{'LName','Fix'});
    disp('-- Bird log get;');
    %Segy read & saveTmp
    [PR{n}.SgyHead,PR{n}.Head,Data]=gSgyRead([SU.RootDir '\' LName '\' LName '.sgy'],'',[]);
    PR{n}.SgyHead.fNameTmp=[SU.RootDir '\' LName '\' LName '.sgy_tmp'];gDataSave(PR{n}.SgyHead.fNameTmp,Data);
    disp('-- Sgy get.');
    %Line information
    PR{n}.LLog=rmfield(SU,{'RootDir','LPlan','NavS','NavP','CompTimeLocShift','SgyFormatForced','SgyReelPos','Job'});
    PR{n}.LLog.LName=LName;PR{n}.LLog.LHead=LHead;PR{n}.LLog.ShotNum=numel(PR{n}.StNav.ShotID);PR{n}.LLog.CompDay=[nan nan];PR{n}.LLog.CompTime=[nan nan];PR{n}.LLog.GpsDay=[nan nan];PR{n}.LLog.GpsTime=[nan nan];
    PR{n}.LLog.GpsDay=[PR{n}.GunLog.GpsDay(1) PR{n}.GunLog.GpsDay(end)];PR{n}.LLog.GpsTime=[PR{n}.GunLog.GpsTime(1) PR{n}.GunLog.GpsTime(end)];
    %Check data
    if numel(PR{n}.StNav.ShotID)~=numel(PR{1, 1}.GunLog.ShotID),warning('ShotID''s Number for GunLog and StationLog are different. Need check!');end;
    if ~all(PR{n}.GunLog.ShotID==PR{n}.StNav.ShotID),warning('ShotID''s for GunLog and StationLog are different. Need check!');end;
    tmp=atan2d(PR{n}.GunTp.GpsE(end)-PR{n}.GunTp.GpsE(1),PR{n}.GunTp.GpsN(end)-PR{n}.GunTp.GpsN(1));
    if abs(tmp-PR{n}.LLog.LHead)>5, warning(['Input-LineDirection and Calculated-LineDirection with gun towpoint are strongly different. Need check! // Input=' num2str(PR{n}.LLog.LHead) '; Calculated=' num2str(tmp) '.']);end;
    %Plot data
    figure('Name','Logs loaded','NumberTitle','off');gMapPLDraw([],ML{n}.LP);hold on;axis equal;plot(PR{n}.Bathy.GpsE,PR{n}.Bathy.GpsN,'.c');
    plot(PR{n}.StTp.GpsE,PR{n}.StTp.GpsN,'.b');plot(PR{n}.StBuoy.GpsE,PR{n}.StBuoy.GpsN,'.m');plot(PR{n}.GunTp.GpsE,PR{n}.GunTp.GpsN,'.r');
    quiver(PR{n}.GunTp.GpsE,PR{n}.GunTp.GpsN,sind(PR{n}.GunTp.Head),cosd(PR{n}.GunTp.Head),'ShowArrowHead','off','AutoScale','off','Color','r');
    PR{n}.ProcLog=[PR{n}.ProcLog 'PR_Get# LName=' LName ';  LHead=' num2str(LHead) 10];
    clearvars LHead LName n Data tmp
end;
if strcmp(gKey{1},'Fix&Shot_QC'), %Find MissShots // {'Fix&Shot_QC',1};gUhrGeoEelGeomR02;
    try n=gKey{2};catch,n=input('Survey Line Number=');end;
    figure('Name','x=ShotID, y=GunGpsTime-StationGpsTime','NumberTitle','off');plot(PR{n}.StNav.ShotID,((PR{n}.GunLog.GpsDay-PR{n}.StNav.GpsDay(1)).*86400+PR{n}.GunLog.GpsTime)-((PR{n}.StNav.GpsDay-PR{n}.StNav.GpsDay(1)).*86400+PR{n}.StNav.GpsTime),'.-');
    figure('Name','x=GunShotID; y=diff(Time), from GunLog)','NumberTitle','off');plot(PR{n}.GunLog.ShotID(1:end-1),diff((PR{n}.GunLog.GpsDay-PR{n}.GunLog.GpsDay(1)).*86400+PR{n}.GunLog.GpsTime),'.-');
    figure('Name','x=FIX; y=FIX-ShotID, from StNav log','NumberTitle','off');plot(PR{n}.StNav.Fix(1:end),PR{n}.StNav.Fix-PR{n}.StNav.ShotID,'.-'); %figure(3);plot(Z.FIX(1:end-1),diff(Z.FIX)-diff(Z.FFID));
    figure('Name','x=FIX; y=diff(FIX), from StNav log','NumberTitle','off');plot(PR{n}.StNav.Fix(1:end-1),diff(PR{n}.StNav.Fix),'.-');
    figure('Name','x=ShotID; y=diff(Time) from StNav log)','NumberTitle','off');plot(PR{n}.StNav.ShotID(1:end-1),diff((PR{n}.StNav.GpsDay-PR{n}.StNav.GpsDay(1)).*86400+PR{n}.StNav.GpsTime),'.-');
    figure('Name','x=ShotID; y=diff(ShotID), from StNav log','NumberTitle','off');plot(PR{n}.StNav.ShotID(1:end-1),diff(PR{n}.StNav.ShotID),'.-');
    PR{n}.ProcLog=[PR{n}.ProcLog 'FixNum&ShotsNumQC#' 10];
    clearvars n;
end;
if strcmp(gKey{1},'Time_QC'), %delete spike&smooth Time // {'Time_QC','StTp','Gps',1,1:1};gUhrGeoEelGeomR02;
    try fnm=gKey{2};catch,fnm=input('DataSetName will used=');end; try fnpt=gKey{3};catch,fnpt=input('TimeFieldPrefix=');end; try TimeSmooth=gKey{4};catch,TimeSmooth=input('TimeSmooth=');end; try nn=gKey{5};catch,nn=input(['SurveyLines Numbers for ' fnm ' handle de-spike and smooth=']);end;
    if numel(gKey)>5,BitTQH=gKey{6};disp(['BitTQH=' num2str(gKey{6})]);else BitTQH=1;end; %Select bit for mask
    if numel(gKey)>6,flTQH=gKey{7};disp(['flTQH=' num2str(gKey{7})]);else flTQH=false;end; %Select flag for maskBitTQH reset
    for n=nn,
        if ~isfield(PR{n}.(fnm),'QMask'), PR{n}.(fnm).QMask=uint8(zeros(size(PR{n}.(fnm).([fnpt 'Day']))));end;
        if ~isfield(PR{n}.(fnm),[fnpt 'DayRaw']),PR{n}.(fnm).([fnpt 'DayRaw'])=PR{n}.(fnm).([fnpt 'Day']);end; if ~isfield(PR{n}.(fnm),[fnpt 'TimeRaw']),PR{n}.(fnm).([fnpt 'TimeRaw'])=PR{n}.(fnm).([fnpt 'Time']);end;
        if flTQH, PR{n}.(fnm).QMask=bitand(PR{n}.(fnm).QMask,255-BitTQH);end; %reset BitTQH: Handle de-spiked Time
        PR{n}.(fnm).([fnpt 'Day'])=PR{n}.(fnm).([fnpt 'DayRaw']);PR{n}.(fnm).([fnpt 'Time'])=PR{n}.(fnm).([fnpt 'TimeRaw']);tmp=bitand(PR{n}.(fnm).QMask,BitTQH);PR{n}.(fnm).([fnpt 'Day'])(tmp~=0)=nan;PR{n}.(fnm).([fnpt 'Time'])(tmp~=0)=nan; %set to Nan by Mask for Day&Time
        dd=PR{n}.(fnm).([fnpt 'Day'])(1);ddt=(PR{n}.(fnm).([fnpt 'Day'])-dd).*86400+PR{n}.(fnm).([fnpt 'Time']);ddn=1:length(PR{n}.(fnm).([fnpt 'Day']));
        %Handle de-spike
        a=figure('Name',['SpikeDel 1- Time''s linear trend removed // Num:' num2str(n) '  ' PR{n}.LLog.LName],'NumberTitle','off');hold on;L=~isnan(ddt);pl=polyfit(ddn(L),ddt(L),1);
        p=gMapPickHandleNan(ddn,ddt-polyval(pl,ddn),a);pause;mask1=~get(p,'UserData');close(a);ddt(mask1)=nan;
        a=figure('Name',['SpikeDel 2- Time''s diff calculated // Num:' num2str(n) '  ' PR{n}.LLog.LName],'NumberTitle','off');hold on;
        p=gMapPickHandleNan(ddn(2:end),diff(ddt),a);pause;mask2=[false ~get(p,'UserData')];close(a);ddt(mask2)=nan;
        PR{n}.(fnm).QMask(mask1|mask2)=bitor(PR{n}.(fnm).QMask(mask1|mask2),BitTQH);%>>>>Set bitTQH -- Time QC handle de-spiked Time
        %interpolate and smooth Handle de-spiked values
        L=~(mask1|mask2);
        tL=smooth(ddn(L),ddt(L),TimeSmooth,'loess')';ddtZ=interp1(ddn(L),tL,ddn,'linear','extrap');
        PR{n}.(fnm).([fnpt 'Day'])=floor(ddtZ./86400)+dd;PR{n}.(fnm).([fnpt 'Time'])=ddtZ-(PR{n}.(fnm).([fnpt 'Day'])-dd).*86400;
        a=figure('Name',['Despiked&Smooth Time with linear trend removed // Num:' num2str(n) '  ' PR{n}.LLog.LName],'NumberTitle','off');hold on;
        pl=polyfit(ddn,ddtZ,1);plot(ddn,(PR{n}.(fnm).([fnpt 'Day'])-dd).*86400+PR{n}.(fnm).([fnpt 'Time'])-polyval(pl,ddn),'.r');plot(ddn,ddtZ-polyval(pl,ddn),'.-c');drawnow;pause;try close(a);catch,end;
        PR{n}.ProcLog=[PR{n}.ProcLog 'Time_QC# fnm=' fnm '; fnpt=' fnpt '; TimeSmooth=' num2str(TimeSmooth) '; nn=' num2str(nn) '; BitTQH=' num2str(BitTQH) '; flTQH=' num2str(flTQH) 10];
    end;
    clearvars fnm fnpt TimeSmooth nn BitTQH flTQH n tmp dd ddt ddn ddtZ L tL a pl mask1 mask2 ;
end;
if strcmp(gKey{1},'Coord_QC'), %delete spike&smooth Coord // {'Coord_QC','StTp','Gps',10,1};gUhrGeoEelGeomR02;
    try fnm=gKey{2};catch,fnm=input('DataSetName will used=');end; try fnpt=gKey{3};catch,fnpt=input('TimeFieldPrefix=');end; try PosSmooth=gKey{4};catch,PosSmooth=input('PosSmooth=');end; try nn=gKey{5};catch,nn=input(['SurveyLines Numbers for ' fnm ' handle de-spike and smooth=']);end;
    if numel(gKey)>5,BitCQH=gKey{6};disp(['BitCQH=' num2str(gKey{6})]);else BitCQH=2;end; %Select bit for mask
    if numel(gKey)>6,flCQH=gKey{7};disp(['flCQH=' num2str(gKey{7})]);else flCQH=false;end; %Select flag for maskBitCQH reset
    for n=nn,
        if ~isfield(PR{n}.(fnm),'QMask'), PR{n}.(fnm).QMask=uint8(zeros(size(PR{n}.(fnm).([fnpt 'Day']))));end;
        if ~isfield(PR{n}.(fnm),'GpsERaw'),PR{n}.(fnm).GpsERaw=PR{n}.(fnm).GpsE;end; if ~isfield(PR{n}.(fnm),'GpsNRaw'),PR{n}.(fnm).GpsNRaw=PR{n}.(fnm).GpsN;end;
        if flCQH, PR{n}.(fnm).QMask=bitand(PR{n}.(fnm).QMask,255-BitCQH);end; %reset BitCQH: Handle de-spiked GpsE&GpsN
        PR{n}.(fnm).GpsE=PR{n}.(fnm).GpsERaw;PR{n}.(fnm).GpsN=PR{n}.(fnm).GpsNRaw;tmp=bitand(PR{n}.(fnm).QMask,BitCQH);PR{n}.(fnm).GpsE(tmp~=0)=nan;PR{n}.(fnm).GpsN(tmp~=0)=nan; %set to Nan by Mask for GpsE&GpsN
        ddt=(PR{n}.(fnm).([fnpt 'Day'])-PR{n}.(fnm).([fnpt 'Day'])(1)).*86400+PR{n}.(fnm).([fnpt 'Time'])-PR{n}.(fnm).([fnpt 'Time'])(1);
        %Handle de-spike
        a=figure('Name',['SpikeDel 1- EN-plane // Num:' num2str(n) '  ' PR{n}.LLog.LName],'NumberTitle','off');hold on;axis equal;if isfield(SU,'LPlan')&&~isempty(SU.LPlan),gMapPLDraw(a,ML{SU.LPlan}.LP);end;
        p=gMapPickHandleNan(PR{n}.(fnm).GpsE,PR{n}.(fnm).GpsN,a);pause;mask1=~get(p,'UserData');close(a);PR{n}.(fnm).GpsE(mask1)=nan;PR{n}.(fnm).GpsN(mask1)=nan;
        a=figure('Name',['SpikeDel 2- E linear trend removed // Num:' num2str(n) '  ' PR{n}.LLog.LName],'NumberTitle','off');L=~isnan(PR{n}.(fnm).GpsN);p=polyfit(ddt(L),PR{n}.(fnm).GpsN(L),1); %calc&remove linear for N
        p=gMapPickHandleNan(ddt,PR{n}.(fnm).GpsN-polyval(p,ddt),a);pause;mask2=~get(p,'UserData');close(a);PR{n}.(fnm).GpsE(mask2)=nan;PR{n}.(fnm).GpsN(mask2)=nan;
        a=figure('Name',['SpikeDel 3- N linear trend removed // Num:' num2str(n) '  ' PR{n}.LLog.LName],'NumberTitle','off');L=~isnan(PR{n}.(fnm).GpsE);p=polyfit(ddt(L),PR{n}.(fnm).GpsE(L),1); %calc&remove linear for E
        p=gMapPickHandleNan(ddt,PR{n}.(fnm).GpsE-polyval(p,ddt),a);pause;mask3=~get(p,'UserData');close(a);PR{n}.(fnm).GpsE(mask3)=nan;PR{n}.(fnm).GpsN(mask3)=nan;
        PR{n}.(fnm).QMask(mask1|mask2|mask3)=bitor(PR{n}.(fnm).QMask(mask1|mask2|mask3),BitCQH);%>>>>Set BitCQH: Handle de-spiked GpsE&GpsN
        a=figure('Name',['Despiked Coord EN-plane // Num:' num2str(n) '  ' PR{n}.LLog.LName],'NumberTitle','off');if isfield(SU,'LPlan')&&~isempty(SU.LPlan),gMapPLDraw(a,ML{SU.LPlan}.LP);end;hold on;axis equal;
        plot(PR{n}.(fnm).GpsERaw,PR{n}.(fnm).GpsNRaw,'.r');plot(PR{n}.(fnm).GpsE,PR{n}.(fnm).GpsN,'.-c');drawnow;pause;try close(a);catch,end;
        %interpolate and smooth Handle de-spiked values
        L=~(mask1|mask2|mask3);
        yL=smooth(ddt(L),PR{n}.(fnm).GpsE(L),PosSmooth,'loess')';PR{n}.(fnm).GpsE=interp1(ddt(L),yL,ddt,'linear','extrap');
        yL=smooth(ddt(L),PR{n}.(fnm).GpsN(L),PosSmooth,'loess')';PR{n}.(fnm).GpsN=interp1(ddt(L),yL,ddt,'linear','extrap');
        a=figure('Name',['Smoothed Coord EN-plane // Num:' num2str(n) '  ' PR{n}.LLog.LName],'NumberTitle','off');if isfield(SU,'LPlan')&&~isempty(SU.LPlan),gMapPLDraw(a,ML{SU.LPlan}.LP);end;gMapTickLabel(a,'%.2f',9);hold on;axis equal;
        plot(PR{n}.(fnm).GpsERaw,PR{n}.(fnm).GpsNRaw,'.r');plot(PR{n}.(fnm).GpsE,PR{n}.(fnm).GpsN,'.-c');drawnow;pause;try close(a);catch,end;
        PR{n}.ProcLog=[PR{n}.ProcLog 'Coord_QC# fnm=' fnm '; fnpt=' fnpt '; PosSmooth=' num2str(PosSmooth) '; BitCQH=' num2str(BitCQH) '; flTQH=' num2str(flCQH) 10];
    end;
    clearvars fnm fnpt PosSmooth nn BitCQH flCQH n tmp dd ddt a p L yL mask1 mask2 mask3;
end;
if strcmp(gKey{1},'PR_CreateSet'), %Create dataset for Profile - sync all data to ShotID; GunLog is Main // {'PR_CreateSet',1};gUhrGeoEelGeomR02;
    %======= Begin PR{..}.Z "combined-sensors" fields description ====================================================================================
    %ShotID, Fix, GpsDay, GpsTime, VessHead                                                                 -shot points' ID and time
    %GunTpGpsE, GunTpGpsN, GunGpsE, GunGpsN, GunDepth, GunSeaDepth, dTGun, Manifold, Atmosferic, GunVolume  -cluster position and guns characteristics
    %StTpGpsE, StTpGpsN, StBuoyGpsE, StBuoyGpsN, StHead, StTens, StRDepth                                   -streamer&buoys position and streamer characteristics
    %StChGpsE(1..n), StChGpsN(1..n), StChDepth(1..n), StChSeaDepth(1..n), StGun2Ch(1..n)                    -streamer's channels position
    %Cmp1GpsE, Cmp1GpsN                                                                                     -cmp1 position
    %BirdGpsE(1..m), BirdGpsN(1..m), BirdDepth(1..m), BirdHead(1..m), BirdAngle(1..m), BirdTemper(1..m)     -streamer's birds position and characteristics
    %======= End "combined-sensors" fields description ===============================================================================================
    try nn=gKey{2};catch,nn=input('SurveyLine Numbers for PRSet=');end;
    for n=nn,
        tmp1=zeros(1,PR{n}.LLog.ShotNum);tmp2=zeros(PR{n}.LLog.StChNum,PR{n}.LLog.ShotNum);tmp3=zeros(PR{n}.LLog.StBirdNum,PR{n}.LLog.ShotNum);
        PR{n}.Z=struct('ShotID',PR{n}.StNav.ShotID,'Fix',PR{n}.StNav.Fix,'GpsDay',PR{n}.GunLog.GpsDay,'GpsTime',PR{n}.GunLog.GpsTime,'VessHead',tmp1,...
            'GunTpGpsE',tmp1,'GunTpGpsN',tmp1,'GunGpsE',tmp1,'GunGpsN',tmp1,'GunDepth',PR{n}.GunLog.Depth,'GunSeaDepth',tmp1,'dTGun',PR{n}.GunLog.dTGun,'Manifold',PR{n}.GunLog.Manifold,'Atmosferic',PR{n}.GunLog.Atmosferic,'GunVolume',PR{n}.GunLog.Volume,...
            'StTpGpsE',tmp1,'StTpGpsN',tmp1,'StBuoyGpsE',tmp1,'StBuoyGpsN',tmp1,'StHead',tmp1,'StTens',tmp1,'StRDepth',PR{n}.StDpt.Depth,'StChGpsE',tmp2,'StChGpsN',tmp2,'StChDepth',tmp2,'StChSeaDepth',tmp2,'StGun2Ch',tmp2,...
            'Cmp1GpsE',tmp1,'Cmp1GpsN',tmp1,'Cmp1SeaDepth',tmp1,...
            'BirdGpsE',tmp3,'BirdGpsN',tmp3,'BirdDepth',tmp3,'BirdHead',tmp3,'BirdAngle',tmp3,'BirdTemper',tmp3);
        BT=scatteredInterpolant(PR{n}.Bathy.GpsE',PR{n}.Bathy.GpsN',PR{n}.Bathy.Depth','linear','nearest');
        ddt0=(PR{n}.Z.GpsDay-PR{n}.Z.GpsDay(1)).*86400+PR{n}.Z.GpsTime;
        ddt=(PR{n}.StTp.GpsDay-PR{n}.Z.GpsDay(1)).*86400+PR{n}.StTp.GpsTime;
        PR{n}.Z.StTpGpsE=interp1(ddt,PR{n}.StTp.GpsE,ddt0,'linear','extrap'); %StTpGpsE >> interp(GpsTime)
        PR{n}.Z.StTpGpsN=interp1(ddt,PR{n}.StTp.GpsN,ddt0,'linear','extrap'); %StTpGpsN >> interp(GpsTime)
        ddt=(PR{n}.StBuoy.GpsDay-PR{n}.Z.GpsDay(1)).*86400+PR{n}.StBuoy.GpsTime;
        PR{n}.Z.StBuoyGpsE=interp1(ddt,PR{n}.StBuoy.GpsE,ddt0,'linear','extrap'); %StBuoyGpsE >> interp(GpsTime)
        PR{n}.Z.StBuoyGpsN=interp1(ddt,PR{n}.StBuoy.GpsN,ddt0,'linear','extrap'); %StBuoyGpsN >> interp(GpsTime)
        PR{n}.Z.StHead=atan2d(PR{n}.Z.StBuoyGpsE-PR{n}.Z.StTpGpsE,PR{n}.Z.StBuoyGpsN-PR{n}.Z.StTpGpsN); %StHead >> calculate(StTpGps,StBuoyGps) from TP to Buoy
      %StTens >> interp(CompTime, GpsTime)
        ddt=(PR{n}.GunTp.GpsDay-PR{n}.Z.GpsDay(1)).*86400+PR{n}.GunTp.GpsTime;
        PR{n}.Z.VessHead=interp1(ddt,PR{n}.GunTp.Head,ddt0,'linear','extrap'); %StTpGpsE >> interp(GpsTime)
        PR{n}.Z.GunTpGpsE=interp1(ddt,PR{n}.GunTp.GpsE,ddt0,'linear','extrap'); %GunTpGpsE >> interp(GpsTime)
        PR{n}.Z.GunTpGpsN=interp1(ddt,PR{n}.GunTp.GpsN,ddt0,'linear','extrap'); %GunTpGpsN >> interp(GpsTime)
      %TP.GpsE=smooth(TP.GpsE,30,'loess')';TP.GpsN=smooth(TP.GpsN,30,'loess')';
      %EN=gNavLayback([TP.GpsE;TP.GpsN;repmat(SourceLayback,size(TP.GpsE));repmat(0.1,size(TP.GpsE));repmat(StrAzimutz-180,size(TP.GpsE))],SurveyLineDirection);
      %EN(1,:)=smooth(EN(1,:),5,'loess');EN(2,:)=smooth(EN(2,:),5,'loess');%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        PR{n}.Z.GunGpsE=PR{n}.Z.GunTpGpsE+PR{n}.LLog.GunDist.*sind(PR{n}.Z.StHead); %GunGpsE >> calculate(GunTpGps,StHead); depth is ignored
        PR{n}.Z.GunGpsN=PR{n}.Z.GunTpGpsN+PR{n}.LLog.GunDist.*cosd(PR{n}.Z.StHead); %GunGpsN >> calculate(GunTpGps,StHead); depth is ignored
        PR{n}.Z.GunSeaDepth=BT(PR{n}.Z.GunGpsE,PR{n}.Z.GunGpsN); %GunSeaDepth >> interp(GunHGps,Bathy)
        ddt=((PR{n}.BirdLog.GpsDay-PR{n}.Z.GpsDay(1)).*86400+PR{n}.BirdLog.GpsTime);
        PR{n}.Z.BirdDepth=interp1(ddt,PR{n}.BirdLog.Depth',ddt0,'nearest','extrap')'; %BirdDepth >> interp(GpsTime)
        PR{n}.Z.BirdHead=interp1(ddt,PR{n}.BirdLog.Head',ddt0,'nearest','extrap')'; %BirdHead >> interp(GpsTime)
        PR{n}.Z.BirdAngle=interp1(ddt,PR{n}.BirdLog.Angle',ddt0,'nearest','extrap')'; %BirdAngle >> interp(GpsTime)
        PR{n}.Z.BirdTemper=interp1(ddt,PR{n}.BirdLog.Temper',ddt0,'nearest','extrap')'; %BirdTemper >> interp(GpsTime)
        PR{n}.Z.BirdGpsE=repmat(PR{n}.Z.StTpGpsE,PR{n}.LLog.StBirdNum,1)+repmat(PR{n}.LLog.StBirdDist',1,PR{n}.LLog.ShotNum).*repmat(sind(PR{n}.Z.StHead),PR{n}.LLog.StBirdNum,1); %BirdGpsE >> calculate(StTpGps,StHead,LLog); depth is ignored, BuoyGps for control
        PR{n}.Z.BirdGpsN=repmat(PR{n}.Z.StTpGpsN,PR{n}.LLog.StBirdNum,1)+repmat(PR{n}.LLog.StBirdDist',1,PR{n}.LLog.ShotNum).*repmat(cosd(PR{n}.Z.StHead),PR{n}.LLog.StBirdNum,1); %BirdGpsN >> calculate(StTpGps,StHead,LLog); depth is ignored,, BuoyGps for control
        PR{n}.Z.StChGpsE=repmat(PR{n}.Z.StTpGpsE,PR{n}.LLog.StChNum,1)+repmat(PR{n}.LLog.StChDist',1,PR{n}.LLog.ShotNum).*repmat(sind(PR{n}.Z.StHead),PR{n}.LLog.StChNum,1); %StChGpsE >> calculate(StTpGps,StHead,LLog); depth is ignored,, BuoyGps for control
        PR{n}.Z.StChGpsN=repmat(PR{n}.Z.StTpGpsN,PR{n}.LLog.StChNum,1)+repmat(PR{n}.LLog.StChDist',1,PR{n}.LLog.ShotNum).*repmat(cosd(PR{n}.Z.StHead),PR{n}.LLog.StChNum,1); %StChGpsN >> calculate(StTpGps,StHead,LLog); depth is ignored,, BuoyGps for control
        PR{n}.Z.StChDepth=interp1(PR{n}.LLog.StBirdDist,PR{n}.Z.BirdDepth,PR{n}.LLog.StChDist,'linear','extrap'); %StChDepth >> interp(BirdDepth,LLog)
        PR{n}.Z.StChSeaDepth=BT(PR{n}.Z.StChGpsE,PR{n}.Z.StChGpsN); %StChSeaDepth >> interp(StChGps,Bathy)
        PR{n}.Z.StGun2Ch=-sqrt((PR{n}.Z.StChGpsE-repmat(PR{n}.Z.GunGpsE,PR{n}.LLog.StChNum,1)).^2+(PR{n}.Z.StChGpsN-repmat(PR{n}.Z.GunGpsN,PR{n}.LLog.StChNum,1)).^2+(PR{n}.Z.StChDepth-repmat(PR{n}.Z.GunDepth,PR{n}.LLog.StChNum,1)).^2); %PR{n}.Z.StCh2Gun >> distance from channels to gun; depth is ignored
        PR{n}.Z.Cmp1GpsE=(PR{n}.Z.GunGpsE+PR{n}.Z.StChGpsE(1,:))./2;PR{n}.Z.Cmp1GpsN=(PR{n}.Z.GunGpsN+PR{n}.Z.StChGpsN(1,:))./2; %Cmp1 >> calc(GunGps,StCh1Gps)
        PR{n}.Z.Cmp1SeaDepth=BT(PR{n}.Z.Cmp1GpsE,PR{n}.Z.Cmp1GpsN); %StCmp1SeaDepth >> interp(Cmp1Gps,Bathy)
        %Plot data
        figure('Name','Dataset','NumberTitle','off');gMapPLDraw([],ML{n}.LP);hold on;axis equal;plot(PR{n}.Bathy.GpsE,PR{n}.Bathy.GpsN,'.c');
        plot(PR{n}.Z.StChGpsE',PR{n}.Z.StChGpsN','g');plot(PR{n}.Z.BirdGpsE',PR{n}.Z.BirdGpsN','b');
        plot(PR{n}.Z.StTpGpsE,PR{n}.Z.StTpGpsN,'.b');plot(PR{n}.Z.StBuoyGpsE,PR{n}.Z.StBuoyGpsN,'.m');plot(PR{n}.Z.GunTpGpsE,PR{n}.Z.GunTpGpsN,'.r');
        quiver(PR{n}.Z.GunTpGpsE,PR{n}.Z.GunTpGpsN,sind(PR{n}.Z.VessHead),cosd(PR{n}.Z.VessHead),'ShowArrowHead','off','AutoScale','off','Color','r');
      %r=sqrt(diff(Z.GpsE).^2+diff(Z.GpsN).^2);AccDev=sum(r)-sum(ShotDistance.*diff(Z.FIX));disp([mean(r) std(r) min(r) max(r) AccDev]); %Calculate SP-distance-error
      %clipboard('copy', [num2str(mean(r),'%f') char(9) num2str(std(r),'%f') char(9) num2str(min(r),'%f') char(9) num2str(max(r),'%f') char(9) num2str(AccDev,'%f')]); %Copy to clipboard coorditates short-to-short distance: Mean, StdDeviation, Min, Max, AccumulatedDeviation (difference between SeysmicDistance and SailDistance for Source)
        PR{n}.ProcLog=[PR{n}.ProcLog 'PR_CreateSet#' 10];
    end;
    clearvars n tmp1 tmp2 tmp3 BT ddt0 ddt;
end;
if strcmp(gKey{1},'OutPromaxGunGeom'), %create file for PROMAX with Gun // {'OutPromaxGunGeom',1};gUhrGeoEelGeomR02;
    %======= Begin ProMax's Sin geometry table description ========================================================================
    %ColumnName  Short Descript    DBHeader  Type     Description
    %MarkBlock   TRCGeom Sin       SIN       Integer  Mark Block is assigned to the TRC GEOMETRY SIN database attribute in the Assign midpoints step in Bin. This column is also a spreadsheet row counter.
    %Source      SinGeom Source    SOURCE    Integer  Source is a user defined source numbering sequence.
    %Station     SinGeom Station   SOU_SLOC  Integer  Station is required for Assign midpoints step in Bin. The station number is associated with the shot as determined from the acquisition survey.
    %X           SinGeom X_Coord   SOU_X     Float    X is required for Assign midpoints step in Bin. X coordinate of the source in feet or meters. This is obtained from the navigation data or can be extracted from dataset headers that contain X coordinates. This can be the X coordinate of either the center of the source array or the antennae on the boat.
    %Y           SinGeom Y_Coord   SOU_Y     Float    Y is required for Assign midpoints step in Bin. Y coordinate of the source in feet or meters. This is obtained from the navigation data or can be extracted from dataset headers that contain Y coordinates. This can be the Y coordinate of either the center of the source array or the antennae on the boat.
    %DepthSea    SinGeom Sea Depth SOU_H2OD  Float    Depth: is the water depth at the source location in ft. or m.
    %SrcDepth    SinGeom Depth     DEPTH     Float    Src Depth is the depth of the source in ft. or m.
    %FFID        SinGeom FFID      FFID      Integer  FFID is the field file ID. This is usually the tape file number assigned to each shot at time of recording. Therefore, these numbers usually reflect the chronological order of the shots. FFID is normally obtained from the field observer’s notes.
    %StrmrAzmth  SinGeom Azimuth   none      Float    Strmr Azmth is the direction measured relative to North of the line extending from the stern of the vessel towards the streamer tail buoy. Value entered should be the clockwise bearing in degrees from North (0 degrees).
    %Time        SinGeom Time      none      Integer  HHMMSS - Time is the time of shot.
    %Date        SinGeom Date      none      Integer  Julian - Date is the date of shot.
    %SrcPattern  SinGeom Pattern   none      Integer  Src Pattern is the source pattern number corresponding to values in the Src Pattern column in the Patterns spreadsheet. Source patterns are defined in the Patterns spreadsheet.
    %Static      SinGeom Userstat  none      Float    Static is a user defined static in ms. If pre-existing shot statics are going to be applied to a dataset, they can be entered in this column. For example, shot time delays due to time break errors during recording could be entered in this column. These statics can later be applied with Apply User Statics.
    %======= End ProMax's Sin geometry table description ==========================================================================
    try nn=gKey{2};catch,nn=input('SurveyLines Numbers=');end;
    if numel(gKey)>2,SrcPattern0=gKey{3};disp(['SrcPattern0=' num2str(gKey{3})]);else SrcPattern0=1;end; %Set SrcPattern
    if numel(gKey)>3,Static0=gKey{4};disp(['Static0=' num2str(gKey{4})]);else Static0=0;end; %Set Static0
    for n=nn,
        StrmrAzmth=PR{n}.Z.StHead;StrmrAzmth(StrmrAzmth<0)=StrmrAzmth(StrmrAzmth<0)+360;
        TimeHMS=round(gNavTime2Time('Sd2HMS',PR{n}.Z.GpsTime));
        [~,DateJul]=gNavTime2Time('Dx2YDy',PR{n}.Z.GpsDay);
        SrcPattern=repmat(SrcPattern0,1,PR{n}.LLog.ShotNum);
        Static=repmat(Static0,1,PR{n}.LLog.ShotNum);
        PmOut=[PR{n}.Z.Fix;PR{n}.Z.Fix;PR{n}.Z.GunGpsE;PR{n}.Z.GunGpsN;PR{n}.Z.GunSeaDepth;PR{n}.Z.GunDepth;PR{n}.Z.ShotID;StrmrAzmth;TimeHMS;DateJul;SrcPattern;Static];
        [fId,mes]=fopen([SU.RootDir '\' PR{n}.LLog.LName '\calc_' PR{n}.LLog.LName '_GunPromax.txt'],'w');if ~isempty(mes),error(mes);end;
        fprintf(fId,'%6d %6d %10.1f %11.1f %8.1f %5.1f %7d %5.1f %6d %3d %2d %4.1f\r\n',PmOut);fclose(fId);
        PR{n}.ProcLog=[PR{n}.ProcLog 'OutPromaxGunGeom# SrcPattern0=' num2str(SrcPattern0) '; Static0=' num2str(Static0) 10];
    end;
    clearvars nn n SrcPattern0 Static0 StrmrAzmth TimeHMS DateJul SrcPattern Static PmOut fId mes;
end;
if strcmp(gKey{1},'OutP190Geom'), %create file P190 for Gun // {'OutP190Geom','Gun',2018,1,10,'S'};gUhrGeoEelGeomR02;{'OutP190Geom','Cmp1',2018,1,10,'C'};gUhrGeoEelGeomR02;
    %======= Begin P190 fields description ========================================================================
    %P190Head.HType - Record Identifier 'H' + Header Record Type + Header Record Type Modifier (A1+I2+I2);
    %P190Head.HDescript - Parameter Description (A27);
    %P190Head.HData - Parameter Data (A48);
    %Head.RecordId - Char; Record identification (COL1; A1): 'S'=Centre of Source; 'G'=Receiver Group; 'Q'=Bin Centre; 'A'=Antenna Position; 'T'=Tailbuoy Position; 'C'=Common Mid Point; 'V'=Vessel Reference Point; 'E'=Echo Sounder; 'Z'=Other, defined in H0800.
    %Head.LineName - Char; Line name (left justified, including reshoot code) (COL2-13 A12);
    %Head.Spare1 - Char*3; Spare (COL14-16 A3); if nonexist, then create values '   ';
    %Head.VesselId - Char; Vessel ID (COL17 A1);
    %Head.SourceId - Char; Source ID (COL18 A1);
    %Head.OtherId - Char; Tailbuoy / Other ID (COL19 A1);
    %Head.PointNum - Float; Point number (right justified) (COL20-25 A6); if nonexist, then create values from 1 to N;
    %Head.GpsLat - Float; Latitude in d.m.s. N/S (COL26-35 2(I2), F5.2, A1) or in grads N/S (COL26-35 F9.6, A1);
    %Head.GpsLon - Float; Longitude in d.m.s. E/W (COL36-46 I3, I2, F5.2, A1) or in grads E/W (COL36-46 F10.6, A1);
    %Head.GpsE - Float; Map grid Easting in metres (COL47-55 F9.1) or in non metric (COL47-55 I9);
    %Head.GpsN - Float; Map grid Northing in metres (COL56-64 F9.1) or in non metric (COL56-64 I9);
    %Head.WaterDepth* - Float; Water depth defined datum defined in H1700 (COL65-70 F6.1) or elevation in non metric (COL65-70 I6); if nonexist, then create values '   0.0';
    %Head.GpsDay - Float; Date (date number 1 corresponds to Jan-1-000; the year 0000 is merely a reference point); calculated using Julian Day of year (COL71-73 I3);
    %Head.GpsTime - Float; Second in day; calculated using time h.m.s., GMT or as stated in H1000 (COL74-79 3I2);
    %Head.Spare2 - Char; Spare (COL80 1X); if nonexist, then create values ' '.
    %======= End P190 fields description ==========================================================================
    try fnpt=gKey{2};catch,fnpt=input('CoordinateFieldPrefix=');end; try P190HeadYear=gKey{3};catch,P190HeadYear=input('P190HeadYear=');end; try nn=gKey{4};catch,nn=input('SurveyLines Numbers=');end;
    if numel(gKey)>4,CatStep=gKey{5};disp(['CatStep=' num2str(gKey{5})]);else CatStep=1;end; %Catalogue points step for file
    if numel(gKey)>5,RecordId=gKey{6};disp(['RecordId=' gKey{6}]);else RecordId='S';end; %Set RecordId for P1/90
    if numel(gKey)>6,Spare1=gKey{7};disp(['Spare1=' gKey{7}]);else Spare1=('   ');end; %Set Spare1 for P1/90
    if numel(gKey)>7,VesselId=gKey{8};disp(['VesselId=' gKey{8}]);else VesselId='1';end; %Set VesselId for P1/90
    if numel(gKey)>8,SourceId=gKey{9};disp(['SourceId=' gKey{9}]);else SourceId='1';end; %Set SourceId for P1/90
    if numel(gKey)>9,OtherId=gKey{10};disp(['OtherId=' gKey{10}]);else OtherId='1';end; %Set OtherId for P1/90
    if numel(gKey)>10,Spare2=gKey{11};disp(['Spare2=' gKey{11}]);else Spare2=' ';end; %Set Spare2 for P1/90
    if numel(gKey)>11,WCode=gKey{12};disp(['WCode=' gKey{12}]);else WCode='NNMMM';end; %Set WCode for P1/90
    for n=nn,
        [P190Head,~]=gP190Read([SU.RootDir '\' PR{n}.LLog.(['NameP190' fnpt 'Head'])],P190HeadYear);P190Head.fNameN=PR{n}.LLog.LName;
        Head.RecordId=RecordId;Head.LineName=PR{n}.LLog.LName';Head.Spare1=Spare1';Head.VesselId=VesselId;Head.SourceId=SourceId;Head.OtherId=OtherId;
        Head.PointNum=PR{n}.Z.Fix;Head.GpsE=PR{n}.Z.([fnpt 'GpsE']);Head.GpsN=PR{n}.Z.([fnpt 'GpsN']);
        [Head.GpsLat,Head.GpsLon,~]=gNavCoord2Coord(Head.GpsE,Head.GpsN,[],SU.NavS,SU.NavP,[SU.NavP.TargCode SU.NavS.TargCode]);
        Head.WaterDepth=PR{n}.Z.([fnpt 'SeaDepth']);Head.GpsDay=PR{n}.Z.GpsDay;Head.GpsTime=PR{n}.Z.GpsTime;Head.Spare2=Spare2;
        gP190Write([SU.RootDir '\' PR{n}.LLog.LName '\calc_' PR{n}.LLog.LName '_'  fnpt '.190'],P190Head,Head,1,WCode);
        PL=gP1902PL(Head,'.-b');PL(n).PLName=[PR{n}.LLog.LName '_'  fnpt];gMapPL2AcadExport([SU.RootDir '\' PR{n}.LLog.LName '\calc_' PR{n}.LLog.LName '_' fnpt '.scr'],PL,[3 0],[0.3 1],[1 0 500 2],2,1,1); %gMapPL2AcadExport(fName,PL,PLNameAttr=[Size Angle],CircleAttr=[Radius DrawModulio],KPNameAttr=[Size Angle DrawModulio KPDigitNum],DigitNum,PointsStep,flLayers), where
        gP1902Cat(P190Head,Head,[SU.RootDir '\' PR{n}.LLog.LName '\calc_' PR{n}.LLog.LName '_'  fnpt '.ctl'],[PR{n}.LLog.LName '_'  fnpt],CatStep); %Create coordinates catalogue with step CatStep pings
        PR{n}.ProcLog=[PR{n}.ProcLog 'OutP190Geom# CoordinateFieldPrefix=' fnpt '; P190HeadYear=' num2str(P190HeadYear) '; CatStep=' num2str(CatStep) '; RecordId=' RecordId '; Spare1=' Spare1 '; VesselId=' VesselId '; SourceId=' SourceId '; OtherId=' OtherId '; Spare2=' Spare2 '; WCode=' WCode 10];
    end;
    clearvars fnpt P190HeadYear nn CatStep RecordId Spare1 VesselId SourceId OtherId Spare2 WCode n P190Head Head PL
end;
if strcmp(gKey{1},'OutSgyGeom'), %save geometry to Sgy fields // {'OutSgyGeom',1};gUhrGeoEelGeomR02;
    %======= Begin applied Sgy binary header description ===================================================================================
    %Bytes       Type    Name                         Description
    %3201-3204   int32   Job                          Job identification number.
    %3205-3208   int32   Line                         Line number.  For 3-D poststack data, this will typically contain the in-line number.
    %3209-3212   int32   Reel                         Reel number.
    %3213-3214   int16   DataTracePerEnsemble         Number of data traces per ensemble.  Mandatory for prestack data.
    %3215-3216   int16   AuxiliaryTracePerEnsemble    Number of auxiliary traces per ensemble.  Mandatory for prestack data.
    %3217-3218   int16   dt                           Sample interval in microseconds (µs).  Mandatory for all data types.
    %3219-3220   int16   dtOrig                       Sample interval in microseconds  (µs) of original field recording.
    %3221-3222   int16   ns                           Number of samples per data trace.  Mandatory for all types of data. Note: The sample interval and number of samples in the Binary File Header should be for the primary set of seismic data traces in the file.
    %3223-3224   int16   nsOrig                       Number of samples per data trace for original field recording.
    %3225-3226   int16   DataSampleFormat=1           Data sample format code.  Mandatory for all data. 1=4-byte IBM floating-point; 2=4-byte, two's complement integer; 3=2-byte, two's complement integer; 4=4-byte fixed-point with gain (obsolete); 5=4-byte IEEE floating-point; 6=Not currently used; 7=Not currently used; 8=1-byte, two's complement integer.
    %3229-3230   int16   TraceSorting=1               Trace sorting code (i.e. type of ensemble) : -1=Other (should be explained in user Extended Textual File Header stanza; 0=Unknown; 1=As recorded (no sorting); 2=CDP ensemble; 3=Single fold continuous profile; 4=Horizontally stacked; 5=Common source point; 6=Common receiver point; 7=Common offset point; 8=Common mid-point; 9=Common conversion point. Highly recommended for all types of data.
    %3231-3232   int16   VerticalSumCode=1            Vertical sum code: 1 = no sum, 2 = two sum, …, N = M-1 sum  (M = 2 to 32,767).
    %3255-3256   int16   MeasurementSystem=1          Measurement system: Highly recommended for all types of data.  If Location Data stanzas are included in the file, this entry must agree with the Location Data stanza.  If there is a disagreement, the last Location Data stanza is the controlling authority. 1=Meters; 2=Feet.
    %3261-3500   int16   Unassigned1=[2 1 0 0 0 0 0 0 0]
    %#3261-3262  int16   Data type=2                  Exxon: 1=Land2D, 2=Marine2D, 3=Land3D, 4=Marine3D.
    %#3263-3264  int16   Coordinate flag=1            Exxon: 0=No coordinate in trace headers, 1=Coordinates in trace headers.
    %#3265-3266  int16   Statics flag=0               Exxon: 0=No statics in trace headers, 1=Statics in trace headers.
    %3501-3502   int16   SegyFormatRevisionNumber=0   SEG Y Format Revision Number. This is a 16-bit unsigned value with a Q-point between the first and second bytes. Thus for SEG Y Revision 1.0, as defined in this document, this will be recorded as 0100. This field is mandatory for all versions of SEG Y, although a value of zero indicates "traditional" SEG Y conforming to the 1975 standard.
    %3503-3504   int16   FixedLengthTraceFlag=0       Fixed length trace flag. A value of one indicates that all traces in this SEG Y file are guaranteed to have the same sample interval and number of samples, as specified in Textual File Header bytes 3217-3218 and 3221-3222. A value of zero indicates that the length of the traces in the file may vary and the number of samples in bytes 115-116 of the Trace Header must be examined to determine the actual length of each trace. This field is mandatory for all versions of SEG Y, although a value of zero indicates "traditional" SEG Y conforming to the 1975 standard.
    %3505-3506   int16   NumberOfExtTextualHeaders=0  Number of 3200-byte, Extended Textual File Header records following the Binary Header. A value of zero indicates there are no Extended Textual File Header records (i.e. this file has no Extended Textual File Header(s)).  A value of -1 indicates that there are a variable number of Extended Textual File Header records and the end of the Extended Textual File Header is denoted by an ((SEG: EndText)) stanza in the final record.
    %======= End Sgy binary header description =============================================================================================
    %======= Begin applied Sgy trace header description ====================================================================================
    %Bytes   Type    Name                       Description
    %01-04   int32   TraceSequenceLine          Trace sequence number within line — Numbers continue to increase if the same line continues across multiple SEG Y files. Highly recommended for all types of data.
    %09-12   int32   FieldRecord==ShotID        Original field record number. Highly recommended for all types of data.
    %13-16   int32   TraceNumber                Trace number within the original field record. Highly recommended for all types of data.
    %17-20   int32   EnergySourcePoint==Fix     Energy source point number — Used when more than one record occurs at the same effective surface location.  It is recommended that the new entry defined in Trace Header bytes 197-202 be used for shotpoint number.
    %29-30   int16   TraceIdenitifactionCode    Trace identification code: -1=Other; 0=Unknown; 1=Seismic data; 2=Dead; 3=Dummy; 4=Time break; 5=Uphole; 6=Sweep; 7=Timing; 8=Waterbreak; 9=Near-field gun signature; 10=Far-field gun signature; 11=Seismic pressure sensor; 12=Multicomponent seismic sensor - Vertical component; 13=Multicomponent seismic sensor - Cross-line component; 14=Multicomponent seismic sensor - In-line component; 15=Rotated multicomponent seismic sensor - Vertical component; 16=Rotated multicomponent seismic sensor - Transverse component; 17=Rotated multicomponent seismic sensor - Radial component; 18=Vibrator reaction mass; 19=Vibrator baseplate; 20=Vibrator estimated ground force; 21=Vibrator reference; 22=Time-velocity pairs; 23 … N=optional use,  (maximum N = 32,767). Highly recommended for all types of data.
    %31-32   int16   NSummedTraces=1          Automatically set by GeoEel // Number of vertically summed traces yielding this trace.  (1 is one trace, 2 is two summed traces, etc.)
    %33-34   int16   NStackedTraces=1         Automatically set by GeoEel // Number of horizontally stacked traces yielding this trace.  (1 is one trace, 2 is two stacked traces, etc.)
    %35-36   int16   DataUse                    Data use: 1=Production; 2=Test.
    %37-40   int32   offset                     Distance from center of the source point to the center of the receiver group (negative if opposite to direction in which line is shot).
    %49-52   int32   SourceDepth                Source depth below surface (a positive number).
    %61-64   int32   SourceWaterDepth           Water depth at source.
    %65-68   int32   GroupWaterDepth            Water depth at group.
    %69-70   int16   ElevationScalar=-100       Scalar to be applied to all elevations and depths specified in Trace Header bytes 41-68 to give the real value.  Scalar = 1, +10, +100, +1000, or +10,000.  If positive, scalar is used as a multiplier; if negative, scalar is used as a divisor.
    %71-72   int16   SourceGroupScalar=-100     Scalar to be applied to all coordinates specified in Trace Header bytes 73-88 and to bytes Trace Header 181-188 to give the real value.  Scalar = 1, +10, +100, +1000, or +10,000.  If positive, scalar is used as a multiplier; if negative, scalar is used as divisor.
    %73-76   int32   SourceX                    Source coordinate - X.
    %77-80   int32   SourceY                    Source coordinate - Y.
    %81-84   int32   GroupX                     Group coordinate - X.
    %85-88   int32   GroupY                     Group coordinate - Y.
    %89-90   int16   CoordinateUnits=1          Coordinate units: 1=Length (meters or feet); 2=Seconds of arc; 3=Decimal degrees; 4=Degrees, minutes, seconds (DMS). Note: To encode +-DDDMMSS bytes 89-90 equal= +-DDD*10^4 + MM*10^2 + SS with bytes 71-72 set to 1; To encode +-DDDMMSS.ss bytes 89-90 equal= +-DDD*10^6 + MM*10^4 + SS*10^2 with bytes 71-72 set to -100.
    %91-92   int16   WeatheringVelocity         Water or Weathering velocity. (ft/s or m/s as specified in Binary File Header bytes 3255-3256).
    %109-110 int16   DelayRecordingTime         Delay recording time — Time in milliseconds between initiation time of energy source and the time when recording of data samples begins.  In SEG Y rev 0 this entry was intended for deep-water work if data recording does not start at zero time.  The entry can be negative to accommodate negative start times (i.e. data recorded before time zero, presumably as a result of static application to the data trace).  If a non-zero value (negative or positive) is recorded in this entry, a comment to that effect should appear in the Textual File Header.
    %115-116 int16   ns                       Automatically set by GeoEel // Number of samples in this trace. Highly recommended for all types of data.
    %117-118 int16   dt                       Automatically set by GeoEel // Sample interval in microseconds (µs) for this trace. The number of bytes in a trace record must be consistent with the number of samples written in the trace header.  This is important for all recording media; but it is particularly crucial for the correct processing of SEG Y data in disk files (see Appendix C). If the fixed length trace flag in bytes 3503-3504 of the Binary File Header is set, the sample interval and number of samples in every trace in the SEG Y file must be the same as the values recorded in the Binary File Header.  If the fixed length trace flag is not set, the sample interval and number of samples may vary from trace to trace. Highly recommended for all types of data.
    %119-120 int16   GainType=1                 Gain type of field instruments: 1=fixed; 2=binary; 3=floating point; 4 … N=optional use.
    %121-122 int16   InstrumentGainConstant     Instrument gain constant (dB).
    %123-124 int16   InstrumentInitialGain      Instrument early or initial gain (dB).
    %157-158 int16   YearDataRecorded           Year data recorded — The 1975 standard is unclear as to whether this should be recorded as a 2-digit or a 4-digit year and both have been used.  For SEG Y revisions beyond rev 0, the year should be recorded as the complete 4-digit Gregorian calendar year (i.e. the year 2001 should be recorded as 2001 (7D1)).
    %159-160 int16   DayOfYear                  Day of year (Julian day for GMT and UTC time basis).
    %161-162 int16   HourOfDay                  Hour of day (24 hour clock).
    %163-164 int16   MinuteOfHour               Minute of hour.
    %165-166 int16   SecondOfMinute             Second of minute.
    %167-168 int16   TimeBaseCode=4             Time basis code: 1=Local; 2=GMT (Greenwich Mean Time); 3=Other, should be explained in a user defined stanza in the Extended Textual File Header; 4=UTC (Coordinated Universal Time).
    %189-192 int32   Inline3D                   !!! used as microsecond. Usually for 3-D poststack data, this field should be used for the in-line number. If one in-line per SEG Y file is being recorded, this value should be the same for all traces in the file and the same value will be recorded in bytes 3205-3208 of the Binary File Header.
    %193-196 int32   Crossline3D                !!! used as Receiver/Cable depth below surface. Usually for 3-D poststack data, this field should be used for the cross-line number. This will typically be the same value as the ensemble (CDP) number in Trace Header bytes 21-24, but this does not have to be the case.
    %225-228 int32   SourceMeasurementMantissa  !!! used as AdditionalInformation mantissa. Usually Source Measurement — Describes the source effort used to generate the trace. The measurement can be simple, qualitative measurements such as the total weight of explosive used or the peak air gun pressure or the number of vibrators times the sweep duration.  Although these simple measurements are acceptable, it is preferable to use true measurement units of energy or work. The constant is encoded as a four-byte, two's complement integer (bytes 225-228) which is the mantissa and a two-byte, two's complement integer (bytes 209-230) which is the power of ten exponent (i.e. Bytes 225-228 * 10**Bytes 229-230).
    %229-230 int16   SourceMeasurementExponent  !!! used as AdditionalInformation exponent. Usually two-byte, two's complement integer (bytes 209-230) which is the power of ten exponent (i.e. Bytes 225-228 * 10**Bytes 229-230).
    %231-232 int16   SourceMeasurementUnit=-1  Source Measurement Unit — The unit used for the Source Measurement, Trace header bytes 225-230. -1 = Other (should be described in Source Measurement Unit stanza, page 39); 0=Unknown; 1=Joule(J); 2=Kilowatt(kW); 3=Pascal(Pa); 4=Bar(Bar); 4=Bar-meter(Bar-m); 5=Newton(N); 6=Kilograms(kg).
    %AdditionalInformation (Bytes 225-228 * 10**Bytes 229-230) write to one or more Channels. There are follow information:
    %1-vessel heading; 2-GunTowPointX; 3-GunTowPointY; 4-Manifold pressure in psi; 5-Atmosferic pressure in psi; 6-cluster number; 7-cluster's guns volume; 8- guns error in microsecond;
    %9- StreamerTowPointX; 10- StreamerTowPointY; 11- Streamer's Buoy X; 12- Streamer's Buoy Y; 13- Streamer's heading (towpoint-to-tail) in deg; 14- Streamer's tencion; 15- Streamer's depth by repeater in m;
    %16- Birds depth in m; 17- Birds heading in deg; 18- Birds wing angle; 19- Birds temperature.
    %======= End Sgy trace header description ==============================================================================================
    try nn=gKey{2};catch,nn=input('Survey Line Number=');end;
    for n=nn,
        SgyHead=PR{n}.SgyHead;
        %===Sgy Binary Header Correct
        if SgyHead.Endian=='l', warning('Segy byte order was corrected to Big Endian!');SgyHead.Endian='b';end;
        SgyHead.Job=SU.Job; %Job identification number.
        tmp=(uint8(PR{n}.LLog.LName)<58)&(uint8(PR{n}.LLog.LName)>47);SgyHead.Line=str2double(PR{n}.LLog.LName(tmp)); %Line number.  For 3-D poststack data, this will typically contain the in-line number. // Exxon format: The Line Number in bytes 3205-3208 (32-bit integer) shall be formed from the alpha-numeric line name written to card image C2 of the EBCDIC volume header by removing the alpha characters from the name and concatenating the remaining numeric characters to give an integer number.
        SgyHead.Reel=str2double(PR{n}.LLog.LName(SU.SgyReelPos));%Reel number (sequence).
        SgyHead.DataTracePerEnsemble=PR{n}.LLog.StChNum; %Number of data traces per ensemble.  Mandatory for prestack data.
        SgyHead.AuxiliaryTracePerEnsemble=PR{n}.LLog.StAuxNum; %Number of auxiliary traces per ensemble.  Mandatory for prestack data.
        if SgyHead.dt==0,warning('Sample interval for binary header is not set. Need check!');end; %Sample interval in microseconds (µs).  Mandatory for all data types.
        if SgyHead.dtOrig==0, SgyHead.dtOrig=SgyHead.dt;end; %Sample interval in microseconds  (µs) of original field recording.
        if SgyHead.ns==0,warning('Sample numbers for binary header is not set. Need check!');end; %Number of samples per data trace.  Mandatory for all types of data. Note: The sample interval and number of samples in the Binary File Header should be for the primary set of seismic data traces in the file.
        if SgyHead.nsOrig==0, SgyHead.nsOrig=SgyHead.ns;end; %Number of samples per data trace for original field recording.
        if ~isempty(SU.SgyFormatForced),SgyHead.FDataSampleFormat=SU.SgyFormatForced;SgyHead.DataSampleFormat=SU.SgyFormatForced;end; %Data sample format code.  Mandatory for all data. 1=4-byte IBM floating-point; 2=4-byte, two's complement integer; 3=2-byte, two's complement integer; 4=4-byte fixed-point with gain (obsolete); 5=4-byte IEEE floating-point; 6=Not currently used; 7=Not currently used; 8=1-byte, two's complement integer.
        SgyHead.TraceSorting=1; %Trace sorting code (i.e. type of ensemble) : -1=Other (should be explained in user Extended Textual File Header stanza; 0=Unknown; 1=As recorded (no sorting); 2=CDP ensemble; 3=Single fold continuous profile; 4=Horizontally stacked; 5=Common source point; 6=Common receiver point; 7=Common offset point; 8=Common mid-point; 9=Common conversion point. Highly recommended for all types of data.
        SgyHead.VerticalSumCode=1; %Vertical sum code: 1 = no sum, 2 = two sum, …, N = M-1 sum  (M = 2 to 32,767).
        SgyHead.MeasurementSystem=1; %Measurement system: Highly recommended for all types of data.  If Location Data stanzas are included in the file, this entry must agree with the Location Data stanza.  If there is a disagreement, the last Location Data stanza is the controlling authority. 1=Meters; 2=Feet.
        tmp=[0 2 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0];SgyHead.Unassigned1(1:numel(tmp))=tmp; %3261-3500 is Unassigned1 //Exxon extended from 3261 to 3278: 3261-3262 is Data type; 3263-3264 is Coordinate flag; 3265-3266 is Statics flag.
        if SgyHead.SegyFormatRevisionNumber~=0, warning('SegyFormatRevisionNumber was corrected to zero. Need check!');SgyHead.SegyFormatRevisionNumber=0;end; %SEG Y Format Revision Number. This is a 16-bit unsigned value with a Q-point between the first and second bytes. Thus for SEG Y Revision 1.0, as defined in this document, this will be recorded as 0100. This field is mandatory for all versions of SEG Y, although a value of zero indicates "traditional" SEG Y conforming to the 1975 standard.
        SgyHead.FixedLengthTraceFlag=0; %Fixed length trace flag. A value of one indicates that all traces in this SEG Y file are guaranteed to have the same sample interval and number of samples, as specified in Textual File Header bytes 3217-3218 and 3221-3222. A value of zero indicates that the length of the traces in the file may vary and the number of samples in bytes 115-116 of the Trace Header must be examined to determine the actual length of each trace. This field is mandatory for all versions of SEG Y, although a value of zero indicates "traditional" SEG Y conforming to the 1975 standard.
        SgyHead.NumberOfExtTextualHeaders=0; %Number of 3200-byte, Extended Textual File Header records following the Binary Header. A value of zero indicates there are no Extended Textual File Header records (i.e. this file has no Extended Textual File Header(s)).  A value of -1 indicates that there are a variable number of Extended Textual File Header records and the end of the Extended Textual File Header is denoted by an ((SEG: EndText)) stanza in the final record.
        %===Sgy Trace Headers Correct
        Head=PR{n}.Head;
        L1=find(Head.FieldRecord==PR{n}.Z.ShotID(1),1);L2=find(Head.FieldRecord==PR{n}.Z.ShotID(end),1)+PR{n}.LLog.StAllNum-1; %(L1:L2) is Traces, another is Noise-records
        if ~all(Head.FieldRecord(L1:PR{n}.LLog.StAllNum:L2)==PR{n}.Z.ShotID),error('ShotID''s for Sgy and StationLog are different.');end;
        Head.TraceSequenceLine=1:numel(Head.TraceSequenceLine);
        Head.WeatheringVelocity(:)=PR{n}.LLog.WaterVelocity;
        Head.DataUse(1:L1-1)=2;Head.DataUse(L1:L2)=1;Head.DataUse(L2+1:end)=2; %Data use: 1=Production; 2=Test.
        Head.GainType(:)=1; %Gain type of field instruments: 1=fixed; 2=binary; 3=floating point; 4 … N=optional use.
        if any(Head.DelayRecordingTime~=Head.DelayRecordingTime(1)),warning('DelayRecordingTime is not equal for all traces. Need check!');end; if Head.DelayRecordingTime(1)~=0,warning('DelayRecordingTime is not zero. Need check!');end;
        if any(Head.ns~=SgyHead.ns),warning('Sample numbers is not equal for header and all traces. Need check!');end;
        if any(Head.dt~=SgyHead.dt),warning('Sample interval is not equal for header and all traces. Need check!');end;
        %Set Gun
        Head.EnergySourcePoint(:)=0;Head.EnergySourcePoint(L1:L2)=repmat(PR{n}.Z.Fix,PR{n}.LLog.StAllNum,1); %Fix number to seismic and aux channels
        Head.CoordinateUnits(:)=1; %coordinates in meters
        Head.SourceGroupScalar(:)=-100;sc=abs(Head.SourceGroupScalar(1)).^sign(Head.SourceGroupScalar(1)); %scale 0.01
        Head.SourceX(:)=0;Head.SourceX(L1:L2)=repmat(PR{n}.Z.GunGpsE./sc,PR{n}.LLog.StAllNum,1); %scaled SourceX
        Head.SourceY(:)=0;Head.SourceY(L1:L2)=repmat(PR{n}.Z.GunGpsN./sc,PR{n}.LLog.StAllNum,1); %scaled SourceY
        Head.ElevationScalar(:)=-100;sce=abs(Head.ElevationScalar(1)).^sign(Head.ElevationScalar(1)); %elevation scale 0.01
        Head.SourceDepth(:)=0;Head.SourceDepth(L1:L2)=repmat(PR{n}.Z.GunDepth./sce,PR{n}.LLog.StAllNum,1); %Gun Depth to seismic and aux channels
        Head.SourceWaterDepth(:)=0;Head.SourceWaterDepth(L1:L2)=repmat(PR{n}.Z.GunSeaDepth./sce,PR{n}.LLog.StAllNum,1); %Gun Sea Depth to seismic and aux channels
        %Incapsulate Gun&Birds&Streamer to SourceMeasurementMantissa
        Head.SourceMeasurementMantissa(:)=0;Head.SourceMeasurementExponent(:)=0;Head.SourceMeasurementUnit(:)=-1; %SourceMeasurementUnit==Other
        tn2=0;
        tn=0+tn2;Head.SourceMeasurementMantissa(L1+tn:PR{n}.LLog.StAllNum:L2)=PR{n}.Z.VessHead.*1000; Head.SourceMeasurementExponent(L1+tn:PR{n}.LLog.StAllNum:L2)=-3; %Head of vessel
        tn=1+tn2;Head.SourceMeasurementMantissa(L1+tn:PR{n}.LLog.StAllNum:L2)=PR{n}.Z.GunTpGpsE.*100; Head.SourceMeasurementExponent(L1+tn:PR{n}.LLog.StAllNum:L2)=-2; %Gun towpoint E
        tn=2+tn2;Head.SourceMeasurementMantissa(L1+tn:PR{n}.LLog.StAllNum:L2)=PR{n}.Z.GunTpGpsN.*100; Head.SourceMeasurementExponent(L1+tn:PR{n}.LLog.StAllNum:L2)=-2; %Gun towpoint N
        tn=3+tn2;Head.SourceMeasurementMantissa(L1+tn:PR{n}.LLog.StAllNum:L2)=PR{n}.Z.Manifold.*100; Head.SourceMeasurementExponent(L1+tn:PR{n}.LLog.StAllNum:L2)=-2; %Manifold pressure psi
        tn=4+tn2;Head.SourceMeasurementMantissa(L1+tn:PR{n}.LLog.StAllNum:L2)=PR{n}.Z.Atmosferic.*100; Head.SourceMeasurementExponent(L1+tn:PR{n}.LLog.StAllNum:L2)=-2; %Atmosferic pressure psi
        tn=5+tn2;Head.SourceMeasurementMantissa(L1+tn:PR{n}.LLog.StAllNum:L2)=1; Head.SourceMeasurementExponent(L1+tn:PR{n}.LLog.StAllNum:L2)=0; %Cluster number
        tn=6+tn2;Head.SourceMeasurementMantissa(L1+tn:PR{n}.LLog.StAllNum:L2)=PR{n}.Z.GunVolume.*100; Head.SourceMeasurementExponent(L1+tn:PR{n}.LLog.StAllNum:L2)=-2; %Gun's volume
        tn=7+tn2;tn2=tn2+size(PR{n}.Z.dTGun,1)-1;tmp=PR{n}.Z.dTGun;tmp(isnan(tmp))=999;
        for kn=1:size(PR{n}.Z.dTGun,1);Head.SourceMeasurementMantissa((L1+tn+kn-1):PR{n}.LLog.StAllNum:L2)=tmp(kn,:);Head.SourceMeasurementExponent((L1+tn+kn-1):PR{n}.LLog.StAllNum:L2)=0;end; %Gun1..n error write to Channel-1..n
        tn=8+tn2;Head.SourceMeasurementMantissa(L1+tn:PR{n}.LLog.StAllNum:L2)=PR{n}.Z.StTpGpsE.*100; Head.SourceMeasurementExponent(L1+tn:PR{n}.LLog.StAllNum:L2)=-2; %Streamer towpoint E
        tn=9+tn2;Head.SourceMeasurementMantissa(L1+tn:PR{n}.LLog.StAllNum:L2)=PR{n}.Z.StTpGpsN.*100; Head.SourceMeasurementExponent(L1+tn:PR{n}.LLog.StAllNum:L2)=-2; %Streamer towpoint N
        tn=10+tn2;Head.SourceMeasurementMantissa(L1+tn:PR{n}.LLog.StAllNum:L2)=PR{n}.Z.StBuoyGpsE.*100; Head.SourceMeasurementExponent(L1+tn:PR{n}.LLog.StAllNum:L2)=-2; %Streamer tail E
        tn=11+tn2;Head.SourceMeasurementMantissa(L1+tn:PR{n}.LLog.StAllNum:L2)=PR{n}.Z.StBuoyGpsN.*100; Head.SourceMeasurementExponent(L1+tn:PR{n}.LLog.StAllNum:L2)=-2; %Streamer tail N
        tn=12+tn2;Head.SourceMeasurementMantissa(L1+tn:PR{n}.LLog.StAllNum:L2)=PR{n}.Z.StHead.*100; Head.SourceMeasurementExponent(L1+tn:PR{n}.LLog.StAllNum:L2)=-2; %Streamer heading
        tn=13+tn2;Head.SourceMeasurementMantissa(L1+tn:PR{n}.LLog.StAllNum:L2)=PR{n}.Z.StTens.*100; Head.SourceMeasurementExponent(L1+tn:PR{n}.LLog.StAllNum:L2)=-2; %Streamer tension
        tn=14+tn2;Head.SourceMeasurementMantissa(L1+tn:PR{n}.LLog.StAllNum:L2)=PR{n}.Z.StRDepth.*100; Head.SourceMeasurementExponent(L1+tn:PR{n}.LLog.StAllNum:L2)=-2; %Streamer repeater depth
        tn=15+tn2;tn2=tn2+size(PR{n}.Z.BirdDepth,1)-1;tmp=PR{n}.Z.BirdDepth;tmp(isnan(tmp))=999;
        for kn=1:size(PR{n}.Z.BirdDepth,1);Head.SourceMeasurementMantissa((L1+tn+kn-1):PR{n}.LLog.StAllNum:L2)=tmp(kn,:).*100;Head.SourceMeasurementExponent((L1+tn+kn-1):PR{n}.LLog.StAllNum:L2)=-2;end %Birds1..n depth
        tn=16+tn2;tn2=tn2+size(PR{n}.Z.BirdHead,1)-1;tmp=PR{n}.Z.BirdHead;tmp(isnan(tmp))=999;
        for kn=1:size(PR{n}.Z.BirdHead,1);Head.SourceMeasurementMantissa((L1+tn+kn-1):PR{n}.LLog.StAllNum:L2)=tmp(kn,:).*100;Head.SourceMeasurementExponent((L1+tn+kn-1):PR{n}.LLog.StAllNum:L2)=-2;end %Birds1..n heading
        tn=17+tn2;tn2=tn2+size(PR{n}.Z.BirdAngle,1)-1;tmp=PR{n}.Z.BirdAngle;tmp(isnan(tmp))=999;
        for kn=1:size(PR{n}.Z.BirdAngle,1);Head.SourceMeasurementMantissa((L1+tn+kn-1):PR{n}.LLog.StAllNum:L2)=tmp(kn,:).*100;Head.SourceMeasurementExponent((L1+tn+kn-1):PR{n}.LLog.StAllNum:L2)=-2;end %Birds1..n angle
        tn=18+tn2;tn2=tn2+size(PR{n}.Z.BirdTemper,1)-1;tmp=PR{n}.Z.BirdTemper;tmp(isnan(tmp))=999;
        for kn=1:size(PR{n}.Z.BirdTemper,1);Head.SourceMeasurementMantissa((L1+tn+kn-1):PR{n}.LLog.StAllNum:L2)=tmp(kn,:).*100;Head.SourceMeasurementExponent((L1+tn+kn-1):PR{n}.LLog.StAllNum:L2)=-2;end %Birds1..n temper
        %Set Channels
        tmp=repmat(PR{n}.LLog.StAllGain',1,sum(PR{n}.Head.TraceNumber==1));Head.InstrumentGainConstant=tmp(:)';Head.InstrumentInitialGain=tmp(:)'; %Instrument gain constant (dB).
        tmp=[ones(PR{n}.LLog.StChNum,sum(PR{n}.Head.TraceNumber==1));repmat(PR{n}.LLog.StAuxIdenitifactionCode',1,sum(PR{n}.Head.TraceNumber==1))];Head.TraceIdenitifactionCode=tmp(:)';
        AuxTr=zeros(PR{n}.LLog.StAuxNum,PR{n}.LLog.ShotNum);
        tmp=[PR{n}.Z.StGun2Ch;AuxTr];Head.offset(:)=0;Head.offset(L1:L2)=tmp; %channels to gun distance
        tmp=[PR{n}.Z.StChGpsE;AuxTr];Head.GroupX(:)=0;Head.GroupX(L1:L2)=tmp./sc; %scaled GroupX
        tmp=[PR{n}.Z.StChGpsN;AuxTr];Head.GroupY(:)=0;Head.GroupY(L1:L2)=tmp./sc; %scaled GroupX
        tmp=[PR{n}.Z.StChDepth;AuxTr];Head.Crossline3D(:)=0;Head.Crossline3D(L1:L2)=tmp./sce; %channels depth
        tmp=[PR{n}.Z.StChSeaDepth;AuxTr];Head.GroupWaterDepth(:)=0;Head.GroupWaterDepth(L1:L2)=tmp./sce; %channels water depth
        %Set Date and Time
        Head.TimeBaseCode(:)=4;
        [tmp1,tmp2]=gNavTime2Time('Dx2YDy',PR{n}.Z.GpsDay);
        Head.YearDataRecorded(L1:L2)=repmat(tmp1,PR{n}.LLog.StAllNum,1);Head.DayOfYear(L1:L2)=repmat(tmp2,PR{n}.LLog.StAllNum,1); %year, julian day
        [tmp1,tmp2,tmp3]=gNavTime2Time('Sd2HMS3',PR{n}.Z.GpsTime);Head.HourOfDay(L1:L2)=repmat(tmp1,PR{n}.LLog.StAllNum,1);Head.MinuteOfHour(L1:L2)=repmat(tmp2,PR{n}.LLog.StAllNum,1);Head.SecondOfMinute(L1:L2)=repmat(fix(tmp3),PR{n}.LLog.StAllNum,1); %houre, minute, second
        Head.Inline3D(L1:L2)=repmat((tmp3-fix(tmp3)).*1000000,PR{n}.LLog.StAllNum,1); %microsecond
        Data=gDataLoad([SU.RootDir '\' PR{n}.LLog.LName '\' PR{n}.LLog.LName '.sgy_tmp']);
        gSgyWrite(SgyHead,Head,Data,[SU.RootDir '\' PR{n}.LLog.LName '\calc_' PR{n}.LLog.LName '_nav.sgy']);
        PR{n}.ProcLog=[PR{n}.ProcLog 'OutSgyGeom#' 10];
    end;
    clearvars nn n SgyHead tmp L Head L1 L2 sc sce tn2 tn kn AuxTr tmp1 tmp2 tmp3 Data
end;
if strcmp(gKey{1},'SgyTextural'), %Sgy Textural Header Correct // {'SgyTextural',1};gUhrGeoEelGeomR02;
    try nn=gKey{2};catch,nn=input('Survey Line Number=');end;
    StHead=struct('Pos','','Num','','Rec','');
    for n=nn,
        switch PR{n}.LLog.NameSgyTxt,
            case 'rfgf.ru',
                %    12345678901234567890123456789012345678901234567890123456789012345678901234567890
                %             1         2         3         4         5         6         7         8
                THeader=[...
                    'C01 CLIENT                        COMPANY                       CREW NO         '
                    'C02 LINE            AREA                        MAP ID                          '
                    'C03 REEL NO           DAY-START OF REEL     YEAR      OBSERVER                  '
                    'C04 INSTRUMENT: MFG            MODEL            SERIAL NO                       '
                    'C05 DATA TRACES/RECORD        AUXILIARY TRACES/RECORD         CDF FOLD          '
                    'C06 SAMPLE INTERVAL         SAMPLES/TRACE       BITS/IN      BYTES SAMPLE       '
                    'C07 RECORDING FORMAT        FORMAT THIS REEL        MEASUREMENT SYSTEM          '
                    'C08 SAMPLE CODE: FLOATING PT     FIXED PT     FIXED PT-GAIN     CORRELATED      '
                    'C09 GAIN TYPE:  FIXED     BINARY     FLOATING POINT     OTHER                   '
                    'C10 FILTERS: ALIAS     HZ  NOTCH     HZ  BAND     -     HZ  SLOPE    -   DB/OCT '
                    'C11 SOURCE: TYPE            NUMBER/POINT        POINT/INTERVAL                  '
                    'C12      PATTERN:                          LENGTH        WIDTH                  '
                    'C13 SWEEP: START     HZ  END     HZ  LENGTH      MS  CHANNEL NO     TYPE        '
                    'C14 TAPER: START LENGTH      MS   END LENGTH       MS  TYPE                     '
                    'C15 SPREAD: OFFSET        MAX DISTANCE        GROUP INTERVAL                    '
                    'C16 GEOPHONES: PER GROUP     SPACING     FREQUENCY     MFG          MODEL       '
                    'C17      PATTERN:                          LENGTH        WIDTH                  '
                    'C18 TRACES SORTED BY: RECORD     CDP     OTHER                                  '
                    'C19 AMPLITUDE RECOVERY: NONE      SPHERICAL DIV       AGC    OTHER              '
                    'C20 MAP PROJECTION                      ZONE ID       COORDINATE UNITS          '
                    'C21 DEMULTIPLEXING SOFT                                                         '
                    'C22                                                                             '
                    'C23                                                                             '
                    'C24                                                                             '
                    'C25                                                                             '
                    'C26                                                                             '
                    'C27 GRID ORIG 0                                                                 '
                    'C28                                                                             '
                    'C29                                                                             '
                    'C30                                                                             '
                    'C31 I-LINE X-LINE BIN SIZE AND AZIMUTH                                          '
                    'C32 I-LINE X-LINE INCREMENTS                                                    '
                    'C33                                                                             '
                    'C34                                                                             '
                    'C35                                                                             '
                    'C36                                                                             '
                    'C37 SURVEY NAME                               LINE NAME                         '
                    'C38                                                                             '
                    'C39                                                                             '
                    'C40                                                                             '];
                m=0;
                %====C01====+++
                m=m+1;StHead(m)=struct('Pos',012,'Num',22,'Rec','EXXON MOBILE');    %+++ CLIENT \\ Заказчик
                m=m+1;StHead(m)=struct('Pos',043,'Num',21,'Rec','ROMONA');          %COMPANY/CONTRACTOR \\ Компания-исполнитель
                m=m+1;StHead(m)=struct('Pos',073,'Num',08,'Rec','I.KIREEV');        %CREW NO/VESSEL NAME \\ Имя партии, судна
                %====C02====+++
                tmp=PR{n}.LLog.LName; if numel(tmp)>12,tmp(13:end)=[];end;
                m=m+1;StHead(m)=struct('Pos',090,'Num',12,'Rec',tmp);               %LINE \\ Имя профиля или съемки \\ 
                m=m+1;StHead(m)=struct('Pos',106,'Num',25,'Rec','NN45');            %+++ AREA \\ Площадь
                m=m+1;StHead(m)=struct('Pos',136,'Num',25,'Rec','WGS84;6378137;298.2572236'); %+++ MAP ID/INT.DATUM \\ Проекция, эллипсоид
                %====C03====
                m=m+1;StHead(m)=struct('Pos',173,'Num',09,'Rec','');                %REEL NO \\ Номер ленты
                m=m+1;StHead(m)=struct('Pos',201,'Num',03,'Rec',num2str(Head.DayOfYear(1),'%3d')); %DAY-START OF REEL/LINE \\ Дата начала работ
                tmp=gNavTime2Time('Dx2YMD3z',PR{n}.Z.GpsDay(1));
                m=m+1;StHead(m)=struct('Pos',210,'Num',04,'Rec',num2str(tmp(1),'%04d')); %YEAR \\ Год
                m=m+1;StHead(m)=struct('Pos',224,'Num',17,'Rec','');                %OBSERVER \\ Оператор
                %====C04====
                m=m+1;StHead(m)=struct('Pos',261,'Num',10,'Rec','');                %INSTRUMENT:MFG \\ Аппаратура (производитель?)
                m=m+1;StHead(m)=struct('Pos',278,'Num',10,'Rec','');                %MODEL \\ Модель
                m=m+1;StHead(m)=struct('Pos',299,'Num',22,'Rec','');                %SERIAL NO \\ Серийный номер
                %====C05====+++
                m=m+1;StHead(m)=struct('Pos',344,'Num',06,'Rec',num2str(PR{n}.LLog.StChNum,'%04d')); %++++ DATA TRACES/RECORD \\ Количество трасс на запись
                m=m+1;StHead(m)=struct('Pos',375,'Num',07,'Rec',num2str(PR{n}.LLog.StAuxNum,'%02d')); %++++ AUXILIARY TRACES/RECORD \\ Вспомогательные трассы на запись
                m=m+1;StHead(m)=struct('Pos',392,'Num',09,'Rec','');                %CDP FOLD \\ Кратность
                %====C06====+++
                m=m+1;StHead(m)=struct('Pos',421,'Num',06,'Rec',num2str(PR{n}.SgyHead.dt./1000,'%05.3f')); %++++ SAMPLE INTERVAL (mks) \\ Шаг дискретизации в мкс
                m=m+1;StHead(m)=struct('Pos',443,'Num',05,'Rec',num2str(PR{n}.SgyHead.ns,'%05d')); %++++ SAMPLES/TRACE \\ Количество отсчетов на трассу
                m=m+1;StHead(m)=struct('Pos',457,'Num',04,'Rec','');                %BITS/IN \\ Плотность записи Бит/дюйм
                m=m+1;StHead(m)=struct('Pos',475,'Num',06,'Rec','4');               %BYTES/SAMPLE \\ Плотность записи Байт/отсчет
                %====C07====+++
                m=m+1;StHead(m)=struct('Pos',502,'Num',06,'Rec','SEGY1');           %+++ RECORDING FORMAT \\ Формат записи
                m=m+1;StHead(m)=struct('Pos',526,'Num',06,'Rec','NTFS');            %+++ FORMAT THIS REEL \\ Формат магнитного носителя
                m=m+1;StHead(m)=struct('Pos',552,'Num',09,'Rec','');                %MEASUREMENT SYSTEM \\ Система измерений
                %====C08====
                m=m+1;StHead(m)=struct('Pos',590,'Num',03,'Rec','yes');             %SAMLPE CODE: FLOATING PT \\ Формат числа: Плавающая точка
                m=m+1;StHead(m)=struct('Pos',603,'Num',03,'Rec','');                %FIXED PT \\ Фиксированная точка
                m=m+1;StHead(m)=struct('Pos',621,'Num',03,'Rec','');                %FIXED PT-GAIN \\ Фиксированная точка - усиление
                m=m+1;StHead(m)=struct('Pos',636,'Num',05,'Rec','');                %CORRELATED \\ Корреляция
                %====C09====
                m=m+1;StHead(m)=struct('Pos',663,'Num',03,'Rec','');                %GAIN TYPE: FIXED \\ Тип усиления: фиксированный
                m=m+1;StHead(m)=struct('Pos',674,'Num',03,'Rec','');                %BINARY \\ Двоичный
                m=m+1;StHead(m)=struct('Pos',693,'Num',03,'Rec','');                %FLOATING POINT \\ Плавающая точка
                m=m+1;StHead(m)=struct('Pos',703,'Num',08,'Rec','');                %OTHER \\ Другие
                %====C10===
                m=m+1;StHead(m)=struct('Pos',740,'Num',03,'Rec','');                %FILTER: ALIAS \\ Фильтры: альясинг (Гц)
                m=m+1;StHead(m)=struct('Pos',754,'Num',03,'Rec','');                %NOTCH \\ Режекторный (Гц)
                m=m+1;StHead(m)=struct('Pos',767,'Num',03,'Rec','');                %BAND \\ Полоса пропускания низкие частоты (Гц)
                m=m+1;StHead(m)=struct('Pos',773,'Num',03,'Rec','');                %\\ Полоса пропускания высокие частоты (Гц)
                m=m+1;StHead(m)=struct('Pos',787,'Num',02,'Rec','');                %SLOPE \\ Крутизна низкие частоты (Дб/Окт)
                m=m+1;StHead(m)=struct('Pos',792,'Num',02,'Rec','');                %\\ Крутизна высокие частоты (Дб/Окт)
                %====C11====
                m=m+1;StHead(m)=struct('Pos',818,'Num',10,'Rec','');                %SOURCE: TYPE \\ Источник: тип
                m=m+1;StHead(m)=struct('Pos',842,'Num',06,'Rec','');                %NUMBER/POINT \\ Номер/точка
                m=m+1;StHead(m)=struct('Pos',864,'Num',17,'Rec',num2str(PR{n}.LLog.SpInterval,'%06.3f')); %POINT INTERVAL \\ Расстояние ПВ
                %====C12====
                m=m+1;StHead(m)=struct('Pos',898,'Num',25,'Rec','');                %PATTERN: \\ Параметры группирования источника
                m=m+1;StHead(m)=struct('Pos',931,'Num',06,'Rec','');                %LENGTH \\ Длина
                m=m+1;StHead(m)=struct('Pos',944,'Num',17,'Rec','');                %WIDTH \\ Ширина
                %====C13====
                m=m+1;StHead(m)=struct('Pos',978,'Num',03,'Rec','');                %SWEEP: START \\ Параметры свипа низкая частота (Гц)
                m=m+1;StHead(m)=struct('Pos',990,'Num',03,'Rec','');                %END \\ Параметры свипа высокая частота (Гц)
                m=m+1;StHead(m)=struct('Pos',1005,'Num',04,'Rec','');               %LENGTH \\ Длинна (мс)
                m=m+1;StHead(m)=struct('Pos',1025,'Num',03,'Rec','');               %CHANNEL NO \\ Номер канала
                m=m+1;StHead(m)=struct('Pos',1034,'Num',07,'Rec','');               %TYPE \\ Тип свипа
                %====C14====
                m=m+1;StHead(m)=struct('Pos',1065,'Num',05,'Rec','');               %TAPER: START LENGTH \\ Тайперинг начало (мс)
                m=m+1;StHead(m)=struct('Pos',1086,'Num',05,'Rec','');               %END LENGTH \\ конец (мс)
                m=m+1;StHead(m)=struct('Pos',1101,'Num',20,'Rec','');               %TYPE \\ Тип
                %====C15====
                m=m+1;StHead(m)=struct('Pos',1140,'Num',06,'Rec','');               %SPREAD: OFFSET \\ Параметры расстановки:
                m=m+1;StHead(m)=struct('Pos',1160,'Num',06,'Rec','');               %MAX DISTANCE \\ Максимальное удаление
                m=m+1;StHead(m)=struct('Pos',1182,'Num',19,'Rec','');               %GROUP INTERVAL \\ Расстояние между центрами групп
                %====C16====
                m=m+1;StHead(m)=struct('Pos',1226,'Num',03,'Rec','');               %GEOPHONES: PER GROUP \\ Сейсмоприемники: в группе
                m=m+1;StHead(m)=struct('Pos',1238,'Num',03,'Rec','');               %SPACING \\ База
                m=m+1;StHead(m)=struct('Pos',1252,'Num',03,'Rec','');               %FREQUENCY \\ Частота
                m=m+1;StHead(m)=struct('Pos',1260,'Num',03,'Rec','');               %MGF \\ Идентификатор (производитель?)
                m=m+1;StHead(m)=struct('Pos',1275,'Num',06,'Rec','');               %MODEL \\ Модель
                %====C17====
                m=m+1;StHead(m)=struct('Pos',1298,'Num',25,'Rec','');               %PATTERN \\ Параметры группирования
                m=m+1;StHead(m)=struct('Pos',1331,'Num',06,'Rec','');               %LENGTH \\ Длина
                m=m+1;StHead(m)=struct('Pos',1344,'Num',17,'Rec','');               %WIDTH \\ Ширина
                %====C18====
                m=m+1;StHead(m)=struct('Pos',1390,'Num',03,'Rec','');               %TRACES SORTED BY: RECORD \\ Тип сортировки трасс: рекорд(сейсмограмма ОТВ)
                m=m+1;StHead(m)=struct('Pos',1398,'Num',03,'Rec','');               %CDP \\ ОГТ
                m=m+1;StHead(m)=struct('Pos',1408,'Num',33,'Rec','');               %OTHER \\ Другой
                %====C19===
                m=m+1;StHead(m)=struct('Pos',1470,'Num',04,'Rec','');               %AMPLITUDE RECOVERY: NONE \\ Выравнивание амплитуд: отсутствует
                m=m+1;StHead(m)=struct('Pos',1489,'Num',05,'Rec','');               %SPHERICAL DIV \\ Сферическое расхождение
                m=m+1;StHead(m)=struct('Pos',1499,'Num',02,'Rec','');               %AGC \\ Параметры усиления (АРУ?)
                m=m+1;StHead(m)=struct('Pos',1508,'Num',13,'Rec','yes');            %OTHER \\ Другое
                %====C20====
                m=m+1;StHead(m)=struct('Pos',1540,'Num',20,'Rec','UTM;177W;00N;0.9996'); %MAP PROJECTION \\ Проекция
                m=m+1;StHead(m)=struct('Pos',1569,'Num',05,'Rec','01N');            %ZONE ID \\ Меридиан. Зона
                m=m+1;StHead(m)=struct('Pos',1592,'Num',09,'Rec','Metre');          %COORDINATE UNITS \\ Единицы измерения координат
                %====C21====+++
                %====C22====
                %====C23====
                %====C24====
                %====C25====
                %====C26====
                m=m+1;StHead(m)=struct('Pos',1627,'Num',19,'Rec','not applicable'); %+++ CONTRACTOR AND SOFTWARE VERSION USED TO PERFORM THE DEMULTIPLEXING \\ Наименование организации-обработчика и программного обеспечения, применявшегося для демультиплексации
                %====C27====+++
                m=m+1;StHead(m)=struct('Pos',2097,'Num',64,'Rec','500000.00E; 0.00N'); %+++ GRID ORIG 0 \\ Начало координатной сетки
                %====C28====
                %====C29====
                %====C30====
                %====C31====+++
                m=m+1;StHead(m)=struct('Pos',2440,'Num',41,'Rec','not applicable'); %+++ I-LINE X-LINE BIN SIZE AND AZIMUTH \\ Размеры площадки Bin, инлайна и крослайна и азимут.
                %====C32====+++
                m=m+1;StHead(m)=struct('Pos',2510,'Num',09,'Rec','not applicable'); %+++ I-LINE X-LINE INCREMENTS \\ Инкремент инлайна и крослайна.
                %====C33====
                %====C34====
                %====C35====
                %====C36====
                %====C37====
                m=m+1;StHead(m)=struct('Pos',2897,'Num',29,'Rec','MALMA');         %SURVEY NAME \\ Имя площади работ (съемки, месторождения)
                m=m+1;StHead(m)=struct('Pos',2937,'Num',24,'Rec',PR{n}.LLog.LName); %LINE NAME \\ Имя профиля
                %====C38====
                %====C39====+++
                m=m+1;StHead(m)=struct('Pos',3045,'Num',76,'Rec','SEG Y REV1');    %+++ SEG-Y REV \\ Ревизия формата
                %====C40====+++
                m=m+1;StHead(m)=struct('Pos',3125,'Num',76,'Rec','END EBCDIC');    %+++ END EBCDIC \\ Конец заголовка EBCDIC
            case 'GS0064',
                %    12345678901234567890123456789012345678901234567890123456789012345678901234567890
                %             1         2         3         4         5         6         7         8
                THeader=[...
                    'C01 CLIENT                        COMPANY                       CREW NO         '
                    'C02 LINE              AREA                      MAP ID                          '
                    'C03 REEL NO           DAY-START OF REEL     YEAR      OBSERVER                  '
                    'C04 INSTRUMENT: MFG            MODEL            SERIAL NO                       '
                    'C05 DATA TRACES/RECORD        AUXILIARY TRACES/RECORD        CDF FOLD           '
                    'C06 SAMPLE INTERVAL         SAMPLES/TRACE       BITS/IN      BYTES SAMPLE       '
                    'C07 RECORDING FORMAT        FORMAT THIS REEL        MEASUREMENT SYSTEM          '
                    'C08 SAMPLE CODE: FLOATING PT            BYTE ORDER: BIG ENDIAN                  '
                    'C09 GAIN  TYPE: FIXED     BINARY     FLOATING POINT     OTHER                   '
                    'C10 FILTERS: ALIAS     HZ  NOTCH     HZ  BAND     -     HZ  SLOPE    -          '
                    'C11 SOURCE: TYPE           NUMBER/POINT         POINT/INTERVAL                  '
                    'C12     PATTERN:                           LENGTH        WIDTH                  '
                    'C13 SWEEP: START     HZ  END     HZ  LENGTH      MS  CHANNEL NO     TYPE        '
                    'C14 TAPER: START LENGTH       MS  END LENGTH       MS  TYPE                     '
                    'C15 SPREAD: OFFSET        MAX DISTANCE        GROUP INTERVAL                    '
                    'C16 GEOPHONES: PER GROUP     SPACING     FREQUENCY     MFG          MODE        '
                    'C17     PATTERN:                           LENGTH        WIDTH                  '
                    'C18 TRACES SORTED BY: RECORD     CDP     OTHER                                  '
                    'C19 AMPLITUDE RECOVERY: NONE      SPHERICAL DIV       AGC    OTHER              '
                    'C20 MAP PROJECTION                      ZONE ID       COORDINATE UNITS          '
                    'C21 PROCESSING DESCRIPTION:                                                     '
                    'C22                                                                             '
                    'C23 PROCESSING FLOW:                                                            '
                    'C24                                                                             '
                    'C25                                                                             '
                    'C26                                                                             '
                    'C27 SHOTPOINT RANGE: min        - max                                           '
                    'C28 CMP RANGE:       min        - max 2D SP-CMP RELATION: e.g. SP = (CDP/a - b) '
                    'C29 PROCESSING GRID: xy''s & iline/xline''s of cornerpoints                       '
                    'C30                                                                             '
                    'C31                                                                             '
                    'C32                                                                             '
                    'C33                                                                             '
                    'C34                                                                             '
                    'C35                                                                             '
                    'C36                                                                             '
                    'C37                                                                             '
                    'C38                                                                             '
                    'C39                                                                             '
                    'C40                                                                             '];
                m=0;
                %====C01====
                m=m+1;StHead(m)=struct('Pos',0012,'Num',22,'Rec','EXXON MOBILE');   %CLIENT \\ Заказчик
                m=m+1;StHead(m)=struct('Pos',0043,'Num',21,'Rec','ROMONA');         %COMPANY \\ Компания-исполнитель
                m=m+1;StHead(m)=struct('Pos',0073,'Num',08,'Rec','I.KIREEV');       %CREW NO \\ Имя партии, судна
                %====C02==== Exxon: Line (2D) or Survey (3D) name and Area Code; shall not exceed 12 characters in length.
                tmp=PR{n}.LLog.LName; if numel(tmp)>12,tmp(13:end)=[];end;
                m=m+1;StHead(m)=struct('Pos',0090,'Num',12,'Rec',tmp);              %LINE \\ Имя профиля или съемки \\ 
                m=m+1;StHead(m)=struct('Pos',0106,'Num',25,'Rec','54NN');           %AREA \\ Площадь
                m=m+1;StHead(m)=struct('Pos',0136,'Num',25,'Rec','WGS84;6378137;298.2572236'); %MAP ID/INT.DATUM \\ Проекция, эллипсоид
                %====C03====
                m=m+1;StHead(m)=struct('Pos',0173,'Num',09,'Rec','');               %REEL NO \\ Номер ленты
                m=m+1;StHead(m)=struct('Pos',0201,'Num',03,'Rec',num2str(Head.DayOfYear(1),'%3d')); %DAY-START OF LINE \\ Дата начала работ
                tmp=gNavTime2Time('Dx2YMD3z',PR{n}.Z.GpsDay(1));
                m=m+1;StHead(m)=struct('Pos',0210,'Num',04,'Rec',num2str(tmp(1),'%04d')); %YEAR \\ Год
                m=m+1;StHead(m)=struct('Pos',0224,'Num',17,'Rec','');               %OBSERVER \\ Оператор
                %====C04====
                m=m+1;StHead(m)=struct('Pos',0261,'Num',10,'Rec','');               %INSTRUMENT:MFG \\ Аппаратура (производитель?)
                m=m+1;StHead(m)=struct('Pos',0278,'Num',10,'Rec','');               %MODEL \\ Модель
                m=m+1;StHead(m)=struct('Pos',0299,'Num',22,'Rec','');               %SERIAL NO \\ Серийный номер
                %====C05==== Exxon: Data traces per record
                m=m+1;StHead(m)=struct('Pos',0344,'Num',06,'Rec',num2str(PR{n}.LLog.StChNum,'%04d')); %DATA TRACES/RECORD \\ Количество трасс на запись
                m=m+1;StHead(m)=struct('Pos',0375,'Num',07,'Rec',num2str(PR{n}.LLog.StAuxNum,'%02d')); %AUXILIARY TRACES/RECORD \\ Вспомогательные трассы на запись
                m=m+1;StHead(m)=struct('Pos',0392,'Num',09,'Rec','');               %CDP FOLD \\ Кратность
                %====C06==== Exxon: Sample interval
                m=m+1;StHead(m)=struct('Pos',0421,'Num',06,'Rec',num2str(PR{n}.SgyHead.dt./1000,'%05.3f')); %SAMPLE INTERVAL (mks) \\ Шаг дискретизации в мкс
                m=m+1;StHead(m)=struct('Pos',0443,'Num',05,'Rec',num2str(PR{n}.SgyHead.ns,'%05d')); %SAMPLES/TRACE \\ Количество отсчетов на трассу
                m=m+1;StHead(m)=struct('Pos',0457,'Num',04,'Rec','');               %BITS/IN \\ Плотность записи Бит/дюйм
                m=m+1;StHead(m)=struct('Pos',0475,'Num',06,'Rec','');               %BYTES/SAMPLE \\ Плотность записи Байт/отсчет
                %====C07====
                m=m+1;StHead(m)=struct('Pos',0502,'Num',06,'Rec','');               %RECORDING FORMAT \\ Формат записи
                m=m+1;StHead(m)=struct('Pos',0526,'Num',06,'Rec','');               %FORMAT THIS REEL \\ Формат магнитного носителя
                m=m+1;StHead(m)=struct('Pos',0552,'Num',09,'Rec','SI');             %MEASUREMENT SYSTEM \\ Система измерений
                %====C08==== Exxon: Byte order \\ Indicate whether byte order is Big or Little Endian. Note: Big-Endian is the only format acceptable to Buyer.
                m=m+1;StHead(m)=struct('Pos',0590,'Num',03,'Rec','yes');            %SAMLPE CODE: FLOATING PT \\ Формат числа: Плавающая точка
                m=m+1;StHead(m)=struct('Pos',0603,'Num',03,'Rec','');               %FIXED PT \\ Фиксированная точка
                m=m+1;StHead(m)=struct('Pos',0621,'Num',04,'Rec','');               %FIXED PT-GAIN \\ Фиксированная точка - усиление
                m=m+1;StHead(m)=struct('Pos',0636,'Num',05,'Rec','');               %CORRELATED \\ Корреляция
                %====C09====
                m=m+1;StHead(m)=struct('Pos',0663,'Num',03,'Rec','');               %GAIN TYPE: FIXED \\ Тип усиления: фиксированный
                m=m+1;StHead(m)=struct('Pos',0674,'Num',03,'Rec','');               %BINARY \\ Двоичный
                m=m+1;StHead(m)=struct('Pos',0693,'Num',03,'Rec','');               %FLOATING POINT \\ Плавающая точка
                m=m+1;StHead(m)=struct('Pos',0703,'Num',08,'Rec','');               %OTHER \\ Другие
                %====C10====
                m=m+1;StHead(m)=struct('Pos',0740,'Num',03,'Rec','');               %FILTER: ALIAS \\ Фильтры: альясинг (Гц)
                m=m+1;StHead(m)=struct('Pos',0754,'Num',03,'Rec','');               %NOTCH \\ Режекторный (Гц)
                m=m+1;StHead(m)=struct('Pos',0767,'Num',03,'Rec','');               %BAND \\ Полоса пропускания низкие частоты (Гц)
                m=m+1;StHead(m)=struct('Pos',0773,'Num',03,'Rec','');               %\\ Полоса пропускания высокие частоты (Гц)
                m=m+1;StHead(m)=struct('Pos',0787,'Num',02,'Rec','');               %SLOPE \\ Крутизна низкие частоты (Дб/Окт)
                m=m+1;StHead(m)=struct('Pos',0792,'Num',02,'Rec','');               %\\ Крутизна высокие частоты (Дб/Окт)
                %====C11====
                m=m+1;StHead(m)=struct('Pos',0818,'Num',10,'Rec','');               %SOURCE: TYPE \\ Источник: тип
                m=m+1;StHead(m)=struct('Pos',0842,'Num',06,'Rec','');               %NUMBER/POINT \\ Номер/точка
                m=m+1;StHead(m)=struct('Pos',0864,'Num',17,'Rec',num2str(PR{n}.LLog.SpInterval,'%06.3f')); %POINT INTERVAL \\ Расстояние ПВ
                %====C12====
                m=m+1;StHead(m)=struct('Pos',0898,'Num',25,'Rec','');               %PATTERN: \\ Параметры группирования источника
                m=m+1;StHead(m)=struct('Pos',0931,'Num',06,'Rec','');               %LENGTH \\ Длина
                m=m+1;StHead(m)=struct('Pos',0944,'Num',17,'Rec','');               %WIDTH \\ Ширина
                %====C13====
                m=m+1;StHead(m)=struct('Pos',0978,'Num',03,'Rec','');               %SWEEP: START \\ Параметры свипа низкая частота (Гц)
                m=m+1;StHead(m)=struct('Pos',0990,'Num',03,'Rec','');               %END \\ Параметры свипа высокая частота (Гц)
                m=m+1;StHead(m)=struct('Pos',1005,'Num',04,'Rec','');              %LENGTH \\ Длинна (мс)
                m=m+1;StHead(m)=struct('Pos',1025,'Num',03,'Rec','');              %CHANNEL NO \\ Номер канала
                m=m+1;StHead(m)=struct('Pos',1034,'Num',07,'Rec','');              %TYPE \\ Тип свипа
                %====C14====
                m=m+1;StHead(m)=struct('Pos',1065,'Num',05,'Rec','');              %TAPER: START LENGTH \\ Тайперинг начало (мс)
                m=m+1;StHead(m)=struct('Pos',1086,'Num',05,'Rec','');              %END LENGTH \\ конец (мс)
                m=m+1;StHead(m)=struct('Pos',1101,'Num',20,'Rec','');              %TYPE \\ Тип
                %====C15====
                m=m+1;StHead(m)=struct('Pos',1140,'Num',06,'Rec','');              %SPREAD: OFFSET \\ Параметры расстановки:
                m=m+1;StHead(m)=struct('Pos',1160,'Num',06,'Rec','');              %MAX DISTANCE \\ Максимальное удаление
                m=m+1;StHead(m)=struct('Pos',1182,'Num',19,'Rec','');              %GROUP INTERVAL \\ Расстояние между центрами групп
                %====C16====
                m=m+1;StHead(m)=struct('Pos',1226,'Num',03,'Rec','');              %GEOPHONES: PER GROUP \\ Сейсмоприемники: в группе
                m=m+1;StHead(m)=struct('Pos',1238,'Num',03,'Rec','');              %SPACING \\ База
                m=m+1;StHead(m)=struct('Pos',1252,'Num',03,'Rec','');              %FREQUENCY \\ Частота
                m=m+1;StHead(m)=struct('Pos',1260,'Num',03,'Rec','');              %MGF \\ Идентификатор (производитель?)
                m=m+1;StHead(m)=struct('Pos',1275,'Num',06,'Rec','');              %MODEL \\ Модель
                %====C17===
                m=m+1;StHead(m)=struct('Pos',1298,'Num',25,'Rec','');              %PATTERN \\ Параметры группирования
                m=m+1;StHead(m)=struct('Pos',1331,'Num',06,'Rec','');              %LENGTH \\ Длина
                m=m+1;StHead(m)=struct('Pos',1344,'Num',17,'Rec','');              %WIDTH \\ Ширина
                %====C18===
                m=m+1;StHead(m)=struct('Pos',1390,'Num',03,'Rec','');              %TRACES SORTED BY: RECORD \\ Тип сортировки трасс: рекорд(сейсмограмма ОТВ)
                m=m+1;StHead(m)=struct('Pos',1398,'Num',03,'Rec','');              %CDP \\ ОГТ
                m=m+1;StHead(m)=struct('Pos',1408,'Num',33,'Rec','');              %OTHER \\ Другой
                %====C19====
                m=m+1;StHead(m)=struct('Pos',1470,'Num',04,'Rec','');              %AMPLITUDE RECOVERY: NONE \\ Выравнивание амплитуд: отсутствует
                m=m+1;StHead(m)=struct('Pos',1489,'Num',05,'Rec','');              %SPHERICAL DIV \\ Сферическое расхождение
                m=m+1;StHead(m)=struct('Pos',1499,'Num',02,'Rec','');              %AGC \\ Параметры усиления (АРУ?)
                m=m+1;StHead(m)=struct('Pos',1508,'Num',13,'Rec','');              %OTHER \\ Другое
                %====C20====
                m=m+1;StHead(m)=struct('Pos',1540,'Num',20,'Rec','UTM;177W;00N;0.9996'); %MAP PROJECTION \\ Проекция
                m=m+1;StHead(m)=struct('Pos',1569,'Num',05,'Rec','01N');           %ZONE ID \\ Меридиан. Зона
                m=m+1;StHead(m)=struct('Pos',1592,'Num',09,'Rec','Metre');         %COORDINATE UNITS \\ Единицы измерения координат
                %====C21==== Exxon: Processing description \\ Brief processing description of data volume, i.e. Migrated Stack, RAP stack, CDP gathers with Decon.
                %====C22==== Exxon: Processing description \\ Brief processing description (cont. from C21)
                %====C23==== Exxon: Detailed processing description \\ Detailed processing flow, similar to film side label
                %====C24==== Exxon: Detailed processing description \\ Detailed processing flow, similar to film side label
                %====C25==== Exxon: Detailed processing description \\ Detailed processing flow, similar to film side label
                %====C26==== Exxon: Detailed processing description \\ Detailed processing flow, similar to film side label
                %====C27==== Exxon: Shotpoint range/Sub-range for 2D or Inline/crossline range for 3D \\ Sub-ranges are to be used when a single 2D line (pre-stack) or 3D survey spans multiple physical output media.
                m=m+1;StHead(m)=struct('Pos',2107,'Num',05,'Rec',num2str(PR{n}.Z.ShotID(1),'%05d')); %First fix
                m=m+1;StHead(m)=struct('Pos',2119,'Num',05,'Rec',num2str(PR{n}.Z.ShotID(end),'%05d')); %Last fix
                %====C28==== Exxon: CDP range/Sub-range \\ Sub-ranges are to be used when a single 2D line (pre-stack) or 3D survey spans multiple physical output media.
                %====C29==== Exxon: Processing Grid \\ X, Y and inline/crossline numbers of 4 corner points.
                %====C30==== Exxon: Reserved for processing specific information \\ Continuation of C23-C26. Include location and description of any trace header bytes that are not pre-defined.
                %====C31==== Exxon: Reserved for processing specific information \\ Continuation of C23-C26. Include location and description of any trace header bytes that are not pre-defined.
                %====C32==== Exxon: Reserved for processing specific information \\ Continuation of C23-C26. Include location and description of any trace header bytes that are not pre-defined.
                %====C33==== Exxon: Reserved for processing specific information \\ Continuation of C23-C26. Include location and description of any trace header bytes that are not pre-defined.
                %====C34==== Exxon: Reserved for processing specific information \\ Continuation of C23-C26. Include location and description of any trace header bytes that are not pre-defined.
                %====C35==== Exxon: Reserved for processing specific information \\ Continuation of C23-C26. Include location and description of any trace header bytes that are not pre-defined.
                %====C36==== Exxon: Reserved for processing specific information \\ Continuation of C23-C26. Include location and description of any trace header bytes that are not pre-defined.
                %====C37==== Exxon: Reserved for processing specific information \\ Continuation of C23-C26. Include location and description of any trace header bytes that are not pre-defined.
                %====C38==== Exxon: Reserved for processing specific information \\ Continuation of C23-C26. Include location and description of any trace header bytes that are not pre-defined.
                %====C39====
                m=m+1;StHead(m)=struct('Pos',3045,'Num',76,'Rec','SEG Y REV1');    %+++ SEG-Y REV \\ Ревизия формата
                %====C40====
                m=m+1;StHead(m)=struct('Pos',3125,'Num',76,'Rec','END EBCDIC');    %+++ END EBCDIC \\ Конец заголовка EBCDIC
            otherwise, THeader=[SU.RootDir '\' PR{n}.LLog.NameSgyTxt];
        end;
        THeader=gSgyTextCorrect(THeader,StHead);[PR{n}.SgyHead.TextualFileHeader,L]=gSgyTextAscii2Ebcdic(THeader);
        if ~isempty(L), warning(['File -' PR{n}.LLog.NameSgyTxt 'incorrect symbols''s code position:']);disp(L);end;
    end;
    clearvars nn n m StHead tmp L THeader
end;
clear gKey;

%mail@ge0mlib.com 09/11/2020