Skip to content

Commit 67adce2

Browse files
committed
Merge 'upstream/main' into create_empty
2 parents 94fd3fe + 92bccd8 commit 67adce2

5 files changed

Lines changed: 2 additions & 176 deletions

File tree

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
uses: actions/checkout@v4
3838

3939
- name: Set up Python ${{ matrix.python }}
40-
uses: actions/setup-python@v5
40+
uses: actions/setup-python@v6
4141
with:
4242
python-version: ${{ matrix.python }}
4343

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
aiohttp==3.12.15
22
autodoc-pydantic==2.2.0
3-
furo==2025.7.19
3+
furo==2025.9.25
44
linkify-it-py==2.0.3
55
matplotlib==3.10.6
66
myst-nb==1.3.0

src/mdio/commands/segy.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -257,17 +257,7 @@ def segy_import( # noqa: PLR0913
257257
--header-names shot,cable,chan
258258
--header-types int32,None,int32
259259
--chunk-size 8,2,256,512
260-
--grid-overrides '{"ChannelWrap": True, "ChannelsPerCable": 800,
261-
"CalculateCable": True}'
262260
263-
\b
264-
If we do have cable numbers in the headers, but channels are still sequential (aka.
265-
unwrapped), we can still ingest it like this.
266-
--header-locations 9,213,13
267-
--header-names shot,cable,chan
268-
--header-types int32,int16,int32
269-
--chunk-size 8,2,256,512
270-
--grid-overrides '{"ChannelWrap":True, "ChannelsPerCable": 800}'
271261
\b
272262
No grid overrides are necessary for shot gathers with channel numbers and wrapped channels.
273263

src/mdio/segy/geometry.py

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import numpy as np
1414
from numpy.lib import recfunctions as rfn
1515

16-
from mdio.segy.exceptions import GridOverrideIncompatibleError
1716
from mdio.segy.exceptions import GridOverrideKeysError
1817
from mdio.segy.exceptions import GridOverrideMissingParameterError
1918
from mdio.segy.exceptions import GridOverrideUnknownError
@@ -371,12 +370,6 @@ class DuplicateIndex(GridOverrideCommand):
371370

372371
def validate(self, index_headers: HeaderArray, grid_overrides: dict[str, bool | int]) -> None:
373372
"""Validate if this transform should run on the type of data."""
374-
if "ChannelWrap" in grid_overrides:
375-
raise GridOverrideIncompatibleError(self.name, "ChannelWrap")
376-
377-
if "CalculateCable" in grid_overrides:
378-
raise GridOverrideIncompatibleError(self.name, "CalculateCable")
379-
380373
if self.required_keys is not None:
381374
self.check_required_keys(index_headers)
382375
self.check_required_params(grid_overrides)
@@ -434,12 +427,6 @@ class AutoChannelWrap(GridOverrideCommand):
434427

435428
def validate(self, index_headers: HeaderArray, grid_overrides: dict[str, bool | int]) -> None:
436429
"""Validate if this transform should run on the type of data."""
437-
if "ChannelWrap" in grid_overrides:
438-
raise GridOverrideIncompatibleError(self.name, "ChannelWrap")
439-
440-
if "CalculateCable" in grid_overrides:
441-
raise GridOverrideIncompatibleError(self.name, "CalculateCable")
442-
443430
self.check_required_keys(index_headers)
444431
self.check_required_params(grid_overrides)
445432

