salvus.project.tools.io.seisio.seisio
SeisIO file format reader.
Classes
DataProxy
DataProxyclass DataProxy(builtins.object):
def __init__(
self,
extents: List[salvus.project.tools.io.seisio.seisio.Extent],
header_dtype: numpy.dtype,
compression: salvus.project.tools.io.seisio.compression.TraceCompression,
):
...Memory mapped data proxy.
Parameters
extentsList[salvus.project.tools.io.seisio.seisio.Extent] — The extents for the file.header_dtypenumpy.dtype — The header type as a structured numpy dtype.compressionsalvus.project.tools.io.seisio.compression.TraceCompression — The compression settings.
Methods
find_extent_for_index()
find_extent_for_index()def find_extent_for_index(self, idx: int) -> Tuple[int, int]:
...Find the index of the corresponding extent and the internal index in each extent.
Parameters
idxint — The global index.
Returns Tuple[int, int]
get_header()
get_header()def get_header(self, idx: int) -> numpy.ndarray:
...Get a header.
Parameters
idxint — The index of the header/trace.
Returns numpy.ndarray
get_header_for_slice()
get_header_for_slice()def get_header_for_slice(self, val: builtins.slice) -> numpy.ndarray:
...Get a header.
Parameters
valbuiltins.slice — The slice object.
Returns numpy.ndarray
get_header_mmap()
get_header_mmap()def get_header_mmap(self, extent_idx: int) -> numpy.memmap:
...Get the memory map for a header file.
Parameters
extent_idxint — The index of the extent.
Returns numpy.memmap
get_trace()
get_trace()def get_trace(self, idx: int) -> numpy.ndarray:
...Get a trace.
Parameters
idxint — The index of the trace.
Returns numpy.ndarray
get_trace_mmap()
get_trace_mmap()def get_trace_mmap(self, extent_idx: int) -> numpy.memmap:
...Get the memory map for a trace file.
Parameters
extent_idxint — The index of the extent.
Returns numpy.memmap
Endianness
Endiannessclass Endianness(enum.Enum):
def __init__(self):
...The byte order of the file.
Initialize self. See help(type(self)) for accurate signature.
Extent
Extentclass Extent(builtins.object):
def __init__(
self,
db: pathlib.Path,
hd: pathlib.Path,
tr: pathlib.Path,
tr_size: Optional[int] = None,
hd_size: Optional[int] = None,
db_size: Optional[int] = None,
number_of_traces: Optional[int] = None,
trace_mmap: Optional[numpy.memmap] = None,
header_mmap: Optional[numpy.memmap] = None,
) -> None:
...Represent a single extent.
Parameters
dbpathlib.Path — Path to the .db? file.hdpathlib.Path — Path to the .hd? file.trpathlib.Path — Path to the .tr.? file.tr_sizeOptional[int] — Optional file size.hd_sizeOptional[int] — Optional file size.db_sizeOptional[int] — Optional file size.number_of_tracesOptional[int] — Total number of traces.trace_mmapOptional[numpy.memmap] — Memory map to the trace file.header_mmapOptional[numpy.memmap] — Memory map to the header file.
HeaderProxy
HeaderProxyclass HeaderProxy(builtins.object):
def __init__(self, data_proxy: DataProxy):
...Proxy object to ease header access across extents.
Parameters
data_proxyDataProxy — The data proxy of the file.
SeisIO
SeisIOclass SeisIO(builtins.object):
def __init__(
self,
filename: Union[str, pathlib.Path],
root_path: Union[str, pathlib.Path],
):
...Object accessing a SeisIO file.
Parameters
filenameUnion[str, pathlib.Path] — The path to the .seis file.root_pathUnion[str, pathlib.Path] — Root project directory for the SeisIO format - path the `${project} refers to in the JSON files.
Attributes
header salvus.project.tools.io.seisio.seisio.HeaderProxy
header salvus.project.tools.io.seisio.seisio.HeaderProxyQuick access to all headers.
number_of_traces int
number_of_traces intTotal number of traces.
sampling_rate_in_hertz float
sampling_rate_in_hertz floatThe sampling rate in Hz.
start_time_in_seconds float
start_time_in_seconds floatTime of the first sample.
total_header_file_size int
total_header_file_size intTotal size in bytes of the header files.
total_trace_file_size int
total_trace_file_size intTotal size in bytes of the trace files.
Methods
get_header()
get_header()def get_header(self, idx: int) -> numpy.ndarray:
...Get a header.
Parameters
idxint — Index of the header.
Returns numpy.ndarray
get_header_mmap()
get_header_mmap()def get_header_mmap(self, extent_idx: int) -> numpy.memmap:
...Get the memory mapped full header array for a given extent.
Parameters
extent_idxint — The index of the extent.
Returns numpy.memmap
get_trace()
get_trace()def get_trace(self, idx: int) -> numpy.ndarray:
...Get a trace.
Parameters
idxint — Index of the trace.
Returns numpy.ndarray