def checkBlockData(self, ert, obs_key, report_step): """ @type ert: EnKFMain @type obs_key: str @type report_step: int """ enkf_obs = ert.getObservations() obs_vector = enkf_obs[obs_key] loader = PlotBlockDataLoader(obs_vector) fs = ert.getEnkfFsManager().getCurrentFileSystem() plot_block_data = loader.load(fs, report_step) self.assertEqual(ert.getEnsembleSize(), len(plot_block_data)) depth = plot_block_data.getDepth() depth_test_values = [1752.24998474, 1757.88926697, 1760.70924377] if report_step == 56: depth_test_values.append(1763.52885437) self.assertAlmostEqualList(depth_test_values, depth) block_obs = len(obs_vector.getNode(report_step)) self.assertEqual(block_obs, len(plot_block_data[0])) self.assertEqual(block_obs, len(plot_block_data[9])) if report_step == 50: rft_values = [244.681655884, 245.217041016, 245.48500061] else: rft_values = [ 239.7550354, 240.290313721, 240.558197021, 240.825881958 ] self.assertAlmostEqualList(rft_values, plot_block_data[0]) if report_step == 50: rft_values = [238.702560425, 239.237838745, 239.505737305] else: rft_values = [ 234.41583252, 234.95098877, 235.218841553, 235.486480713 ] self.assertAlmostEqualList(rft_values, plot_block_data[9])
def checkBlockData(self, ert, obs_key, report_step): """ @type ert: EnKFMain @type obs_key: str @type report_step: int """ enkf_obs = ert.getObservations() obs_vector = enkf_obs[obs_key] loader = PlotBlockDataLoader(obs_vector) fs = ert.getEnkfFsManager().getCurrentFileSystem() plot_block_data = loader.load(fs, report_step) self.assertEqual(ert.getEnsembleSize(), len(plot_block_data)) depth = plot_block_data.getDepth() depth_test_values = [1752.24998474, 1757.88926697, 1760.70924377] if report_step == 56: depth_test_values.append(1763.52885437) self.assertAlmostEqualList(depth_test_values, depth) block_obs = len(obs_vector.getNode(report_step)) self.assertEqual(block_obs, len(plot_block_data[0])) self.assertEqual(block_obs, len(plot_block_data[9])) if report_step == 50: rft_values = [244.681655884, 245.217041016, 245.48500061] else: rft_values = [239.7550354, 240.290313721, 240.558197021, 240.825881958] self.assertAlmostEqualList(rft_values, plot_block_data[0]) if report_step == 50: rft_values = [238.702560425, 239.237838745, 239.505737305] else: rft_values = [234.41583252, 234.95098877, 235.218841553, 235.486480713] self.assertAlmostEqualList(rft_values, plot_block_data[9])
def fetchData(self, key, case=None): enkf_fs = self.ert().getEnkfFsManager().getFileSystem(case) observations = self.ert().getObservations() assert observations.hasKey(key) observation_vector = observations[key] loader = PlotBlockDataLoader(observation_vector) report_step_data = [] for report_step in observation_vector: block_data = loader.load(enkf_fs, report_step) data = self.__fetchSimulationData(block_data) data["report_step"] = report_step report_step_data.append(data) if self.__selected_report_step_index is not None: return report_step_data[self.__selected_report_step_index] else: return report_step_data
class EnsembleBlockDataFetcher(DataFetcher): def __init__(self, ert): super(EnsembleBlockDataFetcher, self).__init__(ert) self.__selected_report_step_index = None def __fetchSimulationData(self, block_data): """ @type block_data: PlotBlockData @rtype dict """ data = { "x": [], "y": [], "min_x_values": [], "max_x_values": [], "min_y": None, "max_y": None, "min_x": None, "max_x": None } depth_vector = block_data.getDepth() for depth in depth_vector: data["y"].append(depth) data["min_x_values"].append(None) data["max_x_values"].append(None) min_y = min(data["y"]) max_y = max(data["y"]) if data["min_y"] is None or data["min_y"] > min_y: data["min_y"] = min_y if data["max_y"] is None or data["max_y"] < max_y: data["max_y"] = max_y for block_vector in block_data: x = [] data["x"].append(x) for index in range(len(block_vector)): value = block_vector[index] x.append(value) if data["min_x"] is None or data["min_x"] > value: data["min_x"] = value if data["max_x"] is None or data["max_x"] < value: data["max_x"] = value if data["min_x_values"][index] is None or data["min_x_values"][ index] > value: data["min_x_values"][index] = value if data["max_x_values"][index] is None or data["max_x_values"][ index] < value: data["max_x_values"][index] = value return data def fetchData(self, key, case=None): enkf_fs = self.ert().getEnkfFsManager().getFileSystem(case) observations = self.ert().getObservations() assert observations.hasKey(key) observation_vector = observations[key] loader = PlotBlockDataLoader(observation_vector) report_step_data = [] for report_step in observation_vector: block_data = loader.load(enkf_fs, report_step) data = self.__fetchSimulationData(block_data) data["report_step"] = report_step report_step_data.append(data) if self.__selected_report_step_index is not None: return report_step_data[self.__selected_report_step_index] else: return report_step_data