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 ResDataSet(path, input_kws, target_kws, file_format='resdata', dtype=tf.float32, shuffle_on_epoch_end=False, read_data_on_init=True)[source]#

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.

Parameters:
features: Tensor#

Stores all inputs of the dataset.

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

targets: Tensor#

Stores all targets of the dataset.

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

read_data()[source]#

Extract configured restart keywords and populate feature and target tensors.

Returns:

Result produced by the operation.

Return type:

Any

ResdataFile_to_datapoint(resdata_file)[source]#

Convert one restart file into feature and target tensors.

tuple of tensors.

Parameters:

resdata_file (ResdataFile) -- Opened restart file.

Returns:

Result produced by the operation.

Return type:

tuple[tf.Tensor, tf.Tensor]

Raises:

KeyError -- If the documented validation or operation fails.

on_epoch_end()[source]#

Shuffle the dataset at the end of each epoch.

Warning

Using this method might give an error atm.

main(args)[source]#

Run the module command-line workflow.

Parameters:

args (Any) -- Parsed command-line arguments.

Returns:

Result produced by the operation.

Return type:

Any