예제 #1
0
def test_nshmp14_sub_i():
    gmpes, wts, wts_large_dist, dist_cutoff, site_gmpes = \
        nshmp14_sub_s.get_weights()

    assert gmpes == \
        ['AtkinsonBoore2003SSlab()',
         'AtkinsonBoore2003SSlabCascadia()',
         'ZhaoEtAl2006SSlab()',
         'AbrahamsonEtAl2015SSlab()']

    assert wts == [0.1667, 0.1667, 0.33, 0.33]

    assert wts_large_dist is None

    assert dist_cutoff is None
예제 #2
0
    def from_set_name(cls, set_name, imt = None):
        """
        Construct a DualDistanceWeights instance from set_name.

        Args:
            set_name (str): String indicating what GMPE set to use; valid 
                options are 'nshmp14_acr', 'nshmp14_scr_rlme', 
                'nshmp14_scr_grd', 'nshmp14_sub_i', 'nshmp14_sub_s'. The meaning
                of these strings is found in shakemap.grind.gmpe_sets.
            imt (IMT): Optional OQ IMT instance for filtering GMPE lists.

        """

        self = cls()

        if set_name == 'nshmp14_acr':
            gmpes, wts, wts_large_dist, dist_cutoff, site_gmpes = \
                nshmp14_acr.get_weights()
        elif set_name == 'nshmp14_scr_rlme':
            gmpes, wts, wts_large_dist, dist_cutoff, site_gmpes = \
                nshmp14_scr_rlme.get_weights()
        elif set_name == 'nshmp14_scr_grd':
            gmpes, wts, wts_large_dist, dist_cutoff, site_gmpes = \
                nshmp14_scr_grd.get_weights()
        elif set_name == 'nshmp14_sub_i':
            gmpes, wts, wts_large_dist, dist_cutoff, site_gmpes = \
                nshmp14_sub_i.get_weights()
        elif set_name == 'nshmp14_sub_s':
            gmpes, wts, wts_large_dist, dist_cutoff, site_gmpes = \
                nshmp14_sub_s.get_weights()
        else:
            raise Exception("Unsupported value of set_name.")

        #-----------------------------------------------------------------------
        # Small-distance GMPE and weights
        #-----------------------------------------------------------------------

        # Remove GMPEs not applicable to this IMT and redistribute weights
        if imt is not None:
            sgmpe, swts = filter_gmpe_list(gmpes, wts, imt)
        else:
            sgmpe, swts = gmpes, wts

        self.mgmpe_small = MultiGMPE.from_list(
            sgmpe, swts, default_gmpes_for_site = site_gmpes)

        #-----------------------------------------------------------------------
        # Large-distance GMPE and weights
        #-----------------------------------------------------------------------
        if wts_large_dist is not None:
            # Remove GMPEs not applicable to this IMT and redistribute weights
            if imt is not None:
                sgmpe_large, swts_large = filter_gmpe_list(
                    gmpes, wts_large_dist, imt)
            else:
                sgmpe_large = gmpes
                swts_large = wts_large_dist
            self.mgmpe_large = MultiGMPE.from_list(
                sgmpe_large, swts_large, default_gmpes_for_site = site_gmpes)
            self.dist_cutoff = dist_cutoff
        else:
            self.mgmpe_large = None
            self.dist_cutoff = None
        return self