def sem_data(filename, prn):
    header, data = gpstk.readSEM(filename)
    sat = gpstk.SatID(prn, gpstk.SatID.systemGPS)
    almanac = gpstk.GPSAlmanacStore()
    for d in data:
        if prn == d.PRN:
            orbit = d.toAlmOrbit()
            almanac.addAlmanac(orbit)

    class sem_holder:
        def __init__(self, almanacStore, satStore):
            self.almanacStore = almanacStore
            self.satStore = satStore

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

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

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

    return sem_holder(almanac, sat)
Example #2
0
 def test_stream_strict(self):
     header, data = gpstk.readSEM('sem_data.txt', strict=True)
     self.assertEqual(724, header.week)
     self.assertEqual(405504L, header.Toa)
     self.assertEqual(31, len(data))
     dataPoint = data[15]
     self.assertEqual(16, dataPoint.PRN)
     self.assertAlmostEqual(0.00711489, dataPoint.ecc)
Example #3
0
 def test_stream_strict(self):
     header, data = gpstk.readSEM('sem_data.txt', strict=True)
     self.assertEqual(724, header.week)
     self.assertEqual(405504L, header.Toa)
     self.assertEqual(31, len(data))
     dataPoint = data[15]
     self.assertEqual(16, dataPoint.PRN)
     self.assertAlmostEqual(0.00711489, dataPoint.ecc)
Example #4
0
def sem_data(filename, prn):
    header, data = gpstk.readSEM(filename)
    sat = gpstk.SatID(prn, gpstk.SatID.systemGPS)
    almanac = gpstk.GPSAlmanacStore()
    for d in data:
        if prn == d.PRN:
            orbit = d.toAlmOrbit()
            almanac.addAlmanac(orbit)

    class sem_holder:
        def __init__(self, almanacStore, satStore):
            self.almanacStore = almanacStore
            self.satStore = satStore
        def first_time(self):
            return self.almanacStore.getInitialTime()
        def last_time(self):
            return self.almanacStore.getFinalTime()
        def position(self, t):
            triple = self.almanacStore.getXvt(self.satStore, t).getPos()
            return triple2Position(triple)
    return sem_holder(almanac, sat)
Example #5
0
def main():
    # Read in data, strict=True makes dataSets a list rather than a generator:
    header, dataSets = gpstk.readSEM('sem_data.txt', strict=True)

    # Write the data back to a different file (their contents should match):
    gpstk.writeSEM('sem_data.txt.new', header, dataSets)

    # Read the orbit out of the data:
    orbit = dataSets[0].toAlmOrbit()  # alm orbit of first data point

    austin = gpstk.Position(30, 97, 0, gpstk.Position.Geodetic)  # Austin, TX

    starttime = gpstk.CommonTime()  # iterator time to start at
    starttime.setTimeSystem(gpstk.TimeSystem('GPS'))
    endtime = gpstk.CommonTime()  # end time, 1 day later (see below)
    endtime.setTimeSystem(gpstk.TimeSystem('GPS'))
    endtime.addDays(1)

    X = []
    Y = []

    # Step through a day, adding plot points:
    for t in gpstk.times(starttime, endtime, seconds=1000):
        xvt = orbit.svXvt(t)
        location = gpstk.Position(xvt.x)
        elevation = austin.elevation(location)
        X.append(t.getDays())
        Y.append(elevation)

    # Make the plot
    fig = plt.figure()
    fig.suptitle('Elevation of a GPS satellite throughout the day',
                 fontsize=14,
                 fontweight='bold')
    ax = fig.add_subplot(111)
    ax.set_xlabel('Time (days)')
    ax.set_ylabel('Elevation (degrees)')
    plt.plot(X, Y, 'r')
    plt.show()
