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.

count_datasets(group_name)[source]

Count the number of datasets in the group.

Parameters:

group_name (str) – The name of the group to count.

Returns:

The number of datasets in the group.

Return type:

count (int)

load_data_to_tensor(group_name)[source]

Load the datasets from the group to a tensor.

Parameters:

group_name (str) – The name of the group to load.

Returns:

The tensor with the data from the group.

Return type:

tensor (torch.Tensor)

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].

load_mesh(file_name)[source]

Load the mesh data from the file.

Parameters:

file_name (str) – The name of the VTU file to read.

Returns:

A tuple with the coordinates and fields data.

Return type:

Tuple[torch.Tensor, torch.Tensor]

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

get_data_names()[source]

Get the names of the fields in the mesh.

Returns:

The names of the fields in the mesh.

Return type:

list

get_groupID()[source]

Get the CAD group ID for each cell.

Returns:

The CAD group ID for each cell.

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

Module contents