Exemplo n.º 1
0
 def test_mean(self):
     # for doc purposes: the mean of PMFs is not the PMF of the mean
     numpy.random.seed(42)
     matrix = numpy.random.random(self.matrix.shape)
     pmf1 = disagg.mag_pmf(self.matrix)
     pmf2 = disagg.mag_pmf(matrix)
     mean = (matrix + self.matrix) / 2
     numpy.testing.assert_allclose((pmf1 + pmf2) / 2, [1, 1])
     numpy.testing.assert_allclose(disagg.mag_pmf(mean),
                                   [0.99999944, 0.99999999])
Exemplo n.º 2
0
 def test_mean(self):
     # for doc purposes: the mean of PMFs is not the PMF of the mean
     numpy.random.seed(42)
     matrix = numpy.random.random(self.matrix.shape)
     pmf1 = disagg.mag_pmf(self.matrix)
     pmf2 = disagg.mag_pmf(matrix)
     mean = (matrix + self.matrix) / 2
     numpy.testing.assert_allclose(
         (pmf1 + pmf2) / 2, [1, 1])
     numpy.testing.assert_allclose(
         disagg.mag_pmf(mean), [0.99999944, 0.99999999])
Exemplo n.º 3
0
 def test_magnitude_bins(self):
     """ Testing build disaggregation matrix """
     fname = os.path.join(DATA_PATH, 'data', 'ssm.xml')
     converter = sourceconverter.SourceConverter(50., 1., 10, 0.1, 10)
     groups = to_python(fname, converter)
     sources = []
     for g in groups:
         sources += g.sources
     site = Site(Point(172.63, -43.53),
                 vs30=250,
                 vs30measured=False,
                 z1pt0=330)
     imt = SA(3.0)
     iml = 0.25612220
     gsim_by_trt = {TRT.ACTIVE_SHALLOW_CRUST: Bradley2013()}
     truncation_level = 3.0
     n_epsilons = 1
     mag_bin_width = 0.1
     dist_bin_width = 100.
     coord_bin_width = 100.
     # Compute the disaggregation matrix
     edges, mtx = disagg.disaggregation(sources, site, imt, iml,
                                        gsim_by_trt, truncation_level,
                                        n_epsilons, mag_bin_width,
                                        dist_bin_width, coord_bin_width)
     tm = disagg.mag_pmf(mtx[:, :, :, :, :, 0])
     numpy.testing.assert_array_less(numpy.zeros_like(tm[2:]), tm[2:])
Exemplo n.º 4
0
 def test_magnitude_bins(self):
     """ Testing build disaggregation matrix """
     fname = os.path.join(DATA_PATH, 'data', 'ssm.xml')
     converter = sourceconverter.SourceConverter(50., 1., 10, 0.1, 10)
     groups = to_python(fname, converter)
     sources = []
     for g in groups:
         sources += g.sources
     site = Site(Point(172.63, -43.53), vs30=250, vs30measured=False,
                 z1pt0=330)
     imt = SA(3.0)
     iml = 0.25612220
     gsim_by_trt = {TRT.ACTIVE_SHALLOW_CRUST: Bradley2013()}
     truncation_level = 3.0
     n_epsilons = 1
     mag_bin_width = 0.1
     dist_bin_width = 100.
     coord_bin_width = 100.
     # Compute the disaggregation matrix
     edges, mtx = disagg.disaggregation(sources, site, imt, iml,
                                        gsim_by_trt, truncation_level,
                                        n_epsilons, mag_bin_width,
                                        dist_bin_width, coord_bin_width)
     tm = disagg.mag_pmf(mtx[:, :, :, :, :, 0])
     numpy.testing.assert_array_less(numpy.zeros_like(tm[2:]), tm[2:])
Exemplo n.º 5
0
 def test_mag(self):
     pmf = disagg.mag_pmf(self.matrix)
     self.aae(pmf, [1.0, 1.0])
Exemplo n.º 6
0
 def test_mag(self):
     pmf = disagg.mag_pmf(self.matrix)
     self.aae(pmf, [1.0, 1.0])
Exemplo n.º 7
0
 def test_mag(self):
     pmf = disagg.mag_pmf(self.matrix)
     self.aae(pmf, [30.29, 34.57])