Example #6
0
def main():
    # Read in data, strict=True makes dataSets a list rather than a generator:
    header, dataSets = gpstk.readSEM('sem_data.txt', strict=True)

    # Write the data back to a different file (their contents should match):
    gpstk.writeSEM('sem_data.txt.new', header, dataSets)

    # Read the orbit out of the data:
    orbit = dataSets[0].toAlmOrbit()  # alm orbit of first data point

    austin = gpstk.Position(30, 97, 0, gpstk.Position.Geodetic)  # Austin, TX

    starttime = gpstk.CommonTime()    # iterator time to start at
    starttime.setTimeSystem(gpstk.TimeSystem('GPS'))
    endtime = gpstk.CommonTime()  # end time, 1 day later (see below)
    endtime.setTimeSystem(gpstk.TimeSystem('GPS'))
    endtime.addDays(1)

    X = []
    Y = []

    # Step through a day, adding plot points:
    for t in gpstk.times(starttime, endtime, seconds=1000):
        xvt = orbit.svXvt(t)
        location = gpstk.Position(xvt.x)
        elevation = austin.elevation(location)
        X.append(t.getDays())
        Y.append(elevation)

    # Make the plot
    fig = plt.figure()
    fig.suptitle('Elevation of a GPS satellite throughout the day',
                 fontsize=14, fontweight='bold')
    ax = fig.add_subplot(111)
    ax.set_xlabel('Time (days)')
    ax.set_ylabel('Elevation (degrees)')
    plt.plot(X, Y, 'r')
    plt.show()
Example #7
0
 def test_stream(self):
     header, gen = gpstk.readSEM('sem_data.txt')
     data = list(gen)
     self.assertEqual(31, len(data))
Example #8
0
 def test_stream(self):
     header, gen = gpstk.readSEM(gpstk.data.full_path('sem_data.txt'))
     data = list(gen)
     self.assertEqual(31, len(data))
Example #9
0
#!/usr/bin/env python
"""
A GPSTk example featuring some file input and processing to
create a plot with matplotlib.

Usage:

  python sem_plot.py

"""
import gpstk
from matplotlib.pyplot import figure, show

# Read in data, strict=True makes dataSets a list rather than a generator:
header, dataSets = gpstk.readSEM("data/sem_data.txt", strict=True)

# Write the data back to a different file (their contents should match):
gpstk.writeSEM("sem_data.txt.new", header, dataSets)

# Read the orbit out of the data:
orbit = dataSets[0].toAlmOrbit()  # alm orbit of first data point

austin = gpstk.Position(30, 97, 0, gpstk.Position.Geodetic)  # Austin, TX

starttime = gpstk.CommonTime()  # iterator time to start at
starttime.setTimeSystem(gpstk.TimeSystem("GPS"))
endtime = gpstk.CommonTime()  # end time, 1 day later (see below)
endtime.setTimeSystem(gpstk.TimeSystem("GPS"))
endtime.addDays(1)
# %% Step through a day, adding plot points:
d = []
"""
A GPSTk example featuring some file input and processing to
create a plot with matplotlib.

Usage:

  python sem_plot.py

"""
import gpstk
from matplotlib.pyplot import figure, show


# Read in data, strict=True makes dataSets a list rather than a generator:
header, dataSets = gpstk.readSEM('data/sem_data.txt', strict=True)

# Write the data back to a different file (their contents should match):
gpstk.writeSEM('sem_data.txt.new', header, dataSets)

# Read the orbit out of the data:
orbit = dataSets[0].toAlmOrbit()  # alm orbit of first data point

austin = gpstk.Position(30, 97, 0, gpstk.Position.Geodetic)  # Austin, TX

starttime = gpstk.CommonTime()    # iterator time to start at
starttime.setTimeSystem(gpstk.TimeSystem('GPS'))
endtime = gpstk.CommonTime()  # end time, 1 day later (see below)
endtime.setTimeSystem(gpstk.TimeSystem('GPS'))
endtime.addDays(1)
# %% Step through a day, adding plot points: