krischer / jane

Jane - Document Database for Seismology
http://krischer.github.io/jane
GNU General Public License v3.0
27 stars 9 forks source link

Station bulk request not working #10

Open megies opened 8 years ago

megies commented 8 years ago
from obspy.clients.fdsn import Client
from obspy import UTCDateTime
t1 = UTCDateTime(1950, 1, 1)
t2 = UTCDateTime(2050, 1, 1)
client = Client("http://jane")
bulk = [["GR", "FUR", "*", "*", t1, t2], ["GR", "WET", "*", "*", t1, t2], ["BW", "RJOB", "*", "*", t1, t2]]
client.get_stations_bulk(bulk)

screenshot from 2016-02-13 11 31 14

Compare same request with Client("BGR") which works..

megies commented 8 years ago

ping

megies commented 2 years ago

Same goes for get_waveforms_bulk(), looks like POST requests never were accomodated

megies commented 2 years ago

Ugly workaround for use etc in Massdownloader

import io
from obspy.clients.fdsn import Client
from obspy import UTCDateTime, Stream, read

class PatchedClient(Client):
    def get_waveforms_bulk(self, bulk, quality=None, minimumlength=None,
                           longestonly=None, filename=None,
                           attach_response=False, **kwargs):
        if filename is None:
            st = Stream()
            for item in bulk:
                st += self.get_waveforms(
                    *item, quality=quality, minimumlength=minimumlength,
                    longestonly=longestonly, attach_response=attach_response,
                    **kwargs)
            return st
        with open(filename, 'wb') as fh:
            for item in bulk:
                bio = io.BytesIO()
                self.get_waveforms(
                    *item, quality=quality, minimumlength=minimumlength,
                    longestonly=longestonly, attach_response=attach_response,
                    filename=bio, **kwargs)
                bio.seek(0, 0)
                data = bio.read()
                fh.write(data)

t1 = UTCDateTime(2022, 6, 1, 12)
t2 = t1 + 20
client = PatchedClient("http://jane")
bulk = [["GR", "FUR", "*", "*", t1, t2]]
print(client.get_waveforms(*bulk[0]))
print(client.get_waveforms_bulk(bulk))
client.get_waveforms_bulk(bulk, filename='/tmp/blap.mseed')
print(read('/tmp/blap.mseed'))

CC @jwassermann