예제 #1
0
    def __repr__(self):
        """Return ``repr(self)``."""

        arg_fstr = '\n    {!r},\n    {!r},\n    src_radius={}, det_radius={}'
        if self.pitch != 0:
            arg_fstr += ',\n    pitch={pitch}'
        if self.pitch_offset != 0:
            arg_fstr += ',\n    pitch_offset={pitch_offset}'
        if not np.allclose(self.axis, [0, 0, 1]):
            arg_fstr += ',\n    axis={axis}'
        default_src_to_det = perpendicular_vector(self.axis)
        if not np.allclose(self._src_to_det_init, default_src_to_det):
            arg_fstr += ',\n    src_to_det_init={src_to_det_init}'

        default_axes = [np.cross(self.axis, self._src_to_det_init), self.axis]
        if not np.allclose(self.detector.axes, default_axes):
            arg_fstr += ',\n    det_init_axes={det_init_axes!r}'

        arg_str = arg_fstr.format(
            self.motion_partition, self.det_partition,
            self.src_radius, self.det_radius,
            pitch=self.pitch,
            pitch_offset=self.pitch_offset,
            axis=list(self.axis),
            src_to_det_init=list(self.src_to_det_init),
            det_init_axes=[list(a) for a in self.det_init_axes])
        return '{}({})'.format(self.__class__.__name__, arg_str)
예제 #2
0
    def __repr__(self):
        """Return ``repr(self)``."""

        arg_fstr = '\n    {!r},\n    {!r},\n    src_radius={}, det_radius={}'
        if self.pitch != 0:
            arg_fstr += ',\n    pitch={pitch}'
        if self.pitch_offset != 0:
            arg_fstr += ',\n    pitch_offset={pitch_offset}'
        if not np.allclose(self.axis, [0, 0, 1]):
            arg_fstr += ',\n    axis={axis}'
        default_src_to_det = perpendicular_vector(self.axis)
        if not np.allclose(self._src_to_det_init, default_src_to_det):
            arg_fstr += ',\n    src_to_det_init={src_to_det_init}'

        default_axes = [np.cross(self.axis, self._src_to_det_init), self.axis]
        if not np.allclose(self.detector.axes, default_axes):
            arg_fstr += ',\n    det_init_axes={det_init_axes!r}'

        arg_str = arg_fstr.format(
            self.motion_partition, self.det_partition,
            self.src_radius, self.det_radius,
            pitch=self.pitch,
            pitch_offset=self.pitch_offset,
            axis=list(self.axis),
            src_to_det_init=list(self.src_to_det_init),
            det_init_axes=[list(a) for a in self.det_init_axes])
        return '{}({})'.format(self.__class__.__name__, arg_str)
예제 #3
0
    def __init__(self, apart, dpart, src_radius, det_radius, **kwargs):
        """Initialize a new instance.

        Parameters
        ----------
        apart : 1-dim. `RectPartition`
            Partition of the angle interval
        dpart : 1-dim. `RectPartition`
            Partition of the detector parameter interval
        src_radius : nonnegative float
            Radius of the source circle
        det_radius : nonnegative float
            Radius of the detector circle
        src_to_det_init : `array-like` (shape ``(2,)``), optional
            Initial state of the vector pointing from source to detector
            reference point. The zero vector is not allowed.
            Default: ``(1, 0)``.
        det_init_axis : `array-like` (shape ``(2,)``), optional
            Initial axis defining the detector orientation.
            By default, a normalized `perpendicular_vector` to
            ``src_to_det_init`` is used.
        """
        src_to_det_init = kwargs.pop('src_to_det_init', (1.0, 0.0))
        det_init_axis = kwargs.pop('det_init_axis', None)

        if np.shape(src_to_det_init) != (2,):
            raise ValueError('`src_to_det_init` has shape {}, '
                             'expected (2,)'
                             ''.format(np.shape(src_to_det_init)))
        if np.linalg.norm(src_to_det_init) <= 1e-10:
            raise ValueError('`src_to_det_init` {} too close '
                             'to zero'.format(src_to_det_init))
        self._src_to_det_init = (np.asarray(src_to_det_init, dtype='float64') /
                                 np.linalg.norm(src_to_det_init))

        if det_init_axis is None:
            det_init_axis = perpendicular_vector(self._src_to_det_init)

        self._src_radius, src_radius_in = float(src_radius), src_radius
        if self.src_radius < 0:
            raise ValueError('`src_radius` {} is negative'
                             ''.format(src_radius_in))
        self._det_radius, det_radius_in = float(det_radius), det_radius
        if det_radius < 0:
            raise ValueError('`det_radius` {} is negative'
                             ''.format(det_radius_in))
        if self.src_radius == 0 and self.det_radius == 0:
            raise ValueError('source and detector radii cannot both be 0')

        detector = Flat1dDetector(dpart, det_init_axis)
        super().__init__(ndim=2, motion_part=apart, detector=detector)
