geosoft.gxpy.segy_reader submodule

Read SEG-Y files into geosoft databases, grids and voxels. :Classes:

SegyReader Reads SEG-Y files and creates Geosoft grids or voxels

New in version 9.9.1.

class DataType(value)[source]

Bases: enum.Enum

An enumeration.

IBM_FLOAT4 = 'IBM_float4'
IEEE_FLOAT4 = 'IEEE_float4'
INT16 = 'int16'
INT32 = 'int32'
INT8 = 'int8'
classmethod from_str(str)[source]
class Endianess(value)[source]

Bases: enum.Enum

An enumeration.

BIG_ENDIAN = False
LITTLE_ENDIAN = True
class FieldMapping(value)[source]

Bases: enum.Enum

An enumeration.

Crossline = 'CROSSLINE'
Inline = 'INLINE'
X = 'X'
Y = 'Y'
class InlineCrosslineSanity(value)[source]

Bases: enum.Enum

An enumeration.

MAYBE_SWAPPED = 1
OK = 0
ONLY_ONE_LINE = 2
UNKNOWN_PROBLEM = 3
class SegyReader(filename, is3d=None, endianess=None)[source]

Bases: object

TODO: The GXSEGYREADER GetTiePoint and SetTiePoint functions are important and don’t have wrappers yet. Also, none of the filtering functionality is implemented.

Reads a SEG-Y file and can generate Geosoft database, grid or voxel files from it.

For many SEG-Y files, the following is all that’s needed to use this class:

.. code::
>>> import geosoft.gxpy.segy_reader as gxsegy
>>> segy = gxsegy.SegyReader('c:/data/example.segy')
>>> segy.export_file(gdb='c:/data/output.gdb')

Unfortunately, some SEG-Y files will require some configuration before they can be read properly. TODO: more documentation once the API is finalized.

__init__(filename, is3d=None, endianess=None)[source]

Initialize the SegyReader object and do a quick initial scan of the SEG-Y file.

Parameters

filename – The name of the SEG-Y file to read

:param is3d True is the SEG-Y file is 3D, False if the file is 2D. If this

parameter is not specified, the reader will attempt to automatically determine if the file is 2D or 3D.

Parameters

endianess – Endianess.LITTLE_ENDIAN or Endianess.BIG_ENDIAN, specifying the endianess (byte order) of the SEG-Y file. Defaults to big- endian which is correct for most SEG-Y files.

The new SegyReader object will read the first part of the SEG-Y file and attempt to determine the correct configuration. Most of the methods for this class are for querying and modifying that configuration.

property binary_header

The contents of the SEG-Y binary header, as a dictionary. Usefull for diagnostic purposes.

export_files(**kwargs)[source]

Export the data in the SEG-Y file to the specified Geosoft files.

What files are output depend on the keyword arguments:

:param gdb:              The filename of the Geosoft database file to export to.

If this parameter is not specified, then no database is output.

Parameters
  • voxel – The filename of the Geosoft voxel file to export to. Only valid for 3D SEG-Y files. If this option is not specified, then no voxel file is output.

  • slice_prefix – The base path and filename for slice grids. If this argument is specified, then at least one of inline_slices, crossline_slices or z_slices` must also be specified.

  • inline_slices – An array-like containing the inline coordinates for slice grids. If this argument is specified then, for each coordinate in the list a geosoft grid file is generated from the slice of the SEG-Y volume with that inline coordinate. The filename will consist of slice_prefix folowed by “_IL???.grd” where ??? is the inline coordinate. Only valid for 3D SEG-Y files.

  • crossline_slices – An array-like containing the crossline coordinates for slice grids. If this argument is specified then, for each coordinate in the list a geosoft grid file is generated from the slice of the SEG-Y volume with that crossline coordinate. The filename will consist of slice_prefix folowed by “_XL???.grd” where ??? is the crossline coordinate. Only valid for 3D SEG-Y files.

  • z_slices – An array-like containing the trace index for slice grids. If this argument is specified then, for coordinate in the list a geosoft grid file is generated by taking the element at that index in the trace data for each trace. The filename will consist of slice_prefix folowed by “_Z???.grd” where ??? is the z coordinate. (The parameter values are array indices (0, for the top of the volumne, 1 for the next slice down, etc.) but the number in the file name is the z-coordinate in physical units (e.g. feet, metres, etc,)) Only valid for 3D SEG-Y files.

property field_configuration
property georeferencing

A geosoft.gxpy.coordinate_system.Coordinate_system object containing the coordinate system for the SEG-Y file and the generated output files.

get_trace_data(trace_number)[source]
get_trace_header(trace_number)[source]
get_trace_length_from_file_header(offset)[source]

Specify that trace_length should be set to the value from the specified byte offset in the binary file header.

get_trace_length_from_trace_header(offset)[source]

Specify that trace_length should be set to the value from the specified byte offset in the binary trace header.

Even when this setting is used, the SEG-Y reader still requires that all traces be the same length.

property is_depth_or_time

The “type” of z-units: either ZType.DEPTH or ZType.TIME.

scan_file()[source]
property text_header

The text header from the SEG-Y file as a string.

This is human-readable text and often usefull for configuring the reader.

property trace_data_type

The data type of the trace data in the SEG-Y file. Specified using one of the constants defined in the DataType Enum.

property trace_length

The number of elements in each trace.

property trace_range

The depth of the top and bottom of the traces.

property trace_sample_interval

The interval between successive values in the trace data. E.g. microseconds or millimetres.

property xy_units

The horizontal units or the SEG_Y

property z_offset

The Z-coordinate of the start (top) of each trace

property z_offset_units

The units used for z_offset

property z_units

The units used for trace_sample_interval

class TraceConfigField(ltb, index)[source]

Bases: object

TODO: Not really finished.

After the SEG-Y is scanned, SegyReader.field_configuration.fields will contain a list of all the trace header fields that contain nonzero values.

The EXPORT_TO_GDB field is used to indicate if the data from this field should be written to the GDB on export. The MAPPING field is used to indicate which fields should be interpreted as inline, crossline, x and y. For 3D SEG-Y files, exactly one field should be set to each of these values. For 2D files, only X and Y apply.

The rest of the fields are read-only. I’ve defined the field names for all of them in __INIT__ but some of them are still missing accessors.

__init__(ltb, index)[source]

Initialize self. See help(type(self)) for accurate signature.

property export_to_gdb
property mapping
property max
property min
property name
class TraceFieldConfiguration(ltb)[source]

Bases: object

__init__(ltb)[source]

Initialize self. See help(type(self)) for accurate signature.

class ZType(value)[source]

Bases: enum.Enum

An enumeration.

DEPTH = 'DEPTH'
TIME = 'TIME'