def test_spatial_correlation(self): expected = {sc1: [0.99, 0.41], sc2: [0.99, 0.64], sc3: [0.99, 0.22]} for case in expected: self.run_calc(case.__file__, 'job.ini') oq = self.calc.oqparam self.assertEqual(list(oq.imtls), ['PGA']) dstore = DataStore(self.calc.datastore.calc_id) gmf_by_rupid = groupby( dstore['gmfs/col00'].value, lambda row: row['idx'], lambda rows: [row['BooreAtkinson2008']['PGA'] for row in rows]) dstore.close() gmvs_site_1 = [] gmvs_site_2 = [] for rupid, gmf in gmf_by_rupid.iteritems(): gmvs_site_1.append(gmf[0]) gmvs_site_2.append(gmf[1]) joint_prob_0_5 = joint_prob_of_occurrence( gmvs_site_1, gmvs_site_2, 0.5, oq.investigation_time, oq.ses_per_logic_tree_path) joint_prob_1_0 = joint_prob_of_occurrence( gmvs_site_1, gmvs_site_2, 1.0, oq.investigation_time, oq.ses_per_logic_tree_path) p05, p10 = expected[case] numpy.testing.assert_almost_equal(joint_prob_0_5, p05, decimal=1) numpy.testing.assert_almost_equal(joint_prob_1_0, p10, decimal=1)
def test_spatial_correlation(self): expected = {sc1: [0.99, 0.41], sc2: [0.99, 0.64], sc3: [0.99, 0.22]} for case in expected: self.run_calc(case.__file__, 'job.ini') oq = self.calc.oqparam self.assertEqual(list(oq.imtls), ['PGA']) dstore = DataStore(self.calc.datastore.calc_id) gmf_by_rupid = groupby( dstore['gmfs/col00'].value, lambda row: row['idx'], lambda rows: [row['BooreAtkinson2008']['PGA'] for row in rows]) dstore.close() gmvs_site_1 = [] gmvs_site_2 = [] for rupid, gmf in gmf_by_rupid.items(): gmvs_site_1.append(gmf[0]) gmvs_site_2.append(gmf[1]) joint_prob_0_5 = joint_prob_of_occurrence( gmvs_site_1, gmvs_site_2, 0.5, oq.investigation_time, oq.ses_per_logic_tree_path) joint_prob_1_0 = joint_prob_of_occurrence( gmvs_site_1, gmvs_site_2, 1.0, oq.investigation_time, oq.ses_per_logic_tree_path) p05, p10 = expected[case] numpy.testing.assert_almost_equal(joint_prob_0_5, p05, decimal=1) numpy.testing.assert_almost_equal(joint_prob_1_0, p10, decimal=1)
def test_spatial_correlation(self): expected = {sc1: [0.99, 0.41], sc2: [0.99, 0.64], sc3: [0.99, 0.22]} for case in expected: self.run_calc(case.__file__, 'job.ini') oq = self.calc.oqparam self.assertEqual(list(oq.imtls), ['PGA']) dstore = DataStore(self.calc.datastore.calc_id) gmfa = dstore['gmf_data/1']['BooreAtkinson2008']['PGA'] dstore.close() gmvs_site_1 = gmfa[:, 0] gmvs_site_2 = gmfa[:, 1] joint_prob_0_5 = joint_prob_of_occurrence( gmvs_site_1, gmvs_site_2, 0.5, oq.investigation_time, oq.ses_per_logic_tree_path) joint_prob_1_0 = joint_prob_of_occurrence( gmvs_site_1, gmvs_site_2, 1.0, oq.investigation_time, oq.ses_per_logic_tree_path) p05, p10 = expected[case] numpy.testing.assert_almost_equal(joint_prob_0_5, p05, decimal=1) numpy.testing.assert_almost_equal(joint_prob_1_0, p10, decimal=1)
def test_spatial_correlation(self): expected = {sc1: [0.99, 0.41], sc2: [0.99, 0.64], sc3: [0.99, 0.22]} for case in expected: self.run_calc(case.__file__, 'job.ini') oq = self.calc.oqparam self.assertEqual(list(oq.imtls), ['PGA']) dstore = DataStore(self.calc.datastore.calc_id) gmfa = dstore['gmf_data/1']['BooreAtkinson2008']['PGA'] dstore.close() gmvs_site_1 = gmfa[:, 0] gmvs_site_2 = gmfa[:, 1] joint_prob_0_5 = joint_prob_of_occurrence( gmvs_site_1, gmvs_site_2, 0.5, oq.investigation_time, oq.ses_per_logic_tree_path) joint_prob_1_0 = joint_prob_of_occurrence( gmvs_site_1, gmvs_site_2, 1.0, oq.investigation_time, oq.ses_per_logic_tree_path) p05, p10 = expected[case] numpy.testing.assert_almost_equal(joint_prob_0_5, p05, decimal=1) numpy.testing.assert_almost_equal(joint_prob_1_0, p10, decimal=1)