def test_double(self):
        fname = gettemp(double_ampl_func)
        df = read_csv(fname, {
            'ampcode': ampcode_dt,
            None: numpy.float64
        },
                      index='ampcode')

        a = Amplifier(self.imtls, df, self.soil_levels)
        poes = a.amplify_one(b'A', 'SA(0.1)', self.hcurve[1]).flatten()
        numpy.testing.assert_allclose(poes, [
            0.985122, 0.979701, 0.975965, 0.96634, 0.922497, 0.886351, 0.790249
        ],
                                      atol=1E-6)
        #    poes, [0.989, 0.985, 0.98, 0.97, 0.94, 0.89, 0.79], atol=1E-6)

        poes = a.amplify_one(b'A', 'SA(0.2)', self.hcurve[2]).flatten()
        numpy.testing.assert_allclose(poes, [
            0.985122, 0.979701, 0.975965, 0.96634, 0.922497, 0.886351, 0.790249
        ],
                                      atol=1E-6)
        #    poes, [0.989, 0.985, 0.98, 0.97, 0.94, 0.89, 0.79], atol=1E-6)

        poes = a.amplify_one(b'A', 'SA(0.5)', self.hcurve[3]).flatten()
        numpy.testing.assert_allclose(poes, [
            0.985122, 0.979701, 0.975965, 0.96634, 0.922497, 0.886351, 0.790249
        ],
                                      atol=1E-6)
        #    poes, [0.989, 0.985, 0.98, 0.97, 0.94, 0.89, 0.79], atol=1E-6)

        # amplify GMFs without sigmas
        gmvs = a._amplify_gmvs(b'A', numpy.array([.1, .2, .3]), 'SA(0.5)')
        numpy.testing.assert_allclose(gmvs, [.2, .4, .6])
 def test_trivial(self):
     # using the heaviside function, i.e. `amplify_one` has contributions
     # only for soil_intensity < a * mid_intensity with a=1
     # in this case the minimimum mid_intensity is 0.0015 which is
     # smaller than the minimum soil intensity 0.0020, so some contribution
     # is lost and this is the reason why the first poe in 0.985
     # instead of 0.989
     fname = gettemp(trivial_ampl_func)
     df = read_csv(fname, {
         'ampcode': ampcode_dt,
         None: numpy.float64
     },
                   index='ampcode')
     a = Amplifier(self.imtls, df, self.soil_levels)
     a.check(self.vs30, 0)
     numpy.testing.assert_allclose(a.midlevels, [
         0.0015, 0.0035, 0.0075, 0.015, 0.035, 0.075, 0.15, 0.35, 0.75, 1.1
     ])
     poes = a.amplify_one(b'A', 'SA(0.1)', self.hcurve[1]).flatten()
     numpy.testing.assert_allclose(
         poes, [0.985, 0.98, 0.97, 0.94, 0.89, 0.79, 0.69], atol=1E-6)
     poes = a.amplify_one(b'A', 'SA(0.2)', self.hcurve[2]).flatten()
     numpy.testing.assert_allclose(
         poes, [0.985, 0.98, 0.97, 0.94, 0.89, 0.79, 0.69], atol=1E-6)
     poes = a.amplify_one(b'A', 'SA(0.5)', self.hcurve[3]).flatten()
     numpy.testing.assert_allclose(
         poes, [0.985, 0.98, 0.97, 0.94, 0.89, 0.79, 0.69], atol=1E-6)
    def test_simple(self):
        fname = gettemp(simple_ampl_func)
        df = read_csv(fname, {
            'ampcode': ampcode_dt,
            None: numpy.float64
        },
                      index='ampcode')
        a = Amplifier(self.imtls, df, self.soil_levels)
        # a.check(self.vs30, vs30_tolerance=1)
        poes = a.amplify_one(b'A', 'SA(0.1)', self.hcurve[1]).flatten()
        numpy.testing.assert_allclose(poes, [
            0.981141, 0.975771, 0.964955, 0.935616, 0.882413, 0.785659,
            0.636667
        ],
                                      atol=1e-6)

        poes = a.amplify_one(b'A', 'SA(0.2)', self.hcurve[2]).flatten()
        numpy.testing.assert_allclose(poes, [
            0.981141, 0.975771, 0.964955, 0.935616, 0.882413, 0.785659,
            0.636667
        ],
                                      atol=1e-6)

        poes = a.amplify_one(b'A', 'SA(0.5)', self.hcurve[3]).flatten()
        numpy.testing.assert_allclose(poes, [
            0.981681, 0.976563, 0.967238, 0.940109, 0.890456, 0.799286,
            0.686047
        ],
                                      atol=1e-6)

        # Amplify GMFs with sigmas
        numpy.random.seed(42)
        gmvs = a._amplify_gmvs(b'A', numpy.array([.005, .010, .015]), 'PGA')
        numpy.testing.assert_allclose(gmvs, [0.005401, 0.010356, 0.016704],
                                      atol=1E-5)
Esempio n. 4
0
    def test_double(self):
        fname = gettemp(double_ampl_func)
        aw = read_csv(fname, {
            'ampcode': 'S2',
            'level': numpy.uint8,
            None: numpy.float64
        })
        a = Amplifier(self.imtls, aw)
        poes = a.amplify_one(b'A', 'SA(0.1)', self.hcurve[1]).flatten()
        numpy.testing.assert_allclose(poes, [
            0.989, 0.989, 0.985, 0.98, 0.97, 0.94, 0.89, 0.79, 0.69, 0.09, 0.09
        ],
                                      atol=1E-6)

        poes = a.amplify_one(b'A', 'SA(0.2)', self.hcurve[2]).flatten()
        numpy.testing.assert_allclose(poes, [
            0.989, 0.989, 0.985, 0.98, 0.97, 0.94, 0.89, 0.79, 0.69, 0.09, 0.09
        ],
                                      atol=1E-6)

        poes = a.amplify_one(b'A', 'SA(0.5)', self.hcurve[3]).flatten()
        numpy.testing.assert_allclose(poes, [
            0.989, 0.989, 0.985, 0.98, 0.97, 0.94, 0.89, 0.79, 0.69, 0.09, 0.09
        ],
                                      atol=1E-6)
Esempio n. 5
0
    def test_double(self):
        fname = gettemp(double_ampl_func)
        aw = read_csv(fname, {'ampcode': ampcode_dt, None: numpy.float64})
        a = Amplifier(self.imtls, aw)
        poes = a.amplify_one(b'A', 'SA(0.1)', self.hcurve[1]).flatten()
        numpy.testing.assert_allclose(poes, [
            0.989, 0.989, 0.985, 0.98, 0.97, 0.94, 0.89, 0.79, 0.69, 0.09, 0.09
        ],
                                      atol=1E-6)

        poes = a.amplify_one(b'A', 'SA(0.2)', self.hcurve[2]).flatten()
        numpy.testing.assert_allclose(poes, [
            0.989, 0.989, 0.985, 0.98, 0.97, 0.94, 0.89, 0.79, 0.69, 0.09, 0.09
        ],
                                      atol=1E-6)

        poes = a.amplify_one(b'A', 'SA(0.5)', self.hcurve[3]).flatten()
        numpy.testing.assert_allclose(poes, [
            0.989, 0.989, 0.985, 0.98, 0.97, 0.94, 0.89, 0.79, 0.69, 0.09, 0.09
        ],
                                      atol=1E-6)

        # amplify GMFs without sigmas
        gmvs = a._amplify_gmvs(b'A', numpy.array([.1, .2, .3]), 'SA(0.5)')
        numpy.testing.assert_allclose(gmvs, [.2, .4, .6])
