Esempio n. 1
0
def test_Task_computeTcxoVector1():
    '''
  Task object TCXO helper test
  '''
    outputConfig = NormalRateConfig
    sv0 = GPSSatellite(1)
    sv0.setL1CAEnabled(True)
    signalSources = [sv0]
    noiseParams = NoiseParameters(outputConfig.SAMPLE_RATE_HZ, 1.)
    tcxo = None
    signalFilters = [None] * 4
    groupDelays = False
    bands = [outputConfig.GPS.L1]
    generateDebug = False

    task = Task(outputConfig, signalSources, noiseParams, tcxo, signalFilters,
                groupDelays, bands, generateDebug)
    userTime0_s = 123.
    nSamples = 1024
    firstSampleIndex = 1
    task.update(userTime0_s, nSamples, firstSampleIndex)

    tcxo = task.computeTcxoVector()
    # TCXO object is None because TCXO function is not provided
    assert tcxo is None
Esempio n. 2
0
def test_Task_computeGroupTimeVectors1():
  '''
  Task object group time vector test
  '''
  outputConfig = NormalRateConfig
  sv0 = GPSSatellite(1)
  sv0.setL1CAEnabled(True)
  signalSources = [sv0]
  noiseParams = NoiseParameters(outputConfig.SAMPLE_RATE_HZ, 1.)
  tcxo = TCXOPoly((1.,))
  signalFilters = [None] * 4
  groupDelays = True
  bands = [outputConfig.GPS.L1]
  generateDebug = False

  task = Task(outputConfig,
              signalSources,
              noiseParams,
              tcxo,
              signalFilters,
              groupDelays,
              bands,
              generateDebug)
  nSamples = 1024
  userTime0_s = 0.
  firstSampleIndex = 1
  task.update(userTime0_s, nSamples, firstSampleIndex)
  userTimeAll_s = task.computeTimeVector()
  result = task.computeGroupTimeVectors(userTimeAll_s)
  assert isinstance(result, list)
  for i in range(outputConfig.N_GROUPS):
    assert (result[i] == userTimeAll_s + outputConfig.GROUP_DELAYS[i]).all()
Esempio n. 3
0
def test_Task_generate1():
    '''
  Task object generation test
  '''
    outputConfig = HighRateConfig
    sv0 = GPSSatellite(1)
    sv0.setL1CAEnabled(True)
    signalSources = [sv0]
    noiseParams = NoiseParameters(outputConfig.SAMPLE_RATE_HZ, 1.)
    tcxo = None
    signalFilters = [None] * 4
    groupDelays = True
    bands = [outputConfig.GPS.L1]
    generateDebug = True

    task = Task(outputConfig, signalSources, noiseParams, tcxo, signalFilters,
                groupDelays, bands, generateDebug)
    nSamples = 1024
    userTime0_s = 0.
    firstSampleIndex = 1
    task.update(userTime0_s, nSamples, firstSampleIndex)
    inputParams, sigs, debugData = task.perform()
    assert inputParams[0] == userTime0_s
    assert inputParams[1] == nSamples
    assert inputParams[2] == firstSampleIndex
    assert isinstance(debugData, dict)
    assert sigs.shape == (outputConfig.N_GROUPS, nSamples)
Esempio n. 4
0
def test_Task_update1():
    '''
  Task object parameter update test
  '''
    outputConfig = NormalRateConfig
    sv0 = GPSSatellite(1)
    sv0.setL1CAEnabled(True)
    signalSources = [sv0]
    noiseParams = NoiseParameters(outputConfig.SAMPLE_RATE_HZ, 1.)
    tcxo = TCXOPoly(())
    signalFilters = [None] * 4
    groupDelays = False
    bands = [outputConfig.GPS.L1]
    generateDebug = False

    task = Task(outputConfig, signalSources, noiseParams, tcxo, signalFilters,
                groupDelays, bands, generateDebug)

    userTime0_s = 123.
    nSamples = 1024
    firstSampleIndex = 1
    task.update(userTime0_s, nSamples, firstSampleIndex)
    assert task.nSamples == nSamples
    assert task.firstSampleIndex == firstSampleIndex
    assert task.userTime0_s == userTime0_s
    assert task.noise.shape == (outputConfig.N_GROUPS, nSamples)
    assert isinstance(task.signals, numpy.ndarray)
    assert task.signals.shape == (outputConfig.N_GROUPS, nSamples)
Esempio n. 5
0
def test_Task_computeGroupTimeVectors1():
    '''
  Task object group time vector test
  '''
    outputConfig = NormalRateConfig
    sv0 = GPSSatellite(1)
    sv0.setL1CAEnabled(True)
    signalSources = [sv0]
    noiseParams = NoiseParameters(outputConfig.SAMPLE_RATE_HZ, 1.)
    tcxo = TCXOPoly((1., ))
    signalFilters = [None] * 4
    groupDelays = True
    bands = [outputConfig.GPS.L1]
    generateDebug = False

    task = Task(outputConfig, signalSources, noiseParams, tcxo, signalFilters,
                groupDelays, bands, generateDebug)
    nSamples = 1024
    userTime0_s = 0.
    firstSampleIndex = 1
    task.update(userTime0_s, nSamples, firstSampleIndex)
    userTimeAll_s = task.computeTimeVector()
    result = task.computeGroupTimeVectors(userTimeAll_s)
    assert isinstance(result, list)
    for i in range(outputConfig.N_GROUPS):
        assert (result[i] == userTimeAll_s +
                outputConfig.GROUP_DELAYS[i]).all()
