UNKNOWN_DATA_VERSION

src/xseed.js

const for unknown data version, 0

UNKNOWN_DATA_VERSION

Type: number

CRC_OFFSET

src/xseed.js

const for offset to crc in record, 28

CRC_OFFSET

Type: number

FIXED_HEADER_SIZE

src/xseed.js

const for size of fixed header part of record, 40

FIXED_HEADER_SIZE

Type: number

FDSN_PREFIX

src/xseed.js

const for fdsn prefix for extra headers, FDSN

FDSN_PREFIX

Type: string

LITTLE_ENDIAN

src/xseed.js

const for little endian, true

LITTLE_ENDIAN

Type: boolean

parseXSeedRecords

src/xseed.js

parse arrayBuffer into an array of XSeedRecords.

parseXSeedRecords(arrayBuffer: ArrayBuffer): Array<XSeedRecord>
Parameters
arrayBuffer (ArrayBuffer) bytes to extract xseed records from
Returns
Array<XSeedRecord>: array of all xseed records contained in the buffer

XSeedRecord

src/xseed.js

Represents a xSEED Data Record, with header, extras and data.

new XSeedRecord(header: XSeedHeader, extraHeaders: any, rawData: DataView)
Parameters
header (XSeedHeader) xseed fixed record header
extraHeaders (any) json compatible object with extra headers
rawData (DataView) waveform data, in correct compression for value in header
Static Members
createFromDataView(dataView)
Instance Members
header
extraHeaders
rawData
getSize()
decompress()
asEncodedDataSegment()
codes()
save(dataView)
calcCrc()

XSeedHeader

src/xseed.js

Fixed header of an XSeed data record.

new XSeedHeader()
Static Members
createFromDataView(dataView)
Instance Members
recordIndicator
formatVersion
flags
nanosecond
year
dayOfYear
hour
minute
second
encoding
sampleRatePeriod
sampleRate
numSamples
crc
publicationVersion
identifierLength
extraHeadersLength
identifier
extraHeaders
dataLength
start
end
getSize()
toString()
getStartFieldsAsISO()
timeOfSample(i)
save(dataView, offset, zeroCrc)
_startToMoment()

parseExtraHeaders

src/xseed.js

Parses extra headers as json.

parseExtraHeaders(dataView: DataView): any
Parameters
dataView (DataView) json bytes as DataView
Returns
any: json object

Creates a string version of a number with zero prefix padding. For example padZeros(5, 3) is 005.

padZeros(val: number, len: number): any
Parameters
val (number) number to stringify
len (number) total length of string
Returns
any: zero padded string

makeString

src/xseed.js

creates a string from bytes in a DataView.

makeString(dataView: DataView, offset: number, length: number): string
Parameters
dataView (DataView) data bytes
offset (number) offset to first byte to use
length (number) number of bytes to convert
Returns
string: string resulting from utf-8 conversion

areContiguous

src/xseed.js

Checks if two xseed records are (nearly) contiguous.

areContiguous(dr1: XSeedRecord, dr2: XSeedRecord, sampRatio: number): boolean
Parameters
dr1 (XSeedRecord) first record
dr2 (XSeedRecord) second record
sampRatio (number = 1.5) tolerence expressed as ratio of sample period, default 1.5
Returns
boolean: true if contiguous

createSeismogramSegment

src/xseed.js

concatentates a sequence of XSeedRecords into a single seismogram object. Assumes that they are all contiguous (no gaps or overlaps) and in order. Header values from the first XSeedRecord are used.

createSeismogramSegment(contig: Array<XSeedRecord>): SeismogramSegment
Parameters
contig (Array<XSeedRecord>) array of xseed records
Returns
SeismogramSegment: seismogram segment for the records

Merges xseed records into a Seismogram object, each of which consists of SeismogramSegment objects containing the data as EncodedDataSegment objects. DataRecords are sorted by startTime. This assumes all data records are from the same channel, byChannel can be used first if multiple channels may be present. Gaps may be present.

merge(drList: Array<XSeedRecord>): Seismogram
Parameters
drList (Array<XSeedRecord>) list of xseed records to convert
Returns
Seismogram: the seismogram

byChannel

src/xseed.js

splits a list of data records by channel identifier, returning an object with each NSLC mapped to an array of data records.

byChannel(drList: Array<XSeedRecord>): Map<string, Array<XSeedRecord>>
Parameters
drList (Array<XSeedRecord>) array of xseed records
Returns
Map<string, Array<XSeedRecord>>: map of channel id to array of xseed records, possibly not contiguous

seismogramPerChannel

src/xseed.js

splits the XSeedRecords by channel and creates a single Seismogram for each channel.

seismogramPerChannel(drList: Array<XSeedRecord>): Array<Seismogram>
Parameters
drList (Array<XSeedRecord>) XSeedRecords array
Returns
Array<Seismogram>: Map of code to Seismogram

convertMS2toXSeed

src/xseed.js

Convert array of Miniseed2 DataRecords into an array of XSeedRecords.

convertMS2toXSeed(mseed2: Array<DataRecord>): Array<XSeedRecord>
Parameters
mseed2 (Array<DataRecord>) array of DataRecords
Returns
Array<XSeedRecord>: array of XSeedRecords

convertMS2Record

src/xseed.js

Converts a single miniseed2 DataRecord into a single XSeedRecord.

convertMS2Record(ms2record: DataRecord): XSeedRecord
Parameters
ms2record (DataRecord) Miniseed2 DataRecord to convert
Returns
XSeedRecord: XSeedRecord

calculateCRC32C

src/xseed.js

Copy from https://github.com/ashi009/node-fast-crc32c/blob/master/impls/js_crc32c.js and modify to use ArrayBuffer. Rename calculateCRC32C

This code is a manual javascript translation of c code generated by pycrc 0.7.1 (http://www.tty1.net/pycrc/). Command line used: './pycrc.py --model=crc-32c --generate c --algorithm=table-driven'

calculateCRC32C(buf: (ArrayBuffer | Uint8Array), initial: number): any
Parameters
buf ((ArrayBuffer | Uint8Array)) input data
initial (number = 0) starting value, from earlier data
Returns
any: calculated crc32c value

crcToHexString

src/xseed.js

Convert crc as a number into a hex string.

crcToHexString(crc: number): string
Parameters
crc (number) crc as a number
Returns
string: hex representation