# http://pyrocko.org - GPLv3 # # The Pyrocko Developers, 21st Century # ---|P------/S----------~Lg----------
qc.QThread.__init__(self) self.mutex = qc.QMutex() self.queue = [] self.post_process_sleep = post_process_sleep self._sun_is_shining = True
while True: try: self.acquisition_start() while self._sun_is_shining: t0 = time.time() self.process() t1 = time.time() if self.post_process_sleep != 0.0: time.sleep(max(0, self.post_process_sleep-(t1-t0)))
self.acquisition_stop() break
except ( edl.ReadError, serial_hamster.SerialHamsterError, slink.SlowSlinkError) as e:
logger.error(str(e)) logger.error('Acquistion terminated, restart in 5 s') self.acquisition_stop() time.sleep(5) if not self._sun_is_shining: break
self._sun_is_shining = False
logger.debug("Waiting for thread to terminate...") self.wait() logger.debug("Thread has terminated.")
self.mutex.lock() self.queue.append(tr) self.mutex.unlock()
self.mutex.lock() items = self.queue[:] self.queue[:] = [] self.mutex.unlock() return items
slink.SlowSlink, AcquisitionThread):
slink.SlowSlink.__init__(self, *args, **kwargs) AcquisitionThread.__init__(self)
AcquisitionThread.got_trace(self, tr)
serial_hamster.CamSerialHamster, AcquisitionThread):
serial_hamster.CamSerialHamster.__init__(self, *args, **kwargs) AcquisitionThread.__init__(self, post_process_sleep=0.1)
AcquisitionThread.got_trace(self, tr)
serial_hamster.USBHB628Hamster, AcquisitionThread):
serial_hamster.USBHB628Hamster.__init__( self, deltat=deltat, *args, **kwargs) AcquisitionThread.__init__(self)
AcquisitionThread.got_trace(self, tr)
serial_hamster.SerialHamster, AcquisitionThread):
serial_hamster.SerialHamster.__init__(self, *args, **kwargs) AcquisitionThread.__init__(self, post_process_sleep=0.01)
AcquisitionThread.got_trace(self, tr)
edl.EDLHamster, AcquisitionThread):
edl.EDLHamster.__init__(self, *args, **kwargs) AcquisitionThread.__init__(self)
AcquisitionThread.got_trace(self, tr)
sources = [] iarg = 0 while iarg < len(args): arg = args[iarg]
msl = re.match(r'seedlink://([a-zA-Z0-9.-]+)(:(\d+))?(/(.*))?', arg) mca = re.match(r'cam://([^:]+)', arg) mus = re.match(r'hb628://([^:?]+)(\?([^?]+))?', arg) msc = re.match(r'school://([^:]+)', arg) med = re.match(r'edl://([^:]+)', arg) if msl: host = msl.group(1) port = msl.group(3) if not port: port = '18000'
sl = SlinkAcquisition(host=host, port=port) if msl.group(5): stream_patterns = msl.group(5).split(',')
if '_' not in msl.group(5): try: streams = sl.query_streams() except slink.SlowSlinkError as e: logger.fatal(str(e)) sys.exit(1)
streams = list(set( util.match_nslcs(stream_patterns, streams)))
for stream in streams: sl.add_stream(*stream) else: for stream in stream_patterns: sl.add_raw_stream_selector(stream)
sources.append(sl) elif mca: port = mca.group(1) cam = CamAcquisition(port=port, deltat=0.0314504) sources.append(cam) elif mus: port = mus.group(1) try: d = {} if mus.group(3): d = dict(urlparse.parse_qsl(mus.group(3))) # noqa
deltat = 1.0/float(d.get('rate', '50')) channels = [(int(c), c) for c in d.get('channels', '01234567')] hb628 = USBHB628Acquisition( port=port, deltat=deltat, channels=channels, buffersize=16, lookback=50)
sources.append(hb628) except Exception: raise sys.exit('invalid acquisition source: %s' % arg)
elif msc: port = msc.group(1) sco = SchoolSeismometerAcquisition(port=port) sources.append(sco) elif med: port = med.group(1) edl = EDLAcquisition(port=port) sources.append(edl)
if msl or mca or mus or msc or med: args.pop(iarg) else: iarg += 1
return sources
qc.QObject.__init__(self) self._injector = pile.Injector(*args, **kwargs) self._sources = [] self.startTimer(1000.)
self._sources.append(source)
self._sources.remove(source)
for source in self._sources: trs = source.poll() for tr in trs: self._injector.inject(tr)
# following methods needed because mulitple inheritance does not seem # to work anymore with QObject in Python3 or PyQt5
return self._injector.set_fixation_length(l)
self, path='dump_%(network)s.%(station)s.%(location)s.%(channel)s_' '%(tmin)s_%(tmax)s.mseed'):
return self._injector.set_save_path(path)
return self._injector.fixate_all()
return self._injector.free()
qc.QObject.__init__(self, parent) self.socket = sock self.readyRead.connect( self.handle_read) self.disconnected.connect( self.handle_disconnected) self.nwanted = 8 self.reading_size = True self.handler = None self.nbytes_received = 0 self.nbytes_sent = 0 self.compressor = zlib.compressobj() self.decompressor = zlib.decompressobj()
while True: navail = self.socket.bytesAvailable() if navail < self.nwanted: return
data = self.socket.read(self.nwanted) self.nbytes_received += len(data) if self.reading_size: self.nwanted = struct.unpack('>Q', data)[0] self.reading_size = False else: obj = pickle.loads(self.decompressor.decompress(data)) if obj is None: self.socket.disconnectFromHost() else: self.handle_received(obj) self.nwanted = 8 self.reading_size = True
self.received.emit(self, obj)
data = self.compressor.compress(pickle.dumps(obj)) data_end = self.compressor.flush(zlib.Z_FULL_FLUSH) self.socket.write(struct.pack('>Q', len(data)+len(data_end))) self.socket.write(data) self.socket.write(data_end) self.nbytes_sent += len(data)+len(data_end) + 8
self.disconnected.emit(self)
self.socket.close()
qc.QObject.__init__(self, parent) self.queue = [] self.connection = None
return self.connection is None
self.connection = connection connection.received.connect( self._handle_received)
connection.connect( self.handle_disconnected)
for obj in self.queue: self.connection.ship(obj)
self.queue = []
self.handle_received(obj)
pass
self.connection = None
if self.connection: self.connection.ship(obj) else: self.queue.append(obj)
ConnectionHandler.__init__(self, parent) self.mapping = mapping
command = obj[0] args = obj[1:] self.mapping[command](*args)
qg.QMainWindow.__init__(self, *args) self.app = app
self.app.pile_viewer.get_view().keyPressEvent(ev)
self.removeTab)
self.removeTab(self.indexOf(widget))
w = self.widget(index) w.close() qw.QTabWidget.removeTab(self, index)
self.tabbar_visibility()
elif self.count() > 1: self.tabBar().show()
self.tabCloseRequested.emit(i) else:
'node-uuid': uuid.getnode(), 'platform.architecture': platform.architecture(), 'platform.system': platform.system(), 'platform.release': platform.release(), 'python': platform.python_version(), 'pyrocko': pyrocko.__version__, 'numpy': numpy.__version__, 'scipy': scipy.__version__, 'qt': qc.PYQT_VERSION_STR, }
'<p>Your feedback is important for' ' the development and improvement of Pyrocko.</p>' '<p>Do you want to send this system information anon' 'ymously to <a href="https://pyrocko.org">' 'https://pyrocko.org</a>?</p>'))
'<code style="font-size: small;">%s</code>' % pprint.pformat( sys_info, indent=1).replace('\n', '<br>') )
'This message won\'t be shown again.\n\n' 'We appreciate your contribution!\n- The Pyrocko Developers' ))
def send_data(): import requests import json try: requests.post('https://pyrocko.org/%s' % webtk, data=json.dumps(sys_info)) except Exception as e: print(e) self.button(self.NextButton).clicked.emit(True)
<h3>- <i>The Seismogram browser and workbench.</i></h3> <p>Looks like you are starting the Snuffler for the first time.<br> It allows you to browse and process large archives of waveform data.</p> <p>Basic processing is complemented by Snufflings (<i>Plugins</i>):</p> <ul> <li><b>Download seismograms</b> from Geofon, IRIS and others</li> <li><b>Earthquake catalog</b> access to Geofon, GobalCMT, USGS...</li> <li><b>Cake</b>, Calculate synthetic arrival times</li> <li><b>Seismosizer</b>, generate synthetic seismograms on-the-fly</li> <li> <b>Map</b>, swiftly inspect stations and events on interactive maps </li> </ul> <p>And more, see <a href="https://pyrocko.org/">https://pyrocko.org/</a></p> <p><b>NOTE:</b><br>If you installed snufflings from the <a href="https://github.com/pyrocko/contrib-snufflings">user contributed snufflings repository</a><br>you also have to pull an update from there. </p> <p style="width: 100%; background-color: #e9b96e; margin: 5px; padding: 50;" align="center"> <b>You can always press <code>?</code> for help!</b> </p> </html>''')
self.setOption(self.HaveCustomButton1, False)
self, pile, stations=None, events=None, markers=None, ntracks=12, follow=None, controls=True, opengl=False):
pile, ntracks_shown_max=ntracks, use_opengl=opengl, panel_parent=self)
'Markers', self.marker_editor, visible=False, where=qc.Qt.RightDockWidgetArea) self.get_view().add_stations(stations)
self.get_view().add_events(events)
if len(events) == 1: self.get_view().set_active_event(events[0])
self.get_view().add_markers(markers) self.get_view().associate_phases_to_events()
def wizard_finished(result): if result == wizard.Accepted: snuffler_config.first_start = False config.write_config(snuffler_config, 'snuffler')
self.get_view().follow(float(follow))
# return qc.QSize(800, 600) # used for screen shots in tutorial
self.tabs.remove_tab(widget)
where=qc.Qt.BottomDockWidgetArea):
self.toggle_panel(dockwidget, True)
def visibility(visible): if not visible: self.remove_panel(panel)
dockwidget.visibilityChanged.connect( visibility)
dockwidget.raise_()
self._old_signal_handler = signal.signal( signal.SIGINT, self.myCloseAllWindows)
signal.signal(signal.SIGINT, self._old_signal_handler)
self.connections = [] s = qn.QTcpServer(self) s.listen(qn.QHostAddress.LocalHost) s.newConnection.connect( self.handle_accept) self.server = s
self.loader = SimpleConnectionHandler( self, add_files=self.add_files, update_progress=self.update_progress) ticket = os.urandom(32) self.forker.spawn('loader', self.server.serverPort(), ticket) self.connection_handlers[ticket] = self.loader
sock = self.server.nextPendingConnection() con = Connection(self, sock) self.connections.append(con)
con.disconnected.connect( self.handle_disconnected)
con.received.connect( self.handle_received_ticket)
self.connections.remove(connection) connection.close() del connection
if not isinstance(object, str): self.handle_disconnected(connection)
ticket = object if ticket in self.connection_handlers: h = self.connection_handlers[ticket] connection.received.disconnect( self.handle_received_ticket)
h.set_connection(connection) else: self.handle_disconnected(connection)
return [w for w in self.topLevelWidgets() if isinstance(w, SnufflerWindow) and not w.is_closing()]
paths = [str(e.file())] wins = self.snuffler_windows() if wins: wins[0].get_view().load_soon(paths)
return True else:
if not self.loader: self.start_loader()
self.loader.ship( ('load', pathes, cachedirname, pattern, format))
p = self.pile_viewer.get_pile() p.add_files(files) self.pile_viewer.update_contents()
self.pile_viewer.progressbars.set_status(task, percent)
self.closeAllWindows()
self.quit() |