Esempio n. 6
0
def test_Task_generate0():
    '''
  Task object generation test
  '''
    outputConfig = HighRateConfig
    sv0 = GPSSatellite(1)
    sv0.setL1CAEnabled(True)
    signalSources = [sv0]
    noiseParams = NoiseParameters(outputConfig.SAMPLE_RATE_HZ, 1.)
    tcxo = TCXOPoly((1., ))
    signalFilters = [
        LowPassFilter(outputConfig,
                      outputConfig.GPS.L1.INTERMEDIATE_FREQUENCY_HZ), None,
        None, None
    ]
    groupDelays = True
    bands = [outputConfig.GPS.L1]
    generateDebug = False

    task = Task(outputConfig, signalSources, noiseParams, tcxo, signalFilters,
                groupDelays, bands, generateDebug)
    nSamples = 1024
    userTime0_s = 0.
    firstSampleIndex = 1
    task.update(userTime0_s, nSamples, firstSampleIndex)
    inputParams, sigs, debugData = task.perform()
    assert inputParams[0] == userTime0_s
    assert inputParams[1] == nSamples
    assert inputParams[2] == firstSampleIndex
    assert debugData is None
    assert sigs.shape == (outputConfig.N_GROUPS, nSamples)
Esempio n. 7
0
def test_Task_init():
    '''
  Task object initialization test
  '''
    outputConfig = NormalRateConfig
    sv0 = GPSSatellite(1)
    sv0.setL1CAEnabled(True)
    signalSources = [sv0]
    noiseParams = NoiseParameters(outputConfig.SAMPLE_RATE_HZ, 1.)
    tcxo = TCXOPoly(())
    signalFilters = [None] * 4
    groupDelays = False
    bands = [outputConfig.GPS.L1]
    generateDebug = False

    task = Task(outputConfig, signalSources, noiseParams, tcxo, signalFilters,
                groupDelays, bands, generateDebug)

    assert task.outputConfig == outputConfig
    assert task.bands == bands
    assert task.generateDebug == generateDebug
    assert task.groupDelays == groupDelays
    assert task.noiseParams == noiseParams
    assert task.signalFilters == signalFilters
    assert task.signalSources == signalSources
    assert task.tcxo == tcxo
    assert isinstance(task.noise, numpy.ndarray)
    assert task.noise.shape == (outputConfig.N_GROUPS,
                                outputConfig.SAMPLE_BATCH_SIZE)
    assert isinstance(task.signals, numpy.ndarray)
    assert task.signals.shape == (outputConfig.N_GROUPS,
                                  outputConfig.SAMPLE_BATCH_SIZE)
Esempio n. 8
0
def test_Task_createNoise():
    '''
  Task object noise helper test
  '''
    outputConfig = NormalRateConfig
    sv0 = GPSSatellite(1)
    sv0.setL1CAEnabled(True)
    signalSources = [sv0]
    noiseParams = NoiseParameters(outputConfig.SAMPLE_RATE_HZ, 1.)
    tcxo = TCXOPoly((1., ))
    signalFilters = [None] * 4
    groupDelays = False
    bands = [outputConfig.GPS.L1]
    generateDebug = False

    task = Task(outputConfig, signalSources, noiseParams, tcxo, signalFilters,
                groupDelays, bands, generateDebug)
    userTime0_s = 123.
    nSamples = outputConfig.SAMPLE_BATCH_SIZE
    firstSampleIndex = 1
    task.update(userTime0_s, nSamples, firstSampleIndex)

    noiseMatrix = task.createNoise()
    assert isinstance(noiseMatrix, numpy.ndarray)
    assert noiseMatrix.shape == (outputConfig.N_GROUPS, nSamples)
    assert numpy.mean(noiseMatrix) < 0.1
    assert (noiseMatrix != 0.).sum() > 1000
Esempio n. 9
0
def test_Task_computeTcxoVector2():
    '''
  Task object TCXO helper test
  '''
    outputConfig = NormalRateConfig
    sv0 = GPSSatellite(1)
    sv0.setL1CAEnabled(True)
    signalSources = [sv0]
    noiseParams = NoiseParameters(outputConfig.SAMPLE_RATE_HZ, 1.)
    tcxo = TCXOPoly((1., ))
    signalFilters = [None] * 4
    groupDelays = False
    bands = [outputConfig.GPS.L1]
    generateDebug = False

    task = Task(outputConfig, signalSources, noiseParams, tcxo, signalFilters,
                groupDelays, bands, generateDebug)
    userTime0_s = 123.
    nSamples = 1024
    firstSampleIndex = 1
    task.update(userTime0_s, nSamples, firstSampleIndex)

    tcxoVector = task.computeTcxoVector()
    assert isinstance(tcxoVector, numpy.ndarray)
    assert tcxoVector.shape == (1024, )
    assert (tcxoVector != 0.).all()
