Пример #1
0
 def __init__(self):
     self.networks = {}
     self.client = Client(base_url=SERVER)
     self.pickle_file = os.path.join(
         os.path.dirname(inspect.getsourcefile(self.__class__)),
         'seishub_dict.pickle')
     self.networks = None
 def load_event_object(self):
     """
     Loads the currently selected event from the Seishub database.
     """
     if self.currently_selected_event is None:
         QtGui.QMessageBox.critical(self, "Error",
             "Selected event not found - something is wrong. Please " + \
             "contact the developer or fix the code yourself...")
         return
     from obspy.seishub import Client
     client = Client(base_url=self.base_url)
     try:
         resource = client.event.getResource( \
             self.currently_selected_event["resource_name"])
     except Exception, e:
         error_type_str = e.__class__.__name__
         msg_box = QtGui.QMessageBox()
         msg_box.setIcon(QtGui.QMessageBox.Critical)
         msg_box.setText("Retrieving event from the SeisHub server " + \
             "failed!")
         msg_box.setDetailedText("{err_type}({message})".format( \
             err_type=error_type_str,
             message=str(e)))
         msg_box.exec_()
         return
Пример #3
0
 def initClient(self, client=None, use_client=True):
     self.use_client = use_client
     if not client:
         with open('/home/richter/.sito/pwd_seishub') as f:
             pwd = f.read().strip('\n')
         client = Client(base_url='http://sec24c74.gfz-potsdam.de:8080',
                         user='******',
                         password=pwd)
         client = client.waveform
     self.client = client
    def _on_download_data(self):
        """
        Downloads the data for all picks in self.event.
        """
        if "event" not in self.current_state:
            return

        event = self.current_state["event"]
        client = Client(base_url=str(self.ui.seishub_server.text()),
                        timeout=60)

        progress_dialog = QtGui.QProgressDialog( \
            "Downloading waveform data...", "Cancel", 0,
            len(event.picks))
        progress_dialog.setWindowModality(QtCore.Qt.WindowModal)
        progress_dialog.forceShow()
        # Attempt to load all the station information for all picks.
        for _i, pick in enumerate(event.picks):
            progress_dialog.setValue(_i)
            if progress_dialog.wasCanceled():
                break
            # Do not download it if it is already available.
            if hasattr(pick, "data"):
                # Check if enough data is available.
                if abs((pick.data[0].stats.endtime - \
                    pick.data[0].stats.starttime) - \
                    2.0 * float(self.ui.buffer_seconds.value())) < 0.1:
                    continue
            try:
                st = client.waveform.getWaveform( \
                    network=pick.waveform_id.network_code,
                    station=pick.waveform_id.station_code,
                    location=pick.waveform_id.location_code,
                    channel=pick.waveform_id.channel_code[:-1] + "*",
                    starttime=pick.time - \
                        float(self.ui.buffer_seconds.value()),
                    endtime=pick.time + \
                        float(self.ui.buffer_seconds.value()),
                    getPAZ=True, getCoordinates=True, apply_filter=True)
            except Exception, e:
                error_type_str = e.__class__.__name__
                print "Problem while downloading waveform data:", \
                    "{err_type}({message})".format( \
                    err_type=error_type_str,
                    message=str(e))
                continue
            for trace in st:
                # Convert to ground motion.
                trace.stats.paz["zeros"].append(0 + 0j)
            st.merge(-1)
            st.detrend()
            st.simulate(paz_remove="self", water_level=10.0)
            pick.data = st
Пример #5
0
    def __init__(self,
                 path=None,
                 project='IPOC',
                 client='sec24c74',
                 exception=False,
                 use_local_LVC=False,
                 **kwargs):
        if path is None:
            data = '/home/richter/Data/%s' % project
            results = '/home/richter/Results/%s' % project
        else:
            results = data = '%s/%s' % (path, project)
        super(IPOC, self).__init__(data=data,
                                   results=results,
                                   client=client,
                                   **kwargs)

        self.raw_regex = ('/media/PBO/archive/'
                          '{year}/{code}/{station}/{channel}.D/'
                          '{code}.{station}..{channel}.D.{year}.{day:03d}')
        if not use_local_LVC:
            self.raw_regex_LVC = (
                '/media/PBO/archive/'
                '{year}/{code}/{station}/{channel}.D/'
                '{code}.{station}.{number}.{channel}.D.{year}'
                '.{day:03d}')
        else:
            self.raw_regex_LVC = ('/home/richter/Data/obspyload-data/LVC/'
                                  '{year}/{code}.{station}.{number}.{channel}_'
                                  '{year}_{day:03d}.mseed')

        self.events = '/home/richter/Data/events/2012_03_events_27-93_mag5.5_IPOC.txt'
        self.stations = Stations.read('/home/richter/Data/stations_ipoc.txt')
        self.paz = seismometer.PAZ_STS2
        self.exception = exception
        if self.client in (True, 'sec24c74', 'gfz'):
            self.initClient()
        elif self.client == 'geofon':
            from obspy.arclink import Client
            self.initClient(client=Client())
    def search_for_events(self):
        """
        Read all current values in the GUI and load the requested events.
        """
        # Read all necessary the GUI variables.
        starttime = QDatetoUTCDateTime(self.ui.starttime.dateTime())
        endtime = QDatetoUTCDateTime(self.ui.endtime.dateTime())
        min_mag = self.ui.min_magnitude.value()
        max_mag = self.ui.max_magnitude.value()

        model_box = QtGui.QMessageBox(QtGui.QMessageBox.Information,
            "", "Downloading event index. Please wait...",
            QtGui.QMessageBox.NoButton)
        model_box.show()

        from obspy.seishub import Client
        c = Client(base_url=self.base_url)
        try:
            events = c.event.getList(limit=2500, min_datetime=starttime,
                max_datetime=endtime, min_latitude=self.north_east[0],
                max_latitude=self.south_west[0],
                min_longitude=self.north_east[1],
                max_longitude=self.south_west[1], min_magnitude=min_mag,
                max_magnitude=max_mag)
        except Exception, e:
            error_type_str = e.__class__.__name__
            model_box.done(0)
            msg_box = QtGui.QMessageBox()
            msg_box.setIcon(QtGui.QMessageBox.Critical)
            msg_box.setText("Retrieving events from the SeisHub server " + \
                "failed!")
            msg_box.setDetailedText("{err_type}({message})".format( \
                err_type=error_type_str,
                message=str(e)))
            msg_box.exec_()
            return
Пример #7
0
#!/usr/bin/env python
import numpy as np
import scipy as sp
from obspy.core import UTCDateTime, read, Trace
from obspy.seishub import Client
import sys, string
from matplotlib import mlab
import matplotlib.pyplot as plt
import obspy.signal
import mlpy.wavelet as ml

client = Client(base_url='http://10.153.82.3:9080',
                user='******',
                password='******',
                timeout=10)

try:
    stream = sys.argv[1]
    utctime = sys.argv[2]
    duration = float(sys.argv[3])
    mother = sys.argv[4]
    bb = int(sys.argv[5])
    what = sys.argv[6]
except:
    usage = 'Usage: %s Net.Stat.loc.channel %s UTCtime %f duration %s wavelet %d bb %s Amp/Phase <outfile>'
    print usage
    sys.exit(1)

try:
    outfile = sys.argv[7]
    format = 'png'
Пример #8
0
 def connectToServer(self):
     """
     Connects to the SeisHub server.
     """
     self.client = Client(base_url = self.server)
     self.ping()
Пример #9
0
 def setUp(self):
     self.client = Client("http://teide.geophysik.uni-muenchen.de:8080")
Пример #10
0
 def setUp(self):
     self.client = Client(TESTSERVER)
