📄 writsegy.m
字号:
function [out] = writsegy(profile,t,x,filename);% function [out] = writesegy(profile,t,x,filename) is a simple program% to write your seismic profile to a segy format file in order for you% to be able to read it easily in VISTA or other black box seismic processing% packages. profile is the data traces to write out must be in time along% the rows and position along the columns. t is the timebase (in seconds)% which is a vector% the same length as a column in profile. x is the position vector (in meters)% with the same length as a row of profile. filename is the filename you want% to write this to. Note that you must include it as 'filename' with the single% quotes when written in the function. Example% [out] = writsegy(traces,time,offset,'mydata.sgy')% I strongly suggest you include the .sgy suffix to the file name.% Note that the data is written out in 4 byte floating point format.% out is just a flag that tells you how many numbers have been written.% Copyright D.R. Schmitt, 1998 - Use this program at your own risk.delt = t(2) - t(1);fid = fopen(filename,'w');count = fwrite(fid,['Geophysical Field School - Student Profile - 1998 '],'char');out = count;junk = zeros(3140,1);count = fwrite(fid,junk,'char'); % Write empty ascii headerout = out + count;[m,n] = size(profile);% Binary headerjunk = [ 1 1 1]; count = fwrite(fid,junk,'long'); %out = out + count;junk = [ n 0 delt*1e6 delt*1e6 m m 1 24 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 1 ];count = fwrite(fid,junk,'short'); out = out + count;junk = zeros(1,170); count = fwrite(fid,junk,'short'); out = out + count;% Data and trace headersfor i = 1:n% This section writes the segy headers information - as you might infer% from this there is a reason I tried to keep it from the class as long as% possible!tracehead = [i i i i i i 0 ];count = fwrite(fid,tracehead,'long'); out = out + count;tracehead = [1 1 2 1]; count = fwrite(fid,tracehead,'short'); out = out + count;tracehead = [0 0 0 0 0 0 0 0 ]; count = fwrite(fid,tracehead,'long'); out = out + count;tracehead = [1 1]; count = fwrite(fid,tracehead,'short'); out = out + count;tracehead = [i 0 i 0]; count = fwrite(fid,tracehead,'long'); out = out + count;tracehead = [ 1 0 0 0 0 0 0 0 0 0 0 0 0 m delt*1e6 1 1 1 1];count = fwrite(fid,tracehead,'short'); out = out + count;tracehead = [ 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1997 300 0 0 0 1 0 1 1 1 0 0];count = fwrite(fid,tracehead,'short'); out = out + count;tracehead = zeros(1,60); count = fwrite(fid,tracehead,'char'); out = out + count;% This line writes the actual trace datacount = fwrite(fid,profile(:,i),'float'); out = out + count;end % ifclose all
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -