當前位置: 首頁>>代碼示例>>Python>>正文


Python iris.Client類代碼示例

本文整理匯總了Python中obspy.iris.Client的典型用法代碼示例。如果您正苦於以下問題:Python Client類的具體用法?Python Client怎麽用?Python Client使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Client類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_issue419

 def test_issue419(self):
     """
     obspy.iris.Client.availability should work with output='bulkdataselect'
     """
     client = Client()
     # 1 - default output ('bulkdataselect')
     t1 = UTCDateTime("2010-02-27T06:30:00.000")
     t2 = UTCDateTime("2010-02-27T10:30:00.000")
     result = client.availability('IU', channel='B*', starttime=t1,
                                  endtime=t2)
     self.assertTrue(isinstance(result, basestring))
     self.assertTrue('IU YSS 00 BHZ' in result)
     # 2 - explicit set output 'bulkdataselect'
     t1 = UTCDateTime("2010-02-27T06:30:00.000")
     t2 = UTCDateTime("2010-02-27T10:30:00.000")
     result = client.availability('IU', channel='B*', starttime=t1,
                                  endtime=t2, output='bulkdataselect')
     self.assertTrue(isinstance(result, basestring))
     self.assertTrue('IU YSS 00 BHZ' in result)
     # 3 - output 'bulk' (backward compatibility)
     t1 = UTCDateTime("2010-02-27T06:30:00.000")
     t2 = UTCDateTime("2010-02-27T10:30:00.000")
     with warnings.catch_warnings(record=True):
         warnings.simplefilter('ignore', DeprecationWarning)
         result = client.availability('IU', channel='B*', starttime=t1,
                                      endtime=t2, output='bulk')
     self.assertTrue(isinstance(result, basestring))
     self.assertTrue('IU YSS 00 BHZ' in result)
     # 4 - output 'xml'
     t1 = UTCDateTime("2010-02-27T06:30:00.000")
     t2 = UTCDateTime("2010-02-27T10:30:00.000")
     result = client.availability('IU', channel='B*', starttime=t1,
                                  endtime=t2, output='xml')
     self.assertTrue(isinstance(result, basestring))
     self.assertTrue('<?xml' in result)
開發者ID:msimon00,項目名稱:obspy,代碼行數:35,代碼來源:test_client.py

示例2: test_getEvents

 def test_getEvents(self):
     """
     Tests getEvents method.
     """
     client = Client()
     dt = UTCDateTime("2012-03-13T04:49:38")
     # 1
     cat = client.getEvents(
         mindepth=34.9,
         maxdepth=35.1,
         magtype="MB",
         catalog="NEIC PDE",
         lat=-56.1,
         lon=-26.7,
         maxradius=2,
         starttime=dt,
         endtime=dt + 10,
     )
     self.assertEquals(len(cat), 1)
     ev = cat[0]
     self.assertEquals(len(ev.origins), 1)
     self.assertEquals(len(ev.magnitudes), 1)
     self.assertEquals(ev.origins[0].depth, 35.0)
     self.assertEquals(ev.origins[0].latitude, -55.404)
     self.assertEquals(ev.origins[0].longitude, -27.895)
     self.assertEquals(ev.magnitudes[0].magnitude_type, "MB")
開發者ID:egdorf,項目名稱:obspy,代碼行數:26,代碼來源:test_client.py

示例3: test_sacpz

 def test_sacpz(self):
     """
     Fetches SAC poles and zeros information.
     """
     client = Client()
     # 1
     t1 = UTCDateTime("2005-01-01")
     t2 = UTCDateTime("2008-01-01")
     result = client.sacpz("IU", "ANMO", "00", "BHZ", t1, t2)
     # drop lines with creation date (current time during request)
     result = result.splitlines()
     sacpz_file = os.path.join(self.path, "data", "IU.ANMO.00.BHZ.sacpz")
     expected = open(sacpz_file, "rt").read().splitlines()
     result.pop(5)
     expected.pop(5)
     self.assertEquals(result, expected)
     # 2 - empty location code
     dt = UTCDateTime("2002-11-01")
     result = client.sacpz("UW", "LON", "", "BHZ", dt)
     self.assertTrue("* STATION    (KSTNM): LON" in result)
     self.assertTrue("* LOCATION   (KHOLE):   " in result)
     # 3 - empty location code via '--'
     result = client.sacpz("UW", "LON", "--", "BHZ", dt)
     self.assertTrue("* STATION    (KSTNM): LON" in result)
     self.assertTrue("* LOCATION   (KHOLE):   " in result)
開發者ID:egdorf,項目名稱:obspy,代碼行數:25,代碼來源:test_client.py

示例4: test_traveltime

 def test_traveltime(self):
     """
     Tests calculation of travel-times for seismic phases.
     """
     client = Client()
     result = client.traveltime(evloc=(-36.122, -72.898), evdepth=22.9,
         staloc=[(-33.45, -70.67), (47.61, -122.33), (35.69, 139.69)])
     self.assertTrue(result.startswith('Model: iasp91'))
開發者ID:msimon00,項目名稱:obspy,代碼行數:8,代碼來源:test_client.py

示例5: test_issue623

 def test_issue623(self):
     """
     obspy.iris bulkdataselect only returns last trace in result
     """
     t1 = UTCDateTime("2011-03-11T06:31:30Z")
     t2 = UTCDateTime("2011-03-11T06:48:00Z")
     client = Client()
     st = client.getWaveform("GE", "EIL", "", "BHZ", t1, t2)
     self.assertEqual(len(st), 5)
開發者ID:Ciack404,項目名稱:obspy,代碼行數:9,代碼來源:test_client.py

示例6: test_saveResponse

 def test_saveResponse(self):
     """
     Fetches and stores response information as SEED RESP file.
     """
     client = Client()
     start = UTCDateTime("2005-001T00:00:00")
     end = UTCDateTime("2008-001T00:00:00")
     # RESP, single channel
     origfile = os.path.join(self.path, "data", "RESP.ANMO.IU.00.BHZ")
     tempfile = NamedTemporaryFile().name
     client.saveResponse(tempfile, "IU", "ANMO", "00", "BHZ", start, end)
     self.assertTrue(filecmp.cmp(origfile, tempfile))
     os.remove(tempfile)
     # RESP, multiple channels
     origfile = os.path.join(self.path, "data", "RESP.ANMO.IU._.BH_")
     tempfile = NamedTemporaryFile().name
     client.saveResponse(tempfile, "IU", "ANMO", "*", "BH?", start, end)
     self.assertTrue(filecmp.cmp(origfile, tempfile))
     os.remove(tempfile)
     # StationXML, single channel
     tempfile = NamedTemporaryFile().name
     client.saveResponse(tempfile, "IU", "ANMO", "00", "BHZ", start, end, format="StationXML")
     data = open(tempfile).read()
     self.assertTrue('<Station net_code="IU" sta_code="ANMO">' in data)
     os.remove(tempfile)
     # SACPZ, single channel
     tempfile = NamedTemporaryFile().name
     client.saveResponse(tempfile, "IU", "ANMO", "00", "BHZ", start, end, format="SACPZ")
     data = open(tempfile).read()
     self.assertTrue("NETWORK   (KNETWK): IU" in data)
     self.assertTrue("STATION    (KSTNM): ANMO" in data)
     os.remove(tempfile)
開發者ID:egdorf,項目名稱:obspy,代碼行數:32,代碼來源:test_client.py

示例7: az2

def az2(sfile):
	azDic = {}
	client = Client() #Creando objeto cliente
	evtlat,evtlon = evcor(sfile) #Obteniendo las coordenadas del evento del sfile en decimal
	infile = open(sfile,'rU') 
	for line in infile:

		if line[9:11] == 'ES':
			#print 'Dentro del if'
			station_name = line[1:6].split(' ')[0]
			Baz = client.distaz(stalat=stacor('corstations.txt')[station_name][0], stalon=stacor('corstations.txt')[station_name][1], evtlat=evtlat, evtlon=evtlon)
			azDic[station_name] = Baz['backazimuth']
	return azDic
開發者ID:dsiervo,項目名稱:Ptgc,代碼行數:13,代碼來源:rotate.py

示例8: test_flinnengdahl

 def test_flinnengdahl(self):
     """
     Tests calculation of Flinn-Engdahl region code or name.
     """
     client = Client()
     # code
     result = client.flinnengdahl(lat=-20.5, lon=-100.6, rtype="code")
     self.assertEquals(result, 683)
     # w/o kwargs
     result = client.flinnengdahl(-20.5, -100.6, "code")
     self.assertEquals(result, 683)
     # region
     result = client.flinnengdahl(lat=42, lon=-122.24, rtype="region")
     self.assertEquals(result, "OREGON")
     # w/o kwargs
     result = client.flinnengdahl(42, -122.24, "region")
     self.assertEquals(result, "OREGON")
     # both
     result = client.flinnengdahl(lat=-20.5, lon=-100.6, rtype="both")
     self.assertEquals(result, (683, "SOUTHEAST CENTRAL PACIFIC OCEAN"))
     # w/o kwargs
     result = client.flinnengdahl(-20.5, -100.6, "both")
     self.assertEquals(result, (683, "SOUTHEAST CENTRAL PACIFIC OCEAN"))
     # default rtype
     result = client.flinnengdahl(lat=42, lon=-122.24)
     self.assertEquals(result, (32, "OREGON"))
     # w/o kwargs
     # outside boundaries
     self.assertRaises(Exception, client.flinnengdahl, lat=-90.1, lon=0)
     self.assertRaises(Exception, client.flinnengdahl, lat=90.1, lon=0)
     self.assertRaises(Exception, client.flinnengdahl, lat=0, lon=-180.1)
     self.assertRaises(Exception, client.flinnengdahl, lat=0, lon=180.1)
開發者ID:egdorf,項目名稱:obspy,代碼行數:32,代碼來源:test_client.py

示例9: test_saveWaveform

 def test_saveWaveform(self):
     """
     Testing simple waveform file save method.
     """
     # file identical to file retrieved via web interface
     client = Client()
     start = UTCDateTime("2010-02-27T06:30:00")
     end = UTCDateTime("2010-02-27T06:31:00")
     origfile = os.path.join(self.path, "data", "IU.ANMO.00.BHZ.mseed")
     tempfile = NamedTemporaryFile().name
     client.saveWaveform(tempfile, "IU", "ANMO", "00", "BHZ", start, end)
     self.assertTrue(filecmp.cmp(origfile, tempfile))
     os.remove(tempfile)
     # no data raises an exception
     self.assertRaises(Exception, client.saveWaveform, "YY", "XXXX", "00", "BHZ", start, end)
開發者ID:egdorf,項目名稱:obspy,代碼行數:15,代碼來源:test_client.py

示例10: test_saveWaveformToStringIO

 def test_saveWaveformToStringIO(self):
     """
     Same as test_saveWaveform but saves to a StringIO.
     """
     # file identical to file retrieved via web interface
     client = Client()
     start = UTCDateTime("2010-02-27T06:30:00")
     end = UTCDateTime("2010-02-27T06:31:00")
     memfile = StringIO.StringIO()
     client.saveWaveform(memfile, "IU", "ANMO", "00", "BHZ", start, end)
     memfile.seek(0, 0)
     new_data = memfile.read()
     origfile = os.path.join(self.path, 'data', 'IU.ANMO.00.BHZ.mseed')
     with open(origfile, "rb") as fh:
         org_data = fh.read()
     self.assertEqual(new_data, org_data)
開發者ID:jandog8990,項目名稱:obspy,代碼行數:16,代碼來源:test_client.py

示例11: test_getWaveform

 def test_getWaveform(self):
     """
     Testing simple waveform request method.
     """
     # simple example
     client = Client()
     start = UTCDateTime("2010-02-27T06:30:00.019538Z")
     end = start + 20
     stream = client.getWaveform("IU", "ANMO", "00", "BHZ", start, end)
     self.assertEquals(len(stream), 1)
     self.assertEquals(stream[0].stats.starttime, start)
     self.assertEquals(stream[0].stats.endtime, end)
     self.assertEquals(stream[0].stats.network, "IU")
     self.assertEquals(stream[0].stats.station, "ANMO")
     self.assertEquals(stream[0].stats.location, "00")
     self.assertEquals(stream[0].stats.channel, "BHZ")
     # no data raises an exception
     self.assertRaises(Exception, client.getWaveform, "YY", "XXXX", "00", "BHZ", start, end)
開發者ID:egdorf,項目名稱:obspy,代碼行數:18,代碼來源:test_client.py

示例12: test_timeseries

    def test_timeseries(self):
        """
        Tests timeseries Web service interface.

        Examples are inspired by http://www.iris.edu/ws/timeseries/.
        """
        client = Client()
        # 1
        t1 = UTCDateTime("2005-001T00:00:00")
        t2 = UTCDateTime("2005-001T00:01:00")
        # no filter
        st1 = client.timeseries("IU", "ANMO", "00", "BHZ", t1, t2)
        # instrument corrected
        st2 = client.timeseries("IU", "ANMO", "00", "BHZ", t1, t2, filter=["correct"])
        # compare results
        self.assertEquals(st1[0].stats.starttime, st2[0].stats.starttime)
        self.assertEquals(st1[0].stats.endtime, st2[0].stats.endtime)
        self.assertEquals(st1[0].data[0], 24)
        self.assertAlmostEquals(st2[0].data[0], -2.4910707e-06)
開發者ID:egdorf,項目名稱:obspy,代碼行數:19,代碼來源:test_client.py

