22
33from __future__ import annotations
44
5- from copy import deepcopy
65from typing import TYPE_CHECKING
76
8- import numpy as np
9-
107if TYPE_CHECKING :
118 from numpy .typing import NDArray
129 from segy import SegyFile
@@ -16,19 +13,21 @@ class SegyFileTraceDataWrapper:
1613 def __init__ (self , segy_file : SegyFile , indices : int | list [int ] | NDArray | slice ):
1714 self .segy_file = segy_file
1815 self .indices = indices
19- self ._header_pipeline = deepcopy (segy_file .accessors .header_decode_pipeline )
20- segy_file .accessors .header_decode_pipeline .transforms = []
21- self .traces = segy_file .trace [indices ]
16+ self .idx = self .segy_file .trace .normalize_and_validate_query (self .indices )
17+ self .traces = self .segy_file .trace .fetch (self .idx , raw = True )
18+
19+ self .raw_view = self .traces .view (self .segy_file .spec .trace .dtype )
20+ self .decoded_traces = self .segy_file .accessors .trace_decode_pipeline .apply (self .raw_view .copy ())
2221
23- @property
24- def header (self ) -> NDArray :
25- # The copy is necessary to avoid applying the pipeline to the original header.
26- return self ._header_pipeline .apply (self .traces .header .copy ())
2722
2823 @property
2924 def raw_header (self ) -> NDArray :
30- return np .ascontiguousarray (self .traces .header .copy ()).view ("|V240" )
25+ return self .raw_view .header .view ("|V240" )
26+
27+ @property
28+ def header (self ) -> NDArray :
29+ return self .decoded_traces .header
3130
3231 @property
3332 def sample (self ) -> NDArray :
34- return self .traces .sample
33+ return self .decoded_traces .sample
0 commit comments