diff --git a/src/mdio/commands/segy.py b/src/mdio/commands/segy.py index 7e4d156c..4b5f707f 100644 --- a/src/mdio/commands/segy.py +++ b/src/mdio/commands/segy.py @@ -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 @@ -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, diff --git a/src/mdio/segy/utilities.py b/src/mdio/segy/utilities.py index 293cb3a7..f6c45596 100644 --- a/src/mdio/segy/utilities.py +++ b/src/mdio/segy/utilities.py @@ -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], @@ -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]: @@ -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) diff --git a/tests/integration/test_segy_import_export.py b/tests/integration/test_segy_import_export.py index 8a928a46..9d6b0525 100644 --- a/tests/integration/test_segy_import_export.py +++ b/tests/integration/test_segy_import_export.py @@ -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] @@ -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 @@ -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,