示例13: test_distaz

 def test_distaz(self):
     """
     Tests distance and azimuth calculation between two points on a sphere.
     """
     client = Client()
     # normal request
     result = client.distaz(stalat=1.1, stalon=1.2, evtlat=3.2, evtlon=1.4)
     self.assertAlmostEquals(result["distance"], 2.09554)
     self.assertAlmostEquals(result["backazimuth"], 5.46946)
     self.assertAlmostEquals(result["azimuth"], 185.47692)
     # w/o kwargs
     result = client.distaz(1.1, 1.2, 3.2, 1.4)
     self.assertAlmostEquals(result["distance"], 2.09554)
     self.assertAlmostEquals(result["backazimuth"], 5.46946)
     self.assertAlmostEquals(result["azimuth"], 185.47692)
     # missing parameters
     self.assertRaises(Exception, client.distaz, stalat=1.1)
     self.assertRaises(Exception, client.distaz, 1.1)
     self.assertRaises(Exception, client.distaz, stalat=1.1, stalon=1.2)
     self.assertRaises(Exception, client.distaz, 1.1, 1.2)
開發者ID:egdorf,項目名稱:obspy,代碼行數:20,代碼來源:test_client.py

示例14: test_event

    def test_event(self):
        """
        Tests event Web service interface.

        Examples are inspired by http://www.iris.edu/ws/event/.
        """
        client = Client()
        # 1
        url = "http://www.iris.edu/ws/event/query?mindepth=34.9&" + \
            "maxdepth=35.1&catalog=NEIC%20PDE&contributor=NEIC%20PDE-Q&" + \
            "magtype=MB&lat=-56.1&lon=-26.7&maxradius=1"
        # direct call
        doc1 = urllib.urlopen(url).read()
        # using client
        doc2 = client.event(mindepth=34.9, maxdepth=35.1, catalog="NEIC PDE",
                            contributor="NEIC PDE-Q", magtype="MB", lat=-56.1,
                            lon=-26.7, maxradius=1)
        self.assertEqual(doc1, doc2)
        client = Client()
        # 2
        url = "http://www.iris.edu/ws/event/query?eventid=3316989"
        # direct call
        doc1 = urllib.urlopen(url).read()
        # using client
        doc2 = client.event(eventid=3316989)
        self.assertEqual(doc1, doc2)
        # 2
        url = "http://www.iris.edu/ws/event/query?eventid=3316989"
        # direct call
        doc1 = urllib.urlopen(url).read()
        # using client
        doc2 = client.event(eventid=3316989)
        self.assertEqual(doc1, doc2)
        # 3
        url = "http://www.iris.edu/ws/event/query?minmag=8.5"
        # direct call
        doc1 = urllib.urlopen(url).read()
        # using client
        doc2 = client.event(minmag=8.5)
        self.assertEqual(doc1, doc2)
        # 4
        url = "http://www.iris.edu/ws/event/query?starttime=2011-01-07T" + \
            "14%3A00%3A00&endtime=2011-02-07&minlat=15&maxlat=40&" + \
            "minlon=-170&maxlon=170&preferredonly=yes&" + \
            "includeallmagnitudes=yes&orderby=magnitude"
        # direct call
        doc1 = urllib.urlopen(url).read()
        # using client
        doc2 = client.event(starttime=UTCDateTime(2011, 1, 7, 14),
                            endtime=UTCDateTime('2011-02-07'), minlat=15.0,
                            maxlat=40.0, minlon=-170, maxlon=170,
                            preferredonly=True, includeallmagnitudes=True,
                            orderby='magnitude')
        self.assertEqual(doc1, doc2)
開發者ID:msimon00,項目名稱:obspy,代碼行數:54,代碼來源:test_client.py

示例15: test_resp

    def test_resp(self):
        """
        Tests resp Web service interface.

        Examples are inspired by http://www.iris.edu/ws/resp/.
        """
        client = Client()
        # 1
        t1 = UTCDateTime("2005-001T00:00:00")
        t2 = UTCDateTime("2008-001T00:00:00")
        result = client.resp("IU", "ANMO", "00", "BHZ", t1, t2)
        self.assertTrue("B050F03     Station:     ANMO" in result)
        # 2 - empty location code
        result = client.resp("UW", "LON", "", "EHZ")
        self.assertTrue("B050F03     Station:     LON" in result)
        self.assertTrue("B052F03     Location:    ??" in result)
        # 3 - empty location code via '--'
        result = client.resp("UW", "LON", "--", "EHZ")
        self.assertTrue("B050F03     Station:     LON" in result)
        self.assertTrue("B052F03     Location:    ??" in result)
        # 4
        dt = UTCDateTime("2010-02-27T06:30:00.000")
        result = client.resp("IU", "ANMO", "*", "*", dt)
        self.assertTrue("B050F03     Station:     ANMO" in result)
開發者ID:egdorf,項目名稱:obspy,代碼行數:24,代碼來源:test_client.py


注:本文中的obspy.iris.Client類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。