Example #1
0
)
arg_parser.add_argument("source", help="A recording of SiRF messages or saved numpy array (*.npy).")
arg_parser.add_argument(
    "--plotted-sample-count",
    default=5000,
    type=int,
    help="Number of samples that will be plotted in the scatter plots.",
)
arg_parser.add_argument("--save-hdop-plot", default=None, type=str, help="Where to save the HDOP plot.")
arg_parser.add_argument("--save-fixes-plot", default=None, type=str, help="Where to save the fixes plot.")
arg_parser.add_argument("--no-show", action="store_true", help="Don't show the plots, only save them.")
arg_parser.add_argument("--max-plot-hdop", type=float, help="Don't plot hdops larger than this.")
arg_parser.add_argument("--max-plot-error", type=float, help="Don't plot hdop errors larger than this.")
arguments = arg_parser.parse_args()

fixes = wgs84_fixes_to_numpy.open_source(arguments.source)

hdop = fixes["hdop"]
logging.info("Done. Have %i fixes", len(fixes))

logging.info("Projecting")
proj = pyproj.Proj(proj="ortho", ellps="WGS84", lat_0=numpy.mean(fixes["lat"]), lon_0=numpy.mean(fixes["lon"]))
(x, y) = proj(fixes["lon"], fixes["lat"])
logging.info("Done")

logging.info("Calculating distances")
dist_squared = x ** 2 + y ** 2
dist = numpy.sqrt(dist_squared)
logging.info("Done")

logging.info("HDOP statistics")
arg_parser.add_argument('--max-plot-hdop', type=float,
    help="Don't plot hdops larger than this.")
arg_parser.add_argument('--labels', action='store', default='',
    help="Labels for histograms, comma separated")
arguments = arg_parser.parse_args()

arguments.labels = arguments.labels.split(',')
arguments.labels.extend(arguments.sources[len(arguments.labels):])

fig = plt.figure()

hdops = []
max_hdop = 0
for source in arguments.sources:
    logging.info("Retrieving fixes from %s", source)
    fixes = wgs84_fixes_to_numpy.open_source(source)
    logging.info("Done. Have %i fixes", len(fixes))

    max_hdop = max(max_hdop, numpy.amax(fixes["hdop"]))
    hdops.append(fixes["hdop"])

res = arguments.hist_resolution
bins = [res * x - (res / 2) for x in range(int(math.floor(max_hdop / res) + 2))]

if arguments.max_plot_hdop is not None:
    max_hdop = arguments.max_plot_hdop

for i, (hdop, label) in enumerate(zip(hdops, arguments.labels)):
    plot = fig.add_subplot(len(hdops), 1, i + 1)
    n, _, _ = plot.hist(hdop, bins=bins, label=label, alpha=0.7)