diff --git a/docs/user-guide/data-formats.md b/docs/user-guide/data-formats.md index 7573cd2..be5b6e1 100644 --- a/docs/user-guide/data-formats.md +++ b/docs/user-guide/data-formats.md @@ -20,7 +20,7 @@ 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 | |:-----------------:|:-----------------:| @@ -28,6 +28,7 @@ The formats that are currently implemented are: ASN, FEBUS, OPTASENSE and SINTEL | FEBUS | `"febus"` | | OPTASENSE | `"optasense"` | | SINTELA | `"sintela"` | +| TERRA15 | `"terra15"` | ## Extending *xdas* with your file format diff --git a/xdas/io/__init__.py b/xdas/io/__init__.py index 84d91ec..008cd21 100644 --- a/xdas/io/__init__.py +++ b/xdas/io/__init__.py @@ -1,2 +1,2 @@ -from . import asn, febus, optasense, sintela +from . import asn, febus, optasense, sintela, terra15 from .core import get_free_port diff --git a/xdas/io/terra15.py b/xdas/io/terra15.py new file mode 100644 index 0000000..7c969ac --- /dev/null +++ b/xdas/io/terra15.py @@ -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( + datetime.fromtimestamp(file["data_product"]["gps_time"][0], tz=tz) + ).astype("datetime64[ms]") + tf = np.datetime64( + 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})