Utility functions

This module contains simple utility functions that are used in several of MARXS submodules.

marxs.math Package

Convention of variable naming:

prefix

coordinate system

object

none

none

number (e.g. angle, distance)

e

Euklid (3d)

point

h

homogeneous (4d)

point, plane

p

Pluecker (6d)

line (=ray)

marxs.math.geometry Module

Functions

xyz_square(geometry[, r_factor])

Generate Eukledian positions for the corners of a square.

xyz_circle(geometry[, r_factor, philim, ...])

Generate Eukledian positions along an ellipse.

Classes

NoGeometry([kwargs])

Geometry([kwargs])

FinitePlane([kwargs])

Base class for geometrically flat optical elements.

PlaneWithHole(kwargs)

RectangleHole(kwargs)

Base class for geometrically flat optical elements.

CircularHole(kwargs)

Base class for geometrically flat optical elements.

Cylinder([kwargs])

A Geometry shaped like a ring or tube.

Class Inheritance Diagram

Inheritance diagram of marxs.math.geometry.NoGeometry, marxs.math.geometry.Geometry, marxs.math.geometry.FinitePlane, marxs.math.geometry.PlaneWithHole, marxs.math.geometry.RectangleHole, marxs.math.geometry.CircularHole, marxs.math.geometry.Cylinder

marxs.math.pluecker Module

This module collects routines that deal with lines in Pluecker coordiantes incl. the construction of the Pluecker coordinates from e.g. two points in space or a direction and a point.

Functions

angle_line_plane(p_line, h_plane)

Compute angle between normal to plane and line

dir_point2line(e_dir, e_pos)

Return a line in Pluecker coordinates connecting two points.

e_pointpoint2line(e_p1, e_p2)

Return a line in Pluecker coordinates connecting two points.

intersect_line_plane(p_line, h_plane)

Intersect a line in Pluecker coordinates with a plane in homogeneous coordinates.

point_dir2plane(h_point, h_dir)

Return a plane in homogeneous coordinates

marxs.math.polarization Module

Functions

polarization_vectors(dir_array, angles)

Converts polarization angles to vectors in the direction of polarization.

Q_reflection(delta_dir)

Reflection of a polarization vector on a non-polarizing surface.

paralleltransport_matrix(dir1, dir2[, ...])

Calculate parallel transport ray tracing matrix.

parallel_transport(dir_old, dir_new, ...)

Parallel transport of the polarization vector with no polarization happening.

marxs.math.random Module

Classes

RandomArbitraryPdf(x, pdf[, ...])

Take random draw from an arbitrary (and arbitrarily binned) pdf.

Class Inheritance Diagram

Inheritance diagram of marxs.math.random.RandomArbitraryPdf

marxs.math.rotations Module

Functions

ex2vec_fix(e1, efix)

Rotate x-axis to e1, use efix to break rotation ambiguity.

axangle2mat(axes, angles[, is_normalized])

Rotation matrix for rotation angle angle around axis

marxs.math.utils Module

Functions

angle_between(angle, border1, border2)

Test if an angle is between two others

anglediff(phi)

Angle range covered by phi, accounting for 2 pi properly

distance_point_point(h_p1, h_p2)

Calculate the Eukledian distance between 2 points

e2h(e, w)

Convert Euclidean coordinates to homogeneous coordinates

h2e(h)

Convert homogeneous coordinates to Euclidean coordinates

mat2aff(mat)

Transform 3*3 matrix (e.g. rotation) to affine 4*4 matrix.

norm_vector(vec)

Normalize euklidean vectors.

translation2aff(vec)

Transform 3-d translation vector to affine 4*4 matrix.

zoom2aff(zoom)

Transform zoom to affine 4*4 matrix.

marxs.utils Module

Functions

generate_test_photons([n])

Generate a photon structure for testing.

tablerows_to_2d(tab)

Get a 2d array from an input table.

Classes

SimulationSetupWarning

DataFileFormatException

Exception for grating efficiency files not matching expected format.

Class Inheritance Diagram

Inheritance diagram of marxs.utils.SimulationSetupWarning, marxs.utils.DataFileFormatException