예제 #4
0
    def __init__(self, apart, dpart, axis=[0, 0, 1], **kwargs):
        """Initialize a new instance.

        Parameters
        ----------
        apart : 1-dim. `RectPartition`
            Partition of the angle interval
        dpart : 2-dim. `RectPartition`
            Partition of the detector parameter interval
        axis : `array-like`, shape ``(3,)``, optional
            Fixed rotation axis defined by a 3-element vector
        det_init_pos : `array-like`, shape ``(3,)``, optional
            Initial position of the detector reference point. The zero
            vector is only allowed if ``det_init_axes`` is explicitly
            given.
            By default, a `perpendicular_vector` to ``axis`` is used.
        det_init_axes : 2-tuple of `array-like`'s (shape ``(3,)``), optional
            Initial axes defining the detector orientation.
            By default, the normalized cross product of ``axis`` and
            ``det_init_pos`` is used as first axis and ``axis`` as second.
        """
        AxisOrientedGeometry.__init__(self, axis)

        det_init_pos = kwargs.pop('det_init_pos', perpendicular_vector(axis))
        det_init_axes = kwargs.pop('det_init_axes', None)

        if det_init_axes is None:
            if np.linalg.norm(det_init_pos) <= 1e-10:
                raise ValueError('initial detector position {} is close to '
                                 'zero. This is only allowed for explicit '
                                 '`det_init_axes`.'.format(det_init_pos))

            det_init_axis_0 = np.cross(self.axis, det_init_pos)
            det_init_axis_0 /= np.linalg.norm(det_init_axis_0)
            det_init_axes = (det_init_axis_0, axis)

        self.det_init_axes = det_init_axes

        detector = Flat2dDetector(part=dpart, axes=det_init_axes)
        super().__init__(ndim=3,
                         apart=apart,
                         detector=detector,
                         det_init_pos=det_init_pos)

        if self.motion_partition.ndim != 1:
            raise ValueError('`apart` has dimension {}, expected 1'
                             ''.format(self.motion_partition.ndim))
예제 #5
0
    def __repr__(self):
        """Return ``repr(self)``."""

        inner_fstr = '\n    {!r},\n    {!r}'

        if not np.allclose(self.det_init_pos, [1, 0]):
            inner_fstr += ',\n    det_init_pos={det_init_pos!r}'

        if not np.allclose(self.det_init_pos,
                           perpendicular_vector(self.det_init_pos)):
            inner_fstr += ',\n    det_init_axis={det_init_axis!r}'

        inner_str = inner_fstr.format(self.motion_partition,
                                      self.det_partition,
                                      det_init_pos=self._det_init_pos,
                                      det_init_axis=self.det_init_axis)
        return '{}({})'.format(self.__class__.__name__, inner_str)
예제 #6
0
파일: parallel.py 프로젝트: odlgroup/odl
    def __repr__(self):
        """Return ``repr(self)``."""

        inner_fstr = '\n    {!r},\n    {!r}'

        if not np.allclose(self.det_init_pos, [1, 0]):
            inner_fstr += ',\n    det_init_pos={det_init_pos!r}'

        if not np.allclose(self.det_init_pos,
                           perpendicular_vector(self.det_init_pos)):
            inner_fstr += ',\n    det_init_axis={det_init_axis!r}'

        inner_str = inner_fstr.format(self.motion_partition,
                                      self.det_partition,
                                      det_init_pos=self._det_init_pos,
                                      det_init_axis=self.det_init_axis)
        return '{}({})'.format(self.__class__.__name__, inner_str)
