comet.pyhed.IO package

Submodules

comet.pyhed.IO.saveload module

Part of comet/pyhed/IO

exception comet.pyhed.IO.saveload.ArgsError(value)[source]

Bases: Exception

exception comet.pyhed.IO.saveload.TetgenNotFoundError[source]

Bases: Exception

Special Exception to catch in a try except.

comet.pyhed.IO.saveload.addVolumeConstraintToPoly(name, regions, float_format='6.3f')[source]

Append region information in form of volume constraints to a tetgen.poly file. The given regions has to be of shape (n, 5 or 6), with n times: [number, x, y, z, regional attribute, volume constraint]

comet.pyhed.IO.saveload.checkDirectory(savename, filename=False, verbose=False)[source]

Checks for directory and creates if not.

comet.pyhed.IO.saveload.checkForFile(name)[source]

Checks if file exists and creates a directory if it does not.

comet.pyhed.IO.saveload.createCustEMDirectories(m_dir='.', r_dir='.')[source]

Creates the used custEM directories based on m_dir and r_dir.

comet.pyhed.IO.saveload.cutExtension(path)[source]
comet.pyhed.IO.saveload.delLastLine(opened_file, line_ending='\n')[source]

Efficient way of deleting the last line of a large file.

comet.pyhed.IO.saveload.getItem(archive, key, default=None)[source]

Get item for key from numpy archive via try except with given default value for None.

comet.pyhed.IO.saveload.searchforTetgen(returnPathfile=False)[source]

Try to find a valid tetgen installation for meshing purposes.

path: string
Path to tetgen installation or path to pathfile of pyhed itself.

comet.pyhed.IO.vtk module

Part of comet/pyhed/IO

comet.pyhed.IO.vtk.add_vector_to_vtk(vtk, vector, vectorname, dtype_string='double')[source]

Appends a vector fields to an existing vtk file.

Parameters:
  • vtk (string) – Path to vtk file, where the field is to be appended.
  • vector (np.ndarray) – Real valued array of shape (3, n) n being either the number of nodes or the number of cells.
  • vectorname (string) – Name under which the array is to be identified in the vtk file.
  • dtype_string (string) – Format string in the vtk file. Default ‘double’ is used for float values.
comet.pyhed.IO.vtk.fieldCell2Node(mesh, field)[source]
comet.pyhed.IO.vtk.savefieldvtk(vtk_name, mesh, field, itype='mesh', components=False, scalar=False, save=['real', 'imag'], field_name='field', verbose=True)[source]

Basic VTK export routine when it comes to complex vector fields on unstructured meshes.

Parameters:
  • vtk_name (string) – Path to the resulting vtk file.
  • mesh (string or pg.Mesh or np.ndarray) – Pygimli Mesh instance or path to a mesh file. Alternatively a bare numpy array containing coordinates or meshgrid ranges can be used.
  • field (np.ndarray) – Complex vector field of shape (3, n) with n corresponding either to mesh cell count or node count.
  • itype (string [ ‘mesh’ ]) – Defines input type of mesh. Possible choices are ‘mesh’ for pg.Mesh (instance or file path), ‘coords’ for direct 3d coordinates ranges to build a regular meshgrid, or ‘grid’ if input is a 3d meshgrid.
  • components (boolean [ False ]) – Separately saves the spatial components of the vector field for debugging purposes.
  • scalar (boolean [ False ]) – Input is a simple scalar field (e.g. potential).
  • save (list [ ‘real’, ‘imag’ ]) – The vector is saved once for each entry in the list. Possible choices are ‘real’ to save the real component, ‘imag’ to save the imaginary component, ‘aps’ or ‘amp’ to save the amplitude, and ‘phase’ to save the phase component of the field. Only works with vector fields.
  • field_name (string) – Name under which the array is to be identified in the vtk file.
  • verbose (boolean [ True ]) – Turn on verbose mode.
Returns:

Return type:

True if succesful.

Module contents

Module comet/pyhed/IO

Init file for IO subpackage of pyhed. Mainly used to load and save a bunch of stuff or handling some checks.