Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dascore/data_registry.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ febus_dts_single_reading.h5 e81c7225e6061e6c0ac7fc42d9d623b0c79d20d7ef367a7513a2
ofl100_1.sor 2af23609ac952f588d97ee195338f44227f61322422756e54a5c4a18b6704749 https://github.com/dasdae/test_data/raw/master/otdr/ofl100_1.sor
ofl100_2.sor d8787d6171e2a2b3c6443c28b724440274694d525da617202c6b7a7bb2e13a8c https://github.com/dasdae/test_data/raw/master/otdr/ofl100_2.sor
ofl100_3.sor d9167fffc91565eaa48b65fd55e5f0600b7a96ebac549f1b2344ffb7bacf2336 https://github.com/dasdae/test_data/raw/master/otdr/ofl100_3.sor
sintela_protobuf_1.pb cafa038c033cb5e4cf4aa90bab203eb1e10dc05a6052c0576dc80d6a5b3b42dc https://github.com/dasdae/test_data/raw/master/das/sintela_protobuf_1.pb
5 changes: 5 additions & 0 deletions dascore/io/sintela/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
Sintela readers.
"""
from .core import SintelaBinaryV3
from .core import SintelaProtobufV1
32 changes: 32 additions & 0 deletions dascore/io/sintela_binary/core.py → dascore/io/sintela/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from dascore.io import FiberIO, ScanPayload
from dascore.utils.io import BinaryReader, LocalBinaryReader

from .protobuf_utils import get_supported_family_tag, read_payload, scan_payload
from .utils import (
_HEADER_SIZES,
SYNC_WORD,
Expand Down Expand Up @@ -79,3 +80,34 @@ def read(
)

return dc.spool(patch)


class SintelaProtobufV1(FiberIO):
"""IO class for Sintela protobuf MTLV recordings."""

name = "Sintela_Protobuf"
preferred_extensions = ("pb",)
version = "1"

def get_format(self, resource: BinaryReader, **kwargs) -> tuple[str, str] | bool:
"""Return the format/version tuple if the file is Sintela protobuf."""
position = resource.tell()
try:
tag = get_supported_family_tag(resource)
finally:
resource.seek(position)
return (self.name, self.version) if tag else False
Comment thread
coderabbitai[bot] marked this conversation as resolved.

def scan(self, resource: BinaryReader, **kwargs) -> list[ScanPayload]:
"""Scan a Sintela protobuf recording."""
return scan_payload(resource)

def read(self, resource: BinaryReader, **kwargs) -> dc.BaseSpool:
"""Read a Sintela protobuf recording into a spool."""
data, coords, attrs = read_payload(resource)
selectors = {name: kwargs[name] for name in coords.dims if name in kwargs}
if selectors:
coords, data = coords.select(data, **selectors)
if not np.size(data):
return dc.spool([])
return dc.spool([dc.Patch(data=data, coords=coords, attrs=attrs)])
Loading
Loading