예제 #7
0
    def __repr__(self):
        """Return ``repr(self)``."""
        arg_fstr = '{!r}, {!r}, src_radius={}, det_radius={}'

        if not np.allclose(self._src_to_det_init, [1, 0]):
            arg_fstr += ',\n    src_to_det_init={src_to_det_init!r}'

        default_axis = perpendicular_vector(self._src_to_det_init)
        if not np.allclose(self.detector.axis, default_axis):
            arg_fstr += ',\n    det_init_axis={det_init_axis!r}'

        arg_str = arg_fstr.format(self.motion_partition, self.det_partition,
                                  self.src_radius, self.det_radius,
                                  src_to_det_init=self._src_to_det_init,
                                  det_init_axis=self.detector.axis)

        return '{}({})'.format(self.__class__.__name__, arg_str)
예제 #8
0
파일: parallel.py 프로젝트: odlgroup/odl
    def __init__(self, apart, dpart, axis=[0, 0, 1], **kwargs):
        """Initialize a new instance.

        Parameters
        ----------
        apart : 1-dim. `RectPartition`
            Partition of the angle interval
        dpart : 2-dim. `RectPartition`
            Partition of the detector parameter interval
        axis : `array-like`, shape ``(3,)``, optional
            Fixed rotation axis defined by a 3-element vector
        det_init_pos : `array-like`, shape ``(3,)``, optional
            Initial position of the detector reference point. The zero
            vector is only allowed if ``det_init_axes`` is explicitly
            given.
            By default, a `perpendicular_vector` to ``axis`` is used.
        det_init_axes : 2-tuple of `array-like`'s (shape ``(3,)``), optional
            Initial axes defining the detector orientation.
            By default, the normalized cross product of ``axis`` and
            ``det_init_pos`` is used as first axis and ``axis`` as second.
        """
        AxisOrientedGeometry.__init__(self, axis)

        det_init_pos = kwargs.pop('det_init_pos', perpendicular_vector(axis))
        det_init_axes = kwargs.pop('det_init_axes', None)

        if det_init_axes is None:
            if np.linalg.norm(det_init_pos) <= 1e-10:
                raise ValueError('initial detector position {} is close to '
                                 'zero. This is only allowed for explicit '
                                 '`det_init_axes`.'.format(det_init_pos))

            det_init_axis_0 = np.cross(self.axis, det_init_pos)
            det_init_axis_0 /= np.linalg.norm(det_init_axis_0)
            det_init_axes = (det_init_axis_0, axis)

        self.det_init_axes = det_init_axes

        detector = Flat2dDetector(part=dpart, axes=det_init_axes)
        super().__init__(ndim=3, apart=apart, detector=detector,
                         det_init_pos=det_init_pos)

        if self.motion_partition.ndim != 1:
            raise ValueError('`apart` has dimension {}, expected 1'
                             ''.format(self.motion_partition.ndim))
예제 #9
0
    def __init__(self, apart, dpart, **kwargs):
        """Initialize a new instance.

        Parameters
        ----------
        apart : 2- or 3-dim. `RectPartition`
            Partition of the angle parameter set
        dpart : 2-dim. `RectPartition`
            Partition of the detector parameter interval
        det_init_pos : `array-like`, shape ``(3,)``, optional
            Initial position of the detector reference point. The zero
            vector is only allowed if ``det_init_axes`` is explicitly
            given.
            Default: ``(1, 0, 0)``
        det_init_axes : 2-tuple of `array-like`'s (shape ``(3,)``), optional
            Initial axes defining the detector orientation.
            By default, a normalized `perpendicular_vector` to
            ``det_init_pos`` is taken as first axis, and the normalized
            cross product of these two as second.
        """
        det_init_pos = kwargs.pop('det_init_pos', (1.0, 0.0, 0.0))
        det_init_axes = kwargs.pop('det_init_axes', None)

        if det_init_axes is None:
            if np.linalg.norm(det_init_pos) <= 1e-10:
                raise ValueError('`det_init_pos` {} is close to '
                                 'zero. This is only allowed for explicit '
                                 '`det_init_axes`.'.format(det_init_pos))

            det_init_axis_0 = perpendicular_vector(det_init_pos)
            det_init_axis_1 = np.cross(det_init_pos, det_init_axis_0)
            det_init_axes = (det_init_axis_0, det_init_axis_1)

        detector = Flat2dDetector(part=dpart, axes=det_init_axes)
        super().__init__(ndim=3,
                         apart=apart,
                         detector=detector,
                         det_init_pos=det_init_pos)

        if self.motion_partition.ndim not in (2, 3):
            raise ValueError('`apart` has dimension {}, expected '
                             '2 or 3'.format(self.motion_partition.ndim))
