コード例 #1
0
 def calc(self):
     for a in self.arrivals:
         if a.phase not in 'pP':
             continue
         pick = a.pick_id.get_referred_object()
         station = pick.waveform_id.station_code
         scopy = self.stream.copy()
         wf = scopy.select(station=station)
         if not wf:
             continue
         onset = pick.time
         distance = degrees2kilometers(a.distance)
         azimuth = a.azimuth
         incidence = a.takeoff_angle
         w0, fc = calcsourcespec(wf, onset, self.p_velocity, distance,
                                 azimuth, incidence, self.p_attenuation,
                                 self.plot_flag, self.verbose)
         if w0 is None or fc is None:
             if self.verbose:
                 print("WARNING: insufficient frequency information")
             continue
         WF = select_for_phase(self.stream.select(station=station), a.phase)
         WF = select_for_phase(WF, "P")
         m0, mw = calcMoMw(WF, w0, self.rock_density, self.p_velocity,
                           distance, self.verbose)
         self.moment_props = (station, dict(w0=w0, fc=fc, Mo=m0))
         magnitude = ope.StationMagnitude(mag=mw)
         magnitude.origin_id = self.origin_id
         magnitude.waveform_id = pick.waveform_id
         magnitude.station_magnitude_type = self.type
         self.event.station_magnitudes.append(magnitude)
         self.magnitudes = (station, magnitude)
コード例 #2
0
 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)
コード例 #3
0
def sm_generator(scnls=None, amplitudes=None):
    """Function to create station magntiudes for testing."""
    counter = 1
    sms = []
    scnls = scnls or []
    params = {
        "origin_id": ev.ResourceIdentifier(),
        "station_magnitude_type": "M",
        "method_id": "mag_calculator",
    }

    for scnl in scnls:
        sm = ev.StationMagnitude(
            mag=counter,
            mag_errors=ev.QuantityError(uncertainty=counter * 0.1,
                                        confidence_level=95),
            waveform_id=ev.WaveformStreamID(seed_string=scnl),
            creation_info=ev.CreationInfo(agency_id="dummy_agency",
                                          author="dummy",
                                          creation_time=UTCDateTime()),
            **params,
        )
        sms.append(sm)
        counter += 1
    amplitudes = amplitudes or []
    for amp in amplitudes:
        sm = ev.StationMagnitude(
            mag=counter,
            mag_errors=ev.QuantityError(uncertainty=counter * 0.1,
                                        confidence_level=95),
            amplitude_id=amp.resource_id,
            creation_info=ev.CreationInfo(agency_id="dummy_agency",
                                          author="dummy",
                                          creation_time=UTCDateTime()),
            **params,
        )
        sms.append(sm)
        counter += 1
    return sms
コード例 #4
0
ファイル: testing.py プロジェクト: yanyuandaxia/obspy
 def _get_station_mag():
     station_mag = ev.StationMagnitude(mag=2.24, )
     state['station_mag_id'] = station_mag.resource_id
     return station_mag
コード例 #5
0
 def event_station_mags(self, event_focal_mech):
     """Add a focal mechanism to the event"""
     event_focal_mech.station_magnitudes.append(ev.StationMagnitude())
     return event_focal_mech