Esempio n. 6
0
    def test_simple(self):
        fname = gettemp(simple_ampl_func)
        aw = read_csv(fname, {'ampcode': ampcode_dt, None: numpy.float64})
        a = Amplifier(self.imtls, aw, self.soil_levels)
        a.check(self.vs30, vs30_tolerance=1)
        poes = a.amplify_one(b'A', 'SA(0.1)', self.hcurve[1]).flatten()
        numpy.testing.assert_allclose(
            poes,
            [0.985002, 0.979997, 0.970004, 0.940069, 0.889961, 0.79, 0.690037],
            atol=1E-6)

        poes = a.amplify_one(b'A', 'SA(0.2)', self.hcurve[2]).flatten()
        numpy.testing.assert_allclose(
            poes,
            [0.985002, 0.979997, 0.970004, 0.940069, 0.889961, 0.79, 0.690037],
            atol=1E-6)

        poes = a.amplify_one(b'A', 'SA(0.5)', self.hcurve[3]).flatten()
        numpy.testing.assert_allclose(
            poes,
            [0.985002, 0.979996, 0.969991, 0.940012, 0.889958, 0.79, 0.690037],
            atol=1E-6)

        # amplify GMFs with sigmas
        numpy.random.seed(42)
        gmvs = a._amplify_gmvs(b'A', numpy.array([.005, .010, .015]), 'PGA')
        numpy.testing.assert_allclose(gmvs, [0.005307, 0.010093, 0.016804],
                                      atol=1E-5)
    def test_simple(self):
        #
        # MP: checked using hand calculations some values of the poes computed
        # considering uncertainty
        #
        fname = gettemp(simple_ampl_func)
        df = read_csv(fname, {
            'ampcode': ampcode_dt,
            None: numpy.float64
        },
                      index='ampcode')
        a = Amplifier(self.imtls, df, self.soil_levels)
        a.check(self.vs30, vs30_tolerance=1)
        poes = a.amplify_one(b'A', 'SA(0.1)', self.hcurve[1]).flatten()
        numpy.testing.assert_allclose(poes, [
            0.985008, 0.980001, 0.970019, 0.94006, 0.890007, 0.790198, 0.690201
        ],
                                      atol=1E-6)

        poes = a.amplify_one(b'A', 'SA(0.2)', self.hcurve[2]).flatten()
        numpy.testing.assert_allclose(poes, [
            0.985008, 0.980001, 0.970019, 0.94006, 0.890007, 0.790198, 0.690201
        ],
                                      atol=1E-6)

        poes = a.amplify_one(b'A', 'SA(0.5)', self.hcurve[3]).flatten()
        numpy.testing.assert_allclose(poes, [
            0.985109, 0.980022, 0.970272, 0.940816, 0.890224, 0.792719,
            0.692719
        ],
                                      atol=1E-6)

        # Amplify GMFs with sigmas
        numpy.random.seed(42)
        gmvs = a._amplify_gmvs(b'A', numpy.array([.005, .010, .015]), 'PGA')
        numpy.testing.assert_allclose(gmvs, [0.005401, 0.010356, 0.016704],
                                      atol=1E-5)
Esempio n. 8
0
 def test_simple(self):
     fname = gettemp(simple_ampl_func)
     aw = read_csv(fname, {
         'ampcode': 'S2',
         'level': numpy.uint8,
         None: numpy.float64
     })
     a = Amplifier(self.imtls, aw, self.soil_levels)
     a.check(self.vs30, 1)
     poes = a.amplify_one(b'A', 'SA(0.1)', self.hcurve[1]).flatten()
     numpy.testing.assert_allclose(
         poes,
         [0.985002, 0.979997, 0.970004, 0.940069, 0.889961, 0.79, 0.690037],
         atol=1E-6)
     poes = a.amplify_one(b'A', 'SA(0.2)', self.hcurve[2]).flatten()
     numpy.testing.assert_allclose(
         poes,
         [0.985002, 0.979997, 0.970004, 0.940069, 0.889961, 0.79, 0.690037],
         atol=1E-6)
     poes = a.amplify_one(b'A', 'SA(0.5)', self.hcurve[3]).flatten()
     numpy.testing.assert_allclose(
         poes,
         [0.985002, 0.979996, 0.969991, 0.940012, 0.889958, 0.79, 0.690037],
         atol=1E-6)