def test(self):
     data = gpstk.Xv()
     data.x = gpstk.Triple(1.5, 2.5, 3.5)
     data.v = gpstk.Triple(500, 1000, -100)
     self.assertEqual(1.5, data.x[0])
     expected = 'x:(1.5, 2.5, 3.5), v:(500, 1000, -100)'
     self.assertEqual(expected, str(data))
예제 #2
0
 def test_ephemeris(self):
     g = gpstk.GloEphemeris()
     g.setRecord('mySys', 1, gpstk.CommonTime(), gpstk.Triple(100, 200, 300),
         gpstk.Triple(10, 20, 30), gpstk.Triple(1, 2, 3),
         0.0,  0.0, 1, 2, 3, 1.1, 1.0)
     expected = ("Sys:mySys, PRN:1, Epoch:0000000 00000000 0.000000000000000 UNK, pos:(100, 200, 300), "
         "vel:(10, 20, 30), acc:(1, 2, 3), TauN:0, GammaN:0, MFTime:1, health:2, freqNum:3, ageOfInfo:1.1")
     self.assertEqual(expected, str(g))
예제 #3
0
    def test_methods(self):
        t = gpstk.Triple(1.5, 2.0, -3.0)
        u = gpstk.Triple(10.0, 5.0, 2.0)
        self.assertEqual(15.25, t.dot(t))

        expected = gpstk.Triple(4.0, 6.0, 8.0)
        self.assertEqual(expected, gpstk.Triple(2.0, 3.0, 4.0).scale(2.0))

        self.assertAlmostEqual(3.905124837953327, t.mag())
        self.assertAlmostEqual(5.345455469884399, t.elvAngle(u))
        self.assertAlmostEqual(0.42837471052408865, t.cosVector(u))
예제 #4
0
 def test_spherical_cartesian(self):
     orig = gpstk.Triple(45.0, 30.0, 12.0)
     p = gpstk.Position.convertSphericalToCartesian(orig)
     q = gpstk.Position.convertCartesianToSpherical(p)
     self.assertAlmostEqual(45.0, q[0], places=4)
     self.assertAlmostEqual(30.0, q[1], places=4)
     self.assertAlmostEqual(12.0, q[2], places=4)
예제 #5
0
    def test(self):
        data = gpstk.Xvt()
        data.x = gpstk.Triple(1000.0, 2000.0, 1500.0)
        data.v = gpstk.Triple(50.0, 25.0, -500.0)
        data.clkbias = 0.0001
        data.clkdrift = 0.05
        data.relcorr = 0.83
        data.frame = gpstk.ReferenceFrame(gpstk.ReferenceFrame.WGS84)
        self.assertAlmostEqual(0.0001, data.getClockBias())

        expected = 1.446445072869704e-11
        self.assertAlmostEqual(expected, data.computeRelativityCorrection())

        expected = ('x:(1000, 2000, 1500), v:(50, 25, -500), clk bias:0.0001, '
                    'clk drift:0.05, relcorr:1.44645e-11')
        self.assertEqual(expected, str(data))
예제 #6
0
 def test_cartesian_geocentric(self):
     orig = gpstk.Triple(4000.0, 5000.0, 7000.0)
     p = gpstk.Position.convertCartesianToGeocentric(orig)
     q = gpstk.Position.convertGeocentricToCartesian(p)
     self.assertAlmostEqual(47.54984445710891, p[0], places=4)
     self.assertAlmostEqual(51.34019174590962, p[1], places=4)
     self.assertAlmostEqual(9486.832980505136, p[2], places=4)
     self.assertAlmostEqual(orig[0], q[0], places=4)
     self.assertAlmostEqual(orig[1], q[1], places=4)
     self.assertAlmostEqual(orig[2], q[2], places=4)
예제 #7
0
 def test_operators(self):
     a = gpstk.Triple(1.0, 2.0, 4.0)
     b = gpstk.Triple(5.0, 6.0, 5.0)
     #      +   --------------
     c = gpstk.Triple(6.0, 8.0, 9.0)
     self.assertEqual(c, a + b)
예제 #8
0
 def test_access(self):
     t = gpstk.Triple(1.5, 2.0, -3.0)
     self.assertEqual(1.5, t[0])
     self.assertEqual(2.0, t[1])
     self.assertEqual(-3.0, t[2])
예제 #9
0
 def test_copy_constructor(self):
     t = gpstk.Triple(1.0, 2.0, 3.0)
     u = gpstk.Triple(t)
     v = gpstk.Triple(1.0, 2.0, 3.0)
     self.assertTrue(t == u)
     self.assertTrue(u == v)
