当前位置: 首页>>代码示例>>Python>>正文


Python Client.get_events方法代码示例

本文整理汇总了Python中obspy.clients.fdsn.Client.get_events方法的典型用法代码示例。如果您正苦于以下问题:Python Client.get_events方法的具体用法?Python Client.get_events怎么用?Python Client.get_events使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在obspy.clients.fdsn.Client的用法示例。


在下文中一共展示了Client.get_events方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: find_event

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_events [as 别名]
def find_event(st, timebefore=5, timeafter=5, service="IRIS"):
    '''
    Uses the selected webservice to search for an event matching the stream's starttime plus/minus the specified time window.
    
    If multiple streams match, lists them.
    
    Parameters
    ----------
    st : ObsPy Stream object
        Stream of SAC format seismograms for the event in question
    timebefore : float
        Time in seconds before stream start time from which to search catalog for events
    timeafter : float
        Time insseconds after stream start time up to which to search catalog for events
    service : String
        Web service to use to search for events. Same options as for obspy.fdsn.Client. Default is IRIS.

    Returns
    -------
    event : ObsPy Event object
        Downloaded information for the event, if found.
    '''
    
    webservice = Client(service)
    
    try:
        cat = webservice.get_events(starttime=st[0].stats.starttime - timebefore, endtime=st[0].stats.starttime + timeafter, minmagnitude=st[0].stats.sac.mag - 1.0, maxmagnitude=st[0].stats.sac.mag + 1.0)
        
    except FDSNException:
        print "No event found for stream startttime. Try adjusting time window."
        return
    
    except AttributeError:
        print "No stats.sac dictionary, attempting search based on time window alone..."
        
        try:
            cat = webservice.get_events(starttime=st[0].stats.starttime - timebefore, endtime=st[0].stats.starttime + timeafter)
            
        except FDSNException:
            print "No event found for stream startttime. Try adjusting time window."
            return
    
    if len(cat) > 1:
        print "Multiple events found for stream starttime. Try adjusting time window."
        print cat
        return
    
    event = cat[0]
    
    print event
    
    return event
开发者ID:NeilWilkins,项目名称:vespa,代码行数:54,代码来源:utils.py

示例2: get_all_mags

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_events [as 别名]
def get_all_mags(eventid):
    """Get all magnitudes for a given event ID.

    Args:
        eventid (str): ComCat Event ID.
    Returns:
        dict: Dictionary where keys are "magsrc-magtype" and values
              are magnitude value.

    """
    row = {}
    msg = ''
    client = Client('USGS')
    try:
        obsevent = client.get_events(eventid=eventid).events[0]
    except Exception as e:
        msg = 'Failed to download event %s, error "%s".' % (eventid, str(e))
    for mag in obsevent.magnitudes:
        magvalue = mag.mag
        magtype = mag.magnitude_type
        magsrc = get_mag_src(mag)
        colname = '%s-%s' % (magsrc, magtype)
        if colname in row:
            continue
        row[colname] = magvalue
    return (row, msg)
开发者ID:usgs,项目名称:libcomcat,代码行数:28,代码来源:utils.py

