UNPKG

@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

370 lines (369 loc) 13.7 kB
import { Complex } from "../processing/oregondsputil"; import { FDSNSourceId, NetworkSourceId, StationSourceId, NslcId } from "../fdsn/source-id"; import { DateTime, Interval } from "luxon"; /** xml namespace for stationxml */ export declare const STAML_NS = "http://www.fdsn.org/xml/station/1"; export declare const COUNT_UNIT_NAME = "count"; export declare const FIX_INVALID_STAXML = true; export declare const INVALID_NUMBER = -99999; export declare const FAKE_START_DATE: DateTime<true> | DateTime<false>; /** a fake, completely empty stationxml document in case of no data. */ export declare const FAKE_EMPTY_XML = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> <FDSNStationXML xmlns=\"http://www.fdsn.org/xml/station/1\" schemaVersion=\"1.0\" xsi:schemaLocation=\"http://www.fdsn.org/xml/station/1 http://www.fdsn.org/xml/station/fdsn-station-1.0.xsd\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:iris=\"http://www.fdsn.org/xml/station/1/iris\"> </FDSNStationXML>"; export declare const CHANNEL_CLICK_EVENT = "channelclick"; export declare const STATION_CLICK_EVENT = "stationclick"; /** * Utility function to create CustomEvent for clicking on a Channel, for example * in a map or table. * * @param sta Channel clicked on * @param mouseclick original mouse click Event * @returns CustomEvent populated with channel field in detail. */ export declare function createChannelClickEvent(sta: Channel, mouseclick: Event): CustomEvent; /** * Utility function to create CustomEvent for clicking on a Station, for example * in a map or table. * * @param sta Station clicked on * @param mouseclick original mouse click Event * @returns CustomEvent populated with station field in detail. */ export declare function createStationClickEvent(sta: Station, mouseclick: Event): CustomEvent; export declare class Network { networkCode: string; _startDate: DateTime; _endDate: DateTime | null; restrictedStatus: string; description: string; totalNumberStations: number | null; stations: Array<Station>; constructor(networkCode: string); get sourceId(): NetworkSourceId; get startDate(): DateTime; set startDate(value: DateTime | string); get endDate(): null | DateTime; set endDate(value: DateTime | string | null); get timeRange(): Interval; codes(): string; isActiveAt(d?: DateTime): boolean; isTempNet(): boolean; } export declare class Station { network: Network; stationCode: string; sourceID: string | null; /** @private */ _startDate: DateTime; /** @private */ _endDate: DateTime | null; restrictedStatus: string; name: string; latitude: number; longitude: number; elevation: number; waterLevel: number | null; comments: Array<Comment>; equipmentList: Array<Equipment>; dataAvailability: DataAvailability | null; identifierList: Array<string>; description: string; geology: string; vault: string; channels: Array<Channel>; constructor(network: Network, stationCode: string); get sourceId(): StationSourceId; get startDate(): DateTime; set startDate(value: DateTime | string); get endDate(): DateTime | null; set endDate(value: DateTime | string | null); get timeRange(): Interval; get networkCode(): string; isActiveAt(d?: DateTime): boolean; codes(sep?: string): string; } export declare class Channel { station: Station; /** @private */ _locationCode: string; channelCode: string; /** @private */ _sourceId: FDSNSourceId | undefined; /** @private */ _startDate: DateTime; /** @private */ _endDate: DateTime | null; restrictedStatus: string; latitude: number; longitude: number; elevation: number; depth: number; azimuth: number; dip: number; sampleRate: number; waterLevel: number | null; comments: Array<Comment>; equipmentList: Array<Equipment>; dataAvailability: DataAvailability | null; identifierList: Array<string>; description: string; response: Response | null; sensor: Equipment | null; preamplifier: Equipment | null; datalogger: Equipment | null; constructor(station: Station, channelCode: string, locationCode: string); get sourceId(): FDSNSourceId; get nslcId(): NslcId; get startDate(): DateTime; set startDate(value: DateTime | string); get endDate(): null | DateTime; set endDate(value: DateTime | string | null); get timeRange(): Interval; get locationCode(): string; set locationCode(value: string); get stationCode(): string; get networkCode(): string; /** * Checks if this channel has sensitivity defined, within the response. * * @returns true if instrumentSensitivity exits */ hasInstrumentSensitivity(): boolean; set instrumentSensitivity(value: InstrumentSensitivity); get instrumentSensitivity(): InstrumentSensitivity; /** * return network, station, location and channels codes as one string. * * @returns net.sta.loc.chan */ get nslc(): string; /** * return network, station, location and channels codes as one string. * * @param sep separator, defaults to dot '.' * @returns net.sta.loc.chan */ codes(sep?: string): string; isActiveAt(d?: DateTime): boolean; } export declare class InstrumentSensitivity { sensitivity: number; frequency: number; inputUnits: string; outputUnits: string; constructor(sensitivity: number, frequency: number, inputUnits: string, outputUnits: string); } export declare class Equipment { resourceId: string; type: string; description: string; manufacturer: string; vendor: string; model: string; serialNumber: string; installationDate: DateTime | null; removalDate: DateTime | null; calibrationDateList: Array<DateTime>; constructor(); } export declare class Response { instrumentSensitivity: InstrumentSensitivity | null; stages: Array<Stage>; constructor(instrumentSensitivity?: InstrumentSensitivity, stages?: Array<Stage>); } export declare class Stage { filter: AbstractFilterType | null; decimation: Decimation | null; gain: Gain; constructor(filter: AbstractFilterType | null, decimation: Decimation | null, gain: Gain); } export declare class AbstractFilterType { inputUnits: string; outputUnits: string; name: string; description: string; constructor(inputUnits: string, outputUnits: string); } export declare class PolesZeros extends AbstractFilterType { pzTransferFunctionType: string; normalizationFactor: number; normalizationFrequency: number; zeros: Array<InstanceType<typeof Complex>>; poles: Array<InstanceType<typeof Complex>>; constructor(inputUnits: string, outputUnits: string); } export declare class FIR extends AbstractFilterType { symmetry: string; numerator: Array<number>; constructor(inputUnits: string, outputUnits: string); } export declare class CoefficientsFilter extends AbstractFilterType { cfTransferFunction: string; numerator: Array<number>; denominator: Array<number>; constructor(inputUnits: string, outputUnits: string); } export declare class Decimation { inputSampleRate: number; factor: number; offset: number | null | undefined; delay: number | null | undefined; correction: number | null | undefined; constructor(inputSampleRate: number, factor: number); } export declare class Gain { value: number; frequency: number; constructor(value: number, frequency: number); } export declare class Span { interval: Interval; numberSegments: number; maximumTimeTear: number | null; constructor(interval: Interval); } export declare class DataAvailability { extent: Interval | null; spanList: Array<Span>; constructor(); } export declare class Comment { id: string | null; subject: string | null; value: string; beginEffectiveTime: DateTime | null; endEffectiveTime: DateTime | null; authorList: Array<Author>; constructor(value: string); } export declare class Author { name: string | null; agency: string | null; email: string | null; phone: string | null; } /** * Parses the FDSN StationXML returned from a query. * * @param rawXml parsed xml to extract objects from * @returns an Array of Network objects. */ export declare function parseStationXml(rawXml: Document): Array<Network>; /** * Parses a FDSNStationXML Network xml element into a Network object. * * @param xml the network xml Element * @returns Network instance */ export declare function convertToNetwork(xml: Element): Network; /** * Parses a FDSNStationXML Station xml element into a Station object. * * @param network the containing network * @param xml the station xml Element * @returns Station instance */ export declare function convertToStation(network: Network, xml: Element): Station; /** * Parses a FDSNStationXML Channel xml element into a Channel object. * * @param station the containing staton * @param xml the channel xml Element * @returns Channel instance */ export declare function convertToChannel(station: Station, xml: Element): Channel; export declare function convertToDataAvailability(xml: Element): DataAvailability; export declare function convertToComment(xml: Element): Comment; export declare function convertToAuthor(xml: Element): Author; export declare function convertToEquipment(xml: Element): Equipment; /** * Parses a FDSNStationXML Response xml element into a Response object. * * @param responseXml the response xml Element * @returns Response instance */ export declare function convertToResponse(responseXml: Element): Response; /** * Parses a FDSNStationXML InstrumentSensitivity xml element into a InstrumentSensitivity object. * * @param xml the InstrumentSensitivity xml Element * @returns InstrumentSensitivity instance */ export declare function convertToInstrumentSensitivity(xml: Element): InstrumentSensitivity; /** * Parses a FDSNStationXML Stage xml element into a Stage object. * * @param stageXml the Stage xml Element * @returns Stage instance */ export declare function convertToStage(stageXml: Element): Stage; /** * Parses a FDSNStationXML Decimation xml element into a Decimation object. * * @param decXml the Decimation xml Element * @returns Decimation instance */ export declare function convertToDecimation(decXml: Element): Decimation; /** * Parses a FDSNStationXML Gain xml element into a Gain object. * * @param gainXml the Gain xml Element * @returns Gain instance */ export declare function convertToGain(gainXml: Element): Gain; export declare function createInterval(start: DateTime, end: null | DateTime): Interval; /** * Extracts a complex number from an stationxml element. * * @param el xml element * @returns Complex instance */ export declare function extractComplex(el: Element): InstanceType<typeof Complex>; /** * Generator function to access all stations within all networks in the array. * * @param networks array of Networks * @yields generator yeiding stations */ export declare function allStations(networks: Array<Network>): Generator<Station, void, unknown>; /** * Generator function to access all channels within all stations * within all networks in the array. * * @param networks array of Networks * @yields generator yeiding channels */ export declare function allChannels(networks: Array<Network>): Generator<Channel, void, unknown>; /** * Extract all channels from all stations from all networks in the input array. * Regular expressions may be used instaed of exact code matchs. * * @param networks Array of networks. * @param netCode network code to match * @param staCode station code to match * @param locCode location code to match * @param chanCode channel code to match * @yields Array of channels. */ export declare function findChannels(networks: Array<Network>, netCode: string, staCode: string, locCode: string, chanCode: string): Generator<Channel, void, unknown>; export declare function uniqueSourceIds(channelList: Iterable<Channel>): Array<FDSNSourceId>; export declare function uniqueStations(channelList: Iterable<Channel>): Array<Station>; export declare function uniqueNetworks(channelList: Iterable<Channel>): Array<Network>; /** * Fetches and parses StationXML from a URL. This can be used in instances where * a static stationXML 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 in case of failed connection * @param nodata http code for no data * @returns Promise to parsed StationXML as an Network array */ export declare function fetchStationXml(url: string | URL, timeoutSec?: number, nodata?: number): Promise<Array<Network>>; export declare const parseUtil: { _grabFirstEl: (xml: Element | null | void, tagName: string) => Element | null; _grabFirstElText: (xml: Element | null | void, tagName: string) => string | null; _grabFirstElFloat: (xml: Element | null | void, tagName: string) => number | null; _grabFirstElInt: (xml: Element | null | void, tagName: string) => number | null; _grabAttribute: (xml: Element | null | void, tagName: string) => string | null; _requireAttribute: (xml: Element | null | void, tagName: string) => string; _grabAttributeNS: (xml: Element | null | void, namespace: string, tagName: string) => string | null; };