Skip to content

Commit 8994426

Browse files
committed
Passing all tests
1 parent 162fba0 commit 8994426

File tree

5 files changed

+22
-20
lines changed

5 files changed

+22
-20
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies = [
2626
"psutil>=7.0.0",
2727
"pydantic>=2.11.9",
2828
"rich>=14.1.0",
29-
"segy>=0.5.1",
29+
"segy>=0.5.2",
3030
"tqdm>=4.67.1",
3131
"universal-pathlib>=0.2.6",
3232
"xarray>=2025.9.1",

src/mdio/builder/dataset_builder.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,8 @@ def push_dimension(self, dimension: NamedDimension, position: int, new_dim_chunk
125125
msg = "New dimension chunk size must be greater than 0"
126126
raise ValueError(msg)
127127

128-
print(f"Setting position {position} to size {new_dim_size}")
129-
print(f"Before: {self._dimensions}")
130-
131128
# In-place insertion of the dimension to the existing list of dimensions
132129
self._dimensions.insert(position, dimension)
133-
print(f"After: {self._dimensions}")
134-
135-
# print(f"Setting position {position} to size {new_dim_size}")
136-
# print(self._dimensions)
137-
# self._dimensions[position].size = new_dim_size
138-
# print(self._dimensions)
139130

140131
def propogate_dimension(variable: Variable, position: int, new_dim_chunk_size: int) -> Variable:
141132
"""Propogates the dimension to the variable or coordinate."""
@@ -165,8 +156,6 @@ def propogate_dimension(variable: Variable, position: int, new_dim_chunk_size: i
165156
to_ignore = []
166157
for v in self._dimensions:
167158
to_ignore.append(v.name)
168-
for c in self._coordinates:
169-
to_ignore.append(c.name)
170159

171160
for i in range(len(self._variables)):
172161
var = self._variables[i]

src/mdio/builder/templates/abstract_dataset_template.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ def build_dataset(
6868
Dataset: The constructed dataset
6969
"""
7070
self._dim_sizes = sizes
71-
print(f"Sizes: {self._dim_sizes}")
7271
self._horizontal_coord_unit = horizontal_coord_unit
7372

7473
attributes = self._load_dataset_attributes() or {}
@@ -161,6 +160,10 @@ def _add_dimensions(self) -> None:
161160
for i in range(len(self._dim_names)):
162161
self._builder.add_dimension(self._dim_names[i], self._dim_sizes[i])
163162

163+
for i in range(len(self._dim_sizes) - len(self._dim_names)):
164+
self._builder.add_dimension(f"dim_{i}", self._dim_sizes[len(self._dim_names) + i])
165+
166+
164167
def _add_coordinates(self) -> None:
165168
"""Add custom coordinates.
166169

src/mdio/converters/segy.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,9 @@ def populate_dim_coordinates(
262262
) -> tuple[xr_Dataset, list[str]]:
263263
"""Populate the xarray dataset with dimension coordinate variables."""
264264
for dim in grid.dims:
265-
dataset[dim.name].values[:] = dim.coords
266-
drop_vars_delayed.append(dim.name)
265+
if dim.name in dataset.dims:
266+
dataset[dim.name].values[:] = dim.coords
267+
drop_vars_delayed.append(dim.name)
267268
return dataset, drop_vars_delayed
268269

269270

@@ -508,9 +509,18 @@ def segy_to_mdio( # noqa PLR0913
508509

509510
print(grid)
510511

512+
# When HasDuplicates is True, the grid includes a "trace" dimension that will be
513+
# added to the dataset via a queued transform. We need to exclude it from the sizes
514+
# passed to build_dataset to avoid dimension size mismatches.
515+
dataset_sizes = grid.shape
516+
if "trace" in grid.dim_names:
517+
# Find the trace dimension index and remove it from sizes
518+
trace_idx = grid.dim_names.index("trace")
519+
dataset_sizes = grid.shape[:trace_idx] + grid.shape[trace_idx + 1:]
520+
511521
mdio_ds: Dataset = mdio_template.build_dataset(
512522
name=mdio_template.name,
513-
sizes=grid.shape,
523+
sizes=dataset_sizes,
514524
horizontal_coord_unit=_get_horizontal_coordinate_unit(segy_dimensions),
515525
header_dtype=to_structured_type(segy_spec.trace.header.dtype),
516526
)

uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)