示例3: test_redirection

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_events [as 别名]
    def test_redirection(self):
        """
        Tests the redirection of GET and POST requests. We redirect
        everything if not authentication is used.

        IRIS runs three services to test it:
            http://ds.iris.edu/files/redirect/307/station/1
            http://ds.iris.edu/files/redirect/307/dataselect/1
            http://ds.iris.edu/files/redirect/307/event/1
        """
        c = Client("IRIS", service_mappings={
            "station":
                "http://ds.iris.edu/files/redirect/307/station/1",
            "dataselect":
                "http://ds.iris.edu/files/redirect/307/dataselect/1",
            "event":
                "http://ds.iris.edu/files/redirect/307/event/1"},
            user_agent=USER_AGENT)

        st = c.get_waveforms(
            network="IU", station="ANMO", location="00", channel="BHZ",
            starttime=UTCDateTime("2010-02-27T06:30:00.000"),
            endtime=UTCDateTime("2010-02-27T06:30:01.000"))
        # Just make sure something is being downloaded.
        self.assertTrue(bool(len(st)))

        inv = c.get_stations(
            starttime=UTCDateTime("2000-01-01"),
            endtime=UTCDateTime("2001-01-01"),
            network="IU", station="ANMO", level="network")
        # Just make sure something is being downloaded.
        self.assertTrue(bool(len(inv.networks)))

        cat = c.get_events(starttime=UTCDateTime("2001-01-07T01:00:00"),
                           endtime=UTCDateTime("2001-01-07T01:05:00"),
                           catalog="ISC")
        # Just make sure something is being downloaded.
        self.assertTrue(bool(len(cat)))

        # Also test the bulk requests which are done using POST requests.
        bulk = (("TA", "A25A", "", "BHZ",
                 UTCDateTime("2010-03-25T00:00:00"),
                 UTCDateTime("2010-03-25T00:00:01")),
                ("TA", "A25A", "", "BHE",
                 UTCDateTime("2010-03-25T00:00:00"),
                 UTCDateTime("2010-03-25T00:00:01")))
        st = c.get_waveforms_bulk(bulk, quality="B", longestonly=False)
        # Just make sure something is being downloaded.
        self.assertTrue(bool(len(st)))

        starttime = UTCDateTime(1990, 1, 1)
        endtime = UTCDateTime(1990, 1, 1) + 10
        bulk = [
            ["IU", "ANMO", "", "BHE", starttime, endtime],
            ["IU", "CCM", "", "BHZ", starttime, endtime],
        ]
        inv = c.get_stations_bulk(bulk, level="network")
        # Just make sure something is being downloaded.
        self.assertTrue(bool(len(inv.networks)))
开发者ID:Keita1,项目名称:obspy,代码行数:61,代码来源:test_client.py

示例4: get_events

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_events [as 别名]
def get_events():
    try:
        return read_events(evname)
    except Exception:
        pass
    client = Client()
    events = client.get_events(starttime=t1, endtime=t2, latitude=lat,
                               longitude=lon, minradius=30, maxradius=90,
                               minmagnitude=6., maxmagnitude=6.5)
    events.write(evname, 'QUAKEML')
    return events
开发者ID:trichter,项目名称:rf,代码行数:13,代码来源:create_example_files.py

示例5: test_dist_mat_km

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_events [as 别名]
 def test_dist_mat_km(self):
     """Test spacial clustering."""
     from eqcorrscan.utils.clustering import dist_mat_km
     from obspy.clients.fdsn import Client
     from obspy import UTCDateTime
     client = Client("IRIS")
     starttime = UTCDateTime("2002-01-01")
     endtime = UTCDateTime("2002-01-02")
     cat = client.get_events(starttime=starttime, endtime=endtime,
                             minmagnitude=6, catalog="ISC")
     dist_mat = dist_mat_km(cat)
     self.assertEqual(len(dist_mat), len(cat))
开发者ID:xiansch,项目名称:EQcorrscan,代码行数:14,代码来源:clustering_test.py

示例6: cat4stream

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_events [as 别名]
def cat4stream(stream, client_name, stime=None, etime=None, minmag=None, lat=None, lon=None, mindepth=None):

	client = Client(client_name)
	try:
		eventinfo 	= stream[0].stats.sh
		depth 		= eventinfo['DEPTH']+10
		lat 		= eventinfo['LAT']
		lon 		= eventinfo['LON']
		origin 		= eventinfo['ORIGIN']

		etime = origin + 300
		stime = origin - 300
		cat = client.get_events(starttime=stime, endtime=etime, maxdepth=depth, latitude=lat, longitude=lon, maxradius=0.5, mindepth=mindepth)

		return cat
	except:
		try:
			cat = client.get_events(starttime=stime, endtime=etime, latitude=lat, longitude=lon, minmagnitude=minmag, mindepth=mindepth)
			return cat
		except:
			print('No Catalog found')
			return
