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

    assert gmpes == \
        ['FrankelEtAl1996MwNSHMP2008()',
         'ToroEtAl1997MwNSHMP2008()',
         'SilvaEtAl2002MwNSHMP2008()',
         'Campbell2003MwNSHMP2008()',
         'TavakoliPezeshk2005MwNSHMP2008()',
         'AtkinsonBoore2006Modified2011()',
         'PezeshkEtAl2011()',
         'Atkinson2008prime()',
         'SomervilleEtAl2001NSHMP2008()']

    assert wts == [0.06, 0.11, 0.06, 0.11, 0.11, 0.22, 0.15, 0.08, 0.1]

    assert wts_large_dist == [0.16, 0.0, 0.0, 0.17, 0.17, 0.3, 0.2, 0.0, 0.0]

    assert dist_cutoff == 500

    assert site_gmpes == ['AtkinsonBoore2006Modified2011()']
예제 #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