Example #1
0
 def test_unique_resource_ids(self, catalog, duplicated_catalog):
     """ ensure all resource ids are unique in duplicated event """
     ev1, ev2 = catalog, duplicated_catalog
     rids1 = {x for x in get_instances(ev1, ResourceIdentifier)}
     rids2 = {x for x in get_instances(ev2, ResourceIdentifier)}
     assert len(rids1) and len(rids2)  # ensure rids not empty
     commons = rids1 & rids2
     # all shared resource_ids should not refer to an object
     assert all(x.get_referred_object() is None for x in commons)
Example #2
0
def _get_update_time(eve):
    """ return the most recent time anything was updated in event """
    creations = get_instances(eve, ev.CreationInfo)
    timestamps = [
        getattr(x.creation_time, "timestamp", None) or 0 for x in creations
    ]
    return {"updated": max(timestamps) if timestamps else np.NaN}
Example #3
0
def _event_to_inv_df(event):
    """ Pull all waveform steam IDS out of an event and put it in a
    dataframe """
    wids = {
        x.get_seed_string()
        for x in get_instances(event, WaveformStreamID)
    }
    df = pd.DataFrame(sorted(wids), columns=["seed_id"])
    seed = df["seed_id"].str.split(".", expand=True)
    df["network"], df["station"] = seed[0], seed[1]
    df["location"], df["channel"] = seed[2], seed[3]
    df["start_date"] = np.nan
    df["end_date"] = np.nan
    df["latitude"] = np.nan
    df["longitude"] = np.nan
    df["elevation"] = np.nan
    return stations_to_df(df)
Example #4
0
def _filter(obj, cls, **kwargs):
    return (x for x in get_instances(obj, cls) if _keep_obj(x, **kwargs))