Esempio n. 10
0
def test_Worker_init():
  '''
  Worker object initialization
  '''
  outputConfig = NormalRateConfig
  sv0 = GPSSatellite(1)
  sv0.setL1CAEnabled(True)
  signalSources = [sv0]
  noiseParams = NoiseParameters(outputConfig.SAMPLE_RATE_HZ, 1.)
  tcxo = None
  signalFilters = [None] * 4
  groupDelays = False
  bands = [outputConfig.GPS.L1]
  generateDebug = False

  worker = Worker(outputConfig,
                  signalSources,
                  noiseParams,
                  tcxo,
                  signalFilters,
                  groupDelays,
                  bands,
                  generateDebug)
  assert worker.totalWaitTime_s == 0.
  assert worker.totalExecTime_s == 0.
  assert worker.outputConfig == outputConfig
  assert worker.signalSources == signalSources
  assert worker.noiseParams == noiseParams
  assert worker.tcxo == tcxo
  assert worker.signalFilters == signalFilters
  assert worker.groupDelays == groupDelays
  assert worker.bands == bands
  assert worker.generateDebug == generateDebug
Esempio n. 11
0
def test_Task_createNoise():
  '''
  Task object noise helper test
  '''
  outputConfig = NormalRateConfig
  sv0 = GPSSatellite(1)
  sv0.setL1CAEnabled(True)
  signalSources = [sv0]
  noiseParams = NoiseParameters(outputConfig.SAMPLE_RATE_HZ, 1.)
  tcxo = TCXOPoly((1.,))
  signalFilters = [None] * 4
  groupDelays = False
  bands = [outputConfig.GPS.L1]
  generateDebug = False

  task = Task(outputConfig,
              signalSources,
              noiseParams,
              tcxo,
              signalFilters,
              groupDelays,
              bands,
              generateDebug)
  userTime0_s = 123.
  nSamples = outputConfig.SAMPLE_BATCH_SIZE
  firstSampleIndex = 1
  task.update(userTime0_s, nSamples, firstSampleIndex)

  noiseMatrix = task.createNoise()
  assert isinstance(noiseMatrix, numpy.ndarray)
  assert noiseMatrix.shape == (outputConfig.N_GROUPS, nSamples)
  assert numpy.mean(noiseMatrix) < 0.1
  assert (noiseMatrix != 0.).sum() > 1000
Esempio n. 12
0
def test_Task_generate1():
  '''
  Task object generation test
  '''
  outputConfig = HighRateConfig
  sv0 = GPSSatellite(1)
  sv0.setL1CAEnabled(True)
  signalSources = [sv0]
  noiseParams = NoiseParameters(outputConfig.SAMPLE_RATE_HZ, 1.)
  tcxo = None
  signalFilters = [None] * 4
  groupDelays = True
  bands = [outputConfig.GPS.L1]
  generateDebug = True

  task = Task(outputConfig,
              signalSources,
              noiseParams,
              tcxo,
              signalFilters,
              groupDelays,
              bands,
              generateDebug)
  nSamples = 1024
  userTime0_s = 0.
  firstSampleIndex = 1
  task.update(userTime0_s, nSamples, firstSampleIndex)
  inputParams, sigs, debugData = task.perform()
  assert inputParams[0] == userTime0_s
  assert inputParams[1] == nSamples
  assert inputParams[2] == firstSampleIndex
  assert isinstance(debugData, dict)
  assert sigs.shape == (outputConfig.N_GROUPS, nSamples)
Esempio n. 13
0
def test_Task_computeTcxoVector1():
  '''
  Task object TCXO helper test
  '''
  outputConfig = NormalRateConfig
  sv0 = GPSSatellite(1)
  sv0.setL1CAEnabled(True)
  signalSources = [sv0]
  noiseParams = NoiseParameters(outputConfig.SAMPLE_RATE_HZ, 1.)
  tcxo = None
  signalFilters = [None] * 4
  groupDelays = False
  bands = [outputConfig.GPS.L1]
  generateDebug = False

  task = Task(outputConfig,
              signalSources,
              noiseParams,
              tcxo,
              signalFilters,
              groupDelays,
              bands,
              generateDebug)
  userTime0_s = 123.
  nSamples = 1024
  firstSampleIndex = 1
  task.update(userTime0_s, nSamples, firstSampleIndex)

  tcxo = task.computeTcxoVector()
  # TCXO object is None because TCXO function is not provided
  assert tcxo is None
Esempio n. 14
0
def test_Task_computeTcxoVector2():
  '''
  Task object TCXO helper test
  '''
  outputConfig = NormalRateConfig
  sv0 = GPSSatellite(1)
  sv0.setL1CAEnabled(True)
  signalSources = [sv0]
  noiseParams = NoiseParameters(outputConfig.SAMPLE_RATE_HZ, 1.)
  tcxo = TCXOPoly((1.,))
  signalFilters = [None] * 4
  groupDelays = False
  bands = [outputConfig.GPS.L1]
  generateDebug = False

  task = Task(outputConfig,
              signalSources,
              noiseParams,
              tcxo,
              signalFilters,
              groupDelays,
              bands,
              generateDebug)
  userTime0_s = 123.
  nSamples = 1024
  firstSampleIndex = 1
  task.update(userTime0_s, nSamples, firstSampleIndex)

  tcxoVector = task.computeTcxoVector()
  assert isinstance(tcxoVector, numpy.ndarray)
  assert tcxoVector.shape == (1024,)
  assert (tcxoVector != 0.).all()
