Skip to content

Commit 93292d1

Browse files
committed
Testing
1 parent c7b7241 commit 93292d1

File tree

1 file changed

+68
-11
lines changed

1 file changed

+68
-11
lines changed

src/mdio/segy/_workers.py

Lines changed: 68 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,74 @@ def trace_worker( # noqa: PLR0913
147147

148148
ds_to_write = dataset[worker_variables]
149149

150+
if raw_header_key in worker_variables:
151+
# from segy.schema import HeaderField, ScalarType
152+
from segy.schema import HeaderField
153+
from segy.schema import ScalarType as ScalarType2
154+
155+
new_spec = deepcopy(segy_file.spec)
156+
new_spec.trace.header.fields = []
157+
new_fields = []
158+
159+
for i in range(240):
160+
new_fields.append(HeaderField(name=f"Field_{i}", format=ScalarType.UINT8, byte=i+1))
161+
162+
# # new_spec.trace.header.fields = new_fields
163+
new_spec = new_spec.customize(trace_header_fields=new_fields)
164+
updated_segy_file = SegyFile(segy_file.url, spec=new_spec)
165+
updated_traces = updated_segy_file.trace[live_trace_indexes]
166+
167+
tmp_raw_headers = np.zeros_like(dataset[raw_header_key])
168+
169+
170+
# _foo = traces.tobytes()[:240]
171+
172+
# _asContiguousCopy = np.ascontiguousarray(traces.header.copy()).view("|V240")
173+
# _asContiguousCopy1 = _asContiguousCopy[0]
174+
175+
# _asContiguousNoCopy = np.ascontiguousarray(traces.header).view("|V240")
176+
# _asContiguousNoCopy1 = _asContiguousNoCopy[0]
177+
178+
# _asArrayCopy = traces.header.copy().view("|V240")
179+
# _asArrayCopy1 = _asArrayCopy[0]
180+
181+
# _asArrayNoCopy = traces.header.view("|V240")
182+
# _asArrayNoCopy1 = _asArrayNoCopy[0]
183+
184+
# _fo = type(traces.header)
185+
186+
# _aahhhhhhh = segy_file.header[0]
187+
188+
189+
190+
# _asBytes = traces.header.tobytes()
191+
# _are_equal = _foo == _asBytes[:240]
192+
# _asBytesLen = len(_asBytes)
193+
# _asContiguousBytes = np.ascontiguousarray(traces.header).tobytes()
194+
# _asContiguousBytesLen = len(_asContiguousBytes)
195+
# _asContiguousBytesView = np.ascontiguousarray(traces.header[0]).tobytes().view("|V240")
196+
# _asBuffer = memoryview(traces.header)
197+
198+
199+
# _type = traces.header.dtype
200+
201+
# tmp_raw_headers[not_null] = traces.raw_header
202+
# tmp_raw_headers[not_null] = np.ascontiguousarray(traces.header.copy()).view("|V240")
203+
# tmp_raw_headers[not_null] = _asContiguousBytes
204+
# tmp_raw_headers[not_null] = _asBytes
205+
# tmp_raw_headers[not_null] = traces.header.view("|V240")
206+
# tmp_raw_headers[not_null] = np.ascontiguousarray(traces.header.copy()).view("|V240") # Leaks numpy metadata
207+
208+
209+
tmp_raw_headers[not_null] = updated_traces.header.view("|V240")
210+
211+
ds_to_write[raw_header_key] = Variable(
212+
ds_to_write[raw_header_key].dims,
213+
tmp_raw_headers,
214+
attrs=ds_to_write[raw_header_key].attrs,
215+
encoding=ds_to_write[raw_header_key].encoding, # Not strictly necessary, but safer than not doing it.
216+
)
217+
150218
if header_key in worker_variables:
151219
# TODO(BrianMichell): Implement this better so that we can enable fill values without changing the code
152220
# https://github.com/TGSAI/mdio-python/issues/584
@@ -164,17 +232,6 @@ def trace_worker( # noqa: PLR0913
164232
attrs=ds_to_write[header_key].attrs,
165233
encoding=ds_to_write[header_key].encoding, # Not strictly necessary, but safer than not doing it.
166234
)
167-
if raw_header_key in worker_variables:
168-
tmp_raw_headers = np.zeros_like(dataset[raw_header_key])
169-
# tmp_raw_headers[not_null] = traces.raw_header
170-
tmp_raw_headers[not_null] = np.ascontiguousarray(traces.header.copy()).view("|V240")
171-
172-
ds_to_write[raw_header_key] = Variable(
173-
ds_to_write[raw_header_key].dims,
174-
tmp_raw_headers,
175-
attrs=ds_to_write[raw_header_key].attrs,
176-
encoding=ds_to_write[raw_header_key].encoding, # Not strictly necessary, but safer than not doing it.
177-
)
178235

179236
# del raw_headers # Manage memory
180237
data_variable = ds_to_write[data_variable_name]

0 commit comments

Comments
 (0)