ConeBeamGeometry.det_to_src¶
-
ConeBeamGeometry.
det_to_src
(self, angle, dparam, normalized=True)¶ Vector or direction from a detector location to the source.
The unnormalized version of this vector is computed as follows:
vec = src_position(angle) - det_point_position(angle, dparam)
- Parameters
- angle
array-like
or sequence One or several (Euler) angles in radians at which to evaluate. If
motion_params.ndim >= 2
, a sequence of that length must be provided.- dparam
array-like
or sequence Detector parameter(s) at which to evaluate. If
det_params.ndim >= 2
, a sequence of that length must be provided.
- angle
- Returns
- det_to_src
numpy.ndarray
Vector(s) pointing from a detector point to the source (at infinity). The shape of the returned array is obtained from the (broadcast) shapes of
angle
anddparam
, and broadcasting is supported within both parameters and between them. The precise definition of the shape isbroadcast(bcast_angle, bcast_dparam).shape + (ndim,)
, wherebcast_angle
isangle
ifmotion_params
is 1D,broadcast(*angle)
otherwise,
and
bcast_dparam
defined analogously.
- det_to_src
Examples
The method works with single parameter values, in which case a single vector is returned:
>>> apart = odl.uniform_partition(0, 2 * np.pi, 10) >>> dpart = odl.uniform_partition(-1, 1, 20) >>> geom = odl.tomo.FanBeamGeometry(apart, dpart, src_radius=2, ... det_radius=3) >>> geom.det_to_src(0, 0) array([ 0., -1.]) >>> geom.det_to_src(0, 0, normalized=False) array([ 0., -5.]) >>> vec = geom.det_to_src(0, 1, normalized=False) >>> np.allclose(geom.det_point_position(0, 1) + vec, ... geom.src_position(0)) True >>> dir = geom.det_to_src(np.pi / 2, 0) >>> np.allclose(dir, [1, 0]) True >>> vec = geom.det_to_src(np.pi / 2, 0, normalized=False) >>> np.allclose(vec, [5, 0]) True
Both variables support vectorized calls, i.e., stacks of parameters can be provided. The order of axes in the output (left of the
ndim
axis for the vector dimension) corresponds to the order of arguments:>>> dirs = geom.det_to_src(0, [-1, 0, 0.5, 1]) >>> dirs[1] array([ 0., -1.]) >>> dirs.shape # (num_dparams, ndim) (4, 2) >>> dirs = geom.det_to_src([0, np.pi / 2, np.pi], 0) >>> np.allclose(dirs, [[0, -1], ... [1, 0], ... [0, 1]]) True >>> dirs.shape # (num_angles, ndim) (3, 2) >>> # Providing 3 pairs of parameters, resulting in 3 vectors >>> dirs = geom.det_to_src([0, np.pi / 2, np.pi], [0, -1, 1]) >>> dirs[0] # Corresponds to angle = 0, dparam = 0 array([ 0., -1.]) >>> dirs.shape (3, 2) >>> # Pairs of parameters arranged in arrays of same size >>> geom.det_to_src(np.zeros((4, 5)), np.zeros((4, 5))).shape (4, 5, 2) >>> # "Outer product" type evaluation using broadcasting >>> geom.det_to_src(np.zeros((4, 1)), np.zeros((1, 5))).shape (4, 5, 2)