开发者ID:s-schneider,项目名称:FK-Toolbox,代码行数:24,代码来源:base.py

示例7: test_space_time_cluster

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_events [as 别名]
 def test_space_time_cluster(self):
     """Test clustering in space and time."""
     from eqcorrscan.utils.clustering import space_time_cluster
     from obspy.clients.fdsn import Client
     from obspy import UTCDateTime
     client = Client("IRIS")
     starttime = UTCDateTime("2002-01-01")
     endtime = UTCDateTime("2002-01-02")
     cat = client.get_events(starttime=starttime, endtime=endtime,
                             minmagnitude=6, catalog="ISC")
     groups = space_time_cluster(catalog=cat, t_thresh=86400, d_thresh=1000)
     self.assertEqual(len([ev for group in groups for ev in group]),
                      len(cat))
开发者ID:xiansch,项目名称:EQcorrscan,代码行数:15,代码来源:clustering_test.py

示例8: test_download_write

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_events [as 别名]
    def test_download_write(self):
        """
        Function to download quakeML files from a range of datacenters and \
        attempt to write miniseed files
        """
        import os
        from eqcorrscan.utils import sfile_util
        import obspy
        if int(obspy.__version__.split('.')[0]) >= 1:
            from obspy.clients.fdsn import Client
            from obspy import read_events
            from obspy.clients.fdsn.header import FDSNException
        else:
            from obspy.fdsn import Client
            from obspy import readEvents as read_events
            from obspy.fdsn.header import FDSNException
        import warnings

        event_list = [('GEONET', '2016p008122'),
                      ('NCEDC', '72572665'),
                      ('USGS', 'nc72597260')]
        for event_info in event_list:
            client = Client(event_info[0])
            if event_info[0] == 'GEONET':
                try:
                    data_stream = client.\
                        _download('http://quakeml.geonet.org.nz/' +
                                  'quakeml/1.2/' + event_info[1])
                    data_stream.seek(0, 0)
                    event = read_events(data_stream, format="quakeml")
                    data_stream.close()
                except FDSNException:
                    warnings.warn('FDSNException')
                    continue
            else:
                try:
                    event = client.get_events(eventid=event_info[1],
                                              includearrivals=True)
                except FDSNException:
                    warnings.warn('FDSNException')
                    continue
            test_Sfile_name = sfile_util.eventtosfile(event, 'test', 'L', '.',
                                                      'null', overwrite=True)
            os.remove(test_Sfile_name)
        return True
开发者ID:cjhopp,项目名称:EQcorrscan,代码行数:47,代码来源:sfile_util_test.py

示例9: main

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_events [as 别名]
def main():
# 2. Get your events in an obspy Catalog object. Be sure to include the
#    arrivals, so that hypoDD has something to work on, as waveform
#    cross-correlation has not been implemented yet.
    client = Client("http://rdsa.knmi.nl")
    mycat = client.get_events( minmagnitude=0.0,
                               minlatitude=52.6,
                               minlongitude=6.0,
                               maxlatitude=53.8,
                               maxlongitude=7.5,
                               starttime=UTCDateTime("2015-01-01T00:00:00"),
                               includearrivals=True)

# 3. Initialize a hypoDD object. The working directory should contain the
#    binaries for ph2dt and hypoDD. You need the client argument to download
#    station metadata and waveforms* (*not implemented yet)
    myhypoDD=HypoDDObject(mycat,client,"./work")

# 4. Set values for ph2dt and hypoDD parameters (see manual for details), if
#    you don't want to use the default hypoDDutil values (you probably don't)
    myhypoDD.ph2dt_control.maxsep = 7.5
    myhypoDD.hypoDD_control.dist = 300
#   and so on. You can give values for all parameters, or for none.

# 5. Prepare the control files and input files
    myhypoDD.prepare_all()
# 6. Run ph2dt with the current configuration
    myhypoDD.run_ph2dt()
# 7. Run hypoDD with the current configuration
    myhypoDD.run_hypoDD()