Esempio n. 15
0
def test_Worker_init():
    '''
  Worker object initialization
  '''
    outputConfig = NormalRateConfig
    sv0 = GPSSatellite(1)
    sv0.setL1CAEnabled(True)
    signalSources = [sv0]
    noiseParams = NoiseParameters(outputConfig.SAMPLE_RATE_HZ, 1.)
    tcxo = None
    signalFilters = [None] * 4
    groupDelays = False
    bands = [outputConfig.GPS.L1]
    generateDebug = False

    worker = Worker(outputConfig, signalSources, noiseParams, tcxo,
                    signalFilters, groupDelays, bands, generateDebug)
    assert worker.totalWaitTime_s == 0.
    assert worker.totalExecTime_s == 0.
    assert worker.outputConfig == outputConfig
    assert worker.signalSources == signalSources
    assert worker.noiseParams == noiseParams
    assert worker.tcxo == tcxo
    assert worker.signalFilters == signalFilters
    assert worker.groupDelays == groupDelays
    assert worker.bands == bands
    assert worker.generateDebug == generateDebug
Esempio n. 16
0
def test_Task_update1():
  '''
  Task object parameter update test
  '''
  outputConfig = NormalRateConfig
  sv0 = GPSSatellite(1)
  sv0.setL1CAEnabled(True)
  signalSources = [sv0]
  noiseParams = NoiseParameters(outputConfig.SAMPLE_RATE_HZ, 1.)
  tcxo = TCXOPoly(())
  signalFilters = [None] * 4
  groupDelays = False
  bands = [outputConfig.GPS.L1]
  generateDebug = False

  task = Task(outputConfig,
              signalSources,
              noiseParams,
              tcxo,
              signalFilters,
              groupDelays,
              bands,
              generateDebug)

  userTime0_s = 123.
  nSamples = 1024
  firstSampleIndex = 1
  task.update(userTime0_s, nSamples, firstSampleIndex)
  assert task.nSamples == nSamples
  assert task.firstSampleIndex == firstSampleIndex
  assert task.userTime0_s == userTime0_s
  assert task.noise.shape == (outputConfig.N_GROUPS, nSamples)
  assert isinstance(task.signals, numpy.ndarray)
  assert task.signals.shape == (outputConfig.N_GROUPS,  nSamples)
Esempio n. 17
0
def test_Task_generate0():
  '''
  Task object generation test
  '''
  outputConfig = HighRateConfig
  sv0 = GPSSatellite(1)
  sv0.setL1CAEnabled(True)
  signalSources = [sv0]
  noiseParams = NoiseParameters(outputConfig.SAMPLE_RATE_HZ, 1.)
  tcxo = TCXOPoly((1.,))
  signalFilters = [LowPassFilter(outputConfig,
                                 outputConfig.GPS.L1.INTERMEDIATE_FREQUENCY_HZ),
                   None, None, None]
  groupDelays = True
  bands = [outputConfig.GPS.L1]
  generateDebug = False

  task = Task(outputConfig,
              signalSources,
              noiseParams,
              tcxo,
              signalFilters,
              groupDelays,
              bands,
              generateDebug)
  nSamples = 1024
  userTime0_s = 0.
  firstSampleIndex = 1
  task.update(userTime0_s, nSamples, firstSampleIndex)
  inputParams, sigs, debugData = task.perform()
  assert inputParams[0] == userTime0_s
  assert inputParams[1] == nSamples
  assert inputParams[2] == firstSampleIndex
  assert debugData is None
  assert sigs.shape == (outputConfig.N_GROUPS, nSamples)
Esempio n. 18
0
def test_Task_runOnce0():
  '''
  Worker object loop cycle test
  '''
  class MyQueue(object):

    def __init__(self):
      self.queue = []

    def get(self):
      return self.queue.pop(0)

    def put(self, obj):
      return self.queue.append(obj)

  outputConfig = NormalRateConfig
  sv0 = GPSSatellite(1)
  sv0.setL1CAEnabled(True)
  signalSources = [sv0]
  noiseParams = NoiseParameters(outputConfig.SAMPLE_RATE_HZ, 1.)
  tcxo = None
  signalFilters = [None] * 4
  groupDelays = False
  bands = [outputConfig.GPS.L1]
  generateDebug = False

  worker = Worker(outputConfig,
                  signalSources,
                  noiseParams,
                  tcxo,
                  signalFilters,
                  groupDelays,
                  bands,
                  generateDebug)
  # worker.start()
  worker.queueIn = MyQueue()
  worker.queueOut = MyQueue()
  nSamples = 1024
  userTime0_s = 0.
  firstSampleIndex = 1l
  params = (userTime0_s, nSamples, firstSampleIndex)
  worker.queueIn.put(params)
  task = worker.createTask()
  worker.run_once(task)
  result = worker.queueOut.get()
  (inputParams, signalSamples, debugData) = result
  assert inputParams[0] == userTime0_s
  assert inputParams[1] == nSamples
  assert inputParams[2] == firstSampleIndex
  assert debugData is None
  assert signalSamples.shape == (outputConfig.N_GROUPS, nSamples)
  worker.queueIn.put(None)
  worker.run_once(task)
  worker.queueOut.get()
Esempio n. 19
0
def test_computeEnabledBands2():
    '''
  Bands selection test
  '''
    sv0 = GPSSatellite(1)
    sv0.setL2CEnabled(True)
    sv1 = GLOSatellite(0)
    sv1.setL1Enabled(True)
    bandMap = computeEnabledBands([sv0, sv1], NormalRateConfig)
    assert bandMap[NormalRateConfig.GPS.L1.NAME] == False
    assert bandMap[NormalRateConfig.GPS.L2.NAME] == True
    assert bandMap[NormalRateConfig.GLONASS.L1.NAME] == True
    assert bandMap[NormalRateConfig.GLONASS.L2.NAME] == False
