def setUp(self): self.job_id = 1234 self.poes_levels = classical_psha.POES_PARAM_NAME self.quantiles_levels = classical_psha.QUANTILE_PARAM_NAME self.params = {} self.params["REFERENCE_VS30_VALUE"] = 500 self.params["INTENSITY_MEASURE_LEVELS"] = "5.0000e-03, 7.0000e-03, \ 1.3700e-02, 1.9200e-02, 2.6900e-02, 3.7600e-02, 5.2700e-02, \ 7.3800e-02, 9.8000e-02, 1.0300e-01, 1.4500e-01, 2.0300e-01, \ 2.8400e-01, 3.9700e-01, 5.5600e-01, 7.7800e-01, 1.0900e+00, \ 1.5200e+00, 2.1300e+00" self.engine = job.Job(self.params, self.job_id) self.empty_mean_curve = {"site_lon": 2.0, "site_lat": 5.0, "curve": []} # deleting server side cached data kvs.flush() mean_curve = {"site_lon": 2.0, "site_lat": 5.0, "curve": classical_psha._reconstruct_curve_list_from( [9.8728e-01, 9.8266e-01, 9.4957e-01, 9.0326e-01, 8.1956e-01, 6.9192e-01, 5.2866e-01, 3.6143e-01, 2.4231e-01, 2.2452e-01, 1.2831e-01, 7.0352e-02, 3.6060e-02, 1.6579e-02, 6.4213e-03, 2.0244e-03, 4.8605e-04, 8.1752e-05, 7.3425e-06])} self._store_curve_at(shapes.Site(2.0, 5.0), mean_curve)
def setUp(self): self.mixin = opensha.ClassicalMixin(job.Job(dict()), opensha.ClassicalMixin, "hazard") # Store the canned result data in the KVS. key = self.mixin.id = helpers.TestStore.add(self.mock_results) self.keys.append(key) # Initialize the mixin instance. self.mixin.params = dict(COMPUTE_MEAN_HAZARD_CURVE="True")
def test_plots_the_aggregate_curve_only_if_specified(self): del(self.params["AGGREGATE_LOSS_CURVE"]) # storing a new job definition in kvs self.job = job.Job(self.params, self.job_id, base_path=".") self.job.to_kvs() aggregate.compute_aggregate_curve(self.job) self._assert_plot_is_not_produced()
def setUp(self): self.mixin = opensha.ClassicalMixin(job.Job(dict()), opensha.ClassicalMixin, "hazard") # Store the canned result data in the KVS. key = self.mixin.id = helpers.TestStore.nextkey() helpers.TestStore.put(key, self.mock_results) self.keys.append(key) # Initialize the mixin instance. self.mixin.params = dict()
def setUp(self): self.mixin = opensha.ClassicalMixin(job.Job(dict()), opensha.ClassicalMixin, "hazard") # Store the canned result data in the KVS. key = self.mixin.id = helpers.TestStore.nextkey() self.keys.append(key) for realization in xrange(2): key = "%s/%s" % (self.mixin.id, realization + 1) helpers.TestStore.put(key, self.mock_results[realization]) self.keys.append(key) LOG.debug("keys = '%s'" % self.keys) # Initialize the mixin instance. self.mixin.params = dict(NUMBER_OF_LOGIC_TREE_SAMPLES=2) self.mixin.calc = self.FakeLogicTreeProcessor() self.mixin.cache = dict()
def setUp(self): self.job_id = 1234 self.params = {} self.quantiles_levels = classical_psha.QUANTILE_PARAM_NAME self.engine = job.Job(self.params, self.job_id) self.expected_curve = numpy.array([9.9178000e-01, 9.8892000e-01, 9.6903000e-01, 9.4030000e-01, 8.8405000e-01, 7.8782000e-01, 6.4897250e-01, 4.8284250e-01, 3.4531500e-01, 3.2337000e-01, 1.8880500e-01, 9.5574000e-02, 4.3707250e-02, 1.9643000e-02, 8.1923000e-03, 2.9157000e-03, 7.9955000e-04, 1.5233000e-04, 1.5582000e-05]) # deleting server side cached data kvs.flush()
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 setUp(self): self.mixin = opensha.ClassicalMixin(job.Job(dict()), opensha.ClassicalMixin, "hazard")