Skip to content

Commit

Permalink
Add environment variable for SEG-Y text header encoding (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
tasansal authored Sep 25, 2024
1 parent 5abb0f7 commit 44fc0e8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/mdio/segy/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from __future__ import annotations

import os
from importlib import metadata

from segy.alias.segyio import SEGYIO_BIN_FIELD_MAP
Expand All @@ -16,6 +17,7 @@
from segy.schema import HeaderSpec
from segy.schema import ScalarType
from segy.schema import SegySpec
from segy.schema import TextHeaderEncoding
from segy.schema import TextHeaderSpec
from segy.schema import TraceDataSpec
from segy.schema import TraceSpec
Expand Down Expand Up @@ -57,14 +59,16 @@ def get_trace_fields(version: str) -> list[HeaderField]:

def mdio_segy_spec(version: str | None = None) -> SegySpec:
"""Get a SEG-Y encoding spec for MDIO based on version."""
encoding = os.getenv("MDIO__SEGY__TEXT_ENCODING", TextHeaderEncoding.EBCDIC)

version = MDIO_VERSION if version is None else version

binary_fields = get_binary_fields()
trace_fields = get_trace_fields(version)

return SegySpec(
segy_standard=None,
text_header=TextHeaderSpec(), # default EBCDIC
text_header=TextHeaderSpec(encoding=encoding),
binary_header=HeaderSpec(fields=binary_fields, item_size=400, offset=3200),
trace=TraceSpec(
header=HeaderSpec(fields=trace_fields, item_size=240),
Expand Down

0 comments on commit 44fc0e8

Please sign in to comment.