Ejemplo n.º 1
0
    def applyAmplitude(self, signal, userTimeAll_s, noiseParams):
        '''
    Applies amplitude modulation to signal.

    This method applies polynomial modulation.

    Parameters
    ----------
    signal : numpy.ndarray
      Signal sample vector. Each element defines signal amplitude in range
      [-1; +1]. This vector is modified in place.
    userTimeAll_s : numpy.ndarray
      Sample time vector. Each element defines sample time in seconds.
    noiseParams : NoiseParameters
      Noise parameters to adjust signal amplitude level.

    Returns
    -------
    numpy.ndarray
      Array with output samples
    '''

        poly = self.poly
        if poly is not None:
            amplitudeVector = poly(userTimeAll_s)
            amplitudeVector = AmplitudeBase.convertUnits2Amp(
                amplitudeVector, self.units, noiseParams)
            signal *= amplitudeVector
        else:
            amplitude = AmplitudeBase.convertUnits2Amp(1., self.units,
                                                       noiseParams)
            signal *= amplitude

        return signal
Ejemplo n.º 2
0
def test_AmplitudeBase_convertVolts():
    '''
  Generic tests for AmplitudeBase conversion to volts
  '''
    noiseParams = NoiseParameters(1e6, 1.)
    assert 4. == AmplitudeBase.convertUnits2Amp(4.,
                                                AmplitudeBase.UNITS_AMPLITUDE,
                                                noiseParams)
    assert 2. == AmplitudeBase.convertUnits2Amp(4., AmplitudeBase.UNITS_POWER,
                                                noiseParams)
    assert 20. == AmplitudeBase.convertUnits2Amp(100, AmplitudeBase.UNITS_SNR,
                                                 noiseParams)
    assert 2. == AmplitudeBase.convertUnits2Amp(0., AmplitudeBase.UNITS_SNR_DB,
                                                noiseParams)
Ejemplo n.º 3
0
  def applyAmplitude(self, signal, userTimeAll_s, noiseParams):
    '''
    Applies amplitude modulation to signal.

    Parameters
    ----------
    signal : numpy.ndarray
      Signal sample vector. Each element defines signal amplitude in range
      [-1; +1]. This vector is modified in place.
    userTimeAll_s : numpy.ndarray
      Sample time vector. Each element defines sample time in seconds.
    noiseParams : NoiseParameters
      Noise parameters to adjust signal amplitude level.

    Returns
    -------
    numpy.ndarray
      Array with output samples
    '''

    ampAll = numpy.sin(userTimeAll_s * self.c) * self.amplitude + self.initial

    ampAll = AmplitudeBase.convertUnits2Amp(ampAll,
                                            self.units,
                                            noiseParams)
    signal *= ampAll

    return signal
Ejemplo n.º 4
0
def test_AmplitudeBase_convertVolts():
  '''
  Generic tests for AmplitudeBase conversion to volts
  '''
  noiseParams = NoiseParameters(1e6, 1.)
  assert 4. == AmplitudeBase.convertUnits2Amp(4.,
                                              AmplitudeBase.UNITS_AMPLITUDE,
                                              noiseParams)
  assert 2. == AmplitudeBase.convertUnits2Amp(4.,
                                              AmplitudeBase.UNITS_POWER,
                                              noiseParams)
  assert 20. == AmplitudeBase.convertUnits2Amp(100,
                                               AmplitudeBase.UNITS_SNR,
                                               noiseParams)
  assert 2. == AmplitudeBase.convertUnits2Amp(0.,
                                              AmplitudeBase.UNITS_SNR_DB,
                                              noiseParams)
Ejemplo n.º 5
0
  def applyAmplitude(self, signal, userTimeAll_s, noiseParams):
    '''
    Applies amplitude modulation to signal.

    This method applies polynomial modulation.

    Parameters
    ----------
    signal : numpy.ndarray
      Signal sample vector. Each element defines signal amplitude in range
      [-1; +1]. This vector is modified in place.
    userTimeAll_s : numpy.ndarray
      Sample time vector. Each element defines sample time in seconds.
    noiseParams : NoiseParameters
      Noise parameters to adjust signal amplitude level.

    Returns
    -------
    numpy.ndarray
      Array with output samples
    '''

    poly = self.poly
    if poly is not None:
      amplitudeVector = poly(userTimeAll_s)
      amplitudeVector = AmplitudeBase.convertUnits2Amp(amplitudeVector,
                                                       self.units,
                                                       noiseParams)
      signal *= amplitudeVector
    else:
      amplitude = AmplitudeBase.convertUnits2Amp(1.,
                                                 self.units,
                                                 noiseParams)
      signal *= amplitude

    return signal