Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for TrebleDAS / Terra15 Interrogators #16

Merged
merged 5 commits into from
Sep 17, 2024
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
3 changes: 2 additions & 1 deletion docs/user-guide/data-formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ os.chdir("../_data")

## Implemented file formats

The formats that are currently implemented are: ASN, FEBUS, OPTASENSE and SINTELA. To read them you have to specifiy which one you want in the `engine` argument in {py:func}`xdas.open_dataarray` for a single file or {py:func}`xdas.open_mfdataarray` for multiple files:
The formats that are currently implemented are: ASN, FEBUS, OPTASENSE, SINTELA and TERRA15. To read them you have to specifiy which one you want in the `engine` argument in {py:func}`xdas.open_dataarray` for a single file or {py:func}`xdas.open_mfdataarray` for multiple files:

| DAS constructor | `engine` argument |
|:-----------------:|:-----------------:|
| ASN | `"asn"` |
| FEBUS | `"febus"` |
| OPTASENSE | `"optasense"` |
| SINTELA | `"sintela"` |
| TERRA15 | `"terra15"` |

## Extending *xdas* with your file format

Expand Down
2 changes: 1 addition & 1 deletion xdas/io/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from . import asn, febus, optasense, sintela
from . import asn, febus, optasense, sintela, terra15
from .core import get_free_port
24 changes: 24 additions & 0 deletions xdas/io/terra15.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from datetime import datetime, timezone

import h5py
import numpy as np

from ..core.dataarray import DataArray
from ..virtual import VirtualSource


def read(fname, tz=timezone.utc):
with h5py.File(fname, "r") as file:
ti = np.datetime64(

Check warning on line 12 in xdas/io/terra15.py

View check run for this annotation

Codecov / codecov/patch

xdas/io/terra15.py#L11-L12

Added lines #L11 - L12 were not covered by tests
datetime.fromtimestamp(file["data_product"]["gps_time"][0], tz=tz)
).astype("datetime64[ms]")
tf = np.datetime64(

Check warning on line 15 in xdas/io/terra15.py

View check run for this annotation

Codecov / codecov/patch

xdas/io/terra15.py#L15

Added line #L15 was not covered by tests
datetime.fromtimestamp(file["data_product"]["gps_time"][-1], tz=tz)
).astype("datetime64[ms]")
d0 = file.attrs["sensing_range_start"]
dx = file.attrs["dx"]
data = VirtualSource(file["data_product"]["data"])
nt, nd = data.shape
t = {"tie_indices": [0, nt - 1], "tie_values": [ti, tf]}
d = {"tie_indices": [0, nd - 1], "tie_values": [d0, d0 + (nd - 1) * dx]}
return DataArray(data, {"time": t, "distance": d})

Check warning on line 24 in xdas/io/terra15.py

View check run for this annotation

Codecov / codecov/patch

xdas/io/terra15.py#L18-L24

Added lines #L18 - L24 were not covered by tests