tfields.bases package

Submodules

tfields.bases.bases module

Author: Daniel Boeckenhoff Mail: daniel.boeckenhoff@ipp.mpg.de

part of tfields library Tools for sympy coordinate transformation

tfields.bases.bases.get_coord_system(base)[source]
Parameters:

base (str or sympy.diffgeom.get_coord_system) –

Returns:

sympy.diffgeom.get_coord_system

tfields.bases.bases.get_coord_system_name(base)[source]
Parameters:

base (str or sympy.diffgeom.get_coord_system) –

Returns:

name of base

Return type:

str

tfields.bases.bases.lambdified_trafo(base_old, base_new)[source]
Parameters:
  • base_old (sympy.CoordSystem) –

  • base_new (sympy.CoordSystem) –

Examples

>>> import numpy as np
>>> import tfields

Transform cartestian to cylinder or spherical >>> a = np.array([[3,4,0]])

>>> trafo = tfields.bases.lambdified_trafo(tfields.bases.cartesian,
...                                        tfields.bases.cylinder)
>>> new = np.concatenate([trafo(*coords).T for coords in a])
>>> assert new[0, 0] == 5
>>> trafo = tfields.bases.lambdified_trafo(tfields.bases.cartesian,
...                                        tfields.bases.spherical)
>>> new = np.concatenate([trafo(*coords).T for coords in a])
>>> assert new[0, 0] == 5
tfields.bases.bases.transform(array, base_old, base_new, **kwargs)[source]

Transform the input array in place :param array: :type array: np.ndarray :param base_old: :type base_old: str or sympy.CoordSystem :param base_new: :type base_new: str or sympy.CoordSystem

Examples

Cylindrical coordinates >>> import numpy as np >>> import tfields >>> cart = np.array([[0, 0, 0], … [1, 0, 0], … [1, 1, 0], … [0, 1, 0], … [-1, 1, 0], … [-1, 0, 0], … [-1, -1, 0], … [0, -1, 0], … [1, -1, 0], … [0, 0, 1]]) >>> cyl = tfields.bases.transform(cart, ‘cartesian’, ‘cylinder’) >>> cyl

Transform cylinder to spherical. No connection is defined so routing via cartesian >>> import numpy as np >>> import tfields >>> b = np.array([[5, np.arctan(4. / 3), 0]]) >>> newB = b.copy() >>> tfields.bases.transform(b, ‘cylinder’, ‘spherical’) >>> assert newB[0, 0] == 5 >>> assert round(newB[0, 1], 10) == round(b[0, 1], 10)

tfields.bases.manifold_3 module

tfields.bases.manifold_3.cartesian_to_cylinder(array)[source]
tfields.bases.manifold_3.cartesian_to_spherical(array)[source]

convert array to r, phi, theta r in [0, oo] phi in [-pi, pi] theta element [0, pi]: elevation angle defined from - Z-axis up

tfields.bases.manifold_3.cylinder_to_cartesian(array)[source]
tfields.bases.manifold_3.physical_cylinder_to_natural_cartesian(vector, position=None)[source]

We need to project from PHYSICAL cylinder coordinates to NATURAL cartesian coordinates

tfields.bases.manifold_3.spherical_to_cartesian(array)[source]

Module contents

Author: Daniel Boeckenhoff Mail: daniel.boeckenhoff@ipp.mpg.de

part of tfields library Tools for sympy coordinate transformation