Skip to content

Commit 9da6616

Browse files
committed
Remove extranious validations
1 parent 8b453c2 commit 9da6616

2 files changed

Lines changed: 2 additions & 48 deletions

File tree

src/mdio/ingestion/segy/coordinates.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,13 @@ def _get_coordinates(
5757
segy_headers: Headers read in from SEG-Y file.
5858
mdio_template: The MDIO template to use for the conversion.
5959
60-
Raises:
61-
ValueError: If a dimension or coordinate name from the MDIO template is not found in
62-
the SEG-Y headers.
63-
6460
Returns:
6561
A tuple containing:
6662
- A list of dimension coordinates (1-D arrays).
6763
- A dict of non-dimension coordinates (str: N-D arrays).
6864
"""
69-
dimensions_coords = []
70-
for dim_name in mdio_template.dimension_names:
71-
if dim_name not in grid.dim_names:
72-
err = f"Dimension '{dim_name}' was not found in SEG-Y dimensions."
73-
raise ValueError(err)
74-
dimensions_coords.append(grid.select_dim(dim_name))
75-
76-
non_dim_coords: dict[str, SegyHeaderArray] = {}
77-
for coord_name in mdio_template.coordinate_names:
78-
if coord_name not in segy_headers.dtype.names:
79-
err = f"Coordinate '{coord_name}' not found in SEG-Y dimensions."
80-
raise ValueError(err)
81-
non_dim_coords[coord_name] = np.array(segy_headers[coord_name])
82-
65+
dimensions_coords = [grid.select_dim(name) for name in mdio_template.dimension_names]
66+
non_dim_coords = {name: np.array(segy_headers[name]) for name in mdio_template.coordinate_names}
8367
return dimensions_coords, non_dim_coords
8468

8569

tests/unit/ingestion/test_segy_coordinates.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -52,36 +52,6 @@ def test_returns_dims_and_coords_in_template_order(self) -> None:
5252
np.testing.assert_array_equal(non_dim["cdp_x"], cdp_x)
5353
np.testing.assert_array_equal(non_dim["cdp_y"], cdp_y)
5454

55-
def test_missing_dimension_raises(self) -> None:
56-
"""A template dim missing from the grid should raise ValueError."""
57-
grid = make_grid(
58-
[
59-
("inline", np.array([1, 2], dtype=np.int32)),
60-
# Missing 'crossline'
61-
("time", np.array([0, 4], dtype=np.int32)),
62-
]
63-
)
64-
headers = make_header_array({"cdp_x": np.zeros(2, dtype=np.float64), "cdp_y": np.zeros(2, dtype=np.float64)})
65-
66-
template = Seismic3DPostStackTemplate(data_domain="time")
67-
68-
with pytest.raises(ValueError, match=r"Dimension 'crossline' was not found"):
69-
_get_coordinates(grid, headers, template)
70-
71-
def test_missing_coordinate_field_raises(self) -> None:
72-
"""A template coord absent from SEG-Y headers should raise ValueError."""
73-
inline = np.array([1, 2], dtype=np.int32)
74-
crossline = np.array([10, 20], dtype=np.int32)
75-
sample = np.array([0, 4], dtype=np.int32)
76-
grid = make_grid([("inline", inline), ("crossline", crossline), ("time", sample)])
77-
# Headers lack 'cdp_y'
78-
headers = make_header_array({"cdp_x": np.zeros(4, dtype=np.float64)})
79-
80-
template = Seismic3DPostStackTemplate(data_domain="time")
81-
82-
with pytest.raises(ValueError, match=r"Coordinate 'cdp_y' not found"):
83-
_get_coordinates(grid, headers, template)
84-
8555

8656
class TestPopulateCoordinates:
8757
"""Tests for the ``_populate_coordinates`` wrapper.

0 commit comments

Comments
 (0)