예제 #10
0
def process(input_file, output_file):
    try:
        print 'Reading {}.'.format(input_file)
        header, data = gpstk.readRinex3Obs(input_file)  # read in everything
        #print header

        new_header = gpstk.Rinex3ObsHeader()

        # Initially, valid = 0L, but other values get masked into it.
        new_header.version = header.version
        new_header.fileType = header.fileType
        new_header.valid = new_header.valid | gpstk.Rinex3ObsHeader.validVersion

        new_header.fileProgram = header.fileProgram
        new_header.date = header.date
        new_header.fileAgency = header.fileAgency
        new_header.valid = new_header.valid | gpstk.Rinex3ObsHeader.validRunBy

        new_header.markerName = header.markerName
        new_header.valid = new_header.valid | gpstk.Rinex3ObsHeader.validMarkerName

        new_header.observer = header.observer
        new_header.agency = header.agency
        new_header.valid = new_header.valid | gpstk.Rinex3ObsHeader.validObserver

        new_header.recNo = header.recNo
        new_header.recType = header.recType
        new_header.recVers = header.recVers
        new_header.valid = new_header.valid | gpstk.Rinex3ObsHeader.validReceiver

        new_header.antNo = header.antNo
        new_header.antType = header.antType
        new_header.valid = new_header.valid | gpstk.Rinex3ObsHeader.validAntennaType

        newAntPosition = gpstk.Triple(header.antennaPosition[0],
                                      header.antennaPosition[1],
                                      header.antennaPosition[2])
        new_header.antennaPosition = newAntPosition
        new_header.valid = new_header.valid | gpstk.Rinex3ObsHeader.validAntennaPosition

        newAntDelta = gpstk.Triple(header.antennaDeltaHEN[0],
                                   header.antennaDeltaHEN[1],
                                   header.antennaDeltaHEN[2])
        new_header.antennaDeltaHEN = newAntDelta
        new_header.valid = new_header.valid | gpstk.Rinex3ObsHeader.validAntennaDeltaHEN

        # This is kind of odd.  The Rinex3ObsHeader can handle both V3 and V2
        # formatted files.  The two versions handle observation types differently.
        # - The first structure "mapObsTypes" holds the V3 definitions in a
        # "dictionary of lists" (or "map of vectors" in c++)
        # - The second structure "R2ObsTypes" holds the V2 definitions and is
        # stored as list of strings (or Vector of Strings in c++)
        # It's not clear whether either or both are necessary to write a file.
        # It DOES seem to be clear that both will be available after reading a file.

        for rinObsType in header.mapObsTypes:
            #print "Found obs-type:{}".format(rinObsType)
            newObsIds = []
            for rinObsId in header.mapObsTypes[rinObsType]:
                #print "Found obs-id:{}".format(str(rinObsId))
                #print " --type={} code={} band={}".format(rinObsId.type, rinObsId.code, rinObsId.band)
                newObsId = gpstk.RinexObsID(str(rinObsId))
                newObsIds.append(newObsId)
            new_header.mapObsTypes[rinObsType] = tuple(newObsIds)
        new_header.valid = new_header.valid | gpstk.Rinex3ObsHeader.validNumObs

        for rin_obs_id in header.R2ObsTypes:
            #print "Found obs-id:{}".format(rin_obs_id)
            new_header.R2ObsTypes.append(rin_obs_id)
        new_header.valid = new_header.valid | gpstk.Rinex3ObsHeader.validNumObs

        # This creates a new CivilTime object that we can populate
        new_header.firstObs = gpstk.CivilTime()
        new_header.firstObs.year = header.firstObs.year
        new_header.firstObs.month = header.firstObs.month
        new_header.firstObs.day = header.firstObs.day
        new_header.firstObs.hour = header.firstObs.hour
        new_header.firstObs.minute = header.firstObs.minute
        new_header.firstObs.second = header.firstObs.second
        new_header.valid = new_header.valid | gpstk.Rinex3ObsHeader.validFirstTime

        new_header.markerNumber = header.markerNumber
        new_header.valid = new_header.valid | gpstk.Rinex3ObsHeader.validMarkerNumber

        new_header.interval = header.interval
        new_header.valid = new_header.valid | gpstk.Rinex3ObsHeader.validInterval

        #####
        # Unfortunately, sigStrengthUnit is tied to the wavelengthFactor property,
        # We cannot set the latter due to a missing SWIG Python adapter, and
        # because the same "validity flag" governs both, we can't output
        # sigStrengthUnit without inadvertently outputting a bogus wavelengthFactor.
        #####
        #new_header.wavelengthFactor = header.wavelengthFactor
        #new_header.sigStrengthUnit = header.sigStrengthUnit
        #new_header.valid = new_header.valid | gpstk.Rinex3ObsHeader.validSigStrengthUnit

        for comment in header.commentList:
            new_header.commentList.append(comment)
        new_header.valid = new_header.valid | gpstk.Rinex3ObsHeader.validComment

        new_header.validEoH = True

        # This method is a huge hack to get around a problem in the Rinex3ObsData
        # writer.  See the method for details.
        new_header = tweakInternalHeaderState(new_header)
        #print new_header

        processed_data = []
        # Now we loop through all the epochs and process the data for each one
        for d in data:

            # This creates a new CommonTime object with the system set to GPS.
            timec = gpstk.CommonTime(gpstk.TimeSystem(gpstk.TimeSystem.GPS))
            # This creates a new CommonTime object with the system set to GPS.
            mjd = int(d.time.getDays())
            sod = float(d.time.getSecondOfDay())
            timec.set(mjd, sod, gpstk.TimeSystem(gpstk.TimeSystem.GPS))

            # Assign values to a new Rinex Obs Data object
            nd = gpstk.Rinex3ObsData()
            nd.time = timec
            nd.auxHeader = d.auxHeader
            nd.clockOffset = d.clockOffset
            nd.epochFlag = d.epochFlag
            nd.numSVs = d.numSVs

            for satkey in d.obs.keys():
                newSatKey = gpstk.RinexSatID(satkey.toString())
                satObss = d.obs[newSatKey]
                # satObss is a tuple of  RinexDatum
                newSatObss = []
                for satObs in satObss:
                    #print "{} {} {} {}".format(satkey.toString(), satObs.data, satObs.lli, satObs.ssi)
                    newSatObs = gpstk.RinexDatum()
                    newSatObs.data = satObs.data
                    newSatObs.lli = satObs.lli
                    newSatObs.ssi = satObs.ssi
                    newSatObss.append(newSatObs)

                nd.obs[newSatKey] = tuple(newSatObss)

            #print "O{}".format(d)
            #print "S{}".format(nd)
            processed_data.append(nd)

        gpstk.writeRinex3Obs(output_file, new_header, processed_data)
        print "Wrote output file: {}".format(output_file)

    # We can catch any custom gpstk exception like this:
    except gpstk.Exception as e:
        print e
