[obspy-users] iris web services client - anyone see this problme recently?

Gary Pavlis pavlis at indiana.edu
Tue Jul 7 15:56:30 CEST 2015


Thanks, Lion.   Turned out that the original code I started from 
actually had it right and used the fdsn client.  Some confusion on my 
part got me running in circles and I chased the wrong problem. I'm 
chasing some different issues now, but hopefully I can solve that on my 
own.   You definitely broke the chasing my tail problem so thank you.

The root of the problem was I was led astray by this web page:
http://docs.obspy.org/tutorial/code_snippets/retrieving_data_from_datacenters.html

Which contained a stub for the iris client that is clearly not 
appropriate.   Urge you to update that page since the iris client seems 
to have been depricated.  I made an incorrect conclusion when I looked 
at that page.   A time stamp on the page would have also avoided this 
confusion on my part.

Again, many thanks.
Gary Pavlis

On 7/6/15 5:37 PM, Lion Krischer wrote:
> Hi Gary,
>
> note that you are using obspy.iris which uses the old IRIS web services. To get access to the new FDSN compatible web services you have to use obspy.fdsn. So to fix you problem you either have to write
>
>
>>>> from obspy.iris import Client
>>>> client = Client()  # Do not pass ‘IRIS’ there but a full URL if you really want to
> or (strongly recommended)
>
>>>> from obspy.fdsn import Client
>>>> client = Client(“IRIS”)
> and then use
>
>>>> client.get_waveforms(…)
> This will utilize the new fdsn web services. In that case the client constructor actually does quite a bit and discovers what that particular FDSN web service implementation is capable of.
>
> http://docs.obspy.org/packages/obspy.fdsn.html
>
> Cheers!
>
> Lion
>
>
> On 6 Jul 2015 at 23:03:09, Gary Pavlis (pavlis at indiana.edu) wrote:
>> Something seems to have drastically changed recently in the web service
>> interface to iris dmc. A script I last used about a year ago no longer
>> works. Several issues:
>> 1. I formerly used the fdsn client, but the current document has no
>> such thing. I changed that line to
>>   
>> from obspy.iris import Client
>>   
>> This constructor then works, although it probably does next to nothing:
>> client=Client("IRIS")
>>   
>> 2. Using ipython and some tracebacks from the exception handler I
>> think something is getting botched in the url generator code. You
>> should be able to cut and paste lines below to recreate the problem I'm
>> seeing:
>>   
>> net='TA'
>> sta='D03D'
>>   	chan='BH*'
>>   
>> Note:
>> In [22]: print net, sta, chan
>> TA D03D BH*
>>   
>> Then:
>> from obspy import UTCDateTime
>> out='foo.dat'
>> stime=UTCDateTime(float(1388534670.01))
>> etime=UTCDateTime(float(1389137254.38))
>>   
>> Note:
>> In [26]: print stime
>> 2014-01-01T00:04:30.010000Z
>>   
>> In [27]: print etime
>> 2014-01-07T23:27:34.380000Z
>>   
>> Problem is when I then run:
>> client.timeseries(net,sta,"*","*",stime,etime,out)
>>   
>> I get this from ipython:
>>   
>> ---------------------------------------------------------------------------
>> ValueError Traceback (most recent call last)
>> in ()
>> ----> 1 client.timeseries(net,sta,"*","*",stime,etime,out)
>>   
>> /opt/antelope/python2.7.8/lib/python2.7/site-packages/obspy-0.10.2-py2.7-macosx-10.4-x86_64.egg/obspy/iris/client.pyc
>> in timeseries(self, network, station, location, channel, starttime,
>> endtime, filter, filename, output, **kwargs)
>> 397 # build up query
>> 398 try:
>> --> 399 data = self._fetch("timeseries", param_list=filter,
>> **kwargs)
>> 400 except urllib.request.HTTPError as e:
>> 401 msg = "No waveform data available (%s: %s)"
>>   
>> /opt/antelope/python2.7.8/lib/python2.7/site-packages/obspy-0.10.2-py2.7-macosx-10.4-x86_64.egg/obspy/iris/client.pyc
>> in _fetch(self, service, data, headers, param_list, **params)
>> 135 req = urllib.request.Request(url=remoteaddr, data=data,
>> 136 headers=headers)
>> --> 137 response = urllib.request.urlopen(req, timeout=self.timeout)
>> 138 doc = response.read()
>> 139 return doc
>>   
>> /opt/antelope/python2.7.8/lib/python2.7/urllib2.pyc in urlopen(url,
>> data, timeout)
>> 125 if _opener is None:
>> 126 _opener = build_opener()
>> --> 127 return _opener.open(url, data, timeout)
>> 128
>> 129 def install_opener(opener):
>>   
>> /opt/antelope/python2.7.8/lib/python2.7/urllib2.pyc in open(self,
>> fullurl, data, timeout)
>> 394
>> 395 req.timeout = timeout
>> --> 396 protocol = req.get_type()
>> 397
>> 398 # pre-process request
>>   
>> /opt/antelope/python2.7.8/lib/python2.7/urllib2.pyc in get_type(self)
>> 256 self.type, self.__r_type = splittype(self.__original)
>> 257 if self.type is None:
>> --> 258 raise ValueError, "unknown url type: %s" %
>> self.__original
>> 259 return self.type
>> 260
>>   
>> ValueError: unknown url type:
>> IRIS/timeseries/1/query?f&o&o&.&d&a&t&network=TA&station=D03D&location=%2A&starttime=2014-01-01T00%3A04%3A30.010&output=miniseed&endtime=2014-01-07T23%3A27%3A34.380&channel=%2A
>> ---------------------------------------------------------------------------
>>   
>> I get a similar message from catching an exception in the original much
>> larger script:
>> [ 2015-07-06 11:53:14 ] timeseries threw an error, skipping TA : D03D
>> Time 2014-01-01T00:14:30.009240Z Start 2014-01-01T00:04:30.009240Z End
>> 2014-01-01T00:31:10.009240Z^M
>> Traceback (most recent call last):^M
>> File "/opt/antelope/5.5/contrib/bin/fetchirisdmc", line 130, in
>> fetchdmcthread^M
>> client.timeseries(net,sta,"*","?H*",stime,etime, filename=fname)^M
>> File
>> "/opt/antelope/python2.7.8/lib/python2.7/site-packages/obspy-0.10.2-py2.7-macosx-10.4-x86_64.egg/obspy/iris/client.py",
>> line 399, in timeseries^M
>> data = self._fetch("timeseries", param_list=filter, **kwargs)^M
>> File
>> "/opt/antelope/python2.7.8/lib/python2.7/site-packages/obspy-0.10.2-py2.7-macosx-10.4-x86_64.egg/obspy/iris/client.py",
>> line 137, in _fetch^M
>> response = urllib.request.urlopen(req, timeout=self.timeout)^M
>> File "/opt/antelope/python2.7.8/lib/python2.7/urllib2.py", line 127,
>> in urlopen^M
>> return _opener.open(url, data, timeout)^M
>> File "/opt/antelope/python2.7.8/lib/python2.7/urllib2.py", line 396,
>> in open^M
>> protocol = req.get_type()^M
>> File "/opt/antelope/python2.7.8/lib/python2.7/urllib2.py", line 258,
>> in get_type^M
>> raise ValueError, "unknown url type: %s" % self.__original^M
>> ValueError: unknown url type:
>> IRIS/timeseries/1/query?network=TA&station=D03D&location=%2A&starttime=2014-01-01T00%3A04%3A30.009&output=miniseed&endtime=2014-01-01T00%3A31%3A10.009&channel=%3FH%2A^M
>> ---------------------------------------------------------------------------
>> NOTE: the url is clearly wrong. When I go the URL generator at iris
>> dmc and type in the similar data I used for the timeseries method of the
>> iris client it generates this URL:
>> http://service.iris.edu/fdsnws/dataselect/1/query?net=TA&sta=D03D&loc=*&cha=*&starttime=2014-01-01T00:04:30&endtime=2014-01-01T00:31:30&nodata=404
>>   
>> I notice:
>> a. The leading http:// ... to /1/query... is wrong
>> b. The obspy url following the "ValueError" appears to have some
>> formatting strings that do not have substitutions. Clearly botched.
>>   
>> Has anyone gotten client.timeseries to work recently from iris? Anyone
>> see anything like this before? I can turn this into a simpler script
>> for testing if there is reason to think I've found some bug.
>>   
>> --
>> Prof. Gary L. Pavlis
>> Director of Graduate Studies
>> Department of Geological Sciences
>> Indiana University
>> 1001 East 10th Street
>> Bloomington, IN 47505
>> phone: 812 855 5141
>>   
>> _______________________________________________
>> obspy-users mailing list
>> obspy-users at lists.swapbytes.de
>> http://lists.swapbytes.de/mailman/listinfo/obspy-users
>>   
> _______________________________________________
> obspy-users mailing list
> obspy-users at lists.swapbytes.de
> http://lists.swapbytes.de/mailman/listinfo/obspy-users

-- 
Prof. Gary L. Pavlis
Director of Graduate Studies
Department of Geological Sciences
Indiana University
1001 East 10th Street
Bloomington, IN  47505
phone:  812 855 5141



More information about the obspy-users mailing list