MSeed.Parser (wsdataselect v1.4.0)

Copy Markdown View Source

A lightweight, pure-Elixir miniSEED block reader.

Only the 48-byte fixed header of each record is decoded (to extract the source identifier, start time, sample count / rate and the record length); the raw sample bytes of each record are passed through untouched. This lets callers fetch and order blocks by (source id, time) without decoding any waveform data.

Time and record-length handling follows libmseed for SEED 2.x records:

  • start time is binary (year/day as big-endian uint16, then hour, minute, second and fractional-second byte(s));
  • the record length comes from the Blockette 1000 length exponent (2^exponent), falling back to a default of 512 bytes.

Summary

Functions

Decode a 48-byte miniSEED fixed header.

Read all miniSEED blocks from path within the given byte range.

Determine the record length in bytes from a (whole or partial) record binary, reading the Blockette 1000 length exponent when present.

Build the source identifier in the canonical FDSN:NET_STA_LOC_CHAN form

Types

t()

@type t() :: %MSeed.Parser{
  data_quality: term(),
  end_time: term(),
  nsamples: term(),
  offset: term(),
  raw: term(),
  sample_rate: term(),
  sequence_number: term(),
  sid: term(),
  start_time: term()
}

Functions

parse_header(bin)

@spec parse_header(binary()) :: MSeed.Parser.Header.t() | {:error, :short_header}

Decode a 48-byte miniSEED fixed header.

read_records(path, opts \\ [])

@spec read_records(
  String.t(),
  keyword()
) :: {:ok, [t()]} | {:error, term()}

Read all miniSEED blocks from path within the given byte range.

The caller (e.g. the inventory) is expected to have already resolved the request into concrete files and byte ranges, so no per-record filtering is performed here.

Options:

  • :start_offset - first byte to consider (default 0)
  • :end_offset - last byte to consider (default end of file)
  • :record_length - use a known record length, skipping Blockette detection

Returns {:ok, [%MSeed.Parser{}]} on success.

record_length(bin)

@spec record_length(binary()) :: integer() | nil

Determine the record length in bytes from a (whole or partial) record binary, reading the Blockette 1000 length exponent when present.

sid(net, sta, loc, chan)

@spec sid(String.t(), String.t(), String.t(), String.t()) :: String.t()

Build the source identifier in the canonical FDSN:NET_STA_LOC_CHAN form