data package
Submodules
data.HDF5Reader module
- class data.HDF5Reader.HDF5Dataset(src_file, x_scaler=None, y_scaler=None)[source]
Bases:
TorchDataset
Dataset class for HDF5 files.
- Parameters:
src_file (str) – The path to the HDF5 file to read.
x_scaler (object, optional) – Scaler for the input data. Default is None.
y_scaler (object, optional) – Scaler for the target data. Default is None.
- class data.HDF5Reader.HDF5Reader(file_path)[source]
Bases:
object
Class for reading HDF5 files. The data is stored in groups and datasets. The inputs are stored in the “inputs” group and the outputs are stored in the “outputs” group.
- Parameters:
file_path (str) – The path to the HDF5 file to read.
data.TorchReader module
- class data.TorchReader.TorchDataset(x, y=None, isscaled=(False, False), x_scaler=None, y_scaler=None, dtype=torch.float32)[source]
Bases:
BaseDataset
Dataset class for PyTorch tensors.
- Parameters:
x_scaler (object, optional) – Scaler for the input data.
y_scaler (object, optional) – Scaler for the target data.
- rescale_data(**kwargs)[source]
Reverse the scaling of the data using the provided scalers. This function should be used only if the data has been scaled. The x and y attributes of the dataset are updated with the unscaled data.
- Parameters:
rescale_x (bool) – Whether to unscale the input data (default:
True
).rescale_y (bool) – Whether to unscale the target data (default:
True
).
- scale_data(**kwargs)[source]
Transform the data using the provided scalers. If the scalers are fitted, the data will be transformed. If not, the scalers will be fitted to the data and then the data will be transformed.
- Parameters:
scale_x (bool) – Whether to scale the input data (default:
True
).scale_y (bool) – Whether to scale the target data (default:
True
).
data.VTUReader module
- class data.VTUReader.VTUDataset(mesh_files, x_scaler=None, y_scaler=None, coordinates_idx=[0, 2], fields_idx=[0, 1, 2, 4, 5, 6, 7], dtype=torch.float32)[source]
Bases:
TorchDataset
Dataset class for VTU files.
- Parameters:
mesh_files (List[str]) – List of file names to read.
x_scaler (object, optional) – Scaler for the input data. Default is None.
y_scaler (object, optional) – Scaler for the target data. Default is None.
coordinates_idx (List[int]) – Indexes of the coordinates to read. Default is [0, 2].
fields_idx (List[int]) – Indexes of the fields to read. Default is [0, 1, 2, 4, 5, 6, 7].
- class data.VTUReader.VTUReader(mesh_file)[source]
Bases:
object
Class for reading VTU files and processing the data. The flow field data is stored in the cell centers, so the data is read from there.
- Parameters:
mesh_file (str) – The name of the VTU file to read.
- get_cell_data(fields=[], all_fields=False)[source]
Get the cell data from the mesh.
- Parameters:
fields (list, optional) – The fields idex to read. Default is [].
all_fields (bool, optional) – Whether to read all fields. Default is False.
- get_centers_coordinates()[source]
Get the coordinates of the cell centers.
- Returns:
The coordinates of the cell centers.
- Return type:
np.ndarray
data.dataset module
- class data.dataset.BaseDataset[source]
Bases:
Dataset
Base class for datasets.
- property isscaled
- process_data(process_function)[source]
Process the data using the provided function. The x and y attributes of the dataset are updated with the transformed data.
- Parameters:
process_function (callable) – A function that takes in x and y as input and returns transformed x and y.
- Return type:
None
- rescale_data(rescale_x=True, rescale_y=True)[source]
Reverse the scaling of the data using the provided scalers. This function should be used only if the data has been scaled. The x and y attributes of the dataset are updated with the unscaled data.
- Parameters:
rescale_x (bool) – Whether to unscale the input data (default:
True
).rescale_y (bool) – Whether to unscale the target data (default:
True
).
- Return type:
None
- rescale_x(x)[source]
Rescale the input data using the scaler.
- Parameters:
x (np.array) – The input data to be rescaled.
- Returns:
The rescaled input data.
- Return type:
np.array
- rescale_y(y)[source]
Rescale the target data using the scaler.
- Parameters:
y (np.array) – The target data to be rescaled.
- Returns:
The rescaled target data.
- Return type:
np.array
- scale_data(scale_x=True, scale_y=True)[source]
Transform the data using the provided scalers. If the scalers are fitted, the data will be transformed. If not, the scalers will be fitted to the data and then the data will be transformed.
- Parameters:
scale_x (bool) – Whether to scale the input data (default:
True
).scale_y (bool) – Whether to scale the target data (default:
True
).
- Return type:
None