Skip to content

Commit a7cc672

Browse files
committed
Attempt with manual flattening
1 parent cbbba2e commit a7cc672

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/mdio/core/grid.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,13 @@ def build_map(self, index_headers: HeaderArray) -> None:
145145

146146
# Assign trace indices
147147
trace_indices = np.arange(start, end, dtype=np.uint64)
148-
self.map.oindex[live_dim_indices] = trace_indices
149-
self.live_mask.oindex[live_dim_indices] = True
148+
# Compute flat indices for lower-memory scatter assignment
149+
flat_indices = np.ravel_multi_index(live_dim_indices, live_shape)
150+
flat_map = self.map.reshape(-1)
151+
flat_mask = self.live_mask.reshape(-1)
152+
# Use 1-D fancy indexing (no broadcast) for assignment
153+
flat_map.vindex[flat_indices] = trace_indices
154+
flat_mask.vindex[flat_indices] = True
150155

151156

152157
class GridSerializer(Serializer):

0 commit comments

Comments
 (0)