% GetSegyHeader : Reads the segyheader of a SEGY Y formatted file % % Call : % [SegyHeader]=GetSegyHeader(segyid); % % segyid can be a filehandle or a filename % % % (C) 2001-2004 Thomas Mejer Hansen, tmh@gfy.ku.dk/thomas@cultpenguin.com % % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA % function [SegyHeader]=GetSegyHeader(segyid,varargin); mfilename='GetSegyHeader'; SegymatVerbose([mfilename,' : Start'],90); ninput=nargin; % NEXT TWO LINES TO ENUSRE THAT VARARGIN CAN BE PASSED TO FUNCTION if ninput==2 % CALL USING VARARGIN ninput=1+length(varargin{1}); varargin=varargin{1}; else % DIRECT CALL ninput=length(varargin); end % TRANSFORM VARARGING INTO PARAMETERS cargin=1; while (cargin0), SegymatVerbose(['---------------------------------------------------']) SegymatVerbose(['extended textual file headers are implemented ']) SegymatVerbose(['but have not been tested, since I(tmh@gfy.ku.dk) ']) SegymatVerbose(['have had no access to SEGY REV-1 files formatted ']) SegymatVerbose(['like this. Please contact me if you have such a ']) SegymatVerbose(['file to share ']) SegymatVerbose(['---------------------------------------------------']) txt=sprintf('%d Extended Textual File Headers',SegyHeader.NumberOfExtTextualHeaders); SegymatVerbose(txt); nChars=3200*SegyHeader.NumberOfExtTextualHeaders; SegyHeader.ExtTextualHeaders=fread(segyid,nChars,'schar'); % 3600 else SegymatVerbose('NO extended textual file headers'); end SegyHeader.time=[1:1:SegyHeader.ns].*SegyHeader.dt./1e+6; Revision=SegyHeader.SegyFormatRevisionNumber; if Revision>0, Revision=1; end if (SegyHeader.DataSampleFormat>length(SegyHeader.Rev(Revision+1).DataSampleFormat)); SegymatVerbose([mfilename,' : WARNING : YOU HAVE SELECTED (OR THE FILE IS FORMATTED SUCH THAT) A DATASAMPLE FORMAT THAT IS NOT DEFINED. \nREMEBER IEEE IS NOT SPECIFIED IN THE SEGY REV0 STANDARD !']) if (Revision==0) SegymatVerbose([mfilename,' : TRYING TO USE REVISION 1 AS OPPOSED TO REVISION 0']) Revision=1; if (SegyHeader.DataSampleFormat>length(SegyHeader.Rev(Revision+1).DataSampleFormat)); SegymatVerbose([mfilename,' : FATAL ERROR : STILL THE DATASAMPLE FORMAT IS NOT SUPPRTED - EXITING (Report error to tmh@gfy.ku.dk)']) else SegymatVerbose([mfilename,' : APPARENT SUCCES CHANING FROM Revision 0 to 1 - Continuing']) SegyHeader.SegyFormatRevisionNumber=1; % FORCING REVISION TO BE 1 !!! end end end try Format=SegyHeader.Rev(Revision+1).DataSampleFormat(SegyHeader.DataSampleFormat).name; SegymatVerbose([mfilename,' : SegyRevision ',sprintf('%0.4g',Revision),', ',Format,'(',num2str(SegyHeader.DataSampleFormat),')']) catch end if isstr(segyid) fclose(segyid); end SegymatVerbose([mfilename,' : End'],90);