예제 #11
0
 def test_conversions(self):
     trip = gpstk.Triple(1.5, 2.5, 3.5)
     tupl = (1.5, 2.5, 3.5)
     self.assertEqual(trip, gpstk.makeTriple(tupl))
     self.assertEqual(tupl, gpstk.makeTuple(trip))
new_header.valid = new_header.valid | gpstk.Rinex3ObsHeader.validMarkerName

new_header.observer = header.observer
new_header.agency = header.agency
new_header.valid = new_header.valid | gpstk.Rinex3ObsHeader.validObserver

new_header.recNo = header.recNo
new_header.recType = header.recType
new_header.recVers = header.recVers
new_header.valid = new_header.valid | gpstk.Rinex3ObsHeader.validReceiver

new_header.antNo = header.antNo
new_header.antType = header.antType
new_header.valid = new_header.valid | gpstk.Rinex3ObsHeader.validAntennaType 

newAntPosition = gpstk.Triple(header.antennaPosition[0],header.antennaPosition[1],header.antennaPosition[2])
new_header.antennaPosition = newAntPosition
new_header.valid = new_header.valid | gpstk.Rinex3ObsHeader.validAntennaPosition

newAntDelta = gpstk.Triple(header.antennaDeltaHEN[0],header.antennaDeltaHEN[1],header.antennaDeltaHEN[2])
new_header.antennaDeltaHEN = newAntDelta
new_header.valid = new_header.valid | gpstk.Rinex3ObsHeader.validAntennaDeltaHEN

for rinObsType in header.mapObsTypes:
    #print "Found obs-type:{}".format(rinObsType)
    newObsIds = []
    for rinObsId in header.mapObsTypes[rinObsType]:
        #print "Found obs-id:{}".format(str(rinObsId))
        #print " --type={} code={} band={}".format(rinObsId.type, rinObsId.code, rinObsId.band)
        newObsId = gpstk.RinexObsID(str(rinObsId))
        newObsIds.append(newObsId)
예제 #13
0
        # In order to compute positions we need the current time, the
        # vector of visible satellites, the vector of corresponding
        # ranges, the object containing satellite ephemerides, and a
        # pointer to the tropospheric model to be applied

        time = obsObj.time

        # the RAIMComputer method of PRSolution2 accepts a vector<SatID> as its
        # 2nd argument, but the list is of RinexSatID, which is a subclass of SatID.
        # Since C++ containers are NOT covariant, it is neccessary to change the
        # output to a vector or SatID's rather thta a vector of RinexSatID's.
        satVector = gpstk.seqToVector(prnList, outtype='vector_SatID')
        rangeVector = gpstk.seqToVector(rangeList)
        raimSolver.RAIMCompute(time, satVector, rangeVector, ephStore, tropModel)

        # Note: Given that the default constructor sets public
        # attribute "Algebraic" to FALSE, a linearized least squares
        # algorithm will be used to get the solutions.
        # Also, the default constructor sets ResidualCriterion to true,
        # so the rejection criterion is based on RMS residual of fit,
        # instead of RMS distance from an a priori position.


        if raimSolver.isValid():
            # Vector "Solution" holds the coordinates, expressed in
            # meters in an Earth Centered, Earth Fixed (ECEF) reference
            # frame. The order is x, y, z  (as all ECEF objects)
            pos = gpstk.Triple(raimSolver.Solution[0],  raimSolver.Solution[1], raimSolver.Solution[2])
            err = obsHeader.antennaPosition - pos
            print err