Coverage for /opt/obspy/update-docs/src/obspy/obspy/arclink/client : 71%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*- ArcLink/WebDC client for ObsPy.
:copyright: The ObsPy Development Team (devs@obspy.org) :license: GNU Lesser General Public License, Version 3 (http://www.gnu.org/copyleft/lesser.html) """
""" Raised by the ArcLink client for known exceptions. """
""" The ArcLink/WebDC client.
:type host: str, optional :param host: Host name of the remote ArcLink server (default host is ``'webdc.eu'``). :type port: int, optional :param port: Port of the remote ArcLink server (default port is ``18002``). :type timeout: int, optional :param timeout: Seconds before a connection timeout is raised (default is ``20`` seconds). :type user: str, optional :param user: The user name is used for identification with the ArcLink server. This entry is also used for usage statistics within the data centers, so please provide a meaningful user id (default is ``'ObsPy client'``). :type password: str, optional :param password: A password used for authentication with the ArcLink server (default is an empty string). :type institution: str, optional :param institution: A string containing the name of the institution of the requesting person (default is an ``'Anonymous'``). :type dcid_keys: dict, optional :param dcid_keys: Dictionary of datacenter ids (DCID) and passwords used for decoding encrypted waveform requests. :type dcid_key_file: str, optional :param dcid_key_file: Simple text configuration file containing lines of data center ids (DCIDs) and password pairs separated by a equal sign, e.g. for DCID ``BIA`` and password ``OfH9ekhi`` use ``"BIA=OfH9ekhi"``. If not set, passwords found in a file called `$HOME/dcidpasswords.txt` will be used automatically. :type debug: bool, optional :param debug: Enables verbose output of the connection handling (default is ``False``). :type command_delay: float, optional :param command_delay: Delay between each command send to the ArcLink server (default is ``0``).
.. rubric:: Notes
The following ArcLink servers may be accessed via ObsPy (partly restricted access only):
* WebDC servers: webdc.eu:18001, webdc.eu:18002 * ODC Server: bhlsa03.knmi.nl:18001 * INGV Server: eida.rm.ingv.it:18001 * IPGP Server: geosrt2.ipgp.fr:18001 """ #: Delay in seconds between each status request
password="", institution="Anonymous", timeout=20, dcid_keys={}, dcid_key_file=None, debug=False, command_delay=0): """ Initializes an ArcLink client.
See :class:`obspy.arclink.client.Client` for all parameters. """ # silent connection check if self.debug: print('\nConnected to %s:%d' % (self._client.host, self._client.port)) # check for dcid_key_file # check in user directory return # parse dcid_key_file except: pass else: # ensure that dcid_keys set via parameters are not overwritten
self._client.timeout)
if self.debug: print('>>> ' + buffer)
msg = "Timeout waiting for expected %s, got %s" raise ArcLinkException(msg % (value, line)) if self.debug: print('... ' + line)
self._writeln('USER %s %s' % (self.user, self.password)) else:
# skip routing on request # always use initial node if routing is disabled # request routing table for given network/station/times combination # location and channel information are ignored by ArcLink station=request_data[3], starttime=request_data[0], endtime=request_data[1]) # search routes for network/station/location/channel # retry first ArcLink node if host or port has been changed self._client.port != self.init_port: self._client.host = self.init_host self._client.port = self.init_port if self.debug: print('\nRequesting %s:%d' % (self._client.host, self._client.port)) return self._fetch(request_type, request_data, route) # we got a routing table return self._request(request_type, request_data) # check if current connection is enough item['port'] == self._client.port: if self.debug: print('\nRequesting %s:%d' % (self._client.host, self._client.port)) except Exception: raise msg = 'Could not find route to %s.%s' raise ArcLinkException(msg % (request_data[2], request_data[3]))
# create request string # adding one second to start and end time to ensure right date times # get status id except: if 'ERROR' in status: self._bye() raise ArcLinkException('Error requesting status id') pass else: # loop until we hit ready="true" in the status message # check if status messages changes over time else: # if we hit MAX_REQUESTS equal status break the loop # wait a bit # check for errors 'WARN', 'UNSET']: # cleanup # parse XML for reason # cleanup # cleanup self._writeln('PURGE %d' % req_id) self._bye() # parse XML for error message xml_doc = objectify.fromstring(xml_doc[:-3]) raise ArcLinkException(xml_doc.request.volume.line.get('message')) # safeguard for not covered status messages self._writeln('PURGE %d' % req_id) self._bye() msg = "Uncovered status message - contact a developer to fix this" raise ArcLinkException(msg) raise Exception('Wrong length!') if self.debug: if data.startswith('<?xml'): print(data) else: print("%d bytes of data read" % len(data)) # check for encryption # extract dcid xml_doc = objectify.fromstring(xml_doc[:-3]) dcid = xml_doc.request.volume.get('dcid') # check if given in known list of keys if dcid in self.dcid_keys: # call decrypt routine from obspy.arclink.decrypt import SSLWrapper decryptor = SSLWrapper(self.dcid_keys[dcid]) data = decryptor.update(data) data += decryptor.final() else: msg = "Could not decrypt waveform data for dcid %s." warnings.warn(msg % (dcid))
endtime, format="MSEED", compressed=True, metadata=False, route=True, **kwargs): """ Retrieves waveform data via ArcLink and returns an ObsPy Stream object.
:type network: str :param network: Network code, e.g. ``'BW'``. :type station: str :param station: Station code, e.g. ``'MANZ'``. :type location: str :param location: Location code, e.g. ``'01'``. Location code may contain wild cards. :type channel: str :param channel: Channel code, e.g. ``'EHE'``. Channel code may contain wild cards. :type starttime: :class:`~obspy.core.utcdatetime.UTCDateTime` :param starttime: Start date and time. :type endtime: :class:`~obspy.core.utcdatetime.UTCDateTime` :param endtime: End date and time. :type format: ``'FSEED'`` or ``'MSEED'``, optional :param format: Output format. Either as full SEED (``'FSEED'``) or Mini-SEED (``'MSEED'``) volume. Defaults to ``'MSEED'``. :type compressed: bool, optional :param compressed: Request compressed files from ArcLink server. Defaults to ``True``. :type metadata: bool, optional :param metadata: Fetch PAZ and coordinate information and append to :class:`~obspy.core.trace.Stats` of all fetched traces. Defaults to ``False``. :type route: bool, optional :param route: Enables ArcLink routing. Defaults to ``True``. :return: ObsPy :class:`~obspy.core.stream.Stream` object.
.. rubric:: Example
>>> from obspy.arclink import Client >>> from obspy import UTCDateTime >>> client = Client("webdc.eu", 18001, user='test@obspy.org') >>> t = UTCDateTime("2009-08-20 04:03:12") >>> st = client.getWaveform("BW", "RJOB", "", "EH*", t - 3, t + 15) >>> st.plot() #doctest: +SKIP
.. plot::
from obspy import UTCDateTime from obspy.arclink.client import Client client = Client("webdc.eu", 18001, 'test@obspy.org') t = UTCDateTime("2009-08-20 04:03:12") st = client.getWaveform("BW", "RJOB", "", "EH*", t - 3, t + 15) st.plot() """ msg = "Keywords getPAZ and getCoordinates are deprecated. " + \ "Please use keyword metadata instead." warnings.warn(msg, DeprecationWarning) # handle deprecated keywords - one must be True to enable metadata kwargs.get('getCoordinates', False) starttime, endtime, format=format, compressed=compressed, route=route) # read stream using obspy.mseed # remove temporary file: except: pass # trim stream # fetching PAZ and coordinates # fetch metadata only once location=location, channel=channel, starttime=starttime, endtime=endtime, instruments=True, route=False) # add coordinates # add PAZ # multiple entries found # trim current trace to timespan of current entry entry.get('endtime', None)) # append valid paz raise ArcLinkException(MSG_NOPAZ) # add to end of stream # remove split trace else: # single entry found - apply direct raise ArcLinkException(MSG_NOPAZ)
starttime, endtime, format="MSEED", compressed=True, route=True, unpack=True): """ Writes a retrieved waveform directly into a file.
This method ensures the storage of the unmodified waveform data delivered by the ArcLink server, e.g. preserving the record based quality flags of MiniSEED files which would be neglected reading it with :mod:`obspy.mseed`.
:type filename: str :param filename: Name of the output file. :type network: str :param network: Network code, e.g. ``'BW'``. :type station: str :param station: Station code, e.g. ``'MANZ'``. :type location: str :param location: Location code, e.g. ``'01'``. Location code may contain wild cards. :type channel: str :param channel: Channel code, e.g. ``'EHE'``. Channel code may contain wild cards. :type starttime: :class:`~obspy.core.utcdatetime.UTCDateTime` :param starttime: Start date and time. :type endtime: :class:`~obspy.core.utcdatetime.UTCDateTime` :param endtime: End date and time. :type format: ``'FSEED'`` or ``'MSEED'``, optional :param format: Output format. Either as full SEED (``'FSEED'``) or Mini-SEED (``'MSEED'``) volume. Defaults to ``'MSEED'``.
.. note:: A format ``'XSEED'`` is documented, but not yet implemented in ArcLink. :type compressed: bool, optional :param compressed: Request compressed files from ArcLink server. Default is ``True``. :type route: bool, optional :param route: Enables ArcLink routing. Default is ``True``. :type unpack: bool, optional :param unpack: Unpack compressed waveform files before storing to disk. Default is ``True``. :return: None
.. rubric:: Example
>>> from obspy.arclink import Client >>> from obspy import UTCDateTime >>> client = Client("webdc.eu", 18001, user='test@obspy.org') >>> t = UTCDateTime(2009, 1, 1, 12, 0) >>> client.saveWaveform('BW.MANZ.fullseed', 'BW', 'MANZ', '', '*', ... t, t + 20, format='FSEED') # doctest: +SKIP """ # check parameters msg = "Parameter filename must be either string or file handler." raise TypeError(msg) # request type except: compressed = False else: # request data # fetch waveform # check if data is still encrypted # set "good" filenames if is_name: if compressed and not filename.endswith('.bz2.openssl'): filename += '.bz2.openssl' elif not compressed and not filename.endswith('.openssl'): filename += '.openssl' # warn user that encoded files will not be unpacked if unpack: warnings.warn("Cannot unpack encrypted waveforms.") else: # not encoded - handle as usual # unpack compressed data if option unpack is set # set "good" filenames filename += '.bz2' # create file handler if a file name is given else:
modified_after=None): """ Get primary ArcLink host for given network/stations/time combination.
:type network: str :param network: Network code, e.g. ``'BW'``. :type station: str :param station: Station code, e.g. ``'MANZ'``. :type starttime: :class:`~obspy.core.utcdatetime.UTCDateTime` :param starttime: Start date and time. :type endtime: :class:`~obspy.core.utcdatetime.UTCDateTime` :param endtime: End date and time. :type modified_after: :class:`~obspy.core.utcdatetime.UTCDateTime`, optional :param modified_after: Returns only data modified after given date. Default is ``None``, returning all available data. :return: Dictionary of host names. """ # request type rtype += 'modified_after=%s ' % modified_after.formatArcLink() # request data # fetch plain XML document # parse XML document # get routing version elif _ROUTING_NS_0_1 in xml_doc.nsmap.values(): xml_ns = _ROUTING_NS_0_1 else: msg = "Unknown routing namespace %s" raise ArcLinkException(msg % xml_doc.nsmap) # convert into dictionary # no location/stream codes in 0.1 id = route.get('net_code') + '.' + route.get('sta_code') + '..' else: route.get('stationCode') + '.' + \ route.get('locationCode') + '.' + \ route.get('streamCode') except: temp['priority'] = -1 temp['end'] = UTCDateTime(node.get('end')) else: # address field may contain multiple addresses (?)
""" Searches routing table for requested stream id and date/times. """ # Note: Filtering by date/times is not really supported by ArcLink yet, # therefore not included here # Multiple fitting entries are sorted by priority only continue continue continue continue # no route found # merge all out.append({}) else: # sort by priority y.get('priority', 1000)))
endtime, parameters='*', outages=True, logs=True): """ Retrieve QC information of ArcLink streams.
.. note:: Requesting QC is documented but seems not to work at the moment.
:type network: str :param network: Network code, e.g. ``'BW'``. :type station: str :param station: Station code, e.g. ``'MANZ'``. :type location: str :param location: Location code, e.g. ``'01'``. :type channel: str :param channel: Channel code, e.g. ``'EHE'``. :type starttime: :class:`~obspy.core.utcdatetime.UTCDateTime` :param starttime: Start date and time. :type endtime: :class:`~obspy.core.utcdatetime.UTCDateTime` :param endtime: End date and time. :type parameters: str, optional :param parameters: Comma-separated list of QC parameters. The following QC parameters are implemented in the present version: ``'availability'``, ``'delay'``, ``'gaps count'``, ``'gaps interval'``, ``'gaps length'``, ``'latency'``, ``'offset'``, ``'overlaps count'``, ``'overlaps interval'``, ``'overlaps length'``, ``'rms'``, ``'spikes amplitude'``, ``'spikes count'``, ``'spikes interval'``, ``'timing quality'`` (default is ``'*'`` for requesting all parameters). :type outages: bool, optional :param outages: Include list of outages (default is ``True``). :type logs: bool, optional :param logs: Include log messages (default is ``True``). :return: XML document as string. """ # request type rtype = 'REQUEST QC' if outages is True: rtype += ' outages=true' else: rtype += ' outages=false' if logs is True: rtype += ' logs=false' else: rtype += ' logs=false' rtype += ' parameters=%s' % (parameters) # request data rdata = [starttime, endtime, network, station, channel, location] # fetch plain XML document result = self._fetch(rtype, rdata, route=False) return result
endtime=None, time=None, route=True): """ Returns poles, zeros, normalization factor and sensitivity and station coordinates for a single channel at a given time.
:type network: str :param network: Network code, e.g. ``'BW'``. :type station: str :param station: Station code, e.g. ``'MANZ'``. :type location: str :param location: Location code, e.g. ``'01'``. :type channel: str :param channel: Channel code, e.g. ``'EHE'``. :type time: :class:`~obspy.core.utcdatetime.UTCDateTime` :param time: Date and time. :type route: bool, optional :param route: Enables ArcLink routing (default is ``True``). :return: Dictionary containing keys 'paz' and 'coordinates'.
.. rubric:: Example
>>> from obspy.arclink import Client >>> from obspy import UTCDateTime >>> client = Client("webdc.eu", 18001, user='test@obspy.org') >>> t = UTCDateTime(2009, 1, 1) >>> data = client.getMetadata('BW', 'MANZ', '', 'EHZ', t) >>> data # doctest: +NORMALIZE_WHITESPACE +SKIP {'paz': AttribDict({'poles': [(-0.037004+0.037016j), (-0.037004-0.037016j), (-251.33+0j), (-131.04-467.29j), (-131.04+467.29j)], 'sensitivity': 2516778600.0, 'zeros': [0j, 0j], 'name': 'LMU:STS-2/N/g=1500', 'normalization_factor': 60077000.0}), 'coordinates': AttribDict({'latitude': 49.9862, 'elevation': 635.0, 'longitude': 12.1083})} """ # XXX: deprecation handling # warn if old scheme msg = "The 'starttime' and 'endtime' keywords will be " + \ "deprecated. Please use 'time' instead." warnings.warn(msg, category=DeprecationWarning) # use a single starttime as time keyword elif not time: # if not temporal keyword is given raise an exception raise ValueError("keyword 'time' is required") else: # time is given starttime = time endtime = time + 0.000001 # check if single trace msg = 'getMetadata supports only a single channel, use ' + \ 'getInventory instead' raise ArcLinkException(msg) # fetch inventory location=location, channel=channel, starttime=starttime, endtime=endtime, instruments=True, route=route) data = {} # paz id = '.'.join([network, station, location, channel]) # HACK: returning first PAZ only for now - should happen only for a # timespan and not a single time if len(result[id]) > 1: msg = "Multiple PAZ found for %s. Applying first PAZ." warnings.warn(msg % (id), UserWarning) data['paz'] = result[id][0].paz # coordinates id = '.'.join([network, station]) data['coordinates'] = AttribDict() for key in ['latitude', 'longitude', 'elevation']: data['coordinates'][key] = result[id][key] return data
""" """ # instrument name # normalization factor float(xml_doc.get('normalizationFactor')) else: paz['normalization_factor'] = float(xml_doc.get('norm_fac')) except: paz['normalization_factor'] = None
float(xml_doc.get('normalizationFrequency')) else: paz['normalization_frequency'] = \ float(xml_doc.get('norm_freq')) except: paz['normalization_frequency'] = None
# for backwards compatibility (but this is wrong naming!)
# zeros else: nzeros = int(xml_doc.get('nzeros', 0)) namespaces={'ns': xml_ns})[0] except: pass # check number of zeros raise ArcLinkException('Could not parse all zeros') # poles else: npoles = int(xml_doc.get('npoles', 0)) namespaces={'ns': xml_ns})[0] except: pass # check number of poles raise ArcLinkException('Could not parse all poles')
endtime=None, time=None, route=False): """ Returns poles, zeros, normalization factor and sensitivity for a single channel at a given time.
:type network: str :param network: Network code, e.g. ``'BW'``. :type station: str :param station: Station code, e.g. ``'MANZ'``. :type location: str :param location: Location code, e.g. ``'01'``. :type channel: str :param channel: Channel code, e.g. ``'EHE'``. :type time: :class:`~obspy.core.utcdatetime.UTCDateTime` :param time: Date and time. :type route: bool, optional :param route: Enables ArcLink routing. Defaults to ``True``. :return: Dictionary containing PAZ information.
.. rubric:: Example
>>> from obspy.arclink import Client >>> from obspy import UTCDateTime >>> client = Client("webdc.eu", 18001, user='test@obspy.org') >>> t = UTCDateTime(2009, 1, 1) >>> paz = client.getPAZ('BW', 'MANZ', '', 'EHZ', t) >>> paz # doctest: +NORMALIZE_WHITESPACE +SKIP AttribDict({'poles': [(-0.037004+0.037016j), (-0.037004-0.037016j), (-251.33+0j), (-131.04-467.29j), (-131.04+467.29j)], 'sensitivity': 2516778600.0, 'zeros': [0j, 0j], 'name': 'LMU:STS-2/N/g=1500', 'normalization_factor': 60077000.0}) """ # XXX: deprecation handling # warn if old scheme msg = "The 'starttime' and 'endtime' keywords will be " + \ "deprecated. Please use 'time' instead. Be aware that the" + \ "result of getPAZ() will differ using the 'time' keyword." warnings.warn(msg, category=DeprecationWarning) # use a single starttime as time keyword elif not time: # if not temporal keyword is given raise an exception raise ValueError("keyword 'time' is required") else: # time is given starttime = time endtime = time + 0.000001 # check if single trace ' instead' # fetch inventory location=location, channel=channel, starttime=starttime, endtime=endtime, instruments=True, route=route) # old deprecated schema (ARGS!!!!) # HACK: returning first PAZ only for now if len(result[id]) > 1: msg = "Multiple PAZ found for %s. Applying first PAZ." warnings.warn(msg % (id), UserWarning) paz = result[id][0].paz return {paz.name: paz} else: # new schema except: msg = 'Could not find PAZ for channel %s' % id raise ArcLinkException(msg)
starttime, endtime, format='SEED'): """ Writes response information into a file.
:type filename: str :param filename: Name of the output file. :type network: str :param network: Network code, e.g. ``'BW'``. :type station: str :param station: Station code, e.g. ``'MANZ'``. :type location: str :param location: Location code, e.g. ``'01'``. :type channel: str :param channel: Channel code, e.g. ``'EHE'``. :type starttime: :class:`~obspy.core.utcdatetime.UTCDateTime` :param starttime: Start date and time. :type endtime: :class:`~obspy.core.utcdatetime.UTCDateTime` :param endtime: End date and time. :type format: ``'SEED'``, optional :param format: Output format. Currently only Dataless SEED is supported. :return: None
.. rubric:: Example
>>> from obspy.arclink import Client >>> from obspy import UTCDateTime >>> client = Client("webdc.eu", 18001, user='test@obspy.org') >>> t = UTCDateTime(2009, 1, 1) >>> client.saveResponse('BW.MANZ..EHZ.dataless', 'BW', 'MANZ', '', '*', ... t, t + 1, format="SEED") # doctest: +SKIP """ # check format
# request type # request data # fetch dataless else: raise ValueError("Unsupported format %s" % format)
starttime=UTCDateTime(), endtime=UTCDateTime(), instruments=False, route=True, sensortype='', min_latitude=None, max_latitude=None, min_longitude=None, max_longitude=None, restricted=None, permanent=None, modified_after=None): """ Returns information about the available networks and stations in that particular space/time region.
:type network: str :param network: Network code, e.g. ``'BW'``. :type station: str :param station: Station code, e.g. ``'MANZ'``. Station code may contain wild cards. :type location: str :param location: Location code, e.g. ``'01'``. Location code may contain wild cards. :type channel: str :param channel: Channel code, e.g. ``'EHE'``. Channel code may contain wild cards. :type starttime: :class:`~obspy.core.utcdatetime.UTCDateTime` :param starttime: Start date and time. :type endtime: :class:`~obspy.core.utcdatetime.UTCDateTime` :param endtime: End date and time. :type instruments: bool, optional :param instruments: Include instrument data (default is ``False``). :type route: bool, optional :param route: Enables ArcLink routing (default is ``True``). :type sensortype: str, optional :param sensortype: Limit streams to those using specific sensor types: ``"VBB"``, ``"BB"``, ``"SM"``, ``"OBS"``, etc. Can be also a combination like ``"VBB+BB+SM"``. :type min_latitude: float, optional :param min_latitude: Minimum latitude. :type max_latitude: float, optional :param max_latitude: Maximum latitude. :type min_longitude: float, optional :param min_longitude: Minimum longitude. :type max_longitude: float, optional :param max_longitude: Maximum longitude :type permanent: bool, optional :param permanent: Requesting only permanent or temporary networks respectively. Default is ``None``, therefore requesting all data. :type restricted: bool, optional :param restricted: Requesting only networks/stations/streams that have restricted or open data respectively. Default is ``None``. :type modified_after: :class:`~obspy.core.utcdatetime.UTCDateTime`, optional :param modified_after: Returns only data modified after given date. Default is ``None``, returning all available data. :return: Dictionary of inventory information.
.. rubric:: Example
>>> from obspy.arclink import Client >>> client = Client("webdc.eu", 18001, user='test@obspy.org') >>> inv = client.getInventory('BW', 'M*', '*', 'EHZ', restricted=False, ... permanent=True, min_longitude=12, ... max_longitude=12.2) #doctest: +SKIP >>> inv.keys() # doctest: +SKIP ['BW.MROB', 'BW.MANZ..EHZ', 'BW', 'BW.MANZ', 'BW.MROB..EHZ'] >>> inv['BW'] # doctest: +SKIP AttribDict({'description': 'BayernNetz', 'region': 'Germany', ... >>> inv['BW.MROB'] # doctest: +SKIP AttribDict({'code': 'MROB', 'description': 'Rosenbuehl, Bavaria', ... """ # request type rtype += 'modified_after=%s ' % modified_after.formatArcLink() # request data rdata.append('restricted=true') rdata.append('restricted=false') rdata.append('permanent=true') rdata.append('permanent=false') rdata.append('sensortype=%s' % sensortype) rdata.append('latmin=%f' % min_latitude) rdata.append('latmax=%f' % max_latitude) rdata.append('lonmin=%f' % min_longitude) rdata.append('lonmax=%f' % max_longitude) # fetch plain XML document # set route to False if not network id is given else: # parse XML document # get routing version elif _INVENTORY_NS_0_2 in xml_doc.nsmap.values(): xml_ns = _INVENTORY_NS_0_2 stream_ns = 'seis_stream' component_ns = 'component' seismometer_ns = 'seismometer' name_ns = 'name' resp_paz_ns = 'resp_paz' else: msg = "Unknown inventory namespace %s" raise ArcLinkException(msg % xml_doc.nsmap)
'unit', 'response']:
# convert into dictionary # strings 'net_class', 'region', 'type']: # restricted else: # date / times except: net.start = None # remark namespaces={'ns': xml_ns})[0].text or '' except: net.remark = '' # write network entries # stations namespaces={'ns0': xml_ns}): # strings 'place', 'restricted', 'archive_net']: # floats # restricted else: # date / times except: sta.start = None # remark namespaces={'ns': xml_ns})[0].text or '' except: sta.remark = '' # write station entry # instruments namespaces={'ns': xml_ns}): # date / times except: start = None # check date/time boundaries continue # fetch component namespaces={'ns': xml_ns}): seismometer_id = stream.get(seismometer_ns, None) else: # channel id # channel code is split into two attributes id = '.'.join([net.code, sta.code, stream.get('loc_code', ''), stream.get('code', ' ') + \ comp.get('code', ' ')]) else: stream.get('code', ''), comp.get('code', '')]) # write channel entry
# fetch sensitivity etc except: temp['sensitivity'] = None # again keep it backwards compatible float(comp.get('gainFrequency')) except: temp['sensitivity_frequency'] = None except: temp['sensitivity_unit'] = None
# date / times except: temp['starttime'] = None continue # PAZ '[@' + name_ns + '="' + \ seismometer_id + '"]/@response', namespaces={'ns': xml_ns}) continue # hack for 0.2 schema paz_id = paz_id[4:] name_ns + '="' + paz_id + '"]', namespaces={'ns': xml_ns}) continue # parse PAZ # sensitivity temp['sensitivity_frequency']
# add some seismometer-specific "nice to have" stuff sensors[publicID]['manufacturer'] except: paz['sensor_manufacturer'] = None paz['sensor_model'] = None
""" Returns a dictionary of available networks within the given time span.
.. note:: Currently the time span seems to be ignored by the ArcLink servers, therefore all possible networks are returned.
:type starttime: :class:`~obspy.core.utcdatetime.UTCDateTime` :param starttime: Start date and time. :type endtime: :class:`~obspy.core.utcdatetime.UTCDateTime` :param endtime: End date and time. :return: Dictionary of network data. """ endtime=endtime, route=False)
""" Returns a dictionary of available stations in the given network(s).
.. note:: Currently the time span seems to be ignored by the ArcLink servers, therefore all possible stations are returned.
:type starttime: :class:`~obspy.core.utcdatetime.UTCDateTime` :param starttime: Start date and time. :type endtime: :class:`~obspy.core.utcdatetime.UTCDateTime` :param endtime: End date and time. :type network: str :param network: Network code, e.g. ``'BW'``. :return: Dictionary of station data. """ endtime=endtime) if key.startswith(network + '.') \ and "code" in value]
if __name__ == '__main__': import doctest doctest.testmod(exclude_empty=True) |