Esempio n. 20
0
def test_GPSSV_messages():
    '''
  GPS SV messages test
  '''
    sv = GPSSatellite(1)
    assert sv.l1caMessage == sv.getL1CAMessage()
    assert sv.l2cMessage == sv.getL2CMessage()
    lnav = LNavMessage(1)
    cnav = CNavMessage(1)
    sv.setL1CAMessage(lnav)
    sv.setL2CMessage(cnav)
    assert sv.l1caMessage == sv.getL1CAMessage() == lnav
    assert sv.l2cMessage == sv.getL2CMessage() == cnav
Esempio n. 21
0
def test_generateSamples0():
  '''
  Sample generation test:
  - GPS L1/L2
  - Noise sigma defined
  - Band pass filter type
  - No group delays
  - No process spawning
  '''
  outputFile = file('/dev/null', 'wt')
  logFile = file('/dev/null', 'wt')

  sv0 = GPSSatellite(1)
  sv0.setL1CAEnabled(True)
  sv0.setL2CEnabled(True)
  sv_list = [sv0]

  outputConfig = HighRateConfig
  encoder = GPSL1L2BitEncoder(outputConfig)
  time0S = 0.
  nSamples = HighRateConfig.SAMPLE_BATCH_SIZE + 10000
  noiseSigma = 1.
  tcxo = None
  filterType = 'bandpass'
  groupDelays = False
  threadCount = 0

  class Pbar(object):

    def update(self, value):
      pass

  pbar = Pbar()

  # Execute main sample generation function with all supported SV types and
  # bands. An error shall lead to the test failure.
  # This time execution is performed in the test process.
  generateSamples(outputFile,
                  sv_list,
                  encoder,
                  time0S,
                  nSamples,
                  outputConfig,
                  noiseSigma,
                  tcxo,
                  filterType,
                  groupDelays,
                  logFile,
                  threadCount,
                  pbar)
Esempio n. 22
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)
Esempio n. 23
0
def test_Task_runOnce0():
    '''
  Worker object loop cycle test
  '''
    class MyQueue(object):
        def __init__(self):
            self.queue = []

        def get(self):
            return self.queue.pop(0)

        def put(self, obj):
            return self.queue.append(obj)

    outputConfig = NormalRateConfig
    sv0 = GPSSatellite(1)
    sv0.setL1CAEnabled(True)
    signalSources = [sv0]
    noiseParams = NoiseParameters(outputConfig.SAMPLE_RATE_HZ, 1.)
    tcxo = None
    signalFilters = [None] * 4
    groupDelays = False
    bands = [outputConfig.GPS.L1]
    generateDebug = False

    worker = Worker(outputConfig, signalSources, noiseParams, tcxo,
                    signalFilters, groupDelays, bands, generateDebug)
    # worker.start()
    worker.queueIn = MyQueue()
    worker.queueOut = MyQueue()
    nSamples = 1024
    userTime0_s = 0.
    firstSampleIndex = 1l
    params = (userTime0_s, nSamples, firstSampleIndex)
    worker.queueIn.put(params)
    task = worker.createTask()
    worker.run_once(task)
    result = worker.queueOut.get()
    (inputParams, signalSamples, debugData) = result
    assert inputParams[0] == userTime0_s
    assert inputParams[1] == nSamples
    assert inputParams[2] == firstSampleIndex
    assert debugData is None
    assert signalSamples.shape == (outputConfig.N_GROUPS, nSamples)
    worker.queueIn.put(None)
    worker.run_once(task)
    worker.queueOut.get()
Esempio n. 24
0
def test_GPSSV_messages():
  '''
  GPS SV messages test
  '''
  sv = GPSSatellite(1)
  assert sv.l1caMessage == sv.getL1CAMessage()
  assert sv.l2cMessage == sv.getL2CMessage()
  lnav = LNavMessage(1)
  cnav = CNavMessage(1)
  sv.setL1CAMessage(lnav)
  sv.setL2CMessage(cnav)
  assert sv.l1caMessage == sv.getL1CAMessage() == lnav
  assert sv.l2cMessage == sv.getL2CMessage() == cnav
Esempio n. 25
0
def test_GPSSV_str():
    '''
  GPS SV string representation
  '''
    sv = GPSSatellite(3)
    value = str(sv)
    assert value.find('GPS') >= 0
    assert value.find('3') >= 0
Esempio n. 26
0
def test_generateSamples1():
  '''
  Sample generation test:
  - GPS L1/L2
  - No noise
  - Low pass filter type
  - No group delays
  - Two process spawning
  '''
  outputFile = file('/dev/null', 'wt')
  logFile = file('/dev/null', 'wt')

  sv0 = GPSSatellite(1)
  sv0.setL1CAEnabled(True)
  sv0.setL2CEnabled(True)
  sv_list = [sv0]

  outputConfig = HighRateConfig
  encoder = GPSL1L2BitEncoder(outputConfig)
  time0S = 0.
  nSamples = 9999
  noiseSigma = None
  tcxo = None
  filterType = 'lowpass'
  groupDelays = False
  threadCount = 2
  pbar = None

  # Execute main sample generation function with all supported SV types and
  # bands. An error shall lead to the test failure.
  # This time execution is performed in a separate process.
  generateSamples(outputFile,
                  sv_list,
                  encoder,
                  time0S,
                  nSamples,
                  outputConfig,
                  noiseSigma,
                  tcxo,
                  filterType,
                  groupDelays,
                  logFile,
                  threadCount,
                  pbar)
