2. Developer documentation

2.1. fdsnavail module

fdsnavail lets the user interact with the new availability web service deployed at many data centres. There are three modes of operation: query, scan, and compare.

class fdsnwsscripts.fdsnavail.Availability(stream: Stream = None, starttime: datetime = None, endtime: datetime = None, postfile: str = None)

Bases: object

Availability information about streams

addchunk(streamid: Stream, newts: List[datetime])

Add a new timewindow to this object. This method takes care of merging entries if the availability can be expressed in a more compact way.

Parameters:
  • streamid (Stream) – Stream to be added

  • newts (list) – Time window to be added in the form of a list with two components

json() dict

Return availability information in JSON format compatible with the availability specification

Return type:

dict

output(outformat: str = 'post') str | dict

Return availability information in POST or JSON format

Parameters:

outformat (str) – Output format

Return type:

dict, str

post() str

Return availability information in POST format compatible with the availability specification

Return type:

str

streams() Iterable[Stream]

Return streams in this availability object

class fdsnwsscripts.fdsnavail.Stream(net, sta, loc, cha, qua, sr)

Bases: Stream

Stream with the four components from NSLC code plus quality and sampling rate

strfilter() str

Transform the Stream to a string with key/value pairs to be used in a GET request

Returns:

Equivalent string to be used in a GET request with key/value pairs.

Return type:

str

fdsnwsscripts.fdsnavail.line2filter(line: str) str

Convert a line potentially from a POST request to an equivalent string with key=value pairs to be used in a GET request

Parameters:

line (str) – Line from a POST request.

Returns:

Equivalent string to be used in a GET request with key/value pairs.

Return type:

str

fdsnwsscripts.fdsnavail.mseed2avail(directory: str) Availability

Scan all the files with extension “.mseed” in the directory passed as input parameter.

Parameters:

directory (str) – Directory where the files should be scanned

Returns:

Availability information from the mseed files

Return type:

Availability

fdsnwsscripts.fdsnavail.sds2avail(directory: str) Availability

Scan all the files with extension “.mseed” in the directory passed as input parameter

Parameters:

directory (str) – Directory where the root of the SDS is located

Returns:

Availability information from the SDS structure

Return type:

Availability

fdsnwsscripts.fdsnavail.str2date(dstr: str) datetime | None

Transform a string to a datetime.

Parameters:

dstr (str) – A datetime in ISO format.

Returns:

A datetime represented the converted input.

Return type:

datetime

2.2. fdsnws2sds module

exception fdsnwsscripts.fdsnws2sds.Error

Bases: Exception

2.3. fdsnws2seed module

2.4. fdsnws_fetch module

A command-line FDSN Web Service client using EIDA routing and authentication.

2.4.1. Usage Examples

Request 60 minutes of the "LHZ" channel of EIDA stations starting with "A" for a seismic event around 2010-02-27 07:00 (UTC). Optionally add "-v" for verbosity. Resulting Mini-SEED data will be written to file "data.mseed".

$ %(prog)s -N '*' -S 'A*' -L '*' -C 'LHZ' -s "2010-02-27T07:00:00Z" -e "2010-02-27T08:00:00Z" -v -o data.mseed

The above request is anonymous and therefore restricted data will not be included. To include restricted data, use a file containing a token obtained from an EIDA authentication service and/or a CSV file with username and password for each node not implementing the EIDA auth extension.

$ %(prog)s -a token.asc -c credentials.csv -N '*' -S 'A*' -L '*' -C 'LHZ' -s "2010-02-27T07:00:00Z" -e "2010-02-27T08:00:00Z" -v -o data.mseed

StationXML metadata for the above request can be requested using the following command:

$ %(prog)s -N '*' -S 'A*' -L '*' -C 'LHZ' -s "2010-02-27T07:00:00Z" -e "2010-02-27T08:00:00Z" -y station -q level=response -v -o station.xml

Multiple query parameters can be used:

$ %(prog)s -N '*' -S '*' -L '*' -C '*' -s "2010-02-27T07:00:00Z" -e "2010-02-27T08:00:00Z" -y station -q format=text -q level=channel -q latitude=20 -q longitude=-150 -q maxradius=15 -v -o station.txt

Bulk requests can be made in ArcLink (-f), breq_fast (-b) or native FDSNWS POST (-p) format. Query parameters should not be included in the request file, but specified on the command line.

$ %(prog)s -p request.txt -y station -q level=channel -v -o station.xml
exception fdsnwsscripts.fdsnws_fetch.AuthNotSupported

Bases: Exception

exception fdsnwsscripts.fdsnws_fetch.Error

Bases: Exception