Skip to content

Depreciated Xarray Accessor modules

Warning

These methods have been depreciated in favour of a new segysak Xarray accessor. Examples in this documentation have been updated to use the new accessor or consult the reference.

Accessor modules are accessed as namespaces within the Xarray.Dataset objects created by SEGY-SAK. When segysak is imported, all xarray.Dataset objects will contain the .seis and .seisio namespaces.

segysak Xarray accessor modules

SeisIO

to_netcdf(file_path, **kwargs)

Output to netcdf4 with specs for seisnc.

Parameters:

Name Type Description Default
file_path Union[str, PathLike]

The output file path.

required
**kwargs Dict[str, Any]

As per xarray function to_netcdf.

{}

to_segy(segy_file, use_text=True, coord_scalar=None, data_var='data', vert_dimension='samples', write_dead_traces=False, dead_trace_var=None, trace_header_map=None, **dim_kwargs)

Output Xarray Dataset to SEG-Y format.

Parameters:

Name Type Description Default
segy_file Union[str, PathLike]

The output file to write to.

required
use_text bool

Write the text attribute from the dataset to the text header.

True
coord_scalar Union[float, None]

A SEG-Y compatible coordinate scalar.

None
data_var str

The variable name of the trace data in the Dataset.

'data'
vert_dimension str

The vertical (samples) dimension of the data_var.

'samples'
write_dead_traces bool

Write dead traces as zeros to the SEG-Y file.

False
dead_trace_var Union[str, None]

A dataset variable containing boolean values that identifies dead traces on the non-vertical dimension.

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 int

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 trace sort order will be as per the order passed to the function.

{}

Example

Python
ds3d.seisio.to_segy(
    "output_file.segy",
    use_text = True,
    vert_dimension = "samples",
    trace_header_map = {'cdp_x':181, 'cdp_y':185}
    iline = 189,
    xline = 193,
)

to_subsurface()

Convert seismic data to a subsurface StructuredData Object

Raises:

Type Description
err

[description]

NotImplementedError

[description]

Returns:

Type Description

subsurface.structs.base_structures.StructuredData: subsurface struct

SeisGeom

Bases: TemplateAccessor

calc_corner_points()

Calculate the corner points of the geometry or end points of a 2D line.

This puts two properties in the seisnc attrs with the calculated il/xl and cdp_x and cdp_y if available.

Attr

ds.attrs['corner_points'] ds.attrs['corner_points_xy']

fill_cdpna()

Fills NaN cdp locations by fitting known cdp x and y values to the local grid using a planar surface relationshipt.

get_affine_transform()

Calculate the forward iline/xline -> cdp_x, cdp_y Affine transform for Matplotlib using corner point geometry.

Returns:

Type Description

matplotlib.transforms.Affine2D:

Raises:

Type Description
ValueError

If Dataset is not 3D

get_dead_trace_map(scan=None, zeros_as_nan=False)

Scan the vertical axis of a volume to find traces that are all NaN and return an DataArray which maps the all dead traces.

Faster scans can be performed by setting scan to an int or list of int representing horizontal slice indexes to use for the scan.

Parameters:

Name Type Description Default
scan int/list of int

Horizontal indexes to scan. Defaults to None (scan full volume).

None
zeros_as_nan bool

Treat zeros as NaN during scan.

False

Returns:

Type Description

xarray.DataArray: boolean dead trace map.

get_measurement_system()

Return measurement_system if present, else None

grid_rotation()

Calculate the rotation of the grid using the sum under the curve method.

(x2 − x1)(y2 + y1)

Returns a value >0 if the rotation of points along inline is clockwise.

interp_line(cdp_x, cdp_y, extra=None, bin_spacing_hint=10, line_method='slinear', xysel_method='linear')

Select data at x and y coordinates

Parameters:

Name Type Description Default
bin_spacing_hint number

a bin spacing to stay close to, in cdp world units. Default: 10

10
line_method string

valid values for the kind argument in scipy.interpolate.interp1d

'slinear'
xysel_method string

valid values for DataArray.interp

'linear'

Returns:

Type Description

xarray.Dataset: Interpolated traces along the arbitrary line

is_2d()

Returns True if the dataset is 2D peformant else False

is_2dgath()

Returns True if the dataset is 2D peformant and has offset or angle else False

is_3d()

Returns True if the dataset is 3D peformant else False

is_3dgath()

Returns True if the dataset is 3D peformant and has offset or angle else False

is_depth()

Check if seisnc volume is in depth

is_empty()

Check if empty

is_twt()

Check if seisnc volume is in twt

plot_bounds(ax=None)

Plot survey bbounding box to a new or existing axis

Parameters:

Name Type Description Default
ax

(optional) axis to plot to

None

Returns:

Type Description

matplotlib axis used

subsample_dims(**dim_kwargs)

Return a dictionary of subsampled dims suitable for xarray.interp.

This tool halves

Parameters:

Name Type Description Default
dim_kwargs

dimension names as keyword arguments with values of how many times we should divide the dimension by 2.

{}

surface_from_points(points, attr, left=('cdp_x', 'cdp_y'), right=None, key=None, method='linear')

Sample a 2D point set with an attribute (like Z) to the seisnc geometry using interpolation.

Parameters:

Name Type Description Default
points array - like

Nx2 array-like of points with coordinates corresponding to coord1 and coord2.

required
attr (array - like, str)

If str points should be a DataFrame where attr is the column name of the attribute to be interpolated to the seisnc geometry. Else attr is a 1D array of length N.

required
left tuple

Length 2 tuple of coordinate dimensions to interpolate to.

('cdp_x', 'cdp_y')
right tuple

If points is DataFrame right is a length 2 tuple of column keys corresponding to coordinates in argument left.

None
method str

The interpolation method to use for griddata from scipy. Defaults to 'linear'

'linear'

Returns:

Type Description

xr.Dataset: Surface with geometry specified in left.

xysel(cdp_x, cdp_y, method='nearest', sample_dim_name='cdp')

Select data at x and y coordinates

Parameters:

Name Type Description Default
method str

Same as methods for xarray.Dataset.interp

'nearest'
sample_dim_name str

The name to give the output sampling dimension.

'cdp'

Returns:

Type Description

xarray.Dataset: At selected coordinates.

zeros_like()

Create a new dataset with the same attributes and coordinates and dimensions but with data filled by zeros.