SphericalDetector.surface_deriv

SphericalDetector.surface_deriv(self, param)[source]

Return the surface derivative at param.

The derivative at parameters phi and theta is given by

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

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, -np.pi / 3],
...                              [ np.pi / 2,  np.pi / 3], [20, 10])
>>> det = SphericalDetector(
...     part, axes=[(1, 0, 0), (0, 0, 1)], radius = 2)
>>> np.round(det.surface_deriv([0, 0]), 10)
array([[ 2., -0.,  0.],
       [ 0.,  0.,  2.]])

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, np.pi / 3]])
>>> np.round(deriv[0], 10)
array([[ 2., -0.,  0.],
       [ 0.,  0.,  2.]])
>>> np.round(deriv[1], 2)
array([[ 0.  , -1.  ,  0.  ],
       [-1.73,  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)