4. WriteSegy

WriteSegy.m is available to write a Matrix to disk as a SEG-Y file.

WriteSegyStructure.m is available to write a SEG-Y file using a specified set of headers. This is of special use if one wants to load a seismic data set, work with the data in Matlab, and the write the data to disk using the same header values.

4.1. WriteSegy

WriteSegy can be used to save a matrix of data, in Matlab as a file.

4.1.1. Specify values for the SEG-Y Header

Here dt is a scalar and Inline, Crossline, X and Y are arrays of values of size size(data,2)

>> WriteSegy('datacube.segy',data,
    'dt',.004,'Inline3D',Inline,'Crossline3D',Crossline,
    'cdpX',X,'cdpY',Y);

4.1.2. Specify revision

>> WriteSegy('test.segy',seisdata,'revision',0); % SEG-Y Revision 0
>> WriteSegy('test.segy',seisdata,'revision',1); % SEG-Y Revision 1

4.1.3. Specify data sample format

See Section 2.3.3, “Data Sample Format / Revision” for a list of valid and supported values for the datasample format dsf.

>> % Force Revision 1 and IEEE Floating point :
>> WriteSegy('test.segy',seisdata,'dsf',5,'revision',1); 
>>
>> % Force Revision 0 and IBM Floating point :
>> WriteSegy('test.segy',seisdata,'dsf',1,'revision',0); 

4.2. WriteSegyStructure

WriteSegyStructure can be used to write a seismic data to disk given that both SegyHeader, SegyTraceheaders and the data Data are known. They can be obtained using ReadSegy.m like ;

>> [Data,TraceHeaderInfo,SegyTraceHeaders,SegyHeader]=ReadSegy('data.segy');

To write the data using WriteSegyStructure simply do

>> WriteSegyStructure('datacube.segy',SegyHeader,SegyTraceHeaders,Data);

4.2.1. Force revision

>> % Revision 0
>> WriteSegyStructure('datacube.segy',SegyHeader,
                      SegyTraceHeaders,Data,'revision',0);
>> % Revision 1
>> WriteSegyStructure('datacube.segy',SegyHeader,
                      SegyTraceHeaders,Data,'revision',1);

4.2.2. Force Data Sample Format

See Section 2.3.3, “Data Sample Format / Revision” for a list of valid and supported values for the datasample format dsf.

>> % To force the use of SEG Y revision 0 and data sampling format IEEE :
>> WriteSegyStructure('datacube.segy',SegyHeader,
                       SegyTraceHeaders,Data,'revision',1,'dsf',5);