def rinex3nav_data(filename, prn):
    header, data = gpstk.readRinex3Nav(filename)
    sat = gpstk.SatID(prn, gpstk.SatID.systemGPS)
    g = gpstk.GPSEphemerisStore()
    for d in data:
        if prn == d.PRNID:
            ephem = d.toEngEphemeris()
            g.addEphemeris(ephem)

    class rinex3nav_holder:
        def __init__(self, gpsStore, satStore):
            self.gpsStore = gpsStore
            self.satStore = satStore

        def first_time(self):
            return self.gpsStore.getInitialTime()

        def last_time(self):
            return self.gpsStore.getFinalTime()

        def position(self, t):
            triple = self.gpsStore.getXvt(self.satStore, t).getPos()
            return triple2Position(triple)

    return rinex3nav_holder(g, sat)
Example #2
0
    def test_stream(self):
        header, data = gpstk.readRinex3Nav('rinex3nav_data.txt', strict=True)
        self.assertEqual('06/10/2004 00:00:26', header.date)
        self.assertEqual(166, len(data))
        dataPoint = data[165]
        self.assertAlmostEqual(5153.72985268, dataPoint.Ahalf)
        self.assertEqual(432000.0, dataPoint.Toc)

        # checks converstion to Engineering ephemeris and getting a xvt from it
        eng = dataPoint.toEngEphemeris()
        xvt = eng.svXvt(eng.getTransmitTime())
        self.assertAlmostEqual(4793694.728073199, xvt.x[0])
        self.assertAlmostEqual(2028.248716131878, xvt.v[1])
Example #3
0
    def test_stream(self):
        header, data = gpstk.readRinex3Nav('rinex3nav_data.txt', strict=True)
        self.assertEqual('06/10/2004 00:00:26', header.date)
        self.assertEqual(166, len(data))
        dataPoint = data[165]
        self.assertAlmostEqual(5153.72985268, dataPoint.Ahalf)
        self.assertEqual(432000.0, dataPoint.Toc)

        # checks converstion to Engineering ephemeris and getting a xvt from it
        eng = dataPoint.toEngEphemeris()
        xvt = eng.svXvt(eng.getTransmitTime())
        self.assertAlmostEqual(4793694.728073199, xvt.x[0])
        self.assertAlmostEqual(2028.248716131878, xvt.v[1])
Example #4
0
def rinex3nav_data(filename, prn):
    header, data = gpstk.readRinex3Nav(filename)
    sat = gpstk.SatID(prn, gpstk.SatID.systemGPS)
    g = gpstk.GPSEphemerisStore()
    for d in data:
        if prn == d.PRNID:
            ephem = d.toEngEphemeris()
            g.addEphemeris(ephem)

    class rinex3nav_holder:
        def __init__(self, gpsStore, satStore):
            self.gpsStore = gpsStore
            self.satStore = satStore
        def first_time(self):
            return self.gpsStore.getInitialTime()
        def last_time(self):
            return self.gpsStore.getFinalTime()
        def position(self, t):
            triple = self.gpsStore.getXvt(self.satStore, t).getPos()
            return triple2Position(triple)
    return rinex3nav_holder(g, sat)