예제 #10
0
파일: parallel.py 프로젝트: odlgroup/odl
    def __repr__(self):
        """Return ``repr(self)``."""
        arg_fstr = '\n    {!r},\n    {!r}'
        if not np.allclose(self.axis, [0, 0, 1]):
            arg_fstr += ',\n    axis={axis!r}'

        if not np.allclose(self._det_init_pos,
                           perpendicular_vector(self.axis)):
            arg_fstr += ',\n    det_init_pos={det_init_pos!r}'

        default_axes = [np.cross(self.axis, self._det_init_pos), self.axis]
        if not np.allclose(self.detector.axes, default_axes):
            arg_fstr += ',\n    det_init_axes={det_init_axes!r}'

        arg_str = arg_fstr.format(self.motion_partition,
                                  self.det_partition,
                                  axis=self.axis,
                                  det_init_pos=self._det_init_pos,
                                  det_init_axes=self.detector.axes)
        return '{}({})'.format(self.__class__.__name__, arg_str)
예제 #11
0
    def __repr__(self):
        """Return ``repr(self)``."""
        arg_fstr = '\n    {!r},\n    {!r}'
        if not np.allclose(self.axis, [0, 0, 1]):
            arg_fstr += ',\n    axis={axis!r}'

        if not np.allclose(self._det_init_pos, perpendicular_vector(
                self.axis)):
            arg_fstr += ',\n    det_init_pos={det_init_pos!r}'

        default_axes = [np.cross(self.axis, self._det_init_pos), self.axis]
        if not np.allclose(self.detector.axes, default_axes):
            arg_fstr += ',\n    det_init_axes={det_init_axes!r}'

        arg_str = arg_fstr.format(self.motion_partition,
                                  self.det_partition,
                                  axis=self.axis,
                                  det_init_pos=self._det_init_pos,
                                  det_init_axes=self.detector.axes)
        return '{}({})'.format(self.__class__.__name__, arg_str)
예제 #12
0
    def __init__(self, apart, dpart, **kwargs):
        """Initialize a new instance.

        Parameters
        ----------
        apart : 1-dim. `RectPartition`
            Partition of the angle interval
        dpart : 1-dim. `RectPartition`
            Partition of the detector parameter interval
        det_init_pos : `array-like`, shape ``(2,)``, optional
            Initial position of the detector reference point. The zero
            vector is only allowed if ``det_init_axis`` is explicitly
            given.
            Default: ``(1, 0)``.
        det_init_axis : `array-like` (shape ``(2,)``), optional
            Initial axis defining the detector orientation.
            By default, a normalized `perpendicular_vector` to
            ``det_init_pos`` is used, which is only valid if
            ``det_init_axis`` is not zero.
        """
        self._det_init_pos = kwargs.pop('det_init_pos', (1.0, 0.0))
        self._det_init_axis = kwargs.pop('det_init_axis', None)

        if self.det_init_axis is None:
            if np.linalg.norm(self.det_init_pos) <= 1e-10:
                raise ValueError('`det_init_pos` {} is close to '
                                 'zero. This is only allowed for explicit '
                                 'det_init_axis'
                                 ''.format(self.det_init_pos))

            det_init_axis = perpendicular_vector(self.det_init_pos)

        detector = Flat1dDetector(part=dpart, axis=det_init_axis)
        super().__init__(ndim=2,
                         apart=apart,
                         detector=detector,
                         det_init_pos=self.det_init_pos)

        if self.motion_partition.ndim != 1:
            raise ValueError('`apart` dimension {}, expected 1'
                             ''.format(self.motion_partition.ndim))
