@seismo/core
Version:
This is the package for the core library of Seismo, a JavaScript library for seismic data processing and visualization. It provides utilities for handling seismic data, including FDSN web services, waveform processing, and event handling. The library is d
684 lines (683 loc) • 24.7 kB
TypeScript
import { Station, Channel } from "./stationxml";
import { DateTime } from "luxon";
export declare const QML_NS = "http://quakeml.org/xmlns/quakeml/1.2";
export declare const BED_NS = "http://quakeml.org/xmlns/bed/1.2";
export declare const IRIS_NS = "http://service.iris.edu/fdsnws/event/1/";
export declare const ANSS_NS = "http://anss.org/xmlns/event/0.1";
export declare const ANSS_CATALOG_NS = "http://anss.org/xmlns/catalog/0.1";
export declare const USGS_HOST = "earthquake.usgs.gov";
export declare const UNKNOWN_MAG_TYPE = "unknown";
export declare const UNKNOWN_PUBLIC_ID = "unknownId";
export declare const FAKE_ORIGIN_TIME: DateTime<true> | DateTime<false>;
export declare const FAKE_EMPTY_XML = "<?xml version=\"1.0\"?><q:quakeml xmlns=\"http://quakeml.org/xmlns/bed/1.2\" xmlns:q=\"http://quakeml.org/xmlns/quakeml/1.2\"><eventParameters publicID=\"quakeml:fake/empty\"></eventParameters></q:quakeml>";
export declare const QUAKE_CLICK_EVENT = "quakeclick";
/**
* Utility function to create CustomEvent for clicking on a Quake, for example
* in a map or table.
*
* @param q Quake clicked on
* @param mouseclick original mouse click Event
* @returns CustomEvent populated with quake field in detail.
*/
export declare function createQuakeClickEvent(q: Quake, mouseclick: Event): CustomEvent;
declare class BaseElement {
publicId: string;
comments: Comment[];
creationInfo?: CreationInfo;
protected populate(qml: Element): void;
}
/**
* Represent a QuakeML EventParameters.
*/
export declare class EventParameters extends BaseElement {
eventList: Quake[];
description?: string;
/**
* Parses a QuakeML event parameters xml element into an EventParameters object.
*
* @param eventParametersQML the event parameters xml Element
* @param host optional source of the xml, helpful for parsing the eventid
* @returns EventParameters instance
*/
static createFromXml(eventParametersQML: Element, host?: string): EventParameters;
}
/**
* Represent a QuakeML Event. Renamed to Quake as Event conflicts with
* other uses in javascript.
*/
export declare class Quake extends BaseElement {
eventId: string | undefined;
descriptionList: EventDescription[];
amplitudeList: Array<Amplitude>;
stationMagnitudeList: Array<StationMagnitude>;
magnitudeList: Array<Magnitude>;
originList: Array<Origin>;
pickList: Array<Pick>;
focalMechanismList: Array<FocalMechanism>;
preferredOrigin?: Origin;
preferredMagnitude?: Magnitude;
preferredFocalMechanism?: FocalMechanism;
type?: string;
typeCertainty?: string;
/**
* Parses a QuakeML event xml element into a Quake object. Pass in
* host=seisplotjs.fdsnevent.USGS_HOST for xml from the USGS service
* in order to parse the eventid, otherwise this can be left out
*
* @param qml the event xml Element
* @param host optional source of the xml, helpful for parsing the eventid
* @returns QuakeML Quake(Event) object
*/
static createFromXml(qml: Element, host?: string): Quake;
/**
* Extracts the EventId from a QuakeML element, guessing from one of several
* incompatible (grumble grumble) formats.
*
* @param qml Quake(Event) to extract from
* @param host optional source of the xml to help determine the event id style
* @returns Extracted Id, or "unknownEventId" if we can't figure it out
*/
static extractEventId(qml: Element, host?: string): string;
hasPreferredOrigin(): boolean;
hasOrigin(): boolean;
get origin(): Origin;
hasPreferredMagnitude(): boolean;
hasMagnitude(): boolean;
get magnitude(): Magnitude;
get time(): DateTime;
get latitude(): number;
get longitude(): number;
get depth(): number;
get depthKm(): number;
get description(): string;
get arrivals(): Array<Arrival>;
get picks(): Array<Pick>;
toString(): string;
}
/**
Represents a QuakeML EventDescription.
*/
export declare class EventDescription {
text: string;
type?: string;
constructor(text: string);
/**
* Parses a QuakeML description xml element into a EventDescription object.
*
* @param descriptionQML the description xml Element
* @returns EventDescription instance
*/
static createFromXml(descriptionQML: Element): EventDescription;
toString(): string;
}
/** Represents a QuakeML Amplitude. */
export declare class Amplitude extends BaseElement {
genericAmplitude: RealQuantity;
type?: string;
category?: string;
unit?: string;
methodID?: string;
period?: RealQuantity;
snr?: number;
timeWindow?: TimeWindow;
pick?: Pick;
waveformID?: WaveformID;
filterID?: string;
scalingTime?: TimeQuantity;
magnitudeHint?: string;
evaluationMode?: string;
evaluationStatus?: string;
constructor(genericAmplitude: RealQuantity);
/**
* Parses a QuakeML amplitude xml element into an Amplitude object.
*
* @param amplitudeQML the amplitude xml Element
* @param allPicks picks already extracted from the xml for linking arrivals with picks
* @returns Amplitude instance
*/
static createFromXml(amplitudeQML: Element, allPicks: Pick[]): Amplitude;
}
/** Represents a QuakeML StationMagnitude. */
export declare class StationMagnitude extends BaseElement {
origin: Origin;
mag: RealQuantity;
type?: string;
amplitude?: Amplitude;
methodID?: string;
waveformID?: WaveformID;
constructor(origin: Origin, mag: RealQuantity);
/**
* Parses a QuakeML station magnitude xml element into a StationMagnitude object.
*
* @param stationMagnitudeQML the station magnitude xml Element
* @param allOrigins origins already extracted from the xml for linking station magnitudes with origins
* @param allAmplitudes amplitudes already extracted from the xml for linking station magnitudes with amplitudes
* @returns StationMagnitude instance
*/
static createFromXml(stationMagnitudeQML: Element, allOrigins: Origin[], allAmplitudes: Amplitude[]): StationMagnitude;
}
/** Represents a QuakeML TimeWindow. */
export declare class TimeWindow {
begin: number;
end: number;
reference: DateTime;
constructor(begin: number, end: number, reference: DateTime);
/**
* Parses a QuakeML time window xml element into a TimeWindow object.
*
* @param timeWindowQML the time window xml Element
* @returns TimeWindow instance
*/
static createFromXml(timeWindowQML: Element): TimeWindow;
}
/** Represents a QuakeML Origin. */
export declare class Origin extends BaseElement {
compositeTimes: Array<CompositeTime>;
originUncertainty?: OriginUncertainty;
arrivalList: Array<Arrival>;
timeQuantity: TimeQuantity;
latitudeQuantity: RealQuantity;
longitudeQuantity: RealQuantity;
depthQuantity?: RealQuantity;
depthType?: string;
timeFixed?: boolean;
epicenterFixed?: boolean;
referenceSystemID?: string;
methodID?: string;
earthModelID?: string;
quality?: OriginQuality;
type?: string;
region?: string;
evaluationMode?: string;
evaluationStatus?: string;
constructor(time: TimeQuantity | DateTime, latitude: RealQuantity | number, longitude: RealQuantity | number);
/**
* Parses a QuakeML origin xml element into a Origin object.
*
* @param qml the origin xml Element
* @param allPicks picks already extracted from the xml for linking arrivals with picks
* @returns Origin instance
*/
static createFromXml(qml: Element, allPicks: Array<Pick>): Origin;
toString(): string;
get time(): DateTime;
set time(t: TimeQuantity | DateTime);
get latitude(): number;
set latitude(lat: RealQuantity | number);
get longitude(): number;
set longitude(lon: RealQuantity | number);
get depthKm(): number;
get depth(): number;
set depth(depth: RealQuantity | number);
get arrivals(): Array<Arrival>;
}
/** Represents a QuakeML CompositeTime. */
export declare class CompositeTime {
year?: IntegerQuantity;
month?: IntegerQuantity;
day?: IntegerQuantity;
hour?: IntegerQuantity;
minute?: IntegerQuantity;
second?: RealQuantity;
/**
* Parses a QuakeML composite time xml element into an CompositeTime object.
*
* @param qml the composite time xml Element
* @returns CompositeTime instance
*/
static createFromXml(qml: Element): CompositeTime;
}
/** Represents a QuakeML OriginUncertainty. */
export declare class OriginUncertainty {
horizontalUncertainty?: number;
minHorizontalUncertainty?: number;
maxHorizontalUncertainty?: number;
azimuthMaxHorizontalUncertainty?: number;
confidenceEllipsoid?: ConfidenceEllipsoid;
preferredDescription?: string;
confidenceLevel?: number;
/**
* Parses a QuakeML origin uncertainty xml element into an OriginUncertainty object.
*
* @param qml the origin uncertainty xml Element
* @returns OriginUncertainty instance
*/
static createFromXml(qml: Element): OriginUncertainty;
}
/** Represents a QuakeML ConfidenceEllipsoid. */
export declare class ConfidenceEllipsoid {
semiMajorAxisLength: number;
semiMinorAxisLength: number;
semiIntermediateAxisLength: number;
majorAxisPlunge: number;
majorAxisAzimuth: number;
majorAxisRotation: number;
constructor(semiMajorAxisLength: number, semiMinorAxisLength: number, semiIntermediateAxisLength: number, majorAxisPlunge: number, majorAxisAzimuth: number, majorAxisRotation: number);
/**
* Parses a QuakeML confidence ellipsoid xml element into an ConfidenceEllipsoid object.
*
* @param qml the confidence ellipsoid xml Element
* @returns ConfidenceEllipsoid instance
*/
static createFromXml(qml: Element): ConfidenceEllipsoid;
}
/** Represents a QuakeML OriginQuality. */
export declare class OriginQuality {
associatedPhaseCount?: number;
usedPhaseCount?: number;
associatedStationCount?: number;
usedStationCount?: number;
depthPhaseCount?: number;
standardError?: number;
azimuthalGap?: number;
secondaryAzimuthalGap?: number;
groundTruthLevel?: string;
maximumDistance?: number;
minimumDistance?: number;
medianDistance?: number;
/**
* Parses a QuakeML origin quality xml element into an OriginQuality object.
*
* @param qml the origin quality xml Element
* @returns OriginQuality instance
*/
static createFromXml(qml: Element): OriginQuality;
}
/**
Represents a QuakeML Magnitude.
*/
export declare class Magnitude extends BaseElement {
stationMagnitudeContributions: StationMagnitudeContribution[];
magQuantity: RealQuantity;
type?: string;
origin?: Origin;
methodID?: string;
stationCount?: number;
azimuthalGap?: number;
evaluationMode?: string;
evaluationStatus?: string;
constructor(mag: RealQuantity | number, type?: string);
/**
* Parses a QuakeML magnitude xml element into a Magnitude object.
*
* @param qml the magnitude xml Element
* @param allOrigins origins already extracted from the xml for linking magnitudes with origins
* @param allStationMagnitudes station magnitudes already extracted from the xml
* @returns Magnitude instance
*/
static createFromXml(qml: Element, allOrigins: Origin[], allStationMagnitudes: StationMagnitude[]): Magnitude;
toString(): string;
get mag(): number;
set mag(value: RealQuantity | number);
}
/**
Represents a QuakeML StationMagnitudeContribution.
*/
export declare class StationMagnitudeContribution {
stationMagnitude: StationMagnitude;
residual?: number;
weight?: number;
constructor(stationMagnitude: StationMagnitude);
/**
* Parses a QuakeML station magnitude contribution xml element into a StationMagnitudeContribution object.
*
* @param qml the station magnitude contribution xml Element
* @param allStationMagnitudes station magnitudes already extracted from the xml for linking station magnitudes with station magnitude contributions
* @returns StationMagnitudeContribution instance
*/
static createFromXml(qml: Element, allStationMagnitudes: Array<StationMagnitude>): StationMagnitudeContribution;
}
/**
Represents a QuakeML Arrival, a combination of a Pick with a phase name.
*/
export declare class Arrival extends BaseElement {
phase: string;
pick: Pick;
timeCorrection?: number;
azimuth?: number;
distance?: number;
takeoffAngle?: RealQuantity;
timeResidual?: number;
horizontalSlownessResidual?: number;
backazimuthResidual?: number;
timeWeight?: number;
horizontalSlownessWeight?: number;
backazimuthWeight?: number;
earthModelID?: string;
constructor(phase: string, pick: Pick);
/**
* Parses a QuakeML arrival xml element into a Arrival object.
*
* @param arrivalQML the arrival xml Element
* @param allPicks picks already extracted from the xml for linking arrivals with picks
* @returns Arrival instance
*/
static createFromXml(arrivalQML: Element, allPicks: Array<Pick>): Arrival;
}
/**
Represents a QuakeML Pick.
*/
export declare class Pick extends BaseElement {
timeQuantity: TimeQuantity;
waveformID: WaveformID;
filterID?: string;
methodID?: string;
horizontalSlowness?: RealQuantity;
backazimuth?: RealQuantity;
slownessMethodID?: string;
onset?: string;
phaseHint?: string;
polarity?: string;
evaluationMode?: string;
evaluationStatus?: string;
constructor(time: TimeQuantity | DateTime, waveformID: WaveformID);
get time(): DateTime;
set time(t: Quantity<DateTime> | DateTime);
/**
* Parses a QuakeML pick xml element into a Pick object.
*
* @param pickQML the pick xml Element
* @returns Pick instance
*/
static createFromXml(pickQML: Element): Pick;
get networkCode(): string;
get stationCode(): string;
get locationCode(): string;
get channelCode(): string;
isAtStation(station: Station): boolean;
isOnChannel(channel: Channel): boolean;
toString(): string;
}
/**
Represents a QuakeML Focal Mechanism.
*/
export declare class FocalMechanism extends BaseElement {
waveformIDList: WaveformID[];
momentTensorList: MomentTensor[];
triggeringOrigin?: Origin;
nodalPlanes?: NodalPlanes;
principalAxes?: PrincipalAxes;
azimuthalGap?: number;
stationPolarityCount?: number;
misfit?: number;
stationDistributionRatio?: number;
methodID?: string;
evaluationMode?: string;
evaluationStatus?: string;
/**
* Parses a QuakeML focal mechanism xml element into a FocalMechanism object.
*
* @param focalMechQML the focal mechanism xml Element
* @param allOrigins origins already extracted from the xml for linking focal mechanisms with origins
* @param allMagnitudes magnitudes already extracted from the xml for linking moment tensors with magnitudes
* @returns FocalMechanism instance
*/
static createFromXml(focalMechQML: Element, allOrigins: Origin[], allMagnitudes: Magnitude[]): FocalMechanism;
}
/**
Represents a QuakeML NodalPlanes.
*/
export declare class NodalPlanes {
nodalPlane1?: NodalPlane;
nodalPlane2?: NodalPlane;
preferredPlane?: number;
/**
* Parses a QuakeML nodal planes xml element into a NodalPlanes object.
*
* @param nodalPlanesQML the nodal planes xml Element
* @returns NodalPlanes instance
*/
static createFromXml(nodalPlanesQML: Element): NodalPlanes;
}
/**
Represents a QuakeML NodalPlane.
*/
export declare class NodalPlane {
strike: RealQuantity;
dip: RealQuantity;
rake: RealQuantity;
constructor(strike: RealQuantity, dip: RealQuantity, rake: RealQuantity);
/**
* Parses a QuakeML nodal plane xml element into a NodalPlane object.
*
* @param nodalPlaneQML the nodal plane xml Element
* @returns NodalPlane instance
*/
static createFromXml(nodalPlaneQML: Element): NodalPlane;
}
/**
Represents a QuakeML PrincipalAxes.
*/
export declare class PrincipalAxes {
tAxis: Axis;
pAxis: Axis;
nAxis?: Axis;
constructor(tAxis: Axis, pAxis: Axis);
/**
* Parses a QuakeML princpalAxes element into a PrincipalAxes object.
*
* @param princpalAxesQML the princpalAxes xml Element
* @returns PrincipalAxes instance
*/
static createFromXml(princpalAxesQML: Element): PrincipalAxes;
}
/**
Represents a QuakeML Axis.
*/
export declare class Axis {
azimuth: RealQuantity;
plunge: RealQuantity;
length: RealQuantity;
constructor(azimuth: RealQuantity, plunge: RealQuantity, length: RealQuantity);
/**
* Parses a QuakeML axis xml element into a Axis object.
*
* @param axisQML the axis xml Element
* @returns Axis instance
*/
static createFromXml(axisQML: Element): Axis;
}
/**
Represents a QuakeML MomentTensor.
*/
export declare class MomentTensor extends BaseElement {
dataUsedList: DataUsed[];
derivedOrigin: Origin;
momentMagnitude?: Magnitude;
scalarMoment?: RealQuantity;
tensor?: Tensor;
variance?: number;
varianceReduction?: number;
doubleCouple?: number;
clvd?: number;
iso?: number;
greensFunctionID?: string;
filterID?: string;
sourceTimeFunction?: SourceTimeFunction;
methodID?: string;
category?: string;
inversionType?: string;
constructor(derivedOrigin: Origin);
/**
* Parses a QuakeML momentTensor xml element into a MomentTensor object.
*
* @param momentTensorQML the momentTensor xml Element
* @param allOrigins origins already extracted from the xml for linking moment tensors with origins
* @param allMagnitudes magnitudes already extracted from the xml for linking moment tensors with magnitudes
* @returns MomentTensor instance
*/
static createFromXml(momentTensorQML: Element, allOrigins: Origin[], allMagnitudes: Magnitude[]): MomentTensor;
}
/**
Represents a QuakeML Tensor.
*/
export declare class Tensor {
Mrr: RealQuantity;
Mtt: RealQuantity;
Mpp: RealQuantity;
Mrt: RealQuantity;
Mrp: RealQuantity;
Mtp: RealQuantity;
constructor(Mrr: RealQuantity, Mtt: RealQuantity, Mpp: RealQuantity, Mrt: RealQuantity, Mrp: RealQuantity, Mtp: RealQuantity);
/**
* Parses a QuakeML tensor xml element into a Tensor object.
*
* @param tensorQML the tensor xml Element
* @returns Tensor instance
*/
static createFromXml(tensorQML: Element): Tensor;
}
/**
Represents a QuakeML SourceTimeFunction.
*/
export declare class SourceTimeFunction {
type: string;
duration: number;
riseTime?: number;
decayTime?: number;
constructor(type: string, duration: number);
/**
* Parses a QuakeML sourceTimeFunction xml element into a SourceTimeFunction object.
*
* @param sourceTimeFunctionQML the sourceTimeFunction xml Element
* @returns SourceTimeFunction instance
*/
static createFromXml(sourceTimeFunctionQML: Element): SourceTimeFunction;
}
/**
Represents a QuakeML DataUsed.
*/
export declare class DataUsed {
waveType: string;
stationCount?: number;
componentCount?: number;
shortestPeriod?: number;
longestPeriod?: number;
constructor(waveType: string);
/**
* Parses a QuakeML dataUsed xml element into a DataUsed object.
*
* @param dataUsedQML the dataUsed xml Element
* @returns SourceTimeFunction instance
*/
static createFromXml(dataUsedQML: Element): DataUsed;
}
/**
Represents a QuakeML WaveformID.
*/
export declare class WaveformID {
networkCode: string;
stationCode: string;
channelCode?: string;
locationCode?: string;
constructor(networkCode: string, stationCode: string);
/**
* Parses a QuakeML waveform ID xml element into a WaveformID object.
*
* @param waveformQML the waveform ID xml Element
* @returns WaveformID instance
*/
static createFromXml(waveformQML: Element): WaveformID;
toString(): string;
}
export declare class Quantity<T> {
value: T;
uncertainty?: number;
lowerUncertainty?: number;
upperUncertainty?: number;
confidenceLevel?: number;
constructor(value: T);
/**
* Parses a QuakeML quantity xml element into a Quantity object.
*
* @param quantityQML the quantity xml Element
* @param grab a callback to obtain the value
* @param grabUncertainty a callback to obtain the uncertainties
* @returns Quantity instance
*/
static _createFromXml<T>(quantityQML: Element, grab: (xml: Element | null | void, tagName: string) => T | undefined, grabUncertainty: (xml: Element | null | void, tagName: string) => number | undefined): Quantity<T>;
/**
* Parses a QuakeML real quantity xml element into a RealQuantity object.
*
* @param realQuantityQML the real quantity xml Element
* @returns RealQuantity instance
*/
static createRealQuantityFromXml(realQuantityQML: Element): RealQuantity;
/**
* Parses a QuakeML integer quantity xml element into a RealQuantity object.
*
* @param integerQuantityQML the integer quantity xml Element
* @returns IntegerQuantity instance
*/
static createIntegerQuantityFromXml(integerQuantityQML: Element): IntegerQuantity;
/**
* Parses a QuakeML time quantity xml element into a TimeQuantity object.
*
* @param timeQuantityQML the time quantity xml Element
* @returns TimeQuantity instance
*/
static createTimeQuantityFromXml(timeQuantityQML: Element): TimeQuantity;
}
export type IntegerQuantity = Quantity<number>;
export type RealQuantity = Quantity<number>;
export type TimeQuantity = Quantity<DateTime>;
/**
Represents a QuakeML comment.
*/
export declare class Comment {
text: string;
creationInfo?: CreationInfo;
constructor(text: string);
/**
* Parses a QuakeML comment xml element into a Comment object.
*
* @param commentQML the comment xml Element
* @returns Comment instance
*/
static createFromXml(commentQML: Element): Comment;
}
export declare class CreationInfo {
agencyID?: string;
agencyURI?: string;
author?: string;
authorURI?: string;
creationTime?: DateTime;
version?: string;
/**
* Parses a QuakeML creation info xml element into a CreationInfo object.
*
* @param creationInfoQML the creation info xml Element
* @returns CreationInfo instance
*/
static createFromXml(creationInfoQML: Element): CreationInfo;
}
/**
* Parses a QuakeML xml document into seisplotjs objects
*
* @param rawXml the xml Document to parse
* @param host optional source of the xml, helpful for parsing the eventid
* @returns EventParameters object
*/
export declare function parseQuakeML(rawXml: Document, host?: string): EventParameters;
export declare function createQuakeFromValues(publicId: string, time: DateTime, latitude: number, longitude: number, depth_meter: number): Quake;
/**
* Fetches and parses QuakeML from a URL. This can be used in instances where
* a static quakeML file is available on a web site instead of via a web
* service with query paramters.
* @param url the url to download from
* @param timeoutSec timeout seconds in case of failed connection
* @param nodata nodata http error code
* @returns Promise to parsed quakeML as an EventParameters object
*/
export declare function fetchQuakeML(url: string | URL, timeoutSec?: number, nodata?: number): Promise<EventParameters>;
export declare const parseUtil: {
_grabFirstEl: (xml: Element | null | void, tagName: string) => Element | undefined;
_grabFirstElNS: (xml: Element | null | void, namespace: string, tagName: string) => Element | undefined;
_grabFirstElText: (xml: Element | null | void, tagName: string) => string | undefined;
_grabFirstElFloat: (xml: Element | null | void, tagName: string) => number | undefined;
_grabFirstElInt: (xml: Element | null | void, tagName: string) => number | undefined;
_grabAttribute: (xml: Element | null | void, tagName: string) => string | undefined;
_requireAttribute: (xml: Element | null | void, tagName: string) => string;
_grabAttributeNS: (xml: Element | null | void, namespace: string, tagName: string) => string | undefined;
};
export {};