Example #5
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('rinex3obs_filename')
    parser.add_argument('rinex3nav_filename')
    parser.add_argument('-m', '--rinexmet_filename')
    args = parser.parse_args()

    # Declaration of objects for storing ephemerides and handling RAIM
    bcestore = gpstk.GPSEphemerisStore()
    raimSolver = gpstk.PRSolution2()

    # Object for void-type tropospheric model (in case no meteorological
    # RINEX is available)
    noTropModel = gpstk.ZeroTropModel()

    # Object for GG-type tropospheric model (Goad and Goodman, 1974)
    #  Default constructor => default values for model
    ggTropModel = gpstk.GGTropModel()

    # Pointer to one of the two available tropospheric models. It points
    # to the void model by default
    tropModel = noTropModel

    navHeader, navData = gpstk.readRinex3Nav(args.rinex3nav_filename)
    for navDataObj in navData:
        ephem = navDataObj.toEngEphemeris()
        bcestore.addEphemeris(ephem)

    # Setting the criteria for looking up ephemeris:
    bcestore.SearchNear()

    if args.rinexmet_filename is not None:
        metHeader, metData = gpstk.readRinexMet(args.rinexmet_filename)
        tropModel = ggTropModel

    obsHeader, obsData = gpstk.readRinex3Obs(args.rinex3obs_filename)

    # The following lines fetch the corresponding indexes for some
    # observation types we are interested in. Given that old-style
    # observation types are used, GPS is assumed.
    try:
        indexP1 = obsHeader.getObsIndex('P1')
    except:
        print 'The observation files has no P1 pseudoranges.'
        sys.exit()

    try:
        indexP2 = obsHeader.getObsIndex('P2')
    except:
        indexP2 = -1

    for obsObj in obsData:
        # Find a weather point. Only if a meteorological RINEX file
        # was provided, the meteorological data linked list "rml" is
        # neither empty or at its end, and the time of meteorological
        # records are below observation data epoch.
        if args.rinexmet_filename is not None:
            for metObj in metData:
                if metObj.time >= obsObj.time:
                    break
                else:
                    metDataDict = metObj.getData()
                    temp = metDataDict[gpstk.RinexMetHeader.TD]
                    pressure = metDataDict[gpstk.RinexMetHeader.PR]
                    humidity = metDataDict[gpstk.RinexMetHeader.HR]
                    ggTropModel.setWeather(temp, pressure, humidity)

        if obsObj.epochFlag == 0 or obsObj.epochFlag == 1:
            # Note that we use lists here, but we will need types backed
            # by C++ std::vectors later. We'll just keep it easy and use
            # gpstk.seqToVector to convert them. If there was a speed
            # bottleneck we could use gpstk.cpp.vector_SatID and
            # gpstk.cpp.vector_double though.
            prnList = []
            rangeList = []

            # This part gets the PRN numbers and ionosphere-corrected
            # pseudoranges for the current epoch. They are correspondly fed
            # into "prnList" and "rangeList"; "obs" is a public attribute of
            # Rinex3ObsData to get the map of observations
            for satID, datumList in obsObj.obs.iteritems():
                # The RINEX file may have P1 observations, but the current
                # satellite may not have them.
                P1 = 0.0
                try:
                    P1 = obsObj.getObs(satID, indexP1).data
                except gpstk.exceptions.Exception:
                    continue  # Ignore this satellite if P1 is not found

                ionocorr = 0.0

                # If there are P2 observations, let's try to apply the
                # ionospheric corrections
                if indexP2 >= 0:
                    # The RINEX file may have P2 observations, but the
                    # current satellite may not have them.
                    P2 = 0.0
                    try:
                        P2 = obsObj.getObs(satID, indexP2).data
                    except gpstk.exceptions.Exception:
                        continue  # Ignore this satellite if P1 is not found
                    # list 'vecList' contains RinexDatum, whose public
                    # attribute "data" indeed holds the actual data point
                    ionocorr = 1.0 / (1.0 - gpstk.constants.GAMMA_GPS) * (P1 -
                                                                          P2)

                # Now, we include the current PRN number in the first part
                # of "it" iterator into the list holding the satellites.
                # All satellites in view at this epoch that have P1 or P1+P2
                # observations will be included.
                prnList.append(satID)

                # The same is done for the list of doubles holding the
                # corrected ranges
                rangeList.append(P1 - ionocorr)
                # WARNING: Please note that so far no further correction
                # is done on data: Relativistic effects, tropospheric
                # correction, instrumental delays, etc

            # The default constructor for PRSolution2 objects (like
            # "raimSolver") is to set a RMSLimit of 6.5. We change that
            # here. With this value of 3e6 the solution will have a lot
            # more dispersion.
            raimSolver.RMSLimit = 3e6

            # 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.cpp.seqToVector(prnList, outtype='vector_SatID')
            rangeVector = gpstk.cpp.seqToVector(rangeList)
            raimSolver.RAIMCompute(time, satVector, rangeVector, bcestore,
                                   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)
                x, y, z = raimSolver.Solution[0], raimSolver.Solution[
                    1], raimSolver.Solution[2]
                print "%12.5f %12.5f %12.5f" % (x, y, z)
