def test_AmplitudeSine_SNR0():
  '''
  Test AmplitudeSine SNR_0 computation (1.+2.*sin(2.*pi*t/1.))
  '''
  noiseParams = NoiseParameters(1e6, 1.)
  ampl = AmplitudeSine(AmplitudeBase.UNITS_AMPLITUDE, 1., 2., 1.)
  SNR = 10. * numpy.log10(noiseParams.getFreqTimesTau() / 4.)
  assert numpy.abs(SNR - ampl.computeSNR(noiseParams)) < EPSILON
def test_AmplitudeSine_SNR0():
    '''
  Test AmplitudeSine SNR_0 computation (1.+2.*sin(2.*pi*t/1.))
  '''
    noiseParams = NoiseParameters(1e6, 1.)
    ampl = AmplitudeSine(AmplitudeBase.UNITS_AMPLITUDE, 1., 2., 1.)
    SNR = 10. * numpy.log10(noiseParams.getFreqTimesTau() / 4.)
    assert numpy.abs(SNR - ampl.computeSNR(noiseParams)) < EPSILON
def test_AmplitudeSine_apply0():
  '''
  Test AmplitudeSine computation (1.+2.*sin(2.*pi*t/4.))
  '''
  noiseParams = NoiseParameters(1e6, 1.)
  ampl = AmplitudeSine(AmplitudeBase.UNITS_AMPLITUDE, 1., 2., 4.)
  userTimeAll_s = numpy.asarray([0., 1., 2.], dtype=numpy.float)
  signal = numpy.asarray([0., 1., 1.], dtype=numpy.float)
  signal = ampl.applyAmplitude(signal, userTimeAll_s, noiseParams)
  assert (numpy.abs(signal - numpy.asarray([0., 3., 1.], dtype=numpy.float))
          < EPSILON).all()
def test_AmplitudeSine_apply0():
    '''
  Test AmplitudeSine computation (1.+2.*sin(2.*pi*t/4.))
  '''
    noiseParams = NoiseParameters(1e6, 1.)
    ampl = AmplitudeSine(AmplitudeBase.UNITS_AMPLITUDE, 1., 2., 4.)
    userTimeAll_s = numpy.asarray([0., 1., 2.], dtype=numpy.float)
    signal = numpy.asarray([0., 1., 1.], dtype=numpy.float)
    signal = ampl.applyAmplitude(signal, userTimeAll_s, noiseParams)
    assert (numpy.abs(signal - numpy.asarray([0., 3., 1.], dtype=numpy.float))
            < EPSILON).all()
def test_AmplitudeSine_init():
    '''
  Test AmplitudeSine init
  '''
    ampl = AmplitudeSine(AmplitudeBase.UNITS_AMPLITUDE, 1., 2., 1.)
    assert isinstance(ampl, AmplitudeBase)
    assert ampl.units == AmplitudeBase.UNITS_AMPLITUDE
Beispiel #6
0
def test_factories():
    '''
  Test factories
  '''
    to_map_and_back(AFO, AmplitudePoly(AmplitudeBase.UNITS_AMPLITUDE, (1, )))
    to_map_and_back(AFO,
                    AmplitudeSine(AmplitudeBase.UNITS_AMPLITUDE, 1., 2., 1.))
    value_error(AFO)

    to_map_and_back(DFO, DopplerPoly(1000., 77., (1., 1.)))
    to_map_and_back(DFO, DopplerSine(1000., 55., 4., 3., 5.))
    value_error(DFO)

    to_map_and_back(MFO, BlockMessage(np.random.rand(1023)))
    to_map_and_back(MFO, CNAVMessage(1))
    to_map_and_back(MFO, ConstMessage(1))
    to_map_and_back(MFO, LNAVMessage(1))
    to_map_and_back(MFO, ZeroOneMessage())
    value_error(MFO)

    to_map_and_back(SFO, GPSSatellite(1))
    value_error(SFO)

    to_map_and_back(TFO, PolyTcxo((1., 1.)))
    to_map_and_back(TFO, SineTcxo(0., 1e6, 0.004))
    value_error(TFO)
Beispiel #7
0
        def doUpdate(self, sv, parser, namespace, values, option_string):
            amplitude_units = AMP_MAP[namespace.amplitude_units]

            if namespace.amplitude_type == "poly":
                coeffs = []
                hasHighOrder = False

                srcA = [
                    namespace.amplitude_a3, namespace.amplitude_a2,
                    namespace.amplitude_a1, namespace.amplitude_a0
                ]
                for a in srcA:
                    if a is not None:
                        coeffs.append(a)
                        hasHighOrder = True
                    elif hasHighOrder:
                        coeffs.append(0.)
                amplitude = AmplitudePoly(amplitude_units, tuple(coeffs))
            elif namespace.amplitude_type == "sine":
                initial = 1.
                ampl = 0.5
                period_s = 1.
                if namespace.amplitude_a0 is not None:
                    initial = namespace.amplitude_a0
                if namespace.amplitude_a1 is not None:
                    ampl = namespace.amplitude_a1
                if namespace.amplitude_period is not None:
                    period_s = namespace.amplitude_period

                amplitude = AmplitudeSine(amplitude_units, initial, ampl,
                                          period_s)
            else:
                raise ValueError("Unsupported amplitude type")
            sv.setAmplitude(amplitude)
Beispiel #8
0
def test_SVBase_amplitude():
    '''
  Amplitude control
  '''
    sv = SVBase("TEST_SV")
    amp = AmplitudeSine(AmplitudeBase.UNITS_POWER, 10, 15, 20)
    sv.setAmplitude(amp)
    assert sv.amplitude == amp
    assert sv.getAmplitude() == amp
def test_AmplitudeSine_str0():
    '''
  String representation test for sine amplitude object
  '''
    value = str(AmplitudeSine(AmplitudeBase.UNITS_SNR, 4., 3., 5.))
    assert value.find('SNR') >= 0
    assert value.find('4.') >= 0
    assert value.find('3.') >= 0
    assert value.find('5.') >= 0
    assert value.find('Sine') >= 0