资源简介
该程序可以在MATLAB里直接读取segy数据,更方便 直接调用
代码片段和文件信息
function [dataout sampint numsamps t] = segyinput(sgyfile platform...
traces skip fcode ucode)
% function [dataout sampint numsamps t] = segyinput(sgyfile platform...
% traces skip fcode ucode)
%
% Reads segy data into a structured array format in Matlab workspace.
% The name of the segy file and the platform must both be given
% in single quotes. (Without single quotes you will get an
% “??? Undefined variable ‘unquoted stuff‘.“ error.)
%
% Segyinput also gives you the following options: specify the number of
% traces to read in the format of the data samples and the units of
% measurement used by the survey if desired. The maximum number of traces
% that may be read in or skipped is approximately 8500 if each trace is
% 3000 samples long and the data is stored in a 4 byte format.
%
% Possible platform designations quoted from the FOPEN Matlab help file
% most likely formats first:
%
% ‘b‘ = data written in UNIX format (big endian IEEE floating point)
% ‘l‘ = data written in PC format (little endian IEEE floating point)
% ‘c‘ = Cray floating point (big endian)
% ‘s‘ = 64 bit long data type (big endian IEEE floating point)
% ‘a‘ = 64 bit long data type (little endian IEEE floating point)
% ‘n‘ = defaults to the format the machine running Matlab uses
% ‘d‘ = VAXD floating point with VAX ordering
% ‘g‘ = VAXG floating point with VAX ordering
%
% dataout = a structured array containing four fields: textheader
% binaryheader traceheaders and data
% sampint = sampling interval
% numsamps = number of samples per trace
% t = time vector
% traces = optional argument indicates number of traces to read in;
% otherwise all traces are read in by default
% skip = optional argument; if the number of traces being read in is
% specified this allows a number of traces to be skipped before
% the read in begins (you may have a trace setting without a
% skip setting but not a skip setting without a trace setting)
% fcode = optional argument format code for the data
% options for fcode are:
% 1 = 4 byte floating point
% 2 = 4 byte fixed point
% 3 = 2 byte fixed point
% 4 = fixed point with gain code (not readable with this code)
% 5 = IBM/360 32-bit floats
% ucode = optional argument code for unit used in the seismic survey
% 1 for metres 2 for feet
%
% Written by C. Osborne December 2001 Revised March 2002
% Check the file name for problems.
strlength = max(size(sgyfile));
test1 = sgyfile((strlength - 3):strlength);
if (test1 ~= ‘.sgy‘) | (test1 ~= ‘.seg‘)
disp(‘ ‘)
disp(‘This data does not have a “.sgy“ or “.seg“ extension‘)
disp(‘and may not be segy format data. Do you wish to continue?‘)
intest = input(‘Type y for yes n for no then hit the enter key.\n‘ ‘s‘)
评论
共有 条评论