Example #6
0
def getdata(nfile, ofile, strsat=None):  # one week data
    f1, f2 = gpstk.L1_FREQ_GPS, gpstk.L2_FREQ_GPS
    alfa = 1.0 / ((f1 ** 2 / f2 ** 2) - 1)
    t = []  # observation epoch on code and phase
    Iphase, Icode, IPPS = {}, {}, {}  # dicc: key=time observer; values=iono delay and IPP
    VTECphase, VTECcode, ELEV = {}, {}, {}
    PhaseL1, PhaseL2 = {}, {}
    CodeL1, CodeL2 = {}, {}

    oheader, odata = gpstk.readRinex3Obs(ofile, strict=True)
    nheader, ndata = gpstk.readRinex3Nav(nfile)

    bcestore = gpstk.GPSEphemerisStore()

    for ndato in ndata:
        ephem = ndato.toGPSEphemeris()
        bcestore.addEphemeris(ephem)
    bcestore.SearchNear()

    for observation in odata:
        sats = [satID for satID, datumList in observation.obs.iteritems() if str(satID).split()[0] == "GPS"]
        obs_types = np.array([i for i in oheader.R2ObsTypes])
        if "C1" and "P2" and "L1" and "L2" in obs_types:
            for sat in sats:
                if str(sat) == strsat:  # Return for a specific satellite
                    eph = bcestore.findEphemeris(sat, observation.time)
                    Tgd = eph.Tgd
                    sat_pos = eph.svXvt(observation.time)
                    rec_pos = gpstk.Position(
                        oheader.antennaPosition[0], oheader.antennaPosition[1], oheader.antennaPosition[2]
                    ).asECEF()
                    elev = oheader.antennaPosition.elvAngle(sat_pos.x)
                    azim = oheader.antennaPosition.azAngle(sat_pos.x)
                    time = observation.time
                    R = 6.378e6  # earth radius
                    mapp = 1 / np.cos(np.arcsin(R / (R + 350000)) * np.sin(elev))
                    IPP = rec_pos.getIonosphericPiercePoint(elev, azim, 350000).asECEF()
                    t.append(np.trunc(gpstk.YDSTime(time).sod))

                    if (
                        np.size(np.where(obs_types == "C1")) > 0
                        and np.size(np.where(obs_types == "P2")) > 0
                        and np.size(np.where(obs_types == "L1")) > 0
                        and np.size(np.where(obs_types == "L2")) > 0
                    ):

                        C1_idx = np.where(obs_types == "C1")[0][0]
                        P2_idx = np.where(obs_types == "P2")[0][0]
                        R1 = observation.getObs(sat, C1_idx).data
                        R2 = observation.getObs(sat, P2_idx).data

                        L1_idx = np.where(obs_types == "L1")[0][0]
                        L2_idx = np.where(obs_types == "L2")[0][0]
                        L1 = observation.getObs(sat, L1_idx).data * gpstk.L1_WAVELENGTH_GPS
                        L2 = observation.getObs(sat, L2_idx).data * gpstk.L2_WAVELENGTH_GPS

                        if (
                            R2 < 3e7 and R1 < 3e7 and L2 < 3e7 and L1 < 3e7
                        ):  # Distances should be in order of 1e7 meters, more than that is considered an error

                            iono_delay_c = alfa * (R2 - R1)
                            iono_delay_p = alfa * (L1 - L2)

                            vtec_C = iono_delay_c / mapp
                            vtec_P = iono_delay_p / mapp

                            VTECcode[np.trunc(gpstk.YDSTime(time).sod)] = vtec_C
                            VTECphase[np.trunc(gpstk.YDSTime(time).sod)] = vtec_P
                            Icode[np.trunc(gpstk.YDSTime(time).sod)] = iono_delay_c
                            Iphase[np.trunc(gpstk.YDSTime(time).sod)] = iono_delay_p
                            ELEV[np.trunc(gpstk.YDSTime(time).sod)] = elev
                            IPPS[np.trunc(gpstk.YDSTime(time).sod)] = IPP
                            PhaseL1[np.trunc(gpstk.YDSTime(time).sod)] = L1
                            PhaseL2[np.trunc(gpstk.YDSTime(time).sod)] = L2
                            CodeL1[np.trunc(gpstk.YDSTime(time).sod)] = R1
                            CodeL2[np.trunc(gpstk.YDSTime(time).sod)] = R2

                            # stec=(iono_delay_p*f1**2)/(-40.3) #STEC delay on phase [mm]
                            # vtec=stec/mapp #vertical delay!
        else:
            print "Needs both L1 and L2 frequencies to compute delay"
            break

    return t, Icode, Iphase, VTECphase, ELEV, IPPS, PhaseL1, PhaseL2, CodeL1, CodeL2, Tgd
