📄 s_header_int2double.m
字号:
function seismic=s_header_int2double(seismic,header,fpformat)% Convert the bit pattern of integers in a header to floating point numbers % (used in case header values in an SEG-Y file should have been read as % floating-point numbers)%% Background: By default (and following the SEG-Y standard), function % "read_segy_file" reads trace headers as two-byte or 4-byte integers. % However, some programs --- such as ProMAX --- allow users to put floating-point % numbers into the headers. Thus the values of these headers are read% incorrectly. This function converts header values read as integers to the% values they would have had they been read as floating point numbers.% % Written by: E. R.: June 30, 2005% Last updated:%% seismic=s_header_int2double(seismic,header,fpformat)% INPUT% seismic seismic data set% header mnemonic of header to convert% fpformat string with floating-point format (possible values are 'ibm' and 'ieee')% OUTPUT% seismic seismic with converted header% Find header to convertindex=header_index1(seismic,header);temp=seismic.headers(index,:);% Write header to temporary filetempfile=fullfile(tempdir,'tempconversion');fid=fopen(tempfile,'w');fwrite(fid,temp,'int32');fclose(fid);% Read temporary filefid=fopen(tempfile,'r');if strcmpi(fpformat,'ibm') temp=ibm2ieee(fread(fid,inf,'uint'));elseif strcmpi(fpformat,'ieee') temp=fread(fid,inf,'float32');else error('Unknown floating point format')endseismic.headers(index,:)=temp;% Close temporary filefclose(fid);try if ispc [ier,msg]=dos(['del ',tempfile]); else ier=unix(['rm -f ',tempfile]); endcatchend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -