def make_amplitudes(scnls=None, picks=None): """Create amplitudes for testing.""" counter = 1 amps = [] scnls = scnls or [] params = { "type": "A", "unit": "dimensionless", "method_id": "mag_calculator", "filter_id": ev.ResourceIdentifier("Wood-Anderson"), "magnitude_hint": "M", "category": "point", "evaluation_mode": "manual", "evaluation_status": "confirmed", } for scnl in scnls: a = ev.Amplitude( generic_amplitude=counter, generic_amplitude_errors=ev.QuantityError( uncertainty=counter * 0.1, confidence_level=95 ), period=counter * 2, snr=counter * 5, time_window=ev.TimeWindow(0, 0.1, UTCDateTime()), waveform_id=ev.WaveformStreamID(seed_string=scnl), scaling_time=UTCDateTime(), scaling_time_errors=ev.QuantityError( uncertainty=counter * 0.001, confidence_level=95 ), creation_info=ev.CreationInfo( agency_id="dummy_agency", author="dummy", creation_time=UTCDateTime() ), **params, ) amps.append(a) counter += 1 picks = picks or [] for pick in picks: a = ev.Amplitude( generic_amplitude=counter, generic_amplitude_errors=ev.QuantityError( uncertainty=counter * 0.1, confidence_level=95 ), period=counter * 2, snr=counter * 5, time_window=ev.TimeWindow(0, 0.1, UTCDateTime()), pick_id=pick.resource_id, scaling_time=UTCDateTime(), scaling_time_errors=ev.QuantityError( uncertainty=counter * 0.001, confidence_level=95 ), creation_info=ev.CreationInfo( agency_id="dummy_agency", author="dummy", creation_time=UTCDateTime() ), **params, ) amps.append(a) counter += 1 return amps
def event_amplitudes(self, cat_picks): """Return an event with some amplitudes""" eve = cat_picks[0] eve.amplitudes.append( ev.Amplitude(generic_amplitude=1, evaluation_status="reviewed")) eve.amplitudes.append( ev.Amplitude(generic_amplitude=1, evaluation_status="rejected")) return eve
def _get_amplitudes(): return ev.Amplitude( generic_amplitude=.0012, type='A', unit='m', period=1, time_window=_get_timewindow(), pick_id=state['pick_id'], scalling_time=state['time'], mangitude_hint='ML', scaling_time_errors=ev.QuantityError(uncertainty=42.0), )
def create_amplitude(pickID, amp, unit, category, cinfo): ''' :param pickID: :param amp: :param unit: :param category: :param cinfo: :return: ''' amplitude = ope.Amplitude() amplitude.creation_info = cinfo amplitude.generic_amplitude = amp amplitude.unit = ope.AmplitudeUnit(unit) amplitude.type = ope.AmplitudeCategory(category) amplitude.pick_id = pickID return amplitude
def add_amplitudes(event, amplitudes): amplitude_list = [] for pick in event.picks: try: a0 = amplitudes[pick.waveform_id.station_code] amplitude = ope.Amplitude(generic_amplitude=a0 * 1e-3) amplitude.unit = 'm' amplitude.category = 'point' amplitude.waveform_id = pick.waveform_id amplitude.magnitude_hint = 'ML' amplitude.pick_id = pick.resource_id amplitude.type = 'AML' amplitude_list.append(amplitude) except KeyError: continue event.amplitudes = amplitude_list return event
def calc(self): for a in self.arrivals: if a.phase not in 'sS': continue pick = a.pick_id.get_referred_object() station = pick.waveform_id.station_code wf = select_for_phase(self.stream.select(station=station), a.phase) if not wf: if self.verbose: print('WARNING: no waveform data found for station {0}'. format(station)) continue delta = degrees2kilometers(a.distance) onset = pick.time a0, self.p2p_fig = self.peak_to_peak(wf, onset) amplitude = ope.Amplitude(generic_amplitude=a0 * 1e-3) amplitude.unit = 'm' amplitude.category = 'point' amplitude.waveform_id = pick.waveform_id amplitude.magnitude_hint = self.type amplitude.pick_id = pick.resource_id amplitude.type = 'AML' self.event.amplitudes.append(amplitude) self.amplitudes = (station, amplitude) # using standard Gutenberg-Richter relation # or scale WA amplitude with given scaling relation if str(self.wascaling) == '[0.0, 0.0, 0.0]': print("Calculating original Richter magnitude ...") magnitude = ope.StationMagnitude(mag=np.log10(a0) \ + richter_magnitude_scaling(delta)) else: print("Calculating scaled local magnitude ...") a0 = a0 * 1e03 # mm to nm (see Havskov & Ottemöller, 2010) magnitude = ope.StationMagnitude(mag=np.log10(a0) \ + self.wascaling[0] * np.log10(delta) + self.wascaling[1] * delta + self.wascaling[ 2]) magnitude.origin_id = self.origin_id magnitude.waveform_id = pick.waveform_id magnitude.amplitude_id = amplitude.resource_id magnitude.station_magnitude_type = self.type self.event.station_magnitudes.append(magnitude) self.magnitudes = (station, magnitude)