Example #7
0
#!/usr/bin/env python

"""
An example reading a RINEX obs, nav and met file and using
PRSolution2 to computer a receiver position and compare
this to the position in the obs header.
"""
import gpstk
import sys

obsfn = gpstk.getPathData() + '/arlm200z.15o'
navfn = gpstk.getPathData() + '/arlm200z.15n'
metfn = gpstk.getPathData() + '/arlm200z.15m'

navHeader, navData = gpstk.readRinex3Nav(navfn)
ephStore = gpstk.gpstk.Rinex3EphemerisStore()
for navDataObj in navData:
    ephStore.addEphemeris(navDataObj)

tropModel = gpstk.GGTropModel()
metHeader, metData = gpstk.readRinexMet(metfn)

obsHeader, obsData = gpstk.readRinex3Obs(obsfn)

indexP1 = obsHeader.getObsIndex('C1W')
indexP2 = obsHeader.getObsIndex('C2W')
raimSolver = gpstk.PRSolution2()

for obsObj in obsData:
    for metObj in metData:
        if metObj.time >= obsObj.time:
Example #8
0
def getdata(nfile, ofile, strsat=None):  #one week data
    f1, f2 = gpstk.L1_FREQ_GPS, gpstk.L2_FREQ_GPS
    alfa = 1.0 / ((f1**2 / f2**2) - 1)
    t = []  #observation epoch on code and phase
    Iphase, Icode, IPPS = {}, {}, {
    }  #dicc: key=time observer; values=iono delay and IPP
    VTECphase, VTECcode, ELEV = {}, {}, {}
    PhaseL1, PhaseL2 = {}, {}
    CodeL1, CodeL2 = {}, {}

    oheader, odata = gpstk.readRinex3Obs(ofile, strict=True)
    nheader, ndata = gpstk.readRinex3Nav(nfile)

    bcestore = gpstk.GPSEphemerisStore()

    for ndato in ndata:
        ephem = ndato.toGPSEphemeris()
        bcestore.addEphemeris(ephem)
    bcestore.SearchNear()

    for observation in odata:
        sats = [
            satID for satID, datumList in observation.obs.iteritems()
            if str(satID).split()[0] == "GPS"
        ]
        obs_types = np.array([i for i in oheader.R2ObsTypes])
        if 'C1' and 'P2' and 'L1' and 'L2' in obs_types:
            for sat in sats:
                if str(sat) == strsat:  #Return for a specific satellite
                    eph = bcestore.findEphemeris(sat, observation.time)
                    Tgd = eph.Tgd
                    sat_pos = eph.svXvt(observation.time)
                    rec_pos = gpstk.Position(
                        oheader.antennaPosition[0], oheader.antennaPosition[1],
                        oheader.antennaPosition[2]).asECEF()
                    elev = oheader.antennaPosition.elvAngle(sat_pos.x)
                    azim = oheader.antennaPosition.azAngle(sat_pos.x)
                    time = observation.time
                    R = 6.378e6  #earth radius
                    mapp = 1 / np.cos(
                        np.arcsin(R / (R + 350000)) * np.sin(elev))
                    IPP = rec_pos.getIonosphericPiercePoint(
                        elev, azim, 350000).asECEF()
                    t.append(np.trunc(gpstk.YDSTime(time).sod))

                    if np.size(np.where(obs_types == 'C1')) > 0 and np.size(
                            np.where(obs_types == 'P2')) > 0 and np.size(
                                np.where(obs_types == 'L1')) > 0 and np.size(
                                    np.where(obs_types == 'L2')) > 0:

                        C1_idx = np.where(obs_types == 'C1')[0][0]
                        P2_idx = np.where(obs_types == 'P2')[0][0]
                        R1 = observation.getObs(sat, C1_idx).data
                        R2 = observation.getObs(sat, P2_idx).data

                        L1_idx = np.where(obs_types == 'L1')[0][0]
                        L2_idx = np.where(obs_types == 'L2')[0][0]
                        L1 = observation.getObs(
                            sat, L1_idx).data * gpstk.L1_WAVELENGTH_GPS
                        L2 = observation.getObs(
                            sat, L2_idx).data * gpstk.L2_WAVELENGTH_GPS

                        if R2 < 3e7 and R1 < 3e7 and L2 < 3e7 and L1 < 3e7:  #Distances should be in order of 1e7 meters, more than that is considered an error

                            iono_delay_c = alfa * (R2 - R1)
                            iono_delay_p = alfa * (L1 - L2)

                            vtec_C = iono_delay_c / mapp
                            vtec_P = iono_delay_p / mapp

                            VTECcode[np.trunc(
                                gpstk.YDSTime(time).sod)] = vtec_C
                            VTECphase[np.trunc(
                                gpstk.YDSTime(time).sod)] = vtec_P
                            Icode[np.trunc(
                                gpstk.YDSTime(time).sod)] = iono_delay_c
                            Iphase[np.trunc(
                                gpstk.YDSTime(time).sod)] = iono_delay_p
                            ELEV[np.trunc(gpstk.YDSTime(time).sod)] = elev
                            IPPS[np.trunc(gpstk.YDSTime(time).sod)] = IPP
                            PhaseL1[np.trunc(gpstk.YDSTime(time).sod)] = L1
                            PhaseL2[np.trunc(gpstk.YDSTime(time).sod)] = L2
                            CodeL1[np.trunc(gpstk.YDSTime(time).sod)] = R1
                            CodeL2[np.trunc(gpstk.YDSTime(time).sod)] = R2

                            #stec=(iono_delay_p*f1**2)/(-40.3) #STEC delay on phase [mm]
                            #vtec=stec/mapp #vertical delay!
        else:
            print "Needs both L1 and L2 frequencies to compute delay"
            break

    return t, Icode, Iphase, VTECphase, ELEV, IPPS, PhaseL1, PhaseL2, CodeL1, CodeL2, Tgd