# 8. Get the output in the form of a list of clusters (in the hypoDD sense)
#    a cluster is a catalog with some metadata, like whether hypoDD succeeded
#    with these events or how well connected* the cluster is (*not implemented
#    yet)
    clusters=myhypoDD.get_results()

    for cluster in clusters:
        print "hypoDD cluster ID: {}".format(cluster.hypoDD_id)
        print "cluster was relocated successfully: {}".format(
                                               cluster.successful_relocation
                                               )
        print cluster.catalog
        print
开发者ID:ogalanis,项目名称:hypoDDutils,代码行数:46,代码来源:example.py

示例10: test_download_urls_for_custom_mapping

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_events [as 别名]
    def test_download_urls_for_custom_mapping(self, download_url_mock):
        """
        Tests the downloading of data with custom mappings.
        """
        base_url = "http://example.com"

        # More extensive mock setup simulation service discovery.
        def custom_side_effects(*args, **kwargs):
            if "version" in args[0]:
                return 200, "1.0.200"
            elif "event" in args[0]:
                with open(os.path.join(
                        self.datapath, "2014-01-07_iris_event.wadl"),
                        "rb") as fh:
                    return 200, fh.read()
            elif "station" in args[0]:
                with open(os.path.join(
                        self.datapath,
                        "2014-01-07_iris_station.wadl"), "rb") as fh:
                    return 200, fh.read()
            elif "dataselect" in args[0]:
                with open(os.path.join(
                        self.datapath,
                        "2014-01-07_iris_dataselect.wadl"), "rb") as fh:
                    return 200, fh.read()
            return 404, None

        download_url_mock.side_effect = custom_side_effects

        # Some custom urls
        base_url_event = "http://example.com/beta/event_service/11"
        base_url_station = "http://example.org/beta2/station/7"
        base_url_ds = "http://example.edu/beta3/dataselect/8"

        # An exception will be raised if not actual WADLs are returned.
        # Catch warnings to avoid them being raised for the tests.
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            c = Client(base_url=base_url, service_mappings={
                "event": base_url_event,
                "station": base_url_station,
                "dataselect": base_url_ds,
            })
        for warning in w:
            self.assertTrue("Could not parse" in str(warning) or
                            "cannot deal with" in str(warning))

        # Test the dataselect downloading.
        download_url_mock.reset_mock()
        download_url_mock.side_effect = None
        download_url_mock.return_value = 404, None
        try:
            c.get_waveforms("A", "B", "C", "D", UTCDateTime() - 100,
                            UTCDateTime())
        except:
            pass
        self.assertTrue(
            base_url_ds in download_url_mock.call_args_list[0][0][0])

        # Test the station downloading.
        download_url_mock.reset_mock()
        download_url_mock.side_effect = None
        download_url_mock.return_value = 404, None
        try:
            c.get_stations()
        except:
            pass
        self.assertTrue(
            base_url_station in download_url_mock.call_args_list[0][0][0])

        # Test the event downloading.
        download_url_mock.reset_mock()
        download_url_mock.side_effect = None
        download_url_mock.return_value = 404, None
        try:
            c.get_events()
        except:
            pass
        self.assertTrue(
            base_url_event in download_url_mock.call_args_list[0][0][0])
开发者ID:Keita1,项目名称:obspy,代码行数:82,代码来源:test_client.py