예제 #13
0
파일: detector.py 프로젝트: sushmita13/odl
    def __init__(self, part, axis):
        """Initialize a new instance.

        Parameters
        ----------
        part : 1-dim. `RectPartition`
            Partition of the parameter interval, corresponding to the
            line elements
        axis : `array-like`, shape ``(2,)``
            Principal axis of the detector
        """
        super().__init__(part)
        if self.ndim != 1:
            raise ValueError('expected partition to have 1 dimension, '
                             'got {}'.format(self.ndim))

        if np.linalg.norm(axis) <= 1e-10:
            raise ValueError('`axis` vector {} too close to zero'
                             ''.format(axis))
        self._axis = np.asarray(axis) / np.linalg.norm(axis)
        self._normal = perpendicular_vector(self.axis)
예제 #14
0
파일: detector.py 프로젝트: NikEfth/odl
    def __init__(self, part, axis):
        """Initialize a new instance.

        Parameters
        ----------
        part : 1-dim. `RectPartition`
            Partition of the parameter interval, corresponding to the
            line elements
        axis : `array-like`, shape ``(2,)``
            Principal axis of the detector
        """
        super().__init__(part)
        if self.ndim != 1:
            raise ValueError('expected partition to have 1 dimension, '
                             'got {}.'.format(self.ndim))

        if np.linalg.norm(axis) <= 1e-10:
            raise ValueError('axis vector {} too close to zero.'
                             ''.format(axis))
        self._axis = np.asarray(axis) / np.linalg.norm(axis)
        self._normal = perpendicular_vector(self.axis)
예제 #15
0
파일: parallel.py 프로젝트: odlgroup/odl
    def __init__(self, apart, dpart, **kwargs):
        """Initialize a new instance.

        Parameters
        ----------
        apart : 2- or 3-dim. `RectPartition`
            Partition of the angle parameter set
        dpart : 2-dim. `RectPartition`
            Partition of the detector parameter interval
        det_init_pos : `array-like`, shape ``(3,)``, optional
            Initial position of the detector reference point. The zero
            vector is only allowed if ``det_init_axes`` is explicitly
            given.
            Default: ``(1, 0, 0)``
        det_init_axes : 2-tuple of `array-like`'s (shape ``(3,)``), optional
            Initial axes defining the detector orientation.
            By default, a normalized `perpendicular_vector` to
            ``det_init_pos`` is taken as first axis, and the normalized
            cross product of these two as second.
        """
        det_init_pos = kwargs.pop('det_init_pos', (1.0, 0.0, 0.0))
        det_init_axes = kwargs.pop('det_init_axes', None)

        if det_init_axes is None:
            if np.linalg.norm(det_init_pos) <= 1e-10:
                raise ValueError('`det_init_pos` {} is close to '
                                 'zero. This is only allowed for explicit '
                                 '`det_init_axes`.'.format(det_init_pos))

            det_init_axis_0 = perpendicular_vector(det_init_pos)
            det_init_axis_1 = np.cross(det_init_pos, det_init_axis_0)
            det_init_axes = (det_init_axis_0, det_init_axis_1)

        detector = Flat2dDetector(part=dpart, axes=det_init_axes)
        super().__init__(ndim=3, apart=apart, detector=detector,
                         det_init_pos=det_init_pos)

        if self.motion_partition.ndim not in (2, 3):
            raise ValueError('`apart` has dimension {}, expected '
                             '2 or 3'.format(self.motion_partition.ndim))
