コード例 #1
0
    def test_times_list(self):
        start = gpstk.CommonTime()
        start.addSeconds(100.0)
        end = gpstk.CommonTime()
        end.addSeconds(900.0)
        times = list(gpstk.times(start, end, seconds=200.0))
        self.assertEqual(100.0, times[0].getSecondOfDay())
        self.assertEqual(300.0, times[1].getSecondOfDay())
        self.assertEqual(500.0, times[2].getSecondOfDay())
        self.assertEqual(700.0, times[3].getSecondOfDay())
        self.assertEqual(900.0, times[4].getSecondOfDay())

        times = list(gpstk.times(start, end))
        self.assertEqual(2, len(times))
        self.assertEqual(times[0], start)
        self.assertEqual(times[1], end)
コード例 #2
0
ファイル: test_time.py プロジェクト: REC-SPb-ETU/GPSTk
    def test_times_list(self):
        start = gpstk.CommonTime()
        start.addSeconds(100.0)
        end = gpstk.CommonTime()
        end.addSeconds(900.0)
        times = list(gpstk.times(start, end, seconds=200.0))
        self.assertEqual(100.0, times[0].getSecondOfDay())
        self.assertEqual(300.0, times[1].getSecondOfDay())
        self.assertEqual(500.0, times[2].getSecondOfDay())
        self.assertEqual(700.0, times[3].getSecondOfDay())
        self.assertEqual(900.0, times[4].getSecondOfDay())

        times = list(gpstk.times(start, end))
        self.assertEqual(2, len(times))
        self.assertEqual(times[0], start)
        self.assertEqual(times[1], end)
コード例 #3
0
 def test_times_gen(self):
     start = gpstk.CommonTime()
     start.addSeconds(100.0)
     end = gpstk.CommonTime()
     end.addSeconds(900.0)
     times = gpstk.times(start, end, seconds=200.0)
     self.assertEqual(100.0, times.next().getSecondOfDay())
     self.assertEqual(300.0, times.next().getSecondOfDay())
     self.assertEqual(500.0, times.next().getSecondOfDay())
     self.assertEqual(700.0, times.next().getSecondOfDay())
     self.assertEqual(900.0, times.next().getSecondOfDay())
     self.assertRaises(StopIteration, times.next)
コード例 #4
0
ファイル: test_time.py プロジェクト: REC-SPb-ETU/GPSTk
 def test_times_gen(self):
     start = gpstk.CommonTime()
     start.addSeconds(100.0)
     end = gpstk.CommonTime()
     end.addSeconds(900.0)
     times = gpstk.times(start, end, seconds=200.0)
     self.assertEqual(100.0, times.next().getSecondOfDay())
     self.assertEqual(300.0, times.next().getSecondOfDay())
     self.assertEqual(500.0, times.next().getSecondOfDay())
     self.assertEqual(700.0, times.next().getSecondOfDay())
     self.assertEqual(900.0, times.next().getSecondOfDay())
     self.assertRaises(StopIteration, times.next)
コード例 #5
0
ファイル: test_time.py プロジェクト: zqq12345678/GPSTk
 def test_times_gen(self):
     start = gpstk.CommonTime()
     start.addSeconds(100.0)
     end = gpstk.CommonTime()
     end.addSeconds(900.0)
     times = gpstk.times(start, end, seconds=200.0)
     self.assertEqual(100.0, next(times).getSecondOfDay())
     self.assertEqual(300.0, next(times).getSecondOfDay())
     self.assertEqual(500.0, next(times).getSecondOfDay())
     self.assertEqual(700.0, next(times).getSecondOfDay())
     self.assertEqual(900.0, next(times).getSecondOfDay())
     if sys.version_info[0] < 3:
         self.assertRaises(StopIteration, times.next)
     else:
         self.assertRaises(StopIteration, times.__next__)