Esempio n. 27
0
def test_GPSSv_init():
    '''
  GPS SV initialization test
  '''
    sv = GPSSatellite(1)
    assert isinstance(sv, SVBase)
    assert sv.prn == 1
    assert sv.svName == "GPS1"
    assert isinstance(sv.amplitude, AmplitudeBase)
    assert isinstance(sv.doppler, DopplerBase)
Esempio n. 28
0
def test_GPSSV_getBatchSignals1():
  '''
  GPS SV signal generation: not available
  '''
  sv = GPSSatellite(1)
  start = 0.
  stop = start + (100. / float(NormalRateConfig.SAMPLE_RATE_HZ))
  userTimeAll_s = numpy.linspace(
      start, stop, 100, endpoint=False, dtype=numpy.float)
  samples = numpy.zeros((2, 100))
  noiseParams = NoiseParameters(NormalRateConfig.SAMPLE_RATE_HZ, 1.0)
  result = sv.getBatchSignals(userTimeAll_s,
                              samples,
                              NormalRateConfig,
                              noiseParams,
                              NormalRateConfig.GLONASS.L1,
                              False)
  assert len(result) == 0
  # No signals are generated because SV object doesn't support GLONASS
  assert (samples == 0).all()
Esempio n. 29
0
def test_GPSSV_getBatchSignals1():
    '''
  GPS SV signal generation: not available
  '''
    sv = GPSSatellite(1)
    start = 0.
    stop = start + (100. / float(NormalRateConfig.SAMPLE_RATE_HZ))
    userTimeAll_s = numpy.linspace(start,
                                   stop,
                                   100,
                                   endpoint=False,
                                   dtype=numpy.float)
    samples = numpy.zeros((2, 100))
    noiseParams = NoiseParameters(NormalRateConfig.SAMPLE_RATE_HZ, 1.0)
    result = sv.getBatchSignals(userTimeAll_s, samples, NormalRateConfig,
                                noiseParams, NormalRateConfig.GLONASS.L1,
                                False)
    assert len(result) == 0
    # No signals are generated because SV object doesn't support GLONASS
    assert (samples == 0).all()
Esempio n. 30
0
def test_generateSamples1():
    '''
  Sample generation test:
  - GPS L1/L2
  - No noise
  - Low pass filter type
  - No group delays
  - Two process spawning
  '''
    outputFile = file('/dev/null', 'wt')
    logFile = file('/dev/null', 'wt')

    sv0 = GPSSatellite(1)
    sv0.setL1CAEnabled(True)
    sv0.setL2CEnabled(True)
    sv_list = [sv0]

    outputConfig = HighRateConfig
    encoder = GPSL1L2BitEncoder(outputConfig)
    time0S = 0.
    nSamples = 9999
    noiseSigma = None
    tcxo = None
    filterType = 'lowpass'
    groupDelays = False
    threadCount = 2
    pbar = None

    # Execute main sample generation function with all supported SV types and
    # bands. An error shall lead to the test failure.
    # This time execution is performed in a separate process.
    generateSamples(outputFile, sv_list, encoder, time0S, nSamples,
                    outputConfig, noiseSigma, tcxo, filterType, groupDelays,
                    logFile, threadCount, pbar)
Esempio n. 31
0
def test_GPSSV_getBatchSignals3():
    '''
  GPS SV signal generation: L2C
  '''
    sv = GPSSatellite(1)
    start = 0.
    stop = start + (100. / float(NormalRateConfig.SAMPLE_RATE_HZ))
    userTimeAll_s = numpy.linspace(start,
                                   stop,
                                   100,
                                   endpoint=False,
                                   dtype=numpy.float)
    samples = numpy.zeros((2, 100))
    noiseParams = NoiseParameters(NormalRateConfig.SAMPLE_RATE_HZ, 1.0)
    sv.setL2CEnabled(True)
    result = sv.getBatchSignals(userTimeAll_s, samples, NormalRateConfig,
                                noiseParams, NormalRateConfig.GPS.L2, False)
    assert len(result) == 1
    assert result[0]['type'] == 'GPSL2'
    assert result[0]['doppler'] is None
    assert (samples[0] == 0).all()
    assert (samples[1] != 0).any()
Esempio n. 32
0
def test_Task_init():
  '''
  Task object initialization test
  '''
  outputConfig = NormalRateConfig
  sv0 = GPSSatellite(1)
  sv0.setL1CAEnabled(True)
  signalSources = [sv0]
  noiseParams = NoiseParameters(outputConfig.SAMPLE_RATE_HZ, 1.)
  tcxo = TCXOPoly(())
  signalFilters = [None] * 4
  groupDelays = False
  bands = [outputConfig.GPS.L1]
  generateDebug = False

  task = Task(outputConfig,
              signalSources,
              noiseParams,
              tcxo,
              signalFilters,
              groupDelays,
              bands,
              generateDebug)

  assert task.outputConfig == outputConfig
  assert task.bands == bands
  assert task.generateDebug == generateDebug
  assert task.groupDelays == groupDelays
  assert task.noiseParams == noiseParams
  assert task.signalFilters == signalFilters
  assert task.signalSources == signalSources
  assert task.tcxo == tcxo
  assert isinstance(task.noise, numpy.ndarray)
  assert task.noise.shape == (outputConfig.N_GROUPS,
                              outputConfig.SAMPLE_BATCH_SIZE)
  assert isinstance(task.signals, numpy.ndarray)
  assert task.signals.shape == (outputConfig.N_GROUPS,
                                outputConfig.SAMPLE_BATCH_SIZE)
