Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def runEnsembleExperiment(self, active_realization_mask=None):
""" @rtype: bool """
if active_realization_mask is None:
count = self.ert.getEnsembleSize()
active_realization_mask = BoolVector(default_value=True, initial_size=count)
iter_nr = 0
return self.runSimpleStep(active_realization_mask, EnkfInitModeEnum.INIT_CONDITIONAL, iter_nr)
def selectMatching(self, select_target, select_mask):
"""
@type select_target: BoolVector
@type select_mask: RealizationStateEnum
"""
assert isinstance(select_target, BoolVector)
assert isinstance(select_mask, RealizationStateEnum)
StateMap.cNamespace().select_matching(self, select_target, select_mask)
def __load(self, file_system, report_step, input_mask=None):
assert isinstance(file_system, EnkfFs)
if not input_mask is None:
assert isinstance(input_mask, BoolVector)
self._load(file_system, report_step, input_mask)
def load(self, fs, report_step, input_mask=None):
"""
@type fs: EnkfFs
@type report_step: int
@type input_mask: BoolVector
@rtype: PlotBlockData
"""
state_map = fs.getStateMap()
ensemble_size = len(state_map)
if not input_mask is None:
mask = BoolVector.copy(input_mask)
else:
mask = BoolVector(False, ensemble_size)
state_map.selectMatching(mask, RealizationStateEnum.STATE_HAS_DATA)
depth = self.getDepthValues(report_step)
self.__permutation_vector = depth.permutationSort()
depth.permute(self.__permutation_vector)
plot_block_data = PlotBlockData(depth)
thread_pool = ThreadPool()
for index in range(ensemble_size):
if mask[index]:
thread_pool.addTask(self.loadVector, plot_block_data, fs, report_step, index)
thread_pool.nonBlockingStart()
def __load(self, file_system, report_step, input_mask=None):
assert isinstance(file_system, EnkfFs)
if not input_mask is None:
assert isinstance(input_mask, BoolVector)
EnsemblePlotGenData.cNamespace().load(self, file_system, report_step, input_mask)
def calculatePrincipalComponent(self, fs, local_obsdata, truncation_or_ncomp=3):
pc = Matrix(1, 1)
pc_obs = Matrix(1, 1)
singular_values = DoubleVector()
state_map = fs.getStateMap()
ens_mask = BoolVector(False, self.ert().getEnsembleSize())
state_map.selectMatching(ens_mask, RealizationStateEnum.STATE_HAS_DATA)
active_list = ens_mask.createActiveList( )
if len(ens_mask) > 0:
meas_data = MeasData(ens_mask)
obs_data = ObsData()
self.ert().getObservations().getObservationAndMeasureData(fs, local_obsdata, active_list, meas_data, obs_data)
meas_data.deactivateZeroStdSamples(obs_data)
active_size = len(obs_data)
if active_size > 0:
S = meas_data.createS()
D_obs = obs_data.createDObs()
def createActiveList(ert, fs):
state_map = fs.getStateMap()
ens_mask = BoolVector(False, ert.getEnsembleSize())
state_map.selectMatching(ens_mask, RealizationStateEnum.STATE_INITIALIZED | RealizationStateEnum.STATE_HAS_DATA)
active_list = BoolVector.createActiveList(ens_mask)
return [iens for iens in active_list]
def realizationList(self , state_value):
"""
Will create a list of all realisations with state equal to @state_value.
@type select_mask: RealizationStateEnum
@rtype: IntVector
"""
mask = BoolVector(False, len(self))
self.selectMatching(mask, state_value )
return BoolVector.createActiveList( mask )
def getActiveRealizationsMask(self):
count = getRealizationCount()
mask = BoolVector.createActiveMask(self.getValue())
if mask is None:
raise ValueError("Error while parsing range string!")
if len(mask) > count:
raise ValueError("Mask size changed %d != %d!" % (count, len(mask)))
return mask