Loaders and samplers¶
FieldDataset¶
-
class
FieldDataset
(src, sample_attrs=None, fmt=('dat', 'data', 'hdf5'), subset_generator=None, unravel_model=None, from_samples=False, allow_change_preloaded=False)[source]¶ Baseclass for dataset of fields loaded with similar configs.
-
convert_to_other_fmt
(new_root_dir, new_fmt='hdf5', results_to_events=True, **kwargs)[source]¶ Convert dataset to a new format.
- Parameters
- Returns
- Return type
-
default_sample_attrs
= {'CONTROL': ['BHPT'], 'GRID': [], 'MASKS': ['ACTNUM', 'TIME'], 'ROCK': ['PORO', 'PERMX', 'PERMY', 'PERMZ'], 'STATES': ['PRESSURE', 'RS', 'SGAS', 'SOIL', 'SWAT']}¶
-
dump_samples
(path, n_epoch=1, prefix=None, state=True, **kwargs)[source]¶ Dump samples from the dataset.
-
property
filtered_statistics
¶ Filters out non-normalized attrs and attrs, which are not presented in sample_attrs, from statistics.
-
property
sample_attrs
¶ Attributes represented in the samples.
-
FieldSample¶
-
class
FieldSample
(path=None, field=None, dataset=None, state=None, **sample)[source]¶ Class representing the samples from the dataset.
- Parameters
path (str, optional) – Path to the file. Only HDF5 files are supported at the moment.
field (Field, optional) –
dataset (FieldDataset, optional) –
state (dict, optional) –
sample (dict-like, optional) –
-
apply
(func, attr, *args, inplace=False, **kwargs)¶ Apply function to attributes.
- Parameters
func (callable) – A function to apply. Must accept data as its first argument.
attr (str, array-like) – Attributes to get data from.
args (misc) – Any additional positional arguments to
func
.kwargs (misc) – Any additional named arguments to
func
.
- Returns
output – Transformed component.
- Return type
-
at_wells
(inplace=False)[source]¶ Crop all the spatial arrays to the perforated cells. Ravel if needed.
- Parameters
inplace (bool) –
- Returns
sample – Cropped sample.
- Return type
-
property
attributes
¶ Array of attributes.
-
property
class_name
¶ Name of the component.
-
property
dataset
¶ Link to the parent dataset.
-
del_state
(*args)¶ State remover.
-
property
device
¶ Get the sample’s device (if it is in Torch format)
- Returns
device
- Return type
torch.device
-
drop
(attr)¶ Drop an attribute.
-
static
dump_array_ascii
(buffer, array, header=None, fmt='%f', compressed=True)¶ Writes array-like data into an ASCII buffer.
- Parameters
-
empty_like
()[source]¶ Get an empty sample with the same state and the structure of embedded BaseComponents (if any).
-
property
field
¶ Link to the parent field.
-
init_state
(**kwargs)¶ Init state attributes.
-
items
()¶ Returns pairs of attribute’s names and data.
-
keys
()¶ Array of attributes.
-
load
(**kwargs)[source]¶ Load sample from a file.
- Parameters
kwargs (dict) – Additional named arguments passed to the load method.
- Returns
sample – Sample with loaded data.
- Return type
-
ravel
(attr=None, order='F', inplace=True)¶ Ravel attributes where applicable assuming by default Fortran order.
-
reshape
(attr, newshape, order='C', inplace=True)¶ Reshape numpy.ndarray attributes.
- Parameters
- Returns
output
- Return type
BaseComponent if inplace else reshaped attribute itself.
-
property
sample_attrs
¶ Attributes represented in the sample.
-
set_state
(**kwargs)¶ State setter.
-
property
state
¶ Get state.
-
to
(device, inplace=True)[source]¶ Change the sample’s device (if it is in Torch format).
- Parameters
- Returns
sample – Sample at the new device
- Return type
-
transformed
(transforms, inplace=False)[source]¶ Apply a set of transforms to the sample.
- Parameters
- Returns
sample – Transformed sample.
- Return type
-
values
()¶ Returns a generator of attribute’s data.