예제 #1
0
def _main():
    import argparse

    formatter = argparse.RawDescriptionHelpFormatter
    parser = argparse.ArgumentParser(description=__doc__,
                                     formatter_class=formatter)

    parser.add_argument('toads', nargs='?',
                        type=argparse.FileType('rb'), default='data.toads',
                        help="toads data (\"-\" streams from stdin)")
    parser.add_argument('matches', nargs='?',
                        type=argparse.FileType('rb'), default='data.match',
                        help="toads data (\"-\" streams from stdin)")
    parser.add_argument('--beacon', type=int, default=0,
                        help="transmitter ID of beacon")
    parser.add_argument('--rx0', type=int, default=0,
                        help="receiver ID of first receiver")
    parser.add_argument('--rx1', type=int, default=1,
                        help="receiver ID of second receiver")
    parser.add_argument('--range', type=parse_range, default=None,
                        help="limit to a range of detection IDs")
    parser.add_argument('--deg', type=int, default=2,
                        help="degree of polynomial to fit through the SOAs")
    parser.add_argument('--export', type=str, nargs='?',
                        const=True,
                        help="export plot to a .PDF file")

    args = parser.parse_args()

    toads = toads_data.load_toads(args.toads)
    detections = toads_data.toads_array(toads, with_ids=True)

    all_matches = matchmaker.load_matches(args.matches)

    matches = matchmaker.extract_match_matrix(toads, all_matches,
                                              [args.rx0, args.rx1],
                                              [args.beacon])
    if args.range is not None:
        start, stop = args.range
        matches = [m for m in matches
                   if (m[0] >= start and m[0] <= stop and
                       m[1] >= start and m[1] <= stop)]
    matches = np.array(matches)

    analyze(detections, matches, deg=args.deg)

    if args.export:
        if args.export is True:
            filename = 'beacon_analysis_beacon{}_rx{}_rx{}_deg{}'.format(
                       args.beacon, args.rx0, args.rx1, args.deg)
            if args.range is not None:
                filename += '_{}-{}'.format(args.range[0], args.range[1])
            filename += '.pdf'
        else:
            filename = args.export + '.pdf'

        plt.savefig(filename, format='pdf')

    plt.show()
예제 #2
0
def _main():
    parser = argparse.ArgumentParser(
        description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter)

    parser.add_argument('--toad',
                        dest='toad',
                        action='store_true',
                        help="input data is .toad data instead of .toads")
    parser.add_argument('-i',
                        '--input',
                        type=argparse.FileType('rb'),
                        default='data.toads',
                        help=".toads data (\'-\' streams from stdin)")
    parser.add_argument('-m',
                        '--match',
                        type=argparse.FileType('rb'),
                        default=None,
                        help="exclude unmatched detections")
    # TODO: --filter, e.g. txid == 2
    # TODO: take plot/print commands as arguments, e.g. cmd1 [cmd2,...]
    # TODO: tabbed Qt interface (like detect_analysis)
    args = parser.parse_args()

    if args.toad:
        toads = toads_data.load_toad(args.input)
        detections = toads_data.toads_array(toads, with_ids=False)
    else:
        toads = toads_data.load_toads(args.input)
        detections = toads_data.toads_array(toads, with_ids=True)

    if args.match:
        matches = matchmaker.load_matches(args.match)
        matched_ids = np.sort(np.concatenate(matches))
        detections = detections[matched_ids]

    time0 = np.min(detections['timestamp'])
    print('Timestamps relative to {:.6f}'.format(time0))
    detections['timestamp'] -= time0

    splits = split_rxtx(detections)

    print_rxtx_stats(splits)
    plot_all(detections, splits)
    plt.show()
예제 #3
0
def _main():
    import argparse

    formatter = argparse.RawDescriptionHelpFormatter
    parser = argparse.ArgumentParser(description=__doc__,
                                     formatter_class=formatter)

    parser.add_argument('toads',
                        nargs='?',
                        type=argparse.FileType('rb'),
                        default='rx.toads',
                        help="toads data (\"-\" streams from stdin)")
    parser.add_argument('matches',
                        nargs='?',
                        type=argparse.FileType('rb'),
                        default='rx.match',
                        help="toads data (\"-\" streams from stdin)")
    args = parser.parse_args()

    toads = toads_data.load_toads(args.toads)
    detections = toads_data.toads_array(toads, with_ids=True)
    matches = matchmaker.load_matches(args.matches)
    reldist(detections, matches, 1, 0)
예제 #4
0
def _main():
    import argparse

    formatter = argparse.RawDescriptionHelpFormatter
    parser = argparse.ArgumentParser(description=__doc__,
                                     formatter_class=formatter)

    parser.add_argument('toads',
                        nargs='?',
                        type=argparse.FileType('r'),
                        default='data.toads',
                        help="toads data (\"-\" streams from stdin)")
    parser.add_argument('matches',
                        nargs='?',
                        type=argparse.FileType('r'),
                        default='data.match',
                        help="match data (\"-\" streams from stdin)")
    parser.add_argument('-o',
                        '--output',
                        dest='output',
                        type=argparse.FileType('w'),
                        default='data.tdoa',
                        help="output file (\'-\' for stdout)")
    parser.add_argument('-r',
                        '--rx-coordinates',
                        dest='rx_pos',
                        type=argparse.FileType('r'),
                        default='pos-rx.cfg',
                        help="path to config file that contains the "
                        "coordinates of the receivers")
    parser.add_argument('-b',
                        '--beacon-coordinates',
                        dest='beacon_pos',
                        type=argparse.FileType('r'),
                        default='pos-beacon.cfg',
                        help="path to config file that contains the "
                        "coordinates of the beacon transmitters")
    parser.add_argument('-w',
                        '--window-size',
                        dest='window_size',
                        type=float,
                        default=8,
                        help="maximum difference in timestamp between a beacon"
                        " transmission and a mobile unit transmission for"
                        " the beacon transmission to be eligible to be"
                        " used for estimating the TDOA of the mobile unit"
                        " transmission")
    parser.add_argument('-s',
                        '--sample-rate',
                        dest='sample_rate',
                        type=float,
                        default=2.4e6,
                        help="nominal sample rate of receivers")
    args = parser.parse_args()

    toads = toads_data.load_toads(args.toads)
    matches = matchmaker.load_matches(args.matches)
    rx_pos = load_pos_config(args.rx_pos)
    beacon_pos = load_pos_config(args.beacon_pos)
    tdoa_groups, failures = estimate_tdoas(toads, matches, args.window_size,
                                           beacon_pos, rx_pos,
                                           args.sample_rate)

    print("Number of TDOA estimations:", len(tdoa_groups))
    print("Number of TDOA estimation failures:", len(failures))
    save_tdoa_groups(args.output, tdoa_groups)