예제 #16
0
파일: parallel.py 프로젝트: odlgroup/odl
    def __init__(self, apart, dpart, **kwargs):
        """Initialize a new instance.

        Parameters
        ----------
        apart : 1-dim. `RectPartition`
            Partition of the angle interval
        dpart : 1-dim. `RectPartition`
            Partition of the detector parameter interval
        det_init_pos : `array-like`, shape ``(2,)``, optional
            Initial position of the detector reference point. The zero
            vector is only allowed if ``det_init_axis`` is explicitly
            given.
            Default: ``(1, 0)``.
        det_init_axis : `array-like` (shape ``(2,)``), optional
            Initial axis defining the detector orientation.
            By default, a normalized `perpendicular_vector` to
            ``det_init_pos`` is used, which is only valid if
            ``det_init_axis`` is not zero.
        """
        self._det_init_pos = kwargs.pop('det_init_pos', (1.0, 0.0))
        self._det_init_axis = kwargs.pop('det_init_axis', None)

        if self.det_init_axis is None:
            if np.linalg.norm(self.det_init_pos) <= 1e-10:
                raise ValueError('`det_init_pos` {} is close to '
                                 'zero. This is only allowed for explicit '
                                 'det_init_axis'
                                 ''.format(self.det_init_pos))

            det_init_axis = perpendicular_vector(self.det_init_pos)

        detector = Flat1dDetector(part=dpart, axis=det_init_axis)
        super().__init__(ndim=2, apart=apart, detector=detector,
                         det_init_pos=self.det_init_pos)

        if self.motion_partition.ndim != 1:
            raise ValueError('`apart` dimension {}, expected 1'
                             ''.format(self.motion_partition.ndim))
예제 #17
0
파일: spect.py 프로젝트: chongchenmath/odl
    def __init__(self, apart, dpart, det_rad, axis=[0, 0, 1],
                 **kwargs):
        """Initialize a new instance.

        Parameters
        ----------
        apart : 1-dim. `RectPartition`
            Partition of the angle interval
        dpart : 2-dim. `RectPartition`
            Partition of the detector parameter rectangle
        det_rad : positive float
            Radius of the circular detector orbit.
        axis : `array-like`, shape ``(3,)``, optional
            Fixed rotation axis.
        orig_to_det_init : `array-like`, shape ``(3,)``, optional
            Vector pointing towards the detector reference point in
            the initial position.
            Default: a `perpendicular_vector` to ``axis``.
        det_init_axes : 2-tuple of `array-like`'s (shape ``(3,)``), optional
            Initial axes defining the detector orientation.
            Default: the normalized cross product of ``axis`` and
            ``orig_to_det_init`` is used as first axis and ``axis`` as second.
        """
        self._det_radius = float(det_rad)
        if self.det_radius <= 0:
            raise ValueError('expected a positive radius, got {}'
                             ''.format(det_rad))

        orig_to_det_init = kwargs.pop('orig_to_det_init',
                                      perpendicular_vector(axis))

        init_pos_norm = np.linalg.norm(orig_to_det_init)
        if init_pos_norm > 1e-10:
            orig_to_det_init *= self.det_radius / init_pos_norm
        else:
            raise ValueError('`orig_to_det_init` {} is too close to zero'
                             ''.format(orig_to_det_init))
        kwargs['det_init_pos'] = orig_to_det_init
        super().__init__(apart, dpart, axis, **kwargs)