Example #9
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('rinex3obs_filename')
    parser.add_argument('rinex3nav_filename')
    parser.add_argument('-m', '--rinexmet_filename')
    args = parser.parse_args()

    # Declaration of objects for storing ephemerides and handling RAIM
    bcestore = gpstk.GPSEphemerisStore()
    raimSolver = gpstk.PRSolution2()

    # Object for void-type tropospheric model (in case no meteorological
    # RINEX is available)
    noTropModel = gpstk.ZeroTropModel()

    # Object for GG-type tropospheric model (Goad and Goodman, 1974)
    #  Default constructor => default values for model
    ggTropModel = gpstk.GGTropModel()

    # Pointer to one of the two available tropospheric models. It points
    # to the void model by default
    tropModel = noTropModel


    navHeader, navData = gpstk.readRinex3Nav(args.rinex3nav_filename)
    for navDataObj in navData:
        ephem = navDataObj.toEngEphemeris()
        bcestore.addEphemeris(ephem)

    # Setting the criteria for looking up ephemeris:
    bcestore.SearchNear()

    if args.rinexmet_filename is not None:
        metHeader, metData = gpstk.readRinexMet(args.rinexmet_filename)
        tropModel = ggTropModel

    obsHeader, obsData = gpstk.readRinex3Obs(args.rinex3obs_filename)

    # The following lines fetch the corresponding indexes for some
    # observation types we are interested in. Given that old-style
    # observation types are used, GPS is assumed.
    try:
        indexP1 = obsHeader.getObsIndex('C1P')
    except:
        print 'The observation files has no L1 C/A pseudoranges.'
        sys.exit()

    try:
        indexP2 = obsHeader.getObsIndex('C2W')
    except:
        print 'The observation files has no L2 codeless pseudoranges.'
        indexP2 = -1

    for obsObj in obsData:
        # Find a weather point. Only if a meteorological RINEX file
        # was provided, the meteorological data linked list "rml" is
        # neither empty or at its end, and the time of meteorological
        # records are below observation data epoch.
        if args.rinexmet_filename is not None:
            for metObj in metData:
                if metObj.time >= obsObj.time:
                    break
                else:
                    metDataDict = metObj.getData()
                    temp = metDataDict[gpstk.RinexMetHeader.TD]
                    pressure = metDataDict[gpstk.RinexMetHeader.PR]
                    humidity = metDataDict[gpstk.RinexMetHeader.HR]
                    ggTropModel.setWeather(temp, pressure, humidity)

        if obsObj.epochFlag == 0 or obsObj.epochFlag == 1:
            # Note that we use lists here, but we will need types backed
            # by C++ std::vectors later. We'll just keep it easy and use
            # gpstk.seqToVector to convert them. If there was a speed
            # bottleneck we could use gpstk.cpp.vector_SatID and
            # gpstk.cpp.vector_double though.
            prnList = []
            rangeList = []

            # This part gets the PRN numbers and ionosphere-corrected
            # pseudoranges for the current epoch. They are correspondly fed
            # into "prnList" and "rangeList"; "obs" is a public attribute of
            # Rinex3ObsData to get the map of observations
            for satID, datumList in obsObj.obs.iteritems():
                # The RINEX file may have P1 observations, but the current
                 # satellite may not have them.
                P1 = 0.0
                try:
                    P1 = obsObj.getObs(satID, indexP1).data
                except gpstk.exceptions.Exception:
                    continue  # Ignore this satellite if P1 is not found

                ionocorr = 0.0

                  # If there are P2 observations, let's try to apply the
                  # ionospheric corrections
                if indexP2 >= 0:
                    # The RINEX file may have P2 observations, but the
                    # current satellite may not have them.
                    P2 = 0.0
                    try:
                        P2 = obsObj.getObs(satID, indexP2).data
                    except gpstk.exceptions.Exception:
                        continue  # Ignore this satellite if P1 is not found
                    # list 'vecList' contains RinexDatum, whose public
                    # attribute "data" indeed holds the actual data point
                    ionocorr = 1.0 / (1.0 - gpstk.GAMMA_GPS) * ( P1 - P2 )

                # Now, we include the current PRN number in the first part
                # of "it" iterator into the list holding the satellites.
                # All satellites in view at this epoch that have P1 or P1+P2
                # observations will be included.
                prnList.append(satID)

                # The same is done for the list of doubles holding the
                # corrected ranges
                rangeList.append(P1 - ionocorr)
                # WARNING: Please note that so far no further correction
                # is done on data: Relativistic effects, tropospheric
                # correction, instrumental delays, etc

            # The default constructor for PRSolution2 objects (like
            # "raimSolver") is to set a RMSLimit of 6.5. We change that
            # here. With this value of 3e6 the solution will have a lot
            # more dispersion.
            raimSolver.RMSLimit = 3e6


            # 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.cpp.seqToVector(prnList, outtype='vector_SatID')
            rangeVector = gpstk.cpp.seqToVector(rangeList)
            raimSolver.RAIMCompute(time, satVector, rangeVector, bcestore, 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)
                x, y, z = raimSolver.Solution[0],  raimSolver.Solution[1], raimSolver.Solution[2]
                print "%12.5f %12.5f %12.5f" % (x, y, z)
