gwexpy.timeseries.io.zarr_

Note

Current behavior follows the Phase 7 truth ledger and the #8-19 fail-fast fix:

  • Per-array sample_rate is the primary timing metadata.

  • dt is accepted as a fallback and converted to sample_rate = 1 / dt.

  • If both are missing, reading raises ValueError instead of silently assuming 1 Hz.

  • Legacy stores can be recovered intentionally with exactly one of sample_rate_override=... or dt_override=....

Zarr reader/writer for gwexpy.

Convention

A Zarr store is a group where each array represents one channel. Per-array attributes sample_rate (Hz) and t0 (GPS seconds) are used to reconstruct the time axis. If sample_rate is absent the inverse of dt is tried. If both are absent, reading fails with a clear error instead of silently assuming 1 Hz.

Directory stores, zip stores, and any other backend supported by the zarr library can be used as source / target.

Functions

read_timeseriesdict_zarr(source, *[, ...])

Read a Zarr store into a TimeSeriesDict.

read_timeseries_zarr(source, **kwargs)

Read a Zarr store and return the first channel.

read_timeseriesmatrix_zarr(source, **kwargs)

Read a Zarr store and convert its channels to a matrix.

write_timeseriesdict_zarr(tsd, target, **kwargs)

Write a TimeSeriesDict to a Zarr store.

write_timeseries_zarr(ts, target, **kwargs)

Write one TimeSeries to a Zarr store.

gwexpy.timeseries.io.zarr_.read_timeseriesdict_zarr(source, *, channels=None, unit=None, sample_rate_override=None, dt_override=None, **kwargs) TimeSeriesDict[source]

Read a Zarr store into a TimeSeriesDict.

Parameters:
  • source (str, path-like, or zarr store) – Path to the .zarr directory (or any zarr-compatible store).

  • channels (iterable of str, optional) – Array names to read. If None, all arrays in the root group are loaded.

  • unit (str, optional) – Physical unit override applied to every channel.

  • sample_rate_override (float, optional) – Explicit sample-rate recovery value in Hz for legacy stores that lack per-array sample_rate and dt metadata. Mutually exclusive with dt_override.

  • dt_override (float, optional) – Explicit sample-spacing recovery value in seconds for legacy stores that lack per-array timing metadata. Mutually exclusive with sample_rate_override.

  • **kwargs – Additional keyword arguments forwarded to zarr.open_group.

gwexpy.timeseries.io.zarr_.read_timeseries_zarr(source, **kwargs) TimeSeries[source]

Read a Zarr store and return the first channel.

gwexpy.timeseries.io.zarr_.read_timeseriesmatrix_zarr(source, **kwargs) TimeSeriesMatrix[source]

Read a Zarr store and convert its channels to a matrix.

gwexpy.timeseries.io.zarr_.write_timeseriesdict_zarr(tsd, target, **kwargs)[source]

Write a TimeSeriesDict to a Zarr store.

Each channel is written as an array in the root group with sample_rate, t0, and unit stored as attributes.

gwexpy.timeseries.io.zarr_.write_timeseries_zarr(ts, target, **kwargs)[source]

Write one TimeSeries to a Zarr store.