1212
1313from mdio .api .io import to_mdio
1414from mdio .builder .schemas .dtype import ScalarType
15+ from mdio .segy ._disaster_recovery_wrapper import SegyFileTraceDataWrapper
1516
1617if TYPE_CHECKING :
1718 from segy .arrays import HeaderArray
@@ -138,18 +139,13 @@ def trace_worker( # noqa: PLR0913
138139 # For that reason, we have wrapped the accessors to provide an interface that can be removed
139140 # and not require additional changes to the below code.
140141 # NOTE: The `raw_header_key` code block should be removed in full as it will become dead code.
141- # traces = SegyFileTraceDataWrapper(segy_file, live_trace_indexes)
142- from copy import deepcopy
143-
144- header_pipeline = deepcopy (segy_file .accessors .header_decode_pipeline )
145- segy_file .accessors .header_decode_pipeline .transforms = []
146- traces = segy_file .trace [live_trace_indexes ]
142+ traces = SegyFileTraceDataWrapper (segy_file , live_trace_indexes )
147143
148144 ds_to_write = dataset [worker_variables ]
149145
150146 if raw_header_key in worker_variables :
151147 tmp_raw_headers = np .zeros_like (dataset [raw_header_key ])
152- tmp_raw_headers [not_null ] = np . ascontiguousarray ( traces .header . copy ()). view ( "|V240" )
148+ tmp_raw_headers [not_null ] = traces .raw_header
153149
154150 ds_to_write [raw_header_key ] = Variable (
155151 ds_to_write [raw_header_key ].dims ,
@@ -162,8 +158,7 @@ def trace_worker( # noqa: PLR0913
162158 # TODO(BrianMichell): Implement this better so that we can enable fill values without changing the code
163159 # https://github.com/TGSAI/mdio-python/issues/584
164160 tmp_headers = np .zeros_like (dataset [header_key ])
165- # tmp_headers[not_null] = traces.header
166- tmp_headers [not_null ] = header_pipeline .apply (traces .header .copy ())
161+ tmp_headers [not_null ] = traces .header
167162 # Create a new Variable object to avoid copying the temporary array
168163 # The ideal solution is to use `ds_to_write[header_key][:] = tmp_headers`
169164 # but Xarray appears to be copying memory instead of doing direct assignment.
0 commit comments