コード例 #1
0
import pylab
import sys

from location import Location
from pylabutils import RED, setupPlot

prev, X, Y = None, [], []
for line in sys.stdin:
  data = json.loads(line)
  cur = (
    int(data['timestampMs']) / 1000,
    Location(data['latitude'], data['longitude'])
  )
  if prev is not None:
    acc = data.get('accuracy')
    if acc is None:
      continue
    dx = prev[1].dist(cur[1])
    dt = cur[0] - prev[0]
    X.append(dx / dt)
    Y.append(dt)
  prev = cur
pylab.plot(X, Y, color=RED, linestyle='None', marker='o')
setupPlot(
  'Speed (m/s)',
  'Interval (s)',
  'Polling Interval vs. Speed'
)
pylab.savefig('timings-vs-speed.png')
pylab.close()
コード例 #2
0
import json
import operator
import pylab
import sys

from stats import histogram
from pylabutils import setupPlot

prev = None
A = []
for line in sys.stdin:
    data = json.loads(line)
    acc = data.get('accuracy')
    if acc:
        A.append(min(999, acc))
w = 10.0
XY = histogram(A, w)
X = map(operator.itemgetter(0), XY)
Y = map(operator.itemgetter(1), XY)
pylab.bar(X, Y, width=w)
setupPlot('Accuracy (m)', 'Frequency', 'Accuracy Radius')
pylab.savefig('accuracy-histogram.png')
コード例 #3
0
root = etree.parse(sys.stdin).getroot()
document = root.getchildren()[-1]
placemark = document.getchildren()[-1]
track = placemark.getchildren()[-1]
dts = []
prev_when = None
for child in track.iterchildren():
    if child.tag.endswith('when'):
        ts = dateutil.parser.parse(child.text)
        when = int(time.mktime(ts.timetuple()))
        if prev_when is not None:
            dts.append(when - prev_when)
        prev_when = when

rmv = RollingMeanVar(0.001)
Y = []
for i, dt in enumerate(dts):
    rmv.update(dt, i)
    Y.append(rmv.mean())
pylab.plot(range(len(Y)), Y, color=RED)
setupPlot('Sample Index', 'Interval (s)', 'Polling Interval - Rolling Average')
pylab.savefig('timings-frequency.png')
pylab.close()

Y = map(operator.itemgetter(1), histogram(dt % 60 for dt in dts))
pylab.bar(range(len(Y)), Y, width=1.0)
setupPlot('Interval (s, mod 60)', 'Frequency',
          'Polling Interval - Seconds mod 60')
pylab.savefig('timings-second-histogram.png')
pylab.close()
コード例 #4
0
import json
import math
import pylab
import sys

from location import Location
from pylabutils import RED, setupPlot

prev, X, Y = None, [], []
for line in sys.stdin:
    data = json.loads(line)
    cur = (int(data['timestampMs']) / 1000,
           Location(data['latitude'], data['longitude']))
    if prev is not None:
        acc = data.get('accuracy')
        if acc is None:
            continue
        dx = prev[1].dist(cur[1])
        dt = cur[0] - prev[0]
        X.append(dx / dt)
        Y.append(acc)
    prev = cur
pylab.plot(X, Y, color=RED, linestyle='None', marker='o')
setupPlot('Speed (m/s)', 'Accuracy (m)', 'Accuracy vs. Speed')
pylab.savefig('accuracy-vs-speed.png')
コード例 #5
0
import math
import pylab
import sys

from location import Location
from pylabutils import RED, setupPlot

prev, X, Y = None, [], []
for line in sys.stdin:
  data = json.loads(line)
  cur = (
    int(data['timestampMs']) / 1000,
    Location(data['latitude'], data['longitude'])
  )
  if prev is not None:
    acc = data.get('accuracy')
    if acc is None:
      continue
    dx = prev[1].dist(cur[1])
    dt = cur[0] - prev[0]
    X.append(dx / dt)
    Y.append(acc)
  prev = cur
pylab.plot(X, Y, color=RED, linestyle='None', marker='o')
setupPlot(
  'Speed (m/s)',
  'Accuracy (m)',
  'Accuracy vs. Speed'
)
pylab.savefig('accuracy-vs-speed.png')
コード例 #6
0
import json
import operator
import pylab
import sys

from stats import histogram
from pylabutils import setupPlot

prev = None
A = []
for line in sys.stdin:
  data = json.loads(line)
  acc = data.get('accuracy')
  if acc:
    A.append(min(999, acc))
w = 10.0
XY = histogram(A, w)
X = map(operator.itemgetter(0), XY)
Y = map(operator.itemgetter(1), XY)
pylab.bar(X, Y, width=w)
setupPlot(
  'Accuracy (m)',
  'Frequency',
  'Accuracy Radius'
)
pylab.savefig('accuracy-histogram.png')
コード例 #7
0
  if child.tag.endswith('when'):
    ts = dateutil.parser.parse(child.text)
    when = int(time.mktime(ts.timetuple()))
    if prev_when is not None:
      dts.append(when - prev_when)
    prev_when = when

rmv = RollingMeanVar(0.001)
Y = []
for i, dt in enumerate(dts):
  rmv.update(dt, i)
  Y.append(rmv.mean())
pylab.plot(range(len(Y)), Y, color=RED)
setupPlot(
  'Sample Index',
  'Interval (s)',
  'Polling Interval - Rolling Average'
)
pylab.savefig('timings-frequency.png')
pylab.close()

Y = map(operator.itemgetter(1), histogram(dt % 60 for dt in dts))
pylab.bar(range(len(Y)), Y, width=1.0)
setupPlot(
  'Interval (s, mod 60)',
  'Frequency',
  'Polling Interval - Seconds mod 60'
)
pylab.savefig('timings-second-histogram.png')
pylab.close()