Пример #11
0
T2 = T1 + (60 * 60 * 1) + 30
PAR = dict(LOW=10.0, # bandpass low corner
           HIGH=20.0, # bandpass high corner
           STA=0.5, # length of sta in seconds
           LTA=10, # length of lta in seconds
           ON=3.5, # trigger on threshold
           OFF=1, # trigger off threshold
           ALLOWANCE=1.2, # time in seconds to extend trigger-off time
           MAXLEN=10, # maximum trigger length in seconds
           MIN_STATIONS=3) # minimum of coinciding stations for alert
PAR = AttribDict(PAR)
SUMMARY = "/scratch/uh_trigger/uh_trigger.txt"
PLOTDIR = "/scratch/uh_trigger/"
MAILTO = ["megies"]

client = Client("http://10.153.82.3:8080", timeout=60)

st = Stream()
num_stations = 0
exceptions = []
for station in STATIONS:
    try:
        # we request 60s more at start and end and cut them off later to avoid
        # a false trigger due to the tapering during instrument correction
        tmp = client.waveform.getWaveform(NET, station, "", CHANNEL, T1 - 180,
                                          T2 + 180, getPAZ=True,
                                          getCoordinates=True)
    except Exception, e:
        exceptions.append("%s: %s" % (e.__class__.__name__, e))
        continue
    st.extend(tmp)
Пример #12
0
    HIGH=20.0,  # bandpass high corner
    STA=0.5,  # length of sta in seconds
    LTA=10,  # length of lta in seconds
    ON=3.5,  # trigger on threshold
    OFF=1,  # trigger off threshold
    ALLOWANCE=2,  # time in seconds to extend trigger-off time
    MAXLEN=10,  # maximum trigger length in seconds
    MIN_STATIONS=3,  # minimum of coinciding stations for alert
    ALLOW_LESS_STATIONS=True
)  # allow trigger with less stations than MIN_STATIONS if all stations trigger
PAR = AttribDict(PAR)
SUMMARY = "/scratch/uh_trigger_extra/uh_trigger.txt"
PLOTDIR = "/scratch/uh_trigger_extra/"
MAILTO = ()

client = Client()

# search given timespan one hour at a time, set initial T1 one hour earlier
T1 = START - (60 * 60 * 1)
while T1 < END:
    T1 += (60 * 60 * 1)
    T2 = T1 + (60 * 60 * 1)

    st = Stream()
    num_stations = 0
    for station in STATIONS:
        try:
            # we request 60s more at start and end and cut them off later to avoid
            # a false trigger due to the tapering during instrument correction
            tmp = client.waveform.getWaveform(NET,
                                              station,
from obspy.seishub import Client

client = Client("http://localhost:8080")
st = client.waveform.getWaveform(network="BW",
                                 station="HROE",
                                 starttime="2008-04-17T16:00:00Z",
                                 endtime="2008-04-17T16:10:00Z")
print st
st.plot()

events = client.event.getList(min_datetime="2008-10-10T08:05:00Z",
                              max_datetime="2008-10-10T08:15:00Z")
print events

event = events[0]
print "origin time is", event['datetime']
print "magnitude is", event['magnitude']
print "longitude is", event['longitude']
print "latitude is", event['latitude']
print "depth is", event['depth']
Пример #14
0
#!/usr/bin/env python
from obspy.seishub import Client

client = Client('http://10.153.82.3:8080', timeout=120, retries=10)
events = client.event.getList(limit=2500)
offset = 0
# shift offset until less than 2500 new events get added
while len(events) % 2500 == 0:
    offset += 1
    events += client.event.getList(limit=2500, offset=offset * 2400)
resource_names = [d['resource_name'] for d in events]
# make a unique list
resource_names = list(set(resource_names))
# one resource name got converted to an int on server side..
resource_names = map(str, resource_names)
with open("all_resource_names", "w") as fh:
    fh.write("\n".join(list(resource_names)))