def test__prepare_gmf_serialization_with_imt_other_than_mmi(self): # In case of imt != mmi the GMF values are transformed as needed. location1 = java.jclass("Location")(1.0, 2.0) location2 = java.jclass("Location")(1.1, 2.1) site1 = java.jclass("Site")(location1) site2 = java.jclass("Site")(location2) hashmap = java.jclass("HashMap")() hashmap.put(site1, 0.1) hashmap.put(site2, 0.2) expected = {shapes.Site(2.0, 1.0): {"groundMotion": math.exp(0.1)}, shapes.Site(2.1, 1.1): {"groundMotion": math.exp(0.2)}} actual = scenario._prepare_gmf_serialization(hashmap, "PGA") self.assertEqual(expected, actual)
def test__prepare_gmf_serialization_with_mmi(self): # In case of imt == mmi the GMF values are left unchanged location1 = java.jclass("Location")(1.0, 2.0) location2 = java.jclass("Location")(1.1, 2.1) site1 = java.jclass("Site")(location1) site2 = java.jclass("Site")(location2) hashmap = java.jclass("HashMap")() hashmap.put(site1, 0.1) hashmap.put(site2, 0.2) expected = {shapes.Site(2.0, 1.0): {"groundMotion": 0.1}, shapes.Site(2.1, 1.1): {"groundMotion": 0.2}} actual = scenario._prepare_gmf_serialization(hashmap, "MMI") self.assertEqual(expected, actual)
def test__prepare_gmf_serialization_with_imt_other_than_mmi(self): # In case of imt != mmi the GMF values are transformed as needed. location1 = java.jclass("Location")(1.0, 2.0) location2 = java.jclass("Location")(1.1, 2.1) site1 = java.jclass("Site")(location1) site2 = java.jclass("Site")(location2) hashmap = java.jclass("HashMap")() hashmap.put(site1, 0.1) hashmap.put(site2, 0.2) expected = { shapes.Site(2.0, 1.0): { "groundMotion": math.exp(0.1) }, shapes.Site(2.1, 1.1): { "groundMotion": math.exp(0.2) } } actual = scenario._prepare_gmf_serialization(hashmap, "PGA") self.assertEqual(expected, actual)
def test__prepare_gmf_serialization_with_mmi(self): # In case of imt == mmi the GMF values are left unchanged location1 = java.jclass("Location")(1.0, 2.0) location2 = java.jclass("Location")(1.1, 2.1) site1 = java.jclass("Site")(location1) site2 = java.jclass("Site")(location2) hashmap = java.jclass("HashMap")() hashmap.put(site1, 0.1) hashmap.put(site2, 0.2) expected = { shapes.Site(2.0, 1.0): { "groundMotion": 0.1 }, shapes.Site(2.1, 1.1): { "groundMotion": 0.2 } } actual = scenario._prepare_gmf_serialization(hashmap, "MMI") self.assertEqual(expected, actual)