ntrfc.filehandling package

Submodules

ntrfc.filehandling.datafiles module

ntrfc.filehandling.datafiles.create_dirstructure(directories, path)

:param : directories - list of directories :param : path - path

ntrfc.filehandling.datafiles.get_directory_structure(rootdir)

Creates a nested dictionary representing the folder structure of the specified root directory.

Parameters:

rootdir (str) – The root directory to traverse.

Returns:

A nested dictionary representing the folder structure of the root directory. The keys

are the folder names and the values are dictionaries for subdirectories or None for files.

Return type:

dict

Example

get_directory_structure(‘/home/user/documents’) {

‘documents’: {
‘folder1’: {

‘subfolder1’: None, ‘subfolder2’: {

‘file1.txt’: None, ‘file2.txt’: None

}, ‘file3.txt’: None

}, ‘folder2’: {

‘file4.txt’: None

}

}

}

ntrfc.filehandling.datafiles.get_filelist_fromdir(path)
ntrfc.filehandling.datafiles.inplace_change(filename, old_string, new_string)
ntrfc.filehandling.datafiles.read_pickle(file)
ntrfc.filehandling.datafiles.write_pickle(file, args)
ntrfc.filehandling.datafiles.write_pickle_protocolzero(file, args)
ntrfc.filehandling.datafiles.write_yaml_dict(fpath, data)
Parameters:
  • fpath – target path

  • data – dictionary

ntrfc.filehandling.datafiles.yaml_dict_read(yml_file)

ntrfc.filehandling.mesh module

ntrfc.filehandling.mesh.load_mesh(path_to_mesh)

Load a mesh file and return the corresponding mesh object.

Parameters:

path_to_mesh (str) –

The file path to the mesh file to be loaded. The file extension should be one of:

”.vtk”, “.vtp”, “.vtu”, “.vtm”, “.cgns”, “.msh”.

Returns:

mesh – The mesh object constructed from the input file.

Return type:

pyvista.UnstructuredGrid or pyvista.StructuredGrid

ntrfc.filehandling.mesh.read_cgns(path_to_mesh)

Read a cgns file and return the corresponding mesh object.

Parameters:

path_to_mesh (str) – The file path to the cgns file to be read.

Returns:

mesh – The combined mesh object constructed from all the unstructured or structured grids in the cgns file.

Return type:

pyvista.UnstructuredGrid or pyvista.StructuredGrid

ntrfc.filehandling.mesh.read_vtk(path_to_mesh)

Read a vtk/vtp/vtu file and return the corresponding mesh object.

Parameters:

path_to_mesh (str) – The file path to the vtk/vtp/vtu file to be read.

Returns:

mesh – The mesh object constructed from the input file.

Return type:

pyvista.UnstructuredGrid or pyvista.StructuredGrid

ntrfc.filehandling.mesh.read_vtm(path_to_mesh)

Read a vtm file and return the corresponding mesh object.

Parameters:

path_to_mesh (str) – The file path to the vtm file to be read.

Returns:

mesh – The combined mesh object constructed from all the blocks in the vtm file.

Return type:

pyvista.UnstructuredGrid or pyvista.StructuredGrid

Module contents