示例11: test_redirection_auth

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_events [as 别名]
    def test_redirection_auth(self):
        """
        Tests the redirection of GET and POST requests using authentication.

        By default these should not redirect and an exception is raised.
        """
        # Clear the cache.
        Client._Client__service_discovery_cache.clear()

        # The error will already be raised during the initialization in most
        # cases.
        self.assertRaises(
            FDSNRedirectException,
            Client, "IRIS", service_mappings={
                "station": "http://ds.iris.edu/files/redirect/307/station/1",
                "dataselect":
                    "http://ds.iris.edu/files/redirect/307/dataselect/1",
                "event": "http://ds.iris.edu/files/redirect/307/event/1"},
            user="[email protected]", password="anonymous",
            user_agent=USER_AGENT)

        # The force_redirect flag overwrites that behaviour.
        c_auth = Client("IRIS", service_mappings={
            "station":
                "http://ds.iris.edu/files/redirect/307/station/1",
            "dataselect":
                "http://ds.iris.edu/files/redirect/307/dataselect/1",
            "event":
                "http://ds.iris.edu/files/redirect/307/event/1"},
            user="[email protected]", password="anonymous",
            user_agent=USER_AGENT, force_redirect=True)

        st = c_auth.get_waveforms(
            network="IU", station="ANMO", location="00", channel="BHZ",
            starttime=UTCDateTime("2010-02-27T06:30:00.000"),
            endtime=UTCDateTime("2010-02-27T06:30:01.000"))
        # Just make sure something is being downloaded.
        self.assertTrue(bool(len(st)))

        inv = c_auth.get_stations(
            starttime=UTCDateTime("2000-01-01"),
            endtime=UTCDateTime("2001-01-01"),
            network="IU", station="ANMO", level="network")
        # Just make sure something is being downloaded.
        self.assertTrue(bool(len(inv.networks)))

        cat = c_auth.get_events(starttime=UTCDateTime("2001-01-07T01:00:00"),
                                endtime=UTCDateTime("2001-01-07T01:05:00"),
                                catalog="ISC")
        # Just make sure something is being downloaded.
        self.assertTrue(bool(len(cat)))

        # Also test the bulk requests which are done using POST requests.
        bulk = (("TA", "A25A", "", "BHZ",
                 UTCDateTime("2010-03-25T00:00:00"),
                 UTCDateTime("2010-03-25T00:00:01")),
                ("TA", "A25A", "", "BHE",
                 UTCDateTime("2010-03-25T00:00:00"),
                 UTCDateTime("2010-03-25T00:00:01")))
        st = c_auth.get_waveforms_bulk(bulk, quality="B", longestonly=False)
        # Just make sure something is being downloaded.
        self.assertTrue(bool(len(st)))

        starttime = UTCDateTime(1990, 1, 1)
        endtime = UTCDateTime(1990, 1, 1) + 10
        bulk = [
            ["IU", "ANMO", "", "BHE", starttime, endtime],
            ["IU", "CCM", "", "BHZ", starttime, endtime],
        ]
        inv = c_auth.get_stations_bulk(bulk, level="network")
        # Just make sure something is being downloaded.
        self.assertTrue(bool(len(inv.networks)))
开发者ID:Keita1,项目名称:obspy,代码行数:74,代码来源:test_client.py

示例12: Client

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_events [as 别名]
import numpy as np
import numpy.matlib as mat
#import scipy as Sci
#import scipy.linalg


#---PARAMETERIZATION---#
plt.style.use('ggplot')
plt.rcParams['figure.figsize'] = 12, 8

#---DATA_FROM_FDSN---#
#get specified event
client = Client(base_url = "http://arclink.ethz.ch")
starttime = UTCDateTime("2016-05-20")
endtime = UTCDateTime("2016-05-22")
cat = client.get_events(starttime=starttime, endtime=endtime, minmagnitude=2, limit=5, mindepth=5)
print(type(cat)) #Catalog
print(cat)
cat.plot(outfile='output/py_eq_utc20160521_ml3.0_event.png') #add also resouces like: projection="local"

#get stations with the event
evt = cat[1]
print(type(evt))
print(evt)
origin = evt.origins[0]
otime = origin.time
print(type(origin))
t = origin.time
inv = client.get_stations(longitude=origin.longitude, latitude=origin.latitude, maxradius=0.2, starttime=t, endtime =t+100, channel="HH?", network="CH", level="station")
print(type(inv))
print(inv)
开发者ID:cwebber04,项目名称:SAMSFAULTZ_CODE,代码行数:33,代码来源:py_eq_utc20160521_ml3.0.py