コード例 #6
0
ファイル: sem_plot.py プロジェクト: etschneider/GPSTk
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()
コード例 #7
0
ファイル: sem_plot.py プロジェクト: Milfhunter/gpstk
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()
コード例 #8
0
def main(args=sys.argv[1:]):
    program_description = ('This program takes 2 nav files and '
                            'provides a plot of the magnitude of '
                            'the difference of a given PRN ID.'
                            'Valid file types are ' + str(valid_types) + '.')

    parser = argparse.ArgumentParser(description=program_description)
    parser.add_argument('prn_id', type=int,
                        help='The integer PRN ID you are interested in.')
    parser.add_argument('filetype1', help='Type for the first file.')
    parser.add_argument('filename1', help='File name for the first file.')
    parser.add_argument('filetype2', help='Type for the second file.')
    parser.add_argument('filename2', help='File name for the second file.')
    parser.add_argument('-v', '--verbose', action="store_true",
                        help='Print output locations and error.')
    parser.add_argument('-n', '--noplot', action="store_true",
                        help='Don\'t plot the file.')
    parser.add_argument('-d', '--drawdots', action="store_true",
                        help='Matplotlib will not connect calculated data '
                        'points in the plot')
    parser.add_argument('-t', '--timestep', type=int, default=300,
                        help='Timestep, in seconds, between plot points.')
    parser.add_argument('-s', '--save', help='Save the image to <file>.')
    parser.add_argument('-f', '--format', default='%02H:%02M',
                        help='Format for x time ticks.')

    args = parser.parse_args(args)


    def timestr(t):
        return str(gpstk.CivilTime(t))

    def check(filetype, filename):
        if not filetype in valid_types:
            print 'Invalid filetype:', filetype
            print 'Valid choices are:' + str(valid_types)
            print 'Use the -h or --help flags for more information.\n'
            sys.exit()
            try:
                with open('filename'): pass
            except IOError as e:
                print e
                sys.exit(filename, 'cannot be read.\n')

    check(args.filetype1, args.filename1)
    check(args.filetype2, args.filename2)

    pos1 = read_data(args.filetype1, args.filename1, args.prn_id)
    pos2 = read_data(args.filetype2, args.filename2, args.prn_id)

    X = []  # list of x plot values
    Y = []  # list of y plot values

    starttime = max(pos1.first_time(), pos2.first_time())
    endtime = min(pos1.last_time(), pos2.last_time())

    if args.verbose:
        print (args.filename1 + ' ranges from ' + timestr(pos1.first_time())
              + ' to ' + timestr(pos1.last_time()))
        print (args.filename2 + ' ranges from ' + timestr(pos2.first_time())
              + ' to ' + timestr(pos2.last_time()))
        print 'Earliest time computable:', timestr(starttime)
        print 'Latest time computable:', timestr(endtime), '\n'

    sumErr = 0.0
    sumErrSq = 0.0
    n = 0
    maxErr = 0.0

    for t in gpstk.times(starttime, endtime, seconds=args.timestep):
        try:
            p1 = pos1.position(t)
            p2 = pos2.position(t)
            error = gpstk.range(p1, p2)
            maxErr = max(maxErr, error)
            X.append(t.getDays())
            Y.append(error)
            if args.verbose:
                sumErr += error
                sumErrSq += error*error
                n += 1
                print 'Time:', timestr(t)
                print '\tPosition 1:', p1
                print '\tPosition 2:', p2
                print '\tError:', error
        except gpstk.exceptions.InvalidRequest:
            if args.verbose:
                print 'Can\'t use data at:', timestr(t)

    if args.verbose and n > 0:
        print 'Arithmetic mean of error values: ', sumErr / n, 'm'
        print 'Root mean square of error values:', np.sqrt(sumErrSq / n), 'm'

    fig = plt.figure()
    title = ('Error for PRN ' + str(args.prn_id) + ' starting '
        + gpstk.CivilTime(starttime).printf('%02m/%02d/%04Y %02H:%02M:%02S'))

    fig.suptitle(title, fontsize=14, fontweight='bold')
    ax = fig.add_subplot(111)
    ax.text(0.90, 0.90, args.filetype1 + ': ' + args.filename1
        + '\n' + args.filetype2 + ': ' + args.filename2,
        verticalalignment='bottom', horizontalalignment='right',
        transform=ax.transAxes)
    ax.set_xlabel('Time')
    ax.set_ylabel('Error (meters)')
    if args.drawdots:
        plt.plot(X, Y, 'ro')
    else:
        plt.plot(X, Y, 'r')

    # sets the y scale
    plt.ylim([0, 2.0 * maxErr])

    # converts common time day (float) -> string
    def daytostring(x):
        t = gpstk.CommonTime()
        t.set(x)
        return gpstk.CivilTime(t).printf(args.format)

    # sets the text shown per-pixel when viewed interactively
    def format_coord(x, y):
        return 'x=' + daytostring(x) + ', y=%1.4f'%(y)
    ax.format_coord = format_coord

    # sets x ticks to use the daytostring text
    locs, labels = plt.xticks()
    for i in range(len(locs)):
        labels[i] = daytostring(locs[i])
    ax.set_xticklabels(labels)

    if not args.noplot:
        plt.show()

    if args.save is not None:
        fig.savefig(args.save)
コード例 #9
0
# 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 = []
el = []
for t in gpstk.times(starttime, endtime, seconds=1000):
    d.append(t.getDays())
    xvt = orbit.svXvt(t)
    location = gpstk.Position(xvt.x)
    el.append(austin.elevation(location))

# Make the plot
fig = figure()
ax = fig.gca()
ax.plot(el)
ax.set_xlabel("Time (days)")
ax.set_ylabel("Elevation (degrees)")
ax.set_title("Elevation of a GPS satellite throughout the day")
show()
コード例 #10
0
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 = []
el = []
for t in gpstk.times(starttime, endtime, seconds=1000):
    d.append(t.getDays())
    xvt = orbit.svXvt(t)
    location = gpstk.Position(xvt.x)
    el.append(austin.elevation(location))


# Make the plot
fig = figure()
ax = fig.gca()
ax.plot(el)
ax.set_xlabel('Time (days)')
ax.set_ylabel('Elevation (degrees)')
ax.set_title('Elevation of a GPS satellite throughout the day')
show()