Exemplo n.º 1
0
 def set_orientation(self, value):
     if isinstance(value, (list, N.ndarray)):
         value = N.asarray(value)
         # find quaternion for rotation
         n = N.cross([0, 0, 1], unit_vector(value[:3]))
         phi = N.arccos(N.dot([0, 0, 1], unit_vector(value[:3])))
         self._orientation = quaternion_about_axis(phi, n)
     elif value is True:
         # random orientation
         self._orientation = random_quaternion()
     else:
         # other stuff goes no orientation
         self._orientation = False
Exemplo n.º 2
0
 def set_orientation(self, value):
     if isinstance(value, (list, N.ndarray)):
         value = N.asarray(value)
         # find quaternion for rotation
         n = N.cross([0, 0, 1], unit_vector(value[:3]))
         phi = N.arccos(N.dot([0, 0, 1], unit_vector(value[:3])))
         self._orientation = quaternion_about_axis(phi, n)
     elif value is True:
         # random orientation
         self._orientation = random_quaternion()
     else:
         # other stuff goes no orientation
         self._orientation = False
Exemplo n.º 3
0
    def __init__(self, **kwargs):
        """
        :Keywords:
            snr : float
                Signal to Noise Ratio (SNR) for the noise process.
                Default=1.0
            noise : bool
                If False, do not setup noise generator. For setup in subclass
                Default=True
        """

        # super
        super(Recorder, self).__init__(**kwargs)

        # members
        self._origin = self.position.copy()
        if self.points is None:
            self.nchan = 1
        else:
            self.nchan = self.points.shape[0]
        self._noise_gen = None
        self._snr = None
        traj = kwargs.get('orientation', N.asarray([0.0, 0.0, 1.0]))
        if traj is True or traj is False:
            traj = [0.0, 0.0, 1.0]
        self._trajectory = unit_vector(traj)
        self._trajectory_pos = None

        # set from kwargs
        self.snr = kwargs.get('snr', 1.0)
        self.trajectory_pos = 0.0
        noise = kwargs.get('noise', True)
        if noise is True:
            self._noise_gen = NoiseGen(mu=N.zeros(self.nchan))