Esempio n. 1
0
 def to_sac_stream(self, st, waveform):
     """
     Return a SACTrace based on the given stream, containing metadata headers from the waveform
     """
     tr = SACTrace.from_obspy_trace(st[0])
     tr.kevnm = waveform.event_description[:16]
     event = waveform.event_ref()
     if not event:
         LOGGER.warn("Lost reference to event %s", waveform.event_description)
     else:
         origin = get_preferred_origin(waveform.event_ref())
         if origin:
             tr.evla = origin.latitude
             tr.evlo = origin.longitude
             tr.evdp = origin.depth / 1000
             tr.o = origin.time - waveform.start_time
         magnitude = get_preferred_magnitude(waveform.event_ref())
         if magnitude:
             tr.mag = magnitude.mag
     channel = waveform.channel_ref()
     if not channel:
         LOGGER.warn("Lost reference to channel %s", waveform.sncl)
     else:
         tr.stla = channel.latitude
         tr.stlo = channel.longitude
         tr.stdp = channel.depth
         tr.stel = channel.elevation
         tr.cmpaz = channel.azimuth
         tr.cmpinc = channel.dip + 90
         tr.kinst = channel.sensor.description[:8]
     return Stream([tr.to_obspy_trace()])
Esempio n. 2
0
 def to_sac_stream(self, st, waveform):
     """
     Return a SACTrace based on the given stream, containing metadata headers from the waveform
     """
     tr = SACTrace.from_obspy_trace(st[0])
     tr.kevnm = waveform.event_description[:16]
     event = waveform.event_ref()
     if not event:
         LOGGER.warn("Lost reference to event %s",
                     waveform.event_description)
     else:
         origin = get_preferred_origin(waveform.event_ref())
         if origin:
             tr.evla = origin.latitude
             tr.evlo = origin.longitude
             tr.evdp = origin.depth / 1000
             tr.o = origin.time - waveform.start_time
         magnitude = get_preferred_magnitude(waveform.event_ref())
         if magnitude:
             tr.mag = magnitude.mag
     channel = waveform.channel_ref()
     if not channel:
         LOGGER.warn("Lost reference to channel %s", waveform.sncl)
     else:
         tr.stla = channel.latitude
         tr.stlo = channel.longitude
         tr.stdp = channel.depth
         tr.stel = channel.elevation
         tr.cmpaz = channel.azimuth
         tr.cmpinc = channel.dip + 90
         tr.kinst = channel.sensor.description[:8]
     return Stream([tr.to_obspy_trace()])
Esempio n. 3
0
    def rows(self, data):
        """
        Turn the data into rows (an iterable of lists) of QTableWidgetItems
        """
        for i, event in enumerate(data):
            origin = get_preferred_origin(event)
            if not origin:
                continue
            magnitude = get_preferred_magnitude(event)
            if not magnitude:
                continue
            time = origin.time.strftime("%Y-%m-%d %H:%M:%S")  # use strftime to remove milliseconds
            event_description = "no description"
            if len(event.event_descriptions) > 0:
                event_description = event.event_descriptions[0].text

            yield [
                self.numericWidget(i),
                self.stringWidget(time),
                self.numericWidget(magnitude.mag, "%s %s" % (magnitude.mag, magnitude.magnitude_type)),
                self.numericWidget(origin.longitude, "%.03f°"),
                self.numericWidget(origin.latitude, "%.03f°"),
                self.numericWidget(origin.depth / 1000, "%.02f km"),  # we wish to report in km
                self.stringWidget(event_description.title()),
            ]
Esempio n. 4
0
    def __init__(self, event, network, station, channel, *args, **kwargs):
        super(WaveformEntry, self).__init__(*args, **kwargs)

        self.event_ref = weakref.ref(event)
        self.network_ref = weakref.ref(network)
        self.station_ref = weakref.ref(station)
        self.channel_ref = weakref.ref(channel)

        self.sncl = get_sncl(network, station, channel)

        self.event_description = get_event_description(event)
        origin = get_preferred_origin(event)
        self.event_time = origin.time
        self.event_time_str = format_time_str(origin.time)
        self.event_depth = origin.depth / 1000
        mag = get_preferred_magnitude(event)
        self.event_mag = "%s%s" % (mag.mag, mag.magnitude_type)
        self.event_mag_value = mag.mag
        self.waveform_id = '%s_%s' % (self.sncl, get_event_id(event))

        self.distance = get_distance(origin.latitude, origin.longitude,
                                     station.latitude, station.longitude)
Esempio n. 5
0
    def __init__(self, event, network, station, channel, *args, **kwargs):
        super(WaveformEntry, self).__init__(*args, **kwargs)

        self.event_ref = weakref.ref(event)
        self.network_ref = weakref.ref(network)
        self.station_ref = weakref.ref(station)
        self.channel_ref = weakref.ref(channel)

        self.sncl = get_sncl(network, station, channel)

        self.event_description = get_event_description(event)
        origin = get_preferred_origin(event)
        self.event_time = origin.time
        self.event_time_str = format_time_str(origin.time)
        self.event_depth = origin.depth / 1000
        mag = get_preferred_magnitude(event)
        self.event_mag = "%s%s" % (mag.mag, mag.magnitude_type)
        self.event_mag_value = mag.mag
        self.waveform_id = '%s_%s' % (self.sncl, get_event_id(event))

        self.distance = get_distance(
            origin.latitude, origin.longitude,
            station.latitude, station.longitude)