def test_eq(self): """ Exercise equality comparison of VulnerabilityFunctions. Two functions created with the same IML, Loss Ratio, and CoV values should be considered equal. """ imls = [0.005, 0.007] loss_ratios = [0.0, 1.0] covs = [0.05, 0.05] func1 = shapes.VulnerabilityFunction(imls, loss_ratios, covs) func2 = shapes.VulnerabilityFunction(imls, loss_ratios, covs) self.assertEqual(func1, func2)
def test_loss_ratio_curve_in_the_classical_psha_mixin(self): # mixin "instance" mixin = ClassicalPSHABasedMixin() hazard_curve = shapes.Curve([ (0.01, 0.99), (0.08, 0.96), (0.17, 0.89), (0.26, 0.82), (0.36, 0.70), (0.55, 0.40), (0.70, 0.01)]) vuln_function = shapes.VulnerabilityFunction([(0.1, (0.05, 0.5)), (0.2, (0.08, 0.3)), (0.4, (0.2, 0.2)), (0.6, (0.4, 0.1))]) # pre computed values just use one intermediate # values between the imls psha.STEPS_PER_INTERVAL = 2 mixin.job_id = 1234 mixin.vuln_curves = {"ID": vuln_function} asset = {"vulnerabilityFunctionReference": "ID", "assetID": 1} self.assertTrue(mixin.compute_loss_ratio_curve( shapes.GridPoint(None, 10, 20), asset, hazard_curve) is not None)
def test_lrem_po_computation(self): hazard_curve = shapes.Curve([ (0.01, 0.99), (0.08, 0.96), (0.17, 0.89), (0.26, 0.82), (0.36, 0.70), (0.55, 0.40), (0.70, 0.01)]) # pre computed values just use one intermediate # values between the imls psha.STEPS_PER_INTERVAL = 2 vuln_function = shapes.VulnerabilityFunction([(0.1, (0.05, 0.5)), (0.2, (0.08, 0.3)), (0.4, (0.2, 0.2)), (0.6, (0.4, 0.1))]) lrem = psha._compute_lrem(vuln_function) lrem_po = psha._compute_lrem_po(vuln_function, lrem, hazard_curve) self.assertTrue(numpy.allclose(0.07, lrem_po[0][0], atol=0.005)) self.assertTrue(numpy.allclose(0.06, lrem_po[1][0], atol=0.005)) self.assertTrue(numpy.allclose(0.13, lrem_po[0][1], atol=0.005)) self.assertTrue(numpy.allclose(0.47, lrem_po[5][3], atol=0.005)) self.assertTrue(numpy.allclose(0.23, lrem_po[8][3], atol=0.005)) self.assertTrue(numpy.allclose(0.00, lrem_po[10][0], atol=0.005))
def test_vuln_func_constructor_with_good_input(self): """ This test exercises the VulnerabilityFunction constructor with known-good input. """ shapes.VulnerabilityFunction(self.IMLS_GOOD, self.LOSS_RATIOS_GOOD, self.COVS_GOOD)
def test_with_valid_covs_we_sample_the_loss_ratios(self): """With valid covs we need to sample loss ratios. If the vulnerability function has some covs greater than 0.0 we need to use a different algorithm (sampled based) to compute the loss ratios. """ vuln_function = shapes.VulnerabilityFunction([ (0.10, (0.05, 0.30)), (0.30, (0.10, 0.30)), (0.50, (0.15, 0.20)), (1.00, (0.30, 0.20))]) epsilons = [0.5377, 1.8339, -2.2588, 0.8622, 0.3188, -1.3077, \ -0.4336, 0.3426, 3.5784, 2.7694] expected_asset = object() gmfs = {"IMLs": (0.1576, 0.9706, 0.9572, 0.4854, 0.8003, 0.1419, 0.4218, 0.9157, 0.7922, 0.9595)} self.assertTrue(numpy.allclose(numpy.array([0.0722, 0.4106, 0.1800, 0.1710, 0.2508, 0.0395, 0.1145, 0.2883, 0.4734, 0.4885]), prob._compute_loss_ratios(vuln_function, gmfs, self.EpsilonProvider(expected_asset, epsilons), expected_asset), atol=0.0001))
def setUp(self): imls = [0.10, 0.30, 0.50, 1.00] loss_ratios = [0.05, 0.10, 0.15, 0.30] covs = [0.30, 0.30, 0.20, 0.20] self.vuln_function = shapes.VulnerabilityFunction( imls, loss_ratios, covs, "LN") self.gmvs = { "IMLs": (0.1576, 0.9706, 0.9572, 0.4854, 0.8003, 0.1419, 0.4218, 0.9157, 0.7922, 0.9595) } self.epsilons = [ 0.5377, 1.8339, -2.2588, 0.8622, 0.3188, -1.3077, -0.4336, 0.3426, 3.5784, 2.7694 ] self.asset = models.ExposureData(exposure_model=self.emdl, stco=1000) self.eps_provider = helpers.EpsilonProvider(self.asset, self.epsilons) self.losses = numpy.array([ 72.23120833, 410.55950159, 180.02423357, 171.02684563, 250.77079384, 39.45861103, 114.54372035, 288.28653452, 473.38307021, 488.47447798 ])
def test_end_to_end(self): # manually computed values by Vitor Silva psha.STEPS_PER_INTERVAL = 2 hazard_curve = shapes.Curve([ (0.01, 0.99), (0.08, 0.96), (0.17, 0.89), (0.26, 0.82), (0.36, 0.70), (0.55, 0.40), (0.70, 0.01)]) vuln_function = shapes.VulnerabilityFunction([(0.1, (0.05, 0.5)), (0.2, (0.08, 0.3)), (0.4, (0.2, 0.2)), (0.6, (0.4, 0.1))]) loss_ratio_curve = psha.compute_loss_ratio_curve( vuln_function, hazard_curve) lr_curve_expected = shapes.Curve([(0.0, 0.96), (0.025, 0.96), (0.05, 0.91), (0.065, 0.87), (0.08, 0.83), (0.14, 0.75), (0.2, 0.60), (0.3, 0.47), (0.4, 0.23), (0.7, 0.00), (1.0, 0.00)]) for x_value in lr_curve_expected.abscissae: self.assertTrue(numpy.allclose( lr_curve_expected.ordinate_for(x_value), loss_ratio_curve.ordinate_for(x_value), atol=0.005))
def test_bin_width_from_imls(self): vuln_function = shapes.VulnerabilityFunction( [(0.1, 0.05), (0.2, 0.08), (0.4, 0.2), (0.6, 0.4)]) expected_steps = [0.05, 0.15, 0.3, 0.5, 0.7] self.assertTrue(numpy.allclose(expected_steps, psha._compute_imls(vuln_function)))
def test_compute_beta_dist(self): # expected beta distributions provided by Vitor expected_beta_distributions = [ [1.0000000, 1.0000000, 1.0000000, 1.0000000, 1.0000000], [0.9895151, 0.9999409, 1.0000000, 1.0000000, 1.0000000], [0.9175720, 0.9981966, 0.9999997, 1.0000000, 1.0000000], [0.7764311, 0.9887521, 0.9999922, 1.0000000, 1.0000000], [0.6033381, 0.9633258, 0.9999305, 1.0000000, 1.0000000], [0.4364471, 0.9160514, 0.9996459, 1.0000000, 1.0000000], [0.2975979, 0.8460938, 0.9987356, 1.0000000, 1.0000000], [0.1931667, 0.7574557, 0.9964704, 1.0000000, 1.0000000], [0.1202530, 0.6571491, 0.9917729, 0.9999999, 1.0000000], [0.0722091, 0.5530379, 0.9832939, 0.9999997, 1.0000000], [0.0420056, 0.4521525, 0.9695756, 0.9999988, 1.0000000], [0.0130890, 0.2790107, 0.9213254, 0.9999887, 1.0000000], [0.0037081, 0.1564388, 0.8409617, 0.9999306, 1.0000000], [0.0009665, 0.0805799, 0.7311262, 0.9996882, 1.0000000], [0.0002335, 0.0384571, 0.6024948, 0.9988955, 1.0000000], [0.0000526, 0.0171150, 0.4696314, 0.9967629, 1.0000000], [0.0000022, 0.0027969, 0.2413923, 0.9820831, 1.0000000], [0.0000001, 0.0003598, 0.0998227, 0.9364072, 1.0000000], [0.0000000, 0.0000367, 0.0334502, 0.8381920, 0.9999995], [0.0000000, 0.0000030, 0.0091150, 0.6821293, 0.9999959], [0.0000000, 0.0000002, 0.0020162, 0.4909782, 0.9999755], [0.0000000, 0.0000000, 0.0000509, 0.1617086, 0.9995033], [0.0000000, 0.0000000, 0.0000005, 0.0256980, 0.9945488], [0.0000000, 0.0000000, 0.0000000, 0.0016231, 0.9633558], [0.0000000, 0.0000000, 0.0000000, 0.0000288, 0.8399534], [0.0000000, 0.0000000, 0.0000000, 0.0000001, 0.5409583], [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.3413124], [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.1589844], [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0421052], [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0027925], [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000] ] vuln_function = shapes.VulnerabilityFunction(self.imls, self.mean_loss_ratios, self.covs) # steps = 5 loss_ratios = _generate_loss_ratios(vuln_function, 5) lrem = numpy.empty((len(loss_ratios), vuln_function.imls.size), float) for col, _ in enumerate(vuln_function): for row, loss_ratio in enumerate(loss_ratios): lrem[row][col] = BetaDistribution.survival_function( loss_ratio, col=col, vf=vuln_function) helpers.assertDeepAlmostEqual(self, expected_beta_distributions, lrem, delta=0.0005)
def test_is_empty(self): """ Test the 'is_empty' property of a vulnerability function. """ empty_func = shapes.VulnerabilityFunction([], [], []) # Test empty function: self.assertTrue(empty_func.is_empty) # Test non-empty function: self.assertFalse(self.test_func.is_empty)
def test_loading_and_storing_model_in_kvs(self): path = os.path.join(helpers.SCHEMA_DIR, TEST_FILE) vulnerability.load_vulnerability_model(1234, path) model = vulnerability.load_vuln_model_from_kvs(1234) self.assertEqual(NO_OF_CURVES_IN_TEST_FILE, len(model)) exp_imls = [5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 9.5, 10.0] exp_loss_ratios = [0.00, 0.00, 0.00, 0.00, 0.00, 0.01, 0.06, 0.18, 0.36, 0.36, 0.36] exp_covs = [0.3] * 11 expected_curve = shapes.VulnerabilityFunction(exp_imls, exp_loss_ratios, exp_covs, "LN") self.assertEqual(expected_curve, model["PK"]) expected_curve = shapes.VulnerabilityFunction(exp_imls, exp_loss_ratios, exp_covs, "LN") self.assertEqual(expected_curve, model["IR"])
def load_vulnerability_model(job_id, path, retrofitted=False): """Load and store the vulnerability model defined in the given NRML file in the underlying kvs system.""" vulnerability_model = {} parser = VulnerabilityModelFile(path) for vuln_curve in parser: vuln_func = shapes.VulnerabilityFunction(vuln_curve['IML'], vuln_curve['lossRatio'], vuln_curve['coefficientsVariation']) vulnerability_model[vuln_curve["ID"]] = vuln_func.to_json() kvs.set_value_json_encoded(kvs.tokens.vuln_key(job_id, retrofitted), vulnerability_model)
def test_compute_lrem_using_beta_distribution(self): # expected lrem provided by Vitor expected_beta_distributions = [ [1.0000000, 1.0000000, 1.0000000, 1.0000000, 1.0000000], [0.9895151, 0.9999409, 1.0000000, 1.0000000, 1.0000000], [0.9175720, 0.9981966, 0.9999997, 1.0000000, 1.0000000], [0.7764311, 0.9887521, 0.9999922, 1.0000000, 1.0000000], [0.6033381, 0.9633258, 0.9999305, 1.0000000, 1.0000000], [0.4364471, 0.9160514, 0.9996459, 1.0000000, 1.0000000], [0.2975979, 0.8460938, 0.9987356, 1.0000000, 1.0000000], [0.1931667, 0.7574557, 0.9964704, 1.0000000, 1.0000000], [0.1202530, 0.6571491, 0.9917729, 0.9999999, 1.0000000], [0.0722091, 0.5530379, 0.9832939, 0.9999997, 1.0000000], [0.0420056, 0.4521525, 0.9695756, 0.9999988, 1.0000000], [0.0130890, 0.2790107, 0.9213254, 0.9999887, 1.0000000], [0.0037081, 0.1564388, 0.8409617, 0.9999306, 1.0000000], [0.0009665, 0.0805799, 0.7311262, 0.9996882, 1.0000000], [0.0002335, 0.0384571, 0.6024948, 0.9988955, 1.0000000], [0.0000526, 0.0171150, 0.4696314, 0.9967629, 1.0000000], [0.0000022, 0.0027969, 0.2413923, 0.9820831, 1.0000000], [0.0000001, 0.0003598, 0.0998227, 0.9364072, 1.0000000], [0.0000000, 0.0000367, 0.0334502, 0.8381920, 0.9999995], [0.0000000, 0.0000030, 0.0091150, 0.6821293, 0.9999959], [0.0000000, 0.0000002, 0.0020162, 0.4909782, 0.9999755], [0.0000000, 0.0000000, 0.0000509, 0.1617086, 0.9995033], [0.0000000, 0.0000000, 0.0000005, 0.0256980, 0.9945488], [0.0000000, 0.0000000, 0.0000000, 0.0016231, 0.9633558], [0.0000000, 0.0000000, 0.0000000, 0.0000288, 0.8399534], [0.0000000, 0.0000000, 0.0000000, 0.0000001, 0.5409583], [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.3413124], [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.1589844], [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0421052], [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0027925], [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000] ] vuln_function = shapes.VulnerabilityFunction(self.imls, self.mean_loss_ratios, self.covs, "BT") lrem = _compute_lrem(vuln_function, 5) helpers.assertDeepAlmostEqual(self, expected_beta_distributions, lrem, delta=0.0005)
def test_to_json(self): """ Test that a VulnerabilityFunction can produce a correct JSON representation of itself. """ imls = [0.005, 0.007, 0.0098] loss_ratios = [0.1, 0.3, 0.5] covs = [0.2, 0.4, 0.6] vuln_func = shapes.VulnerabilityFunction(imls, loss_ratios, covs) expected_json = \ '{"0.005": [0.1, 0.2], "0.007": [0.3, 0.4], "0.0098": [0.5, 0.6]}' # The JSON data (which is essentially a dict) may not come out with the # data ordered in a predictable way. So, we'll decode the expected and # actual values and compare them as dicts. json_decoder = json.JSONDecoder() self.assertEqual(json_decoder.decode(expected_json), json_decoder.decode(vuln_func.to_json()))
def load_vulnerability_model(job_id, path): """Load and store the vulnerability model defined in the given NRML file in the underlying kvs system.""" vulnerability_model = {} parser = VulnerabilityModelFile(path) for vulnerability_curve in parser: curve = [] data = zip(vulnerability_curve["lossRatio"], vulnerability_curve["coefficientsVariation"]) for idx, iml in enumerate( vulnerability_curve["IML"]): curve.append((iml, data[idx])) vulnerability_model[vulnerability_curve["ID"]] = \ shapes.VulnerabilityFunction(curve).to_json() kvs.set_value_json_encoded(kvs.tokens.vuln_key(job_id), vulnerability_model)
def test_when_the_mean_is_zero_the_loss_ratio_is_zero(self): """In sampled based, when an interpolated mean loss ratio is zero, the resulting loss ratio is also zero. This is how the interpolation is done: mean_ratio = vuln_function.ordinate_for(ground_motion_field) In this case, the first IML from the GMFs is 0.10 and the mean loss ratio in the vulnerability function for that IML is zero. So the resulting loss ratio must be zero. """ vuln_function = shapes.VulnerabilityFunction([ (0.10, (0.00, 0.30)), (0.30, (0.10, 0.30))]) epsilons = [0.5377] expected_asset = object() gmfs = {"IMLs": (0.1000, )} self.assertEqual(0.0, prob._compute_loss_ratios( vuln_function, gmfs, self.EpsilonProvider( expected_asset, epsilons), expected_asset)[0])
def test_is_beta(self): log_normal = shapes.VulnerabilityFunction([], [], [], "LN") self.assertFalse(log_normal.is_beta) beta = shapes.VulnerabilityFunction([], [], [], "BT") self.assertTrue(beta.is_beta)
def setUp(self): self.vuln_function_1 = shapes.VulnerabilityFunction([ (0.01, (0.001, 0.00)), (0.04, (0.022, 0.00)), (0.07, (0.051, 0.00)), (0.10, (0.080, 0.00)), (0.12, (0.100, 0.00)), (0.22, (0.200, 0.00)), (0.37, (0.405, 0.00)), (0.52, (0.700, 0.00))]) self.gmfs = GMFs self.cum_histogram = numpy.array([112, 46, 26, 18, 14, 12, 8, 7, 7, 6, 5, 4, 4, 4, 4, 4, 2, 1, 1, 1, 1, 1, 1, 1]) self.vuln_function_2 = shapes.VulnerabilityFunction([ (0.00, (0.00, 0.00)), (0.04, (0.00, 0.00)), (0.08, (0.00, 0.00)), (0.12, (0.01, 0.00)), (0.16, (0.04, 0.00)), (0.20, (0.07, 0.00)), (0.24, (0.11, 0.00)), (0.28, (0.15, 0.00)), (0.32, (0.20, 0.00)), (0.36, (0.25, 0.00)), (0.40, (0.30, 0.00)), (0.44, (0.35, 0.00)), (0.48, (0.39, 0.00)), (0.53, (0.43, 0.00)), (0.57, (0.47, 0.00)), (0.61, (0.51, 0.00)), (0.65, (0.55, 0.00)), (0.69, (0.58, 0.00)), (0.73, (0.61, 0.00)), (0.77, (0.64, 0.00)), (0.81, (0.67, 0.00)), (0.85, (0.69, 0.00)), (0.89, (0.71, 0.00)), (0.93, (0.73, 0.00)), (0.97, (0.75, 0.00)), (1.01, (0.77, 0.00)), (1.05, (0.79, 0.00)), (1.09, (0.80, 0.00)), (1.13, (0.81, 0.00)), (1.17, (0.83, 0.00)), (1.21, (0.84, 0.00)), (1.25, (0.85, 0.00)), (1.29, (0.86, 0.00)), (1.33, (0.87, 0.00)), (1.37, (0.88, 0.00)), (1.41, (0.89, 0.00)), (1.45, (0.89, 0.00)), (1.49, (0.90, 0.00)), (1.54, (0.91, 0.00)), (1.58, (0.91, 0.00)), (1.62, (0.92, 0.00)), (1.66, (0.92, 0.00)), (1.70, (0.93, 0.00)), (1.74, (0.93, 0.00)), (1.78, (0.94, 0.00)), (1.82, (0.94, 0.00)), (1.86, (0.94, 0.00)), (1.90, (0.95, 0.00)), (1.94, (0.95, 0.00)), (1.98, (0.95, 0.00)), (2.02, (0.95, 0.00)), (2.06, (0.96, 0.00)), (2.10, (0.96, 0.00)), (2.14, (0.96, 0.00)), (2.18, (0.96, 0.00)), (2.22, (0.97, 0.00)), (2.26, (0.97, 0.00)), (2.30, (0.97, 0.00)), (2.34, (0.97, 0.00)), (2.38, (0.97, 0.00)), (2.42, (0.97, 0.00)), (2.46, (0.98, 0.00)), (2.51, (0.98, 0.00)), (2.55, (0.98, 0.00)), (2.59, (0.98, 0.00)), (2.63, (0.98, 0.00)), (2.67, (0.98, 0.00)), (2.71, (0.98, 0.00)), (2.75, (0.98, 0.00)), (2.79, (0.98, 0.00)), (2.83, (0.98, 0.00)), (2.87, (0.99, 0.00)), (2.91, (0.99, 0.00)), (2.95, (0.99, 0.00)), (2.99, (0.99, 0.00)), (3.03, (0.99, 0.00)), (3.07, (0.99, 0.00)), (3.11, (0.99, 0.00)), (3.15, (0.99, 0.00)), (3.19, (0.99, 0.00)), (3.23, (0.99, 0.00)), (3.27, (0.99, 0.00)), (3.31, (0.99, 0.00)), (3.35, (0.99, 0.00)), (3.39, (0.99, 0.00)), (3.43, (0.99, 0.00)), (3.47, (0.99, 0.00)), (3.52, (0.99, 0.00)), (3.56, (0.99, 0.00)), (3.60, (0.99, 0.00)), (3.64, (0.99, 0.00)), (3.68, (0.99, 0.00)), (3.72, (0.99, 0.00)), (3.76, (0.99, 0.00)), (3.80, (0.99, 0.00)), (3.84, (1.00, 0.00)), (3.88, (1.00, 0.00)), (3.92, (1.00, 0.00)), (3.96, (1.00, 0.00)), (4.00, (1.00, 0.00))]) self.job_id = 1234 self.gmfs_1 = {"IMLs": (0.1439, 0.1821, 0.5343, 0.171, 0.2177, 0.6039, 0.0618, 0.186, 0.5512, 1.2602, 0.2824, 0.2693, 0.1705, 0.8453, 0.6355, 0.0721, 0.2475, 0.1601, 0.3544, 0.1756), "TSES": 200, "TimeSpan": 50} self.asset_1 = {"vulnerabilityFunctionReference": "ID", "assetValue": 22.61} self.gmfs_2 = {"IMLs": (0.1507, 0.2656, 0.5422, 0.3685, 0.3172, 0.6604, 0.1182, 0.1545, 0.7613, 0.5246, 0.2428, 0.2882, 0.2179, 1.2939, 0.6042, 0.1418, 0.3637, 0.222, 0.3613, 0.113), "TSES": 200, "TimeSpan": 50} self.asset_2 = {"vulnerabilityFunctionReference": "ID", "assetValue": 124.27} self.gmfs_3 = {"IMLs": (0.156, 0.3158, 0.3968, 0.2827, 0.1915, 0.5862, 0.1438, 0.2114, 0.5101, 1.0097, 0.226, 0.3443, 0.1693, 1.0754, 0.3533, 0.1461, 0.347, 0.2665, 0.2977, 0.2925), "TSES": 200, "TimeSpan": 50} self.asset_3 = {"vulnerabilityFunctionReference": "ID", "assetValue": 42.93} self.gmfs_4 = {"IMLs": (0.1311, 0.3566, 0.4895, 0.3647, 0.2313, 0.9297, 0.2337, 0.2862, 0.5278, 0.6603, 0.3537, 0.2997, 0.1097, 1.1875, 0.4752, 0.1575, 0.4009, 0.2519, 0.2653, 0.1394), "TSES": 200, "TimeSpan": 50} self.asset_4 = {"vulnerabilityFunctionReference": "ID", "assetValue": 29.37} self.gmfs_5 = {"IMLs": (0.0879, 0.2895, 0.465, 0.2463, 0.1862, 0.763, 0.2189, 0.3324, 0.3215, 0.6406, 0.5014, 0.3877, 0.1318, 1.0545, 0.3035, 0.1118, 0.2981, 0.3492, 0.2406, 0.1043), "TSES": 200, "TimeSpan": 50} self.asset_5 = {"vulnerabilityFunctionReference": "ID", "assetValue": 40.68} self.gmfs_6 = {"IMLs": (0.0872, 0.2288, 0.5655, 0.2118, 0.2, 0.6633, 0.2095, 0.6537, 0.3838, 0.781, 0.3054, 0.5375, 0.1361, 0.8838, 0.3726, 0.0845, 0.1942, 0.4629, 0.1354, 0.1109), "TSES": 200, "TimeSpan": 50} self.asset_6 = {"vulnerabilityFunctionReference": "ID", "assetValue": 178.47} # deleting keys in kvs kvs.get_client(binary=False).flushall() kvs.set_value_json_encoded( kvs.tokens.vuln_key(self.job_id), {"ID": self.vuln_function_2.to_json()}) # store the gmfs self._store_gmfs(self.gmfs_1, 1, 1) self._store_gmfs(self.gmfs_2, 1, 2) self._store_gmfs(self.gmfs_3, 1, 3) self._store_gmfs(self.gmfs_4, 1, 4) self._store_gmfs(self.gmfs_5, 1, 5) self._store_gmfs(self.gmfs_6, 1, 6) # store the assets self._store_asset(self.asset_1, 1, 1) self._store_asset(self.asset_2, 1, 2) self._store_asset(self.asset_3, 1, 3) self._store_asset(self.asset_4, 1, 4) self._store_asset(self.asset_5, 1, 5) self._store_asset(self.asset_6, 1, 6) self.params = {} self.params["OUTPUT_DIR"] = test.OUTPUT_DIR self.params["AGGREGATE_LOSS_CURVE"] = 1 self.params["BASE_PATH"] = "." self.params["INVESTIGATION_TIME"] = 50.0 self.job = job.Job(self.params, self.job_id, base_path=".") self.job.to_kvs() # deleting old file self._delete_test_file()
def setUpClass(cls): cls.test_func = shapes.VulnerabilityFunction(cls.IMLS_GOOD, cls.LOSS_RATIOS_GOOD, cls.COVS_GOOD)