Skip to content

Commit

Permalink
Updates to pass pre-commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
markspec authored and tasansal committed May 18, 2023
1 parent 104dfd5 commit 7db1c77
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 23 deletions.
6 changes: 4 additions & 2 deletions src/mdio/commands/segy.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ def segy_import(
--header-names shot,cable,chan
--header-lengths 4,None,4
--chunk-size 8,2,256,512
--grid-overrides '{"ChannelWrap": True, "ChannelsPerCable": 800, "CalculateCable": True}'
--grid-overrides '{"ChannelWrap": True, "ChannelsPerCable": 800,
"CalculateCable": True}'
\b
If we do have cable numbers in the headers, but channels are still
Expand All @@ -307,7 +308,8 @@ def segy_import(
In cases where the user does not know if the input has unwrapped
channels but desires to store with wrapped channel index use:
--grid-overrides '{"AutoChannelWrap": True, "AutoChannelTraceQC": 1000000}'
--grid-overrides '{"AutoChannelWrap": True,
"AutoChannelTraceQC": 1000000}'
"""
mdio.segy_to_mdio(
segy_path=input_segy_path,
Expand Down
43 changes: 25 additions & 18 deletions src/mdio/segy/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,38 @@


class GeometryTemplateType(Enum):
"""Geometry template types as enum."""

STREAMER_A = 1
STREAMER_B = 2


"""
r"""
STREAMER_A
==========
Cable 1 -> / 1------------------20
Cable 2 -> / 1-----------------20
. / 1-----------------20
Cable 1 -> 1------------------20
Cable 2 -> 1-----------------20
. 1-----------------20
. ⛴ ☆ 1-----------------20
. \ 1-----------------20
Cable 6 -> \ 1-----------------20
Cable 7 -> \ 1-----------------20
. 1-----------------20
Cable 6 -> 1-----------------20
Cable 7 -> 1-----------------20
STREAMER_B
==========
Cable 1 -> / 1------------------20
Cable 2 -> / 21-----------------40
. / 41-----------------60
. ⛴ ☆ - 61-----------------80
. \ 81----------------100
Cable 6 -> \ 101---------------120
Cable 7 -> \ 121---------------140
Cable 1 -> 1------------------20
Cable 2 -> 21-----------------40
. 41-----------------60
. ⛴ ☆ 61-----------------80
. 81----------------100
Cable 6 -> 101---------------120
Cable 7 -> 121---------------140
"""


def get_grid_plan(
def get_grid_plan( # noqa: C901
segy_path: str,
segy_endian: str,
index_bytes: Sequence[int],
Expand Down Expand Up @@ -164,10 +166,15 @@ def qc_index_headers(
index_headers: numpy array with index headers
index_names: Tuple of the names for the index attributes
trace_qc_count: Number of traces to use in QC (default all)
returns:
Returns:
None: if not shot, cable, channel
if shot, cable, channels:
unique_cables: Array with the unique cable ids
cable_chan_min: Array containing the min channel number for each cable,
cable_chan_max: Array containing the max channel number for each cable,
geom_type: Whether type a or b (wrapped or unwrapped chans)
"""

if trace_qc_count is None:
trace_qc_count = index_headers.shape[0]
if trace_qc_count > index_headers.shape[0]:
Expand All @@ -185,7 +192,7 @@ def qc_index_headers(

for idx, cable in enumerate(unique_cables):
my_chan = np.take(
index_headers[0:trace_qc_count, cable_idx],
index_headers[0:trace_qc_count, channel_idx],
np.where(index_headers[0:trace_qc_count, cable_idx] == cable),
)
cable_chan_min[idx] = np.min(my_chan)
Expand Down
10 changes: 7 additions & 3 deletions tests/integration/test_segy_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


def create_4d_segy(file_path, chan_header_type="a", **args):
"""Dummy 4D segy file for use in tests."""
import segyio

fldrs = [2, 3, 5]
Expand All @@ -43,12 +44,13 @@ def create_4d_segy(file_path, chan_header_type="a", **args):
for fldr in fldrs:
if chan_header_type == "b":
tracf = 0
for cable, length in zip(cables, num_traces):
# TODO: Add strict=True and remove noqa when min supported Python is 3.10
for cable, length in zip(cables, num_traces): # noqa: B905
if chan_header_type == "a":
tracf = 0
for i in range(length):
for _i in range(length):
# segyio names and byte locations for headers can be found at:
# https://segyio.readthedocs.io/en/latest/segyio.html#module-segyio.su.words
# https://segyio.readthedocs.io/en/latest/segyio.html
# fldr is byte location 9 - shot
# ep is byte location 17 - shot
# stae is byte location 137 - cable
Expand Down Expand Up @@ -81,6 +83,8 @@ def create_4d_segy(file_path, chan_header_type="a", **args):
)
@pytest.mark.parametrize("chan_header_type", ["a", "b"])
class TestImport4D:
"""Test for 4D segy import with grid overrides."""

def test_import_4d_segy(
self,
tmp_path,
Expand Down

0 comments on commit 7db1c77

Please sign in to comment.