pyopmnearwell.ml.resdata_dataset module

This module provides functionality to parse *.UNRST files for given keywords and transform the extracted values into a tensorflow dataset.

Note: Some manual changes are needed if the tensors of the dataset shall have a shape different from the default one. The lines that need to be changed are marked with # MANUAL CHANGES.

Deprecated: This module is deprecated in favor of the ensemble module which can run an ensemble of pyopmnearwell decks AND extract data afterwards.

class pyopmnearwell.ml.resdata_dataset.ResDataSet(path: str, input_kws: list[str], target_kws: list[str], file_format: Literal['resdata', 'opm'] = 'resdata', dtype=tf.float32, shuffle_on_epoch_end: bool = False, read_data_on_init: bool = True)

Bases: object

Generate samples for a tf.data.Dataset from a folder of .UNRST files.

Example:

After instantiation of the class, it can be passed to tf.data.Dataset.from_generator(), to create a dataset that tensorflow can work with. >>> data = ResDataSet(path, input_kws, target_kws) >>> data.read_data() >>> ds = tf.data.Dataset.from_generator( >>> data, >>> output_signature=(tf.TensorSpec(), tf.TensorSpec()) >>> )

To save the dataset, use >>> ds.save(path) Afterwards, the .UNRST files used to generated the dataset can be deleted.

Methods

ResdataFile_to_datapoint(resdata_file)

Extract values from an ResdataFile object to form an (input, target) tuple of tensors.

__call__()

Call self as a function.

on_epoch_end()

Shuffle the dataset at the end of each epoch.

read_data()

Create a tensorflow dataset from a folder of resdata or opm files.

ResdataFile_to_datapoint(resdata_file: ResdataFile) tuple[Tensor, Tensor]

Extract values from an ResdataFile object to form an (input, target) tuple of tensors.

Args:

ecl_file (EclFile): _description_

Raises:
KeyError: If resdata_file does not have either of the keywords in

self.input_kws or self.target_kws

Returns:
tuple[tf.Tensor, tf.Tensor]: A tuple containing the input and target tensor.

The former has shape (resdata_file.num_report_steps(), num_cells, len(input_kws)), while the latter has shape (resdata_file.num_report_steps(), num_cells, len(target_kws)).

features: Tensor

Stores all inputs of the dataset.

shape=(num_files, num_report_steps, num_cells, len(input_kws))

on_epoch_end()

Shuffle the dataset at the end of each epoch.

Warning:

Using this method might give an error atm.

read_data()

Create a tensorflow dataset from a folder of resdata or opm files.

targets: Tensor

Stores all targets of the dataset.

shape=(num_files, num_report_steps, num_cells, len(target_kws))

pyopmnearwell.ml.resdata_dataset.main(args)

Create a dataset from the given arguments and store it