SEG-Y via Xarray
Opening SEG-Y Data
SEGY Backend for reading Seismic SEGY files.
            SgyBackendEntrypoint
    
              Bases: BackendEntrypoint
            open_dataset(filename_or_obj, dim_byte_fields, drop_variables=None, head_df=None, extra_byte_fields=None, segyio_kwargs=None)
    Open a SEGY file with a native Xarray front end.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
filename_or_obj | 
            
                  Union[str, PathLike]
             | 
            
               The SEG-Y file/path.  | 
            required | 
dim_byte_fields | 
            
                  Dict[str, int]
             | 
            
               Dimension names and byte location pairs. This should at a minimum have the
keys   | 
            required | 
drop_variables | 
            
                  Union[tuple[str], None]
             | 
            
               Ignored  | 
            
                  None
             | 
          
head_df | 
            
                  Union[DataFrame, None]
             | 
            
               The DataFrame output from   | 
            
                  None
             | 
          
extra_byte_fields | 
            
                  dict
             | 
            
               Additional header information to load into the Dataset. Defaults to None.  | 
            
                  None
             | 
          
segyio_kwargs | 
            
                  Union[dict, None]
             | 
            
               Extra keyword arguments for segyio.open  | 
            
                  None
             | 
          
Returns:
| Type | Description | 
|---|---|
                  Dataset
             | 
            
               Lazy segy file Dataset  | 
          
Example
This backend is registered within Xarray and is accessed automatically when using the
xr.open_dataset method for files with extensions of .segy and .sgy.
Ensure the byte locations are correct for your data.
# 3D data
ds3d = xr.open_dataset(
    segyfile_path,
    dim_byte_fields={'iline':189, 'xline':193},
    extra_byte_fields={'cdp_x':181, 'cdp_y':185},
)
# 2D data
ds2d = xr.open_dataset(
    segyfile_path,
    dim_byte_fields={'cdp':22},
    extra_byte_fields={'cdp_x':181, 'cdp_y':185},
)
Saving SEG-Y Data
            SegyWriter
    Handles the writing of SEG-Y files from compatible Datasets. Usually this
class would not be used and SEGY-SAK users can write SEG-Y file via the seisio accessor.
Example
Writing data with the seisio accessor.
ds.seisio.to_segy()
            to_segy(ds, data_var='data', vert_dimension='samples', dead_trace_var=None, trace_header_map=None, **dim_kwargs)
    Output xarray dataset to SEG-Y format.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
ds | 
            
                  Dataset
             | 
            
               The input dataset  | 
            required | 
data_var | 
            
                  str
             | 
            
               The Dataset variable name for the output volume.  | 
            
                  'data'
             | 
          
vert_dimension | 
            
                  str
             | 
            
               Data dimension to output as vertical trace, defaults to 'samples'.  | 
            
                  'samples'
             | 
          
dead_trace_var | 
            
                  Union[str, None]
             | 
            
               A variable in the Dataset which signifies dead traces.  | 
            
                  None
             | 
          
trace_header_map | 
            
                  Dict[str, int]
             | 
            
               Defaults to None. A dictionary of Dataset variables and byte locations. The variable will be written to the trace headers in the assigned byte location. By default CMP=23, cdp_x=181, cdp_y=185, iline=189, xline=193.  | 
            
                  None
             | 
          
dim_kwargs | 
            
               The dimension/byte location pairs to output dimensions to. The number of dim_kwargs should be equal to the number of dimensions on the output data_array. The sort order will be as per the order passed to the function.  | 
            
                  {}
             | 
          
            write_text_header(text, line_numbers=True)
    Write the text header for the file. The line length limit is 80 characters.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
text | 
            
                  str
             | 
            
               The text to write, new lines have newline character   | 
            required | 
line_numbers | 
            
                  bool
             | 
            
               Add line numbers to the output text header.  | 
            
                  True
             |