Example #10
0
def rinex_to_dataframe(obsfile, navfile):
    c = 299792458.

    observation_types=["P1", "P2", "L1", "L2"]
    obsHeader, obsData = gpstk.readRinex3Obs(obsfile)
    navHeader, navData = gpstk.readRinex3Nav(navfile)
    # setup ephemeris store to look for satellite positions
    bcestore = gpstk.GPSEphemerisStore()
    for navDataObj in navData:
        ephem = navDataObj.toGPSEphemeris()
        bcestore.addEphemeris(ephem)
    bcestore.SearchNear()
    navData.close()

    rec_pos = [obsHeader.antennaPosition[0], obsHeader.antennaPosition[1], obsHeader.antennaPosition[2]]
    
    requested_obstypes = observation_types
    obsidxs = []
    obstypes = []
    obsdefs = np.array([i for i in obsHeader.R2ObsTypes])
    for i in requested_obstypes:
        w = np.where(obsdefs==i)[0]
        if len(w)!=0:
            obsidxs.append(w[0])
            obstypes.append(i)
        else:
            print ("WARNING! observation `"+i+"` no present in file")
    obsidxs, obstypes

    r = []
    for obsObject in obsData:
        prnlist = []
        obsdict = {}
        prnspos = []
        prns_clockbias = []
        prns_relcorr = []
        prnselev = []
        prnsaz   = []
        for i in obstypes:
            obsdict[i]=[]

        gpsTime = gpstk.GPSWeekSecond(obsObject.time)

        for satID, datumList in obsObject.obs.iteritems():
            if satID.system == satID.systemGPS:
                prnlist.append("".join(str(satID).split()))
                eph   = bcestore.findEphemeris(satID, obsObject.time)
                

                for i in range(len(obsidxs)):
                    obsdict[obstypes[i]].append(obsObject.getObs(satID, obsidxs[i]).data)
                
                P1 = obsObject.getObs(satID, obsidxs[0]).data
                svTime = obsObject.time - P1/c
                svXvt = eph.svXvt(svTime)
                svTime += - svXvt.getClockBias() + svXvt.getRelativityCorr()
                svXvt = eph.svXvt(svTime)
                
                prnspos.append([svXvt.x[0], svXvt.x[1], svXvt.x[2]])
                prns_clockbias.append(svXvt.getClockBias())
                prns_relcorr.append(svXvt.getRelativityCorr())

                prnselev.append(obsHeader.antennaPosition.elvAngle(svXvt.getPos()))
                prnsaz.append(obsHeader.antennaPosition.azAngle(svXvt.getPos()))
                
        r.append([gpsTime.getWeek(), gpsTime.getSOW(), np.array(prnlist), np.array(prnspos), np.array(prns_clockbias), np.array(prns_relcorr), np.array(prnselev), np.array(prnsaz)] + [np.array(obsdict[i]) for i in obstypes])

    names=["gps_week", "gps_sow", "prns", "prns_pos", "prns_clockbias", "prns_relcorr", "prns_elev", "prns_az"] + obstypes
    r = pd.DataFrame(r, columns=names)
    obsData.close()
    return r, bcestore, np.array(rec_pos)