예제 #18
0
    def __init__(self, apart, dpart, src_radius, det_radius, pitch,
                 axis=[0, 0, 1], **kwargs):
        """Initialize a new instance.

        Parameters
        ----------
        apart : 1-dim. `RectPartition`
            Partition of the angle interval
        dpart : 2-dim. `RectPartition`
            Partition of the detector parameter rectangle
        src_radius : nonnegative float
            Radius of the source circle
        det_radius : nonnegative float
            Radius of the detector circle
        pitch : float
            Constant vertical distance that a point on the helix
            traverses when increasing the angle parameter by ``2 * pi``
        axis : `array-like`, shape ``(3,)``, optional
            Fixed rotation axis, the symmetry axis of the helix

        Other Parameters
        ----------------
        src_to_det_init : `array-like`, shape ``(2,)``, optional
            Initial state of the vector pointing from source to detector
            reference point. The zero vector is not allowed.
            By default, a `perpendicular_vector` to ``axis`` is used.
        det_init_axes : 2-tuple of `array-like`'s (shape ``(2,)``), optional
            Initial axes defining the detector orientation.
            By default, the normalized cross product of ``axis`` and
            ``src_to_det_init`` is used as first axis and ``axis`` as
            second.
        pitch_offset : float, optional
            Offset along the ``axis`` at ``angle=0``
        """
        AxisOrientedGeometry.__init__(self, axis)

        src_to_det_init = kwargs.pop('src_to_det_init',
                                     perpendicular_vector(self.axis))

        if np.linalg.norm(src_to_det_init) <= 1e-10:
            raise ValueError('initial source to detector vector {} is too '
                             'close to zero'.format(src_to_det_init))
        self._src_to_det_init = (np.array(src_to_det_init) /
                                 np.linalg.norm(src_to_det_init))

        det_init_axes = kwargs.pop('det_init_axes', None)
        if det_init_axes is None:
            det_init_axis_0 = np.cross(self.axis, self._src_to_det_init)
            det_init_axes = (det_init_axis_0, axis)

        detector = Flat2dDetector(dpart, det_init_axes)

        super().__init__(ndim=3, motion_part=apart, detector=detector)

        self._pitch = float(pitch)
        self._pitch_offset = float(kwargs.pop('pitch_offset', 0))
        self._src_radius = float(src_radius)
        if self.src_radius < 0:
            raise ValueError('source circle radius {} is negative'
                             ''.format(src_radius))
        self._det_radius = float(det_radius)
        if self.det_radius < 0:
            raise ValueError('detector circle radius {} is negative'
                             ''.format(det_radius))

        if self.src_radius == 0 and self.det_radius == 0:
            raise ValueError('source and detector circle radii cannot both be '
                             '0')
예제 #19
0
    def __init__(self, apart, dpart, src_radius, det_radius, pitch,
                 axis=[0, 0, 1], **kwargs):
        """Initialize a new instance.

        Parameters
        ----------
        apart : 1-dim. `RectPartition`
            Partition of the angle interval
        dpart : 2-dim. `RectPartition`
            Partition of the detector parameter rectangle
        src_radius : nonnegative float
            Radius of the source circle
        det_radius : nonnegative float
            Radius of the detector circle
        pitch : float
            Constant vertical distance that a point on the helix
            traverses when increasing the angle parameter by ``2 * pi``
        axis : `array-like`, shape ``(3,)``, optional
            Fixed rotation axis, the symmetry axis of the helix

        Other Parameters
        ----------------
        src_to_det_init : `array-like`, shape ``(2,)``, optional
            Initial state of the vector pointing from source to detector
            reference point. The zero vector is not allowed.
            By default, a `perpendicular_vector` to ``axis`` is used.
        det_init_axes : 2-tuple of `array-like`'s (shape ``(2,)``), optional
            Initial axes defining the detector orientation.
            By default, the normalized cross product of ``axis`` and
            ``src_to_det_init`` is used as first axis and ``axis`` as
            second.
        pitch_offset : float, optional
            Offset along the ``axis`` at ``angle=0``
        """
        AxisOrientedGeometry.__init__(self, axis)

        src_to_det_init = kwargs.pop('src_to_det_init',
                                     perpendicular_vector(self.axis))

        if np.linalg.norm(src_to_det_init) <= 1e-10:
            raise ValueError('initial source to detector vector {} is too '
                             'close to zero'.format(src_to_det_init))
        self._src_to_det_init = (np.array(src_to_det_init) /
                                 np.linalg.norm(src_to_det_init))

        det_init_axes = kwargs.pop('det_init_axes', None)
        if det_init_axes is None:
            det_init_axis_0 = np.cross(self.axis, self._src_to_det_init)
            det_init_axes = (det_init_axis_0, axis)

        detector = Flat2dDetector(dpart, det_init_axes)

        super().__init__(ndim=3, motion_part=apart, detector=detector)

        self._pitch = float(pitch)
        self._pitch_offset = float(kwargs.pop('pitch_offset', 0))
        self._src_radius = float(src_radius)
        if self.src_radius < 0:
            raise ValueError('source circle radius {} is negative'
                             ''.format(src_radius))
        self._det_radius = float(det_radius)
        if self.det_radius < 0:
            raise ValueError('detector circle radius {} is negative'
                             ''.format(det_radius))

        if self.src_radius == 0 and self.det_radius == 0:
            raise ValueError('source and detector circle radii cannot both be '
                             '0')