@@ -469,58 +456,6 @@ def transform(
469456
return index_headers
470457

471458

472-
class ChannelWrap(GridOverrideCommand):
473-
"""Wrap channels to start from one at cable boundaries."""
474-
475-
required_keys = {"shot_point", "cable", "channel"}
476-
required_parameters = {"ChannelsPerCable"}
477-
478-
def validate(self, index_headers: HeaderArray, grid_overrides: dict[str, bool | int]) -> None:
479-
"""Validate if this transform should run on the type of data."""
480-
if "AutoChannelWrap" in grid_overrides:
481-
raise GridOverrideIncompatibleError(self.name, "AutoCableChannel")
482-
483-
self.check_required_keys(index_headers)
484-
self.check_required_params(grid_overrides)
485-
486-
def transform(self, index_headers: HeaderArray, grid_overrides: dict[str, bool | int]) -> NDArray:
487-
"""Perform the grid transform."""
488-
self.validate(index_headers, grid_overrides)
489-
490-
channels_per_cable = grid_overrides["ChannelsPerCable"]
491-
index_headers["channel"] = (index_headers["channel"] - 1) % channels_per_cable + 1
492-
493-
return index_headers
494-
495-
496-
class CalculateCable(GridOverrideCommand):
497-
"""Calculate cable numbers from unwrapped channels."""
498-
499-
required_keys = {"shot_point", "cable", "channel"}
500-
required_parameters = {"ChannelsPerCable"}
501-
502-
def validate(self, index_headers: HeaderArray, grid_overrides: dict[str, bool | int]) -> None:
503-
"""Validate if this transform should run on the type of data."""
504-
if "AutoChannelWrap" in grid_overrides:
505-
raise GridOverrideIncompatibleError(self.name, "AutoCableChannel")
506-
507-
self.check_required_keys(index_headers)
508-
self.check_required_params(grid_overrides)
509-
510-
def transform(
511-
self,
512-
index_headers: HeaderArray,
513-
grid_overrides: dict[str, bool | int],
514-
) -> NDArray:
515-
"""Perform the grid transform."""
516-
self.validate(index_headers, grid_overrides)
517-
518-
channels_per_cable = grid_overrides["ChannelsPerCable"]
519-
index_headers["cable"] = (index_headers["channel"] - 1) // channels_per_cable + 1
520-
521-
return index_headers
522-
523-
524459
class AutoShotWrap(GridOverrideCommand):
525460
"""Automatically determine ShotGun acquisition type."""
526461

@@ -574,8 +509,6 @@ def __init__(self) -> None:
574509
self.commands = {
575510
"AutoChannelWrap": AutoChannelWrap(),
576511
"AutoShotWrap": AutoShotWrap(),
577-
"CalculateCable": CalculateCable(),
578-
"ChannelWrap": ChannelWrap(),
579512
"NonBinned": NonBinned(),
580513
"HasDuplicates": DuplicateIndex(),
581514
}

tests/unit/test_segy_grid_overrides.py

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
from numpy.testing import assert_array_equal
1515

1616
from mdio.core import Dimension
17-
from mdio.segy.exceptions import GridOverrideIncompatibleError
18-
from mdio.segy.exceptions import GridOverrideMissingParameterError
1917
from mdio.segy.exceptions import GridOverrideUnknownError
2018
from mdio.segy.geometry import GridOverrider
2119

@@ -131,101 +129,6 @@ def test_non_binned(self, mock_streamer_headers: dict[str, npt.NDArray]) -> None
131129
class TestStreamerGridOverrides:
132130
"""Check grid overrides for shot data with streamer acquisition."""
133131

134-
def test_channel_wrap(self, mock_streamer_headers: dict[str, npt.NDArray]) -> None:
135-
"""Test the ChannelWrap command."""
136-
index_names = ("shot_point", "cable", "channel")
137-
grid_overrides = {"ChannelWrap": True, "ChannelsPerCable": len(RECEIVERS)}
138-
139-
new_headers, new_names, new_chunks = run_override(grid_overrides, index_names, mock_streamer_headers)
140-
141-
assert new_names == index_names
142-
assert new_chunks is None
143-
144-
dims = get_dims(new_headers)
145-
146-
assert_array_equal(dims[0].coords, SHOTS)
147-
assert_array_equal(dims[1].coords, CABLES)
148-
assert_array_equal(dims[2].coords, RECEIVERS)
149-
150-
def test_calculate_cable(
151-
self,
152-
mock_streamer_headers: dict[str, npt.NDArray],
153-
) -> None:
154-
"""Test the CalculateCable command."""
155-
index_names = ("shot_point", "cable", "channel")
156-
grid_overrides = {"CalculateCable": True, "ChannelsPerCable": len(RECEIVERS)}
157-
158-
new_headers, new_names, new_chunks = run_override(grid_overrides, index_names, mock_streamer_headers)
159-
160-
assert new_names == index_names
161-
assert new_chunks is None
162-
163-
dims = get_dims(new_headers)
164-
165-
# We need channels because unwrap isn't done here
166-
channels = unique(mock_streamer_headers["channel"])
167-
168-
# We reset the cables to start from 1.
169-
cables = arange(1, len(CABLES) + 1, dtype="uint32")
170-
171-
assert_array_equal(dims[0].coords, SHOTS)
172-
assert_array_equal(dims[1].coords, cables)
173-
assert_array_equal(dims[2].coords, channels)
174-
175-
def test_wrap_and_calc_cable(
176-
self,
177-
mock_streamer_headers: dict[str, npt.NDArray],
178-
) -> None:
179-
"""Test the combined ChannelWrap and CalculateCable commands."""
180-
index_names = ("shot_point", "cable", "channel")
181-
grid_overrides = {
182-
"CalculateCable": True,
183-
"ChannelWrap": True,
184-
"ChannelsPerCable": len(RECEIVERS),
185-
}
186-
187-
new_headers, new_names, new_chunks = run_override(grid_overrides, index_names, mock_streamer_headers)
188-
189-
assert new_names == index_names
190-
assert new_chunks is None
191-
192-
dims = get_dims(new_headers)
193-
# We reset the cables to start from 1.
194-
cables = arange(1, len(CABLES) + 1, dtype="uint32")
195-
196-
assert_array_equal(dims[0].coords, SHOTS)
197-
assert_array_equal(dims[1].coords, cables)
198-
assert_array_equal(dims[2].coords, RECEIVERS)
199-
200-
def test_missing_param(self, mock_streamer_headers: dict[str, npt.NDArray]) -> None:
201-
"""Test missing parameters for the commands."""
202-
index_names = ("shot_point", "cable", "channel")
203-
chunksize = None
204-
overrider = GridOverrider()
205-
206-
with pytest.raises(GridOverrideMissingParameterError):
207-
overrider.run(mock_streamer_headers, index_names, {"ChannelWrap": True}, chunksize)
208-
209-
with pytest.raises(GridOverrideMissingParameterError):
210-
overrider.run(mock_streamer_headers, index_names, {"CalculateCable": True}, chunksize)
211-
212-
def test_incompatible_overrides(
213-
self,
214-
mock_streamer_headers: dict[str, npt.NDArray],
215-
) -> None:
216-
"""Test commands that can't be run together."""
217-
index_names = ("shot_point", "cable", "channel")
218-
chunksize = None
219-
overrider = GridOverrider()
220-
221-
grid_overrides = {"ChannelWrap": True, "AutoChannelWrap": True}
222-
with pytest.raises(GridOverrideIncompatibleError):
223-
overrider.run(mock_streamer_headers, index_names, grid_overrides, chunksize)
224-
225-
grid_overrides = {"CalculateCable": True, "AutoChannelWrap": True}
226-
with pytest.raises(GridOverrideIncompatibleError):
227-
overrider.run(mock_streamer_headers, index_names, grid_overrides, chunksize)
228-
229132
def test_unknown_override(
230133
self,
231134
mock_streamer_headers: dict[str, npt.NDArray],

0 commit comments

Comments
 (0)