Example #11
0
def rinex_to_dataframe(obsfile, navfile):
    c = 299792458.

    #observation_types=["P1", "P2", "L1", "L2"]
    observation_types = ["C1", "P2", "L1", "L2"]
    obsHeader, obsData = gpstk.readRinex3Obs(obsfile)
    navHeader, navData = gpstk.readRinex3Nav(navfile)
    # setup ephemeris store to look for satellite positions
    bcestore = gpstk.GPSEphemerisStore()
    for navDataObj in navData:
        ephem = navDataObj.toGPSEphemeris()
        bcestore.addEphemeris(ephem)
    bcestore.SearchNear()
    navData.close()

    rec_pos = [
        obsHeader.antennaPosition[0], obsHeader.antennaPosition[1],
        obsHeader.antennaPosition[2]
    ]
    requested_obstypes = observation_types
    obsidxs = []
    obstypes = []
    obsdefs = np.array([i for i in obsHeader.R2ObsTypes])
    for i in requested_obstypes:
        w = np.where(obsdefs == i)[0]
        if len(w) != 0:
            obsidxs.append(w[0])
            obstypes.append(i)
        else:
            print("WARNING! observation `" + i + "` no present in file")
    obsidxs, obstypes
    print obsdefs  #que tipos hay

    r = []
    for obsObject in obsData:
        prnlist = []
        obsdict = {}
        prnspos = []
        prns_clockbias = []
        prns_relcorr = []
        prnselev = []
        prnsaz = []
        for i in obstypes:
            obsdict[i] = []

        gpsTime = gpstk.GPSWeekSecond(obsObject.time)

        for satID, datumList in obsObject.obs.iteritems():
            if satID.system == satID.systemGPS:
                prnlist.append("".join(str(satID).split()))
                try:
                    eph = bcestore.findEphemeris(satID, obsObject.time)
                except:
                    print "no encontrada!"

                for i in range(len(obsidxs)):
                    obsdict[obstypes[i]].append(
                        obsObject.getObs(satID, obsidxs[i]).data)

                P1 = obsObject.getObs(satID, obsidxs[0]).data
                svTime = obsObject.time - P1 / c
                svXvt = eph.svXvt(svTime)
                svTime += -svXvt.getClockBias() + svXvt.getRelativityCorr()
                svXvt = eph.svXvt(svTime)

                prnspos.append([svXvt.x[0], svXvt.x[1], svXvt.x[2]])
                prns_clockbias.append(svXvt.getClockBias())
                prns_relcorr.append(svXvt.getRelativityCorr())

                prnselev.append(
                    obsHeader.antennaPosition.elvAngle(svXvt.getPos()))
                prnsaz.append(obsHeader.antennaPosition.azAngle(
                    svXvt.getPos()))

                correct_sod = np.round(
                    gpstk.YDSTime(obsObject.time).sod / 30.0) * 30  #mod 30s

        r.append([
            gpsTime.getWeek(),
            gpsTime.getSOW(), correct_sod,
            np.array(prnlist),
            np.array(prnspos),
            np.array(prns_clockbias),
            np.array(prns_relcorr),
            np.array(prnselev),
            np.array(prnsaz)
        ] + [np.array(obsdict[i]) for i in obstypes])

    names = [
        "gps_week", "gps_sow", "tod", "prns", "prns_pos", "prns_clockbias",
        "prns_relcorr", "prns_elev", "prns_az"
    ] + obstypes
    r = pd.DataFrame(r, columns=names)
    obsData.close()
    return r, bcestore, np.array(rec_pos)