Example #1
0
File: test.py Project: 4x/oq-engine
    def test(self):
        cfg = os.path.join(os.path.dirname(__file__), 'job.ini')
        job = self.run_hazard(cfg)
        [output] = export.core.get_outputs(job.id)
        gmfs = list(qa_utils.get_gmfs_per_site(output, 'PGA'))
        realizations = 1e5 
        first_value = 0.5
        second_value = 1.0
        gmfs_within_range_fst = qa_utils.count(first_value, gmfs[0], gmfs[1]) 
        gmfs_within_range_snd = qa_utils.count(second_value, gmfs[0], gmfs[1])

        self.assertEqual(gmfs_within_range_fst / realizations, 0.020)
        self.assertEqual(gmfs_within_range_snd / realizations, 0.0016)
Example #2
0
 def test(self):
     cfg = os.path.join(os.path.dirname(__file__), 'job.ini')
     job = self.run_hazard(cfg)
     [output] = export.core.get_outputs(job.id, 'gmf_scenario')
     gmfs = list(models.get_gmvs_per_site(output, 'PGA'))
     realizations = 2e4
     first_value = 0.5
     second_value = 1.0
     gmfs_within_range_fst = qa_utils.count(first_value, gmfs[0], gmfs[1])
     gmfs_within_range_snd = qa_utils.count(second_value, gmfs[0], gmfs[1])
     self.assertAlmostEqual(gmfs_within_range_fst / realizations,
                            0.05, places=2)
     self.assertAlmostEqual(gmfs_within_range_snd / realizations,
                            0.006, places=3)
Example #3
0
    def test(self):
        cfg = os.path.join(os.path.dirname(__file__), 'job.ini')
        job = self.run_hazard(cfg)
        [output] = export.core.get_outputs(job.id)
        gmfs = list(models.get_gmvs_per_site(output, 'PGA', sort=lambda x: x))
        realizations = 1e5
        first_value = 0.5
        second_value = 1.0
        gmfs_within_range_fst = qa_utils.count(first_value, gmfs[0], gmfs[1])
        gmfs_within_range_snd = qa_utils.count(second_value, gmfs[0], gmfs[1])

        self.assertAlmostEqual(gmfs_within_range_fst / realizations,
                               0.02,
                               places=2)
        self.assertAlmostEqual(gmfs_within_range_snd / realizations,
                               0.002,
                               places=3)