ptypy.utils.misc#

Miscellaneous utility functions with little dependencies from other modules

This file is part of the PTYPY package.

copyright:

Copyright 2014 by the PTYPY team, see AUTHORS.

license:

see LICENSE for details.

Functions

all_subclasses(cls[, names])

Helper function for finding all subclasses of a base class.

clean_path(filename)

Makes path absolute and create all sub directories if needed.

complex_overload(func)

electron_wavelength(electron_energy)

Calculate electron wavelength based on energy in keV:

expect2(a)

Generates 1d numpy array with 2 entries generated from multiple inputs (tuples, arrays, scalars).

expect3(a)

Generates 1d numpy array with 3 entries generated from multiple inputs (tuples, arrays, scalars).

expectN(a, N)

isstr(s)

This function should be used for checking if an object is of string type

keV2m(keV)

Convert photon energy in keV to wavelength (in vacuum) in meters.

keV2nm(keV)

Convert photon energy in keV to wavelength (in vacuum) in nanometers.

m2keV(m)

Convert wavelength in meters to photon energy in keV.

nm2keV(nm)

Convert wavelength in nanometers to photon energy in keV.

str2index(s)

Converts a str that is supposed to represent a numpy index expression into an index expression

str2int(A)

Transforms numpy array A of strings to np.uint8 and back

str2range(s)

Generates an index list from string input s

unique_path(filename)

Makes path absolute and unique

Classes

Table(dct[, name])

Basic table implemented using numpy.recarray Ideally subclassed to be used with faster or more flexible databases.