示例13: mktemplates

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_events [as 别名]
def mktemplates(network_code='GEONET',
                publicIDs=['2016p008122', '2016p008353', '2016p008155',
                           '2016p008194']):
    """Functional wrapper to make templates"""

    from collections import Counter
    from eqcorrscan.core import template_gen

    # This import section copes with namespace changes between obspy versions
    import obspy
    if int(obspy.__version__.split('.')[0]) >= 1:
        from obspy.clients.fdsn import Client
        from obspy import read_events
    else:
        from obspy.fdsn import Client
        from obspy import readEvents as read_events
    from obspy.core.event import Catalog

    # We want to download some QuakeML files from the New Zealand GeoNet
    # network, GeoNet currently doesn't support FDSN event queries, so we
    # have to work around to download quakeml from their quakeml.geonet site.

    client = Client(network_code)
    # We want to download a few events from an earthquake sequence, these are
    # identified by publiID numbers, given as arguments

    catalog = Catalog()
    for publicID in publicIDs:
        if network_code == 'GEONET':
            data_stream = client._download('http://quakeml.geonet.org.nz/' +
                                           'quakeml/1.2/' + publicID)
            data_stream.seek(0, 0)
            catalog += read_events(data_stream, format="quakeml")
            data_stream.close()
        else:
            catalog += client.get_events(eventid=publicID,
                                         includearrivals=True)

    # Lets plot the catalog to see what we have
    catalog.plot(projection='local', resolution='h')

    # We don't need all the picks, lets take the information from the
    # five most used stations
    all_picks = []
    for event in catalog:
        all_picks += [(pick.waveform_id.station_code) for pick in event.picks]
    all_picks = Counter(all_picks).most_common(5)
    all_picks = [pick[0] for pick in all_picks]

    for event in catalog:
        if len(event.picks) == 0:
            raise IOError('No picks found')
        event.picks = [pick for pick in event.picks
                       if pick.waveform_id.station_code in all_picks]

    # Now we can generate the templates
    templates = template_gen.from_client(catalog=catalog,
                                         client_id=network_code,
                                         lowcut=2.0, highcut=9.0,
                                         samp_rate=20.0, filt_order=4,
                                         length=3.0, prepick=0.15,
                                         swin='all', debug=1, plot=True)

    # We now have a series of templates! Using Obspys Stream.write() method we
    # can save these to disk for later use.  We will do that now for use in the
    # following tutorials.
    for i, template in enumerate(templates):
        template.write('tutorial_template_' + str(i) + '.ms', format='MSEED')
        # Note that this will warn you about data types.  As we don't care
        # at the moment, whatever obspy chooses is fine.
    return
开发者ID:cjhopp,项目名称:EQcorrscan,代码行数:73,代码来源:template_creation.py

示例14: return

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_events [as 别名]
        return ('mo')
    elif depth < 20.0:
        return ('yo')
    elif depth < 30.0:
        return ('go')
    elif depth < 40.0:
        return ('co')
    else:
        return ('bo')

#---DATA_FROM_FDSN---#
#get specified event
client = Client(base_url = "http://arclink.ethz.ch")
starttime = UTCDateTime("2016-01-01")
endtime = UTCDateTime()
cat = client.get_events(starttime=starttime, endtime=endtime, minmagnitude=1)#, filename="requested_events.xml"
evtnum = cat.count()
print(type(cat)) #Catalog
print(cat) #add , CatalogObject.__str__(print_all=True) to print all events
#cat.plot() #add also resouces like: projection="local"
focaltime = []
hypolon = []
hypolat = []
hypodep = []
eqmag = []
for x in range(0, evtnum):
	event = cat[x]
	focaltime.append(event.origins[0].time)
	hypolon.append(event.origins[0].longitude)
	hypolat.append(event.origins[0].latitude)
	hypodep.append(event.origins[0].depth/1000)
开发者ID:cwebber04,项目名称:SAMSFAULTZ_CODE,代码行数:33,代码来源:py_seismicity_schweiz.py

示例15: fdsnws

