Skip to content

Commit 2c39b55

Browse files
committed
Streamline code
1 parent 0cf9667 commit 2c39b55

File tree

1 file changed

+12
-25
lines changed

1 file changed

+12
-25
lines changed

src/mdio/segy/geometry.py

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -387,31 +387,18 @@ def transform(
387387
"""Perform the grid transform."""
388388
self.validate(index_headers, grid_overrides)
389389

390-
# Filter to only include dimension fields, not coordinate fields
391-
# We want to keep fields like shot_point, cable, channel but exclude coordinate fields
392-
# Use the template's coordinate names to determine which fields are coordinates
393-
coordinate_fields = set(template.coordinate_names)
394-
dimension_fields = []
395-
396-
for field_name in index_headers.dtype.names:
397-
# Skip if it's already trace
398-
if field_name == "trace":
399-
continue
400-
# Check if this field is a coordinate field according to the template
401-
if field_name not in coordinate_fields:
402-
dimension_fields.append(field_name)
403-
404-
# Extract only dimension fields for trace indexing
405-
dimension_headers = index_headers[dimension_fields] if dimension_fields else index_headers
406-
407-
# Create trace indices based on dimension fields only
408-
dimension_headers_with_trace = analyze_non_indexed_headers(dimension_headers)
409-
410-
# Add the trace field back to the full index_headers array
411-
if dimension_headers_with_trace is not None and "trace" in dimension_headers_with_trace.dtype.names:
412-
# Extract just the trace values array (not the whole structured array)
413-
trace_values = np.array(dimension_headers_with_trace["trace"])
414-
# Append as a new field to the full headers
390+
# Filter out coordinate fields, keep only dimensions for trace indexing
391+
coord_fields = set(template.coordinate_names) if template else set()
392+
dim_fields = [name for name in index_headers.dtype.names
393+
if name != "trace" and name not in coord_fields]
394+
395+
# Create trace indices on dimension fields only
396+
dim_headers = index_headers[dim_fields] if dim_fields else index_headers
397+
dim_headers_with_trace = analyze_non_indexed_headers(dim_headers)
398+
399+
# Add trace field back to full headers
400+
if dim_headers_with_trace is not None and "trace" in dim_headers_with_trace.dtype.names:
401+
trace_values = np.array(dim_headers_with_trace["trace"])
415402
index_headers = rfn.append_fields(index_headers, "trace", trace_values, usemask=False)
416403

417404
return index_headers

0 commit comments

Comments
 (0)