Esempio n. 33
0
def test_GPSSV_getBatchSignals3():
  '''
  GPS SV signal generation: L2C
  '''
  sv = GPSSatellite(1)
  start = 0.
  stop = start + (100. / float(NormalRateConfig.SAMPLE_RATE_HZ))
  userTimeAll_s = numpy.linspace(
      start, stop, 100, endpoint=False, dtype=numpy.float)
  samples = numpy.zeros((2, 100))
  noiseParams = NoiseParameters(NormalRateConfig.SAMPLE_RATE_HZ, 1.0)
  sv.setL2CEnabled(True)
  result = sv.getBatchSignals(userTimeAll_s,
                              samples,
                              NormalRateConfig,
                              noiseParams,
                              NormalRateConfig.GPS.L2,
                              False)
  assert len(result) == 1
  assert result[0]['type'] == 'GPSL2'
  assert result[0]['doppler'] is None
  assert (samples[0] == 0).all()
  assert (samples[1] != 0).any()
Esempio n. 34
0
        def __call__(self, parser, namespace, values, option_string=None):
            # Initialize SV list if not yet done
            if namespace.gps_sv is None:
                namespace.gps_sv = []

            # Add SV to the tail of the list.
            if option_string == '--gps-sv':
                sv = GPSSatellite(int(values))
            elif option_string == '--glo-sv':
                sv = GLOSatellite(int(values))
            else:
                raise ValueError("Option value is not supported: %s" %
                                 option_string)
            namespace.gps_sv.append(sv)

            # Reset all configuration parameters
            namespace.l2cl_code_type = '01'
            namespace.ignore_code_doppler = False

            # Doppler
            namespace.doppler_type = "zero"
            namespace.doppler_value = 0.
            namespace.doppler_speed = 0.
            namespace.distance = None
            namespace.tec = 50.
            namespace.doppler_amplitude = 0.
            namespace.doppler_period = 1.
            namespace.symbol_delay = None
            namespace.chip_delay = None

            # Source message data
            namespace.message_type = "zero"
            namespace.message_file = None

            # Amplitude parameters
            namespace.amplitude_type = "poly"
            namespace.amplitude_unis = "snr-db"
            namespace.amplitude_a0 = None
            namespace.amplitude_a1 = None
            namespace.amplitude_a2 = None
            namespace.amplitude_a3 = None
            namespace.amplitude_period = None
Esempio n. 35
0
def test_generateSamples0():
    '''
  Sample generation test:
  - GPS L1/L2
  - Noise sigma defined
  - Band pass filter type
  - No group delays
  - No process spawning
  '''
    outputFile = file('/dev/null', 'wt')
    logFile = file('/dev/null', 'wt')

    sv0 = GPSSatellite(1)
    sv0.setL1CAEnabled(True)
    sv0.setL2CEnabled(True)
    sv_list = [sv0]

    outputConfig = HighRateConfig
    encoder = GPSL1L2BitEncoder(outputConfig)
    time0S = 0.
    nSamples = HighRateConfig.SAMPLE_BATCH_SIZE + 10000
    noiseSigma = 1.
    tcxo = None
    filterType = 'bandpass'
    groupDelays = False
    threadCount = 0

    class Pbar(object):
        def update(self, value):
            pass

    pbar = Pbar()

    # Execute main sample generation function with all supported SV types and
    # bands. An error shall lead to the test failure.
    # This time execution is performed in the test process.
    generateSamples(outputFile, sv_list, encoder, time0S, nSamples,
                    outputConfig, noiseSigma, tcxo, filterType, groupDelays,
                    logFile, threadCount, pbar)
Esempio n. 36
0
def test_GPSSV_bands():
    '''
  GPS SV band configurations
  '''
    sv = GPSSatellite(1)
    assert not sv.isBandEnabled(NormalRateConfig.GPS.L1, NormalRateConfig)
    assert not sv.isBandEnabled(NormalRateConfig.GPS.L2, NormalRateConfig)
    assert not sv.isBandEnabled(NormalRateConfig.GLONASS.L1, NormalRateConfig)
    assert not sv.isBandEnabled(NormalRateConfig.GLONASS.L2, NormalRateConfig)
    assert not sv.isL1CAEnabled()
    assert not sv.isL2CEnabled()
    sv.setL1CAEnabled(True)
    assert sv.isBandEnabled(NormalRateConfig.GPS.L1, NormalRateConfig)
    assert not sv.isBandEnabled(NormalRateConfig.GPS.L2, NormalRateConfig)
    assert sv.isL1CAEnabled()
    assert not sv.isL2CEnabled()
    sv.setL2CEnabled(True)
    sv.setL1CAEnabled(False)
    assert not sv.isBandEnabled(NormalRateConfig.GPS.L1, NormalRateConfig)
    assert sv.isBandEnabled(NormalRateConfig.GPS.L2, NormalRateConfig)
    assert not sv.isL1CAEnabled()
    assert sv.isL2CEnabled()
