h5utils package

Submodules

h5utils.h5tovts module

Module providing the h5tovts function.

It can be used as is or via the console entry point in setup.py.

It works with vtk 6.1.0, i.e. the python-vtk6 package on Debian-based distros.

Last successful test using:
  • Ubuntu 20.10

  • python3-vtk7 7.1.1+dfsg2-4ubuntu4 amd64

h5utils.h5tovts.h5tovts(arguments)[source]

h5tovts argument processing function. The arguments can be generated by h5tovts_parse_args().

h5utils.h5tovts.h5tovts_parse_args(args)[source]

Argument parser for h5tovts. The output of this function can be passed to h5tovts().

h5utils.h5tovts.main()[source]

main function, used as console entry point in setup.py

h5utils.h5utils module

This module provides various utilities to work with the HDF5 format (and the VTK formats).

Automatic documentation cannot be generated at the moment, since we use python3 by default.

This script only runs with python2 because the python VTK module is not yet fully ported to python3.

Note

VTK numbering is in increasing X, then Y, then Z.

class h5utils.h5utils.BCClattice[source]

Bases: h5utils.h5utils.Lattice

Create a BCC lattice.

h5utils.h5utils.BFDTD_h5_to_vts(h5file, basepath, total_lattice_size=None, requested_dataset=[], verbosity=0, x_relative_range=[0, 1], y_relative_range=[0, 1], z_relative_range=[0, 1], real_units=False, dry_run=False)[source]

Converts BFDTD h5 files to VTS files.

class h5utils.h5utils.FCClattice[source]

Bases: h5utils.h5utils.Lattice

Create a FCC lattice.

class h5utils.h5utils.Lattice[source]

Bases: object

The lattice class is normally used only for the geometry-lattice variable, and specifies the three lattice directions of the crystal and the lengths of the corresponding lattice vectors.

lattice

Properties:

basis1, basis2, basis3 [vector3]

The three lattice directions of the crystal, specified in the cartesian basis. The lengths of these vectors are ignored–only their directions matter. The lengths are determined by the basis-size property, below. These vectors are then used as a basis for all other 3-vectors in the ctl file. They default to the x, y, and z directions, respectively.

basis-size [vector3]

The components of basis-size are the lengths of the three basis vectors, respectively. They default to unit lengths.

size [vector3]

The size of the lattice (i.e. the length of the lattice vectors Ri, in which the crystal is periodic) in units of the basis vectors. Thus, the actual lengths of the lattice vectors are given by the components of size multiplied by the components of basis-size. (Alternatively, you can think of size as the vector between opposite corners of the primitive cell, specified in the lattice basis.) Defaults to unit lengths.

resolution [number or vector3]

Specifies the computational grid resolution, in pixels per lattice unit (a lattice unit is one basis vector in a given direction). If resolution is a vector3, then specifies a different resolution for each direction; otherwise the resolution is uniform. (The grid size is then the product of the lattice size and the resolution, rounded up to the next positive integer.) Defaults to 10.

If any dimension has the special size no-size, then the dimensionality of the problem is reduced by one; strictly speaking, the dielectric function is taken to be uniform along that dimension. (In this case, the no-size dimension should generally be orthogonal to the other dimensions.)

getBounds()[source]

Return (xmin,xmax, ymin,ymax, zmin,zmax) bounds of the lattice.

getLatticeVectors()[source]

Return lattice vectors

getMesh()[source]
getMeshDelta()[source]
getMinDeltas()[source]
getResolution()[source]

Return resolution.

getSpacing()[source]
getXmeshDelta()[source]
getYmeshDelta()[source]
getZmeshDelta()[source]
setBasisSize(basis_size)[source]
setResolution(Nx, Ny, Nz)[source]

Sets up homogeneous X,Y,Z grids with Nx,Ny,Nz points.

setSize(size)[source]
setXmesh(xmesh)[source]
setYmesh(ymesh)[source]
setZmesh(zmesh)[source]
h5utils.h5utils.MPB_h5tovts(h5file, basepath, total_lattice_size=None, requested_dataset=[], verbosity=0)[source]
  • total_lattice_size : total length of the lattice vectors, i.e. size*basis-size in MPB terms. Overrides any values obtained from reading the lattice vectors in the .h5 file.

h5utils.h5utils.createComplexArrays(name, number_of_tuples)[source]

Creates and returns 4 vtkScalarArray arrays, named (name+’_re’, name+’_im’, name+’_mod’, name+’_phase’), with number_of_tuples tuples in each. The returned arrays are meant to represent the real, imaginary, modulus and phase values of a given complex field.

Parameters
  • name (str) – Base name to use for the generated arrays. Example: name=’E’ -> ‘E_re’, ‘E_im’, ‘E_mod’, ‘E_phase’

  • number_of_tuples (int) – number of tuples

Returns

(A_re, A_im, A_mod, A_phase)

h5utils.h5utils.createvtkArray(name, number_of_tuples, component_names)[source]

vtkScalarArray constructor wrapper.

It creates a vtkScalarArray named name, with number_of_tuples tuples and the given component names component_names. The returned array is filled with zeros.

Example usage:

>>> import h5utils.h5utils as h
>>> A=h.createvtkArray('myname', 4, ['Ex', 'Ey', 'value_of_interest'])
>>> print(A)
vtkFloatArray (0x238d300)
  Debug: Off
  Modified Time: 68
  Reference Count: 1
  Registered Events: (none)
  Name: myname
  Data type: float
  Size: 12
  MaxId: 11
  NumberOfComponents: 3
  ComponentNames: 
    0 : 0x2d7ed00
    1 : 0x2d7b510
    2 : 0x2d7ed50
  Information: 0
  Name: myname
  Number Of Components: 3
  Number Of Tuples: 4
  Size: 12
  MaxId: 11
  LookupTable: (none)
h5utils.h5utils.h5_getDataSets(HDF5_file_object)[source]
h5utils.h5utils.h5_setupLattice(HDF5_file_object, total_lattice_size=None, requested_dataset=[])[source]
h5utils.h5utils.setTupleComplex(offset, value, A_re_array, A_im_array, A_mod_array, A_phase_array)[source]
h5utils.h5utils.stl_to_vts_and_h5(implicit_function, outfile_basename, lattice, epsilon_inside, epsilon_outside)[source]
h5utils.h5utils.stltoh5(stlfile, basepath, epsilon_inside, epsilon_outside, lattice=<h5utils.h5utils.Lattice object>, verbosity=0)[source]

Converts an STL file into an HDF5 file.

It creates an array based on lattice and fills it with epsilon_inside for points inside the geometry defined by the STL file and with epsilon_outside for points outside of it.

Module contents