# 需要导入模块: from obspy.clients.fdsn import Client [as 别名]
# 或者: from obspy.clients.fdsn.Client import get_events [as 别名]
def fdsnws(base_url="http://arclink.ethz.ch:8080",
                      endafter=40.,
                      maxradius=.6,
                      location='*',
                      channel='HNZ,HNE,HNN,HGZ,HGE,HGN,HHZ,HHE,HHN,EHZ,EHE,EHN,SHZ,SHE,SHN',
                      stations_base_url=None,
                      waveforms_base_url=None,
                      quality=None,
                      minimumlength=None,
                      longestonly=None,
           correction_method = remove_sensitivity,
         eventid=None,
                      **get_events_options):
    
    
    # First import :
    from obspy.clients.fdsn import Client
    fdsnclient = Client(base_url)
    
    # eventid in URL case
    if eventid is  None:
        eventid = 'smi:ch.ethz.sed/sc3a/2017epaqsp'
        print('Picks default eventid:',eventid)
    elif '#' in eventid :
        eventid = eventid.split('#')[-1]
        print('Picks eventid in URL format:',eventid)
    
    # Special clients systems
    stationsclient = fdsnclient
    waveformsclient = fdsnclient
    if stations_base_url:
        stationsclient = Client(stations_base_url)
        if not waveforms_base_url:
            waveformsclient = Client(stations_base_url)
    if waveforms_base_url:
        waveformsclient = Client(waveforms_base_url)
        if not stations_base_url:
            stationsclient = Client(waveforms_base_url)
    


    # Load event
    fdsnclient.get_events(eventid=eventid,format='sc3ml',filename='events.xml', **get_events_options)
    eventstreams = {'catalog': obspy.read_events('events.xml',format='sc3ml'),
                    'inventory': obspy.core.inventory.Inventory([],None),
                    'raw' : obspy.core.Stream()}
    if eventstreams['catalog'] is None:
        print('catalog is',eventstreams['catalog'])
    for output in ['catalog','inventory','raw']:
        eventstreams[output].output=output
    
    for event in eventstreams['catalog'].events :
        
        # Load stations
        t=event.preferred_origin().time
        try:
            inventory = stationsclient.get_stations(level='station',
                                                startbefore=t,
                                                endafter=t+endafter,
                                                latitude=event.preferred_origin().latitude,
                                                longitude=event.preferred_origin().longitude,
                                                maxradius=maxradius,
                                                location=location,
                                                channel=channel)
        except:
            print('No station found for event:')
            print(event)
            print('Using client:')
            print(stationsclient)
            continue
        # Load waveforms
        addons = [location, channel] + [t,t+endafter]
        bulk = [tuple(station.split()[0].split('.')[:2]+addons) for station in inventory.get_contents()['stations']]
        try:
            waveforms = waveformsclient.get_waveforms_bulk(bulk,
                                                      attach_response=True,
                                                      quality=quality,
                                                      minimumlength=minimumlength,
                                                      longestonly=longestonly)
        except:
            print('No waveform found for request:')
            print(bulk)
            print('Using client:')
            print(waveformsclient)
            continue
        # Improve waveforms attributes
        for trace in waveforms:
            station = inventory.select(network=trace.stats.network,
                                       station=trace.stats.station).networks[0].stations[0]
            trace.stats.coordinates = {'latitude':station.latitude,
                                       'longitude':station.longitude,
                                       'elevation':station.elevation}
            distance = obspy.geodetics.base.gps2dist_azimuth(station.latitude,
                                                             station.longitude,
                                                             event.preferred_origin().latitude,
                                                             event.preferred_origin().longitude)[0]
            distance = ((distance**2+(trace.stats.coordinates['elevation']*-1)**2.)**.5)
            distance = distance/len(eventstreams['catalog'].events)
            if not hasattr(trace.stats, 'distance'):
                trace.stats.distance = 0.
#.........这里部分代码省略.........
开发者ID:FMassin,项目名称:py-NnK,代码行数:103,代码来源:eventstreams.py


注:本文中的obspy.clients.fdsn.Client.get_events方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。