Esempio n. 37
0
 def __MapTo_GPSSatellite(self, data):
     prn = data['prn']
     doppler = dopplerOF.fromMapForm(data['doppler'])
     amplitude = amplitudeOF.fromMapForm(data['amplitude'])
     l1caEnabled = data['l1caEnabled']
     l2cEnabled = data['l2cEnabled']
     l1caMessage = messageOF.fromMapForm(data['l1caMessage'])
     l2cMessage = messageOF.fromMapForm(data['l2cMessage'])
     clCodeType = data['l2clCodeType']
     codeDopplerIgnored = data['codeDopplerIgnored']
     satellite = GPSSatellite(prn)
     satellite.setAmplitude(amplitude)
     satellite.setDoppler(doppler)
     satellite.setL1CAEnabled(l1caEnabled)
     satellite.setL2CEnabled(l2cEnabled)
     satellite.setL1CAMessage(l1caMessage)
     satellite.setL2CMessage(l2cMessage)
     satellite.setL2CLCodeType(clCodeType)
     satellite.setCodeDopplerIgnored(codeDopplerIgnored)
     return satellite
Esempio n. 38
0
def test_GPSSV_l2clCodeType():
    '''
  GPS SV L2CL code variants
  '''
    sv = GPSSatellite(1)
    sv.setL2CLCodeType('0')
    assert sv.l2clCodeType == '0'
    prn = sv.l2clCodeType
    sv.setL2CLCodeType('0')
    assert sv.l2clCodeType == '0' == sv.getL2CLCodeType()
    assert prn == sv.l2clCodeType
    assert (sv.l2cCode.binCode[1::2] == 0).all()
    sv.setL2CLCodeType('1')
    assert sv.l2clCodeType == '1' == sv.getL2CLCodeType()
    assert prn != sv.l2clCodeType
    assert (sv.l2cCode.binCode[1::2] == 1).all()
    prn = sv.l2clCodeType
    sv.setL2CLCodeType('01')
    assert sv.l2clCodeType == '01' == sv.getL2CLCodeType()
    assert prn != sv.l2clCodeType
    assert (sv.l2cCode.binCode[1::4] == 0).all()
    assert (sv.l2cCode.binCode[3::4] == 1).all()
Esempio n. 39
0
def test_GPSSV_bands():
  '''
  GPS SV band configurations
  '''
  sv = GPSSatellite(1)
  assert not sv.isBandEnabled(NormalRateConfig.GPS.L1, NormalRateConfig)
  assert not sv.isBandEnabled(NormalRateConfig.GPS.L2, NormalRateConfig)
  assert not sv.isBandEnabled(NormalRateConfig.GLONASS.L1, NormalRateConfig)
  assert not sv.isBandEnabled(NormalRateConfig.GLONASS.L2, NormalRateConfig)
  assert not sv.isL1CAEnabled()
  assert not sv.isL2CEnabled()
  sv.setL1CAEnabled(True)
  assert sv.isBandEnabled(NormalRateConfig.GPS.L1, NormalRateConfig)
  assert not sv.isBandEnabled(NormalRateConfig.GPS.L2, NormalRateConfig)
  assert sv.isL1CAEnabled()
  assert not sv.isL2CEnabled()
  sv.setL2CEnabled(True)
  sv.setL1CAEnabled(False)
  assert not sv.isBandEnabled(NormalRateConfig.GPS.L1, NormalRateConfig)
  assert sv.isBandEnabled(NormalRateConfig.GPS.L2, NormalRateConfig)
  assert not sv.isL1CAEnabled()
  assert sv.isL2CEnabled()
Esempio n. 40
0
def test_GPSSV_l2clCodeType():
  '''
  GPS SV L2CL code variants
  '''
  sv = GPSSatellite(1)
  sv.setL2CLCodeType('0')
  assert sv.l2clCodeType == '0'
  prn = sv.l2clCodeType
  sv.setL2CLCodeType('0')
  assert sv.l2clCodeType == '0' == sv.getL2CLCodeType()
  assert prn == sv.l2clCodeType
  assert (sv.l2cCode.binCode[1::2] == 0).all()
  sv.setL2CLCodeType('1')
  assert sv.l2clCodeType == '1' == sv.getL2CLCodeType()
  assert prn != sv.l2clCodeType
  assert (sv.l2cCode.binCode[1::2] == 1).all()
  prn = sv.l2clCodeType
  sv.setL2CLCodeType('01')
  assert sv.l2clCodeType == '01' == sv.getL2CLCodeType()
  assert prn != sv.l2clCodeType
  assert (sv.l2cCode.binCode[1::4] == 0).all()
  assert (sv.l2cCode.binCode[3::4] == 1).all()
Esempio n. 41
0
 def __MapTo_GPSSatellite(self, data):
   prn = data['prn']
   doppler = dopplerOF.fromMapForm(data['doppler'])
   amplitude = amplitudeOF.fromMapForm(data['amplitude'])
   l1caEnabled = data['l1caEnabled']
   l2cEnabled = data['l2cEnabled']
   l1caMessage = messageOF.fromMapForm(data['l1caMessage'])
   l2cMessage = messageOF.fromMapForm(data['l2cMessage'])
   clCodeType = data['l2clCodeType']
   codeDopplerIgnored = data['codeDopplerIgnored']
   satellite = GPSSatellite(prn)
   satellite.setAmplitude(amplitude)
   satellite.setDoppler(doppler)
   satellite.setL1CAEnabled(l1caEnabled)
   satellite.setL2CEnabled(l2cEnabled)
   satellite.setL1CAMessage(l1caMessage)
   satellite.setL2CMessage(l2cMessage)
   satellite.setL2CLCodeType(clCodeType)
   satellite.setCodeDopplerIgnored(codeDopplerIgnored)
   return satellite