def __call__(self): """Return a dict of origin quality attributes.""" out = {} origin = get_preferred(self.event, "origin", init_empty=True) # get phase and pick count self._get_phase_and_pick_counts(origin, out) # now extract information self._get_origin_quality_info(origin, out) self._get_depth_uncertainty_info(origin, out) self._get_origin_uncertainty(origin, out) return out
def test_events_different_time_same_id_not_duplicated(self, tmpdir): """ Events with different times but the same id should not be duplicated; the old path should be used when detected. """ cat = obspy.read_events() first_id = str(cat[0].resource_id) bank = obsplus.EventBank(Path(tmpdir)).put_events(cat) df = bank.read_index().set_index("event_id") # modify first event preferred origin time slightly event = cat[0] origin = get_preferred(event, "origin") origin.time += 10 # save to disk again bank.put_events(event) # ensure event count didnt change assert len(df) == len(bank.read_index()) # read first path and make sure origin time was updated cat2 = bank.get_events(event_id=first_id) assert len(cat2) == 1 assert get_preferred(cat2[0], "origin").time == origin.time
def _get_magnitude_info(eve: ev.Event): """ Extract magnitude information. Get base magnitude, as well as various other magnitude types (where applicable). """ out = {} magnitude = get_preferred(eve, "magnitude", init_empty=True) out["magnitude"] = magnitude.mag out["magnitude_type"] = magnitude.magnitude_type or "" for col_name, mag_type in MAGNITUDE_COLUMN_TYPES.items(): out[col_name] = _get_last_magnitude(eve.magnitudes, mag_type) return out
def _get_origin_basic(eve): """extract basic info from origin.""" ori = get_preferred(eve, "origin", init_empty=True) return getattrs(ori, set(loc_dtypes))