CylindricalDetector.surface_deriv

CylindricalDetector.surface_deriv(param)[source]

Return the surface derivative at param.

The derivative at parameters phi and h is given by

deriv = R * ((-radius * sin(phi), 0),
             (-radius * cos(phi), 0),
             (                 0, 1))

where R is a rotation matrix.

Parameters:
paramarray-like or sequence

Parameter value(s) at which to evaluate. A sequence of parameters must have length 2.

Returns:
derivnumpy.ndarray

Array representing the derivative vector(s) at param. If param is a single parameter, the returned array has shape (2,), otherwise param.shape + (2,).

See also

surface

Examples

The method works with a single parameter, resulting in a single vector:

>>> part = odl.uniform_partition(
...     [-np.pi / 2, -4], [np.pi / 2, 4], (10,8))
>>> det = CylindricalDetector(
...     part, axes=[(1, 0, 0), (0, 0, 1)], radius = 2)
>>> np.round(det.surface_deriv([0, 0]), 10)
array([[ 2., -0.,  0.],
       [ 0.,  0.,  1.]])

It is also vectorized, i.e., it can be called with multiple parameters at once (or an n-dimensional array of parameters):

>>> # 2 pairs of parameters, resulting in 3 vectors for each axis
>>> deriv = det.surface_deriv([[0, np.pi / 2], [0, 1]])
>>> np.round(deriv[0], 10)
array([[ 2., -0.,  0.],
       [ 0.,  0.,  1.]])
>>> np.round(deriv[1], 10)
array([[ 0., -2.,  0.],
       [ 0.,  0.,  1.]])
>>> # Pairs of parameters in a (4, 5) array each
>>> param = (np.zeros((4, 5)), np.zeros((4, 5)))  # pairs of params
>>> det.surface_deriv(param).shape
(4, 5, 2, 3)