def test_when_measure_type_is_mmi_we_store_as_is(self): location = java.jclass("Location")(1.0, 2.0) site = java.jclass("Site")(location) hashmap = java.jclass("HashMap")() hashmap.put(site, 0.1) for gmv in scenario.gmf_to_dict(hashmap, "MMI"): self.assertEqual(0.1, gmv["mag"])
def test_when_measure_type_is_not_mmi_exp_is_stored(self): location = java.jclass("Location")(1.0, 2.0) site = java.jclass("Site")(location) hashmap = java.jclass("HashMap")() hashmap.put(site, 0.1) for gmv in scenario.gmf_to_dict(hashmap, "PGA"): self.assertEqual(math.exp(0.1), gmv["mag"])
def test_transforms_a_java_gmf_to_dict(self): location1 = java.jclass("Location")(1.0, 2.0) location2 = java.jclass("Location")(1.1, 2.1) location3 = java.jclass("Location")(1.2, 2.2) site1 = java.jclass("Site")(location1) site2 = java.jclass("Site")(location2) site3 = java.jclass("Site")(location3) hashmap = java.jclass("HashMap")() hashmap.put(site1, 0.1) hashmap.put(site2, 0.2) hashmap.put(site3, 0.3) gmf_as_dict = scenario.gmf_to_dict(hashmap, "MMI") for gmv in gmf_as_dict: self.assertTrue(gmv["mag"] in (0.1, 0.2, 0.3)) self.assertTrue(gmv["site_lon"] in (2.0, 2.1, 2.2)) self.assertTrue(gmv["site_lat"] in (1.0, 1.1, 1.2))