Settings Management

Altay Sansal

May 07, 2024

3 min read

SegyFileSettings Class

The SegyFileSettings is a configuration object for the SegyFile in the environment. It allows you to customize various aspects of SEG-Y file parsing according to your needs and the specifics of your project.

It is composed of various sub-settings isolated by SEG-Y components and various topics.

  • binary: The SegyBinaryHeaderSettings is used for binary header configuration while reading a SEG-Y file.

  • endian: This setting determines the byte order that is being used in the SEG-Y file. The possible options are "big" or "little" based on Endianness. If left as None, the system defaults to Big Endian ("big").

  • revision: This setting is used to specify the SEG-Y revision number. If left as None, the system will automatically use the revision mentioned in the SEG-Y file.

  • use_pandas: This setting is a boolean that decides whether to use pandas for headers or not. Does not apply to trace data. The trace data is always returned as Numpy arrays. The option to use Numpy for headers is currently disabled and will be available at a later release (as of March 2024).

Usage

You initialize an instance of SegyFileSettings like any other Python object, optionally providing initial values for the settings. For example:

 1from segy.config import SegyBinaryHeaderSettings
 2from segy.config import SegyFileSettings
 3from segy.schema import Endianness
 4
 5
 6# Override extended text header count to zero
 7binary_header_settings = SegyBinaryHeaderSettings(
 8    extended_text_header={"value": 0}
 9)
10
11settings = SegyFileSettings(
12    binary=binary_header_settings,
13    endian=Endianness.LITTLE,
14    revision=1,
15)

Then this can be passed to SegyFile directly.

1from segy import SegyFile
2
3file = SegyFile(uri="...", settings=settings)

If no settings are provided to SegyFile, it will take the default values.

Environment Variables

Environment variables that follow the SEGY__VARIABLE__SUBVARIABLE format will be automatically included in your SegyFileSettings instance:

export SEGY__BINARY__SAMPLES_PER_TRACE__VALUE=1001
export SEGY__BINARY__SAMPLE_INTERVAL__KEY="my_custom_key_in_schema"
export SEGY__ENDIAN="big"
export SEGY__REVISION=0.0

The environment variables will override the defaults in the SegyFileSettings configuration, unless user overrides it again within Python.