Ejemplo n.º 1
0
def load_pro_eq_catalog(cfg: dict) -> GeoDataFrame:
    """
    Loads the prospective earthquake catalog into a `GeoDataFrame` that has all of
    the earthquakes processed into :class:`~openquake.hme.utils.Earthquake`
    objects. The formatting must be identical to the 'observed' seismic catalog.

    :param cfg:
        Configuration for the evaluations, such as that parsed from the YAML
        config file.

    :returns:
        :class:`GeoDataFrame`
    """

    logger.info("making earthquake GDF from seismic catalog")

    seis_cat_cfg: dict = cfg["input"]["seis_catalog"]
    pro_cat_cfg: dict = cfg["input"]["prospective_catalog"]
    seis_cat_params = {
        k: v for k, v in seis_cat_cfg["columns"].items() if v is not None
    }
    pro_cat_file = pro_cat_cfg["prospective_catalog_file"]

    eq_gdf = make_earthquake_gdf_from_csv(pro_cat_file, **seis_cat_params)

    if any(["stop_date", "start_date", "duration"]) in pro_cat_cfg:
        start_date = pro_cat_cfg.get("start_date")
        stop_date = pro_cat_cfg.get("stop_date")
        duration = pro_cat_cfg.get("duration")
        eq_gdf = trim_eq_catalog(
            eq_gdf, start_date=start_date, stop_date=stop_date, duration=duration
        )

    return eq_gdf
Ejemplo n.º 2
0
def load_obs_eq_catalog(cfg: dict) -> GeoDataFrame:
    """
    Loads the observed earthquake catalog into a `GeoDataFrame` that has all of
    the earthquakes processed into :class:`~openquake.hme.utils.Earthquake`
    objects.

    :param cfg:
        Configuration for the evaluations, such as that parsed from the YAML
        config file.

    :returns:
        :class:`GeoDataFrame`
    """

    logger.info("making earthquake GDF from seismic catalog")

    seis_cat_cfg: dict = cfg["input"]["seis_catalog"]
    seis_cat_params = {
        k: v
        for k, v in seis_cat_cfg["columns"].items() if v is not None
    }
    seis_cat_file = seis_cat_cfg["seis_catalog_file"]

    eq_gdf = make_earthquake_gdf_from_csv(seis_cat_file, **seis_cat_params)

    return eq_gdf
Ejemplo n.º 3
0
 def test_add_earthquakes_to_bins(self):
     self.eq_df = make_earthquake_gdf_from_csv(self.test_dir +
                                               "data/phl_eqs.csv")
     add_earthquakes_to_bins(self.eq_df, self.bin_gdf)
     sbin = self.bin_gdf.loc["836860fffffffff"].SpacemagBin
     self.assertEqual(len(sbin.mag_bins[6.0].observed_earthquakes), 2)
Ejemplo n.º 4
0
 def test_make_earthquake_gdf(self):
     self.eq_df = make_earthquake_gdf_from_csv(self.test_dir +
                                               "data/phl_eqs.csv")
     self.assertEqual(self.eq_df.loc[0].magnitude, 7.4)