Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into v0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
atrabattoni committed Sep 17, 2024
2 parents f4efdfe + 0249f19 commit 2da5c64
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/user-guide/data-formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Here below the list of formats that are currently implemented. All HDF5 based fo
| OPTASENSE | `"optasense"` | ✅︎ |
| SILIXA | `"silixa"` ||
| SINTELA | `"sintela"` | ✅︎ |
| TERRA15 | `"terra15"` | ✅︎ |

```{warning}
File formats that do not support virtualization will be loaded in memory. We are working on a solution for non-HDF5 based file formats.
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, miniseed, optasense, silixa, sintela
from . import asn, febus, miniseed, optasense, silixa, 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(
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})

0 comments on commit 2da5c64

Please sign in to comment.