# Path: thrifty/toads_data.py
# class DetectionResult(object):
#     def __init__(self, timestamp, block, soa, carrier_info, corr_info,
#                  rxid=None, txid=None):
#     def serialize(self):
#     def deserialize(cls, string, with_rxid=False, with_txid=False):
# def _load_toads(stream, with_rxid=True, with_txid=True):
# def load_toad(stream):
# def load_toads(stream):
# def toads_array(detections, with_ids=True):
# 
# Path: thrifty/util.py
# def snr(peak_ampl, noise_rms):
# def fft_bin(idx, fft_len):
# def find_nearest(array, values):
# 
# Path: thrifty/matchmaker.py
# def match_toads(toads, window, min_match=2):
# def load_matches(file_):
# def save_matches(matches, file_):
# def extract_match_matrix(detections, matches, rxids, txids=None):
# def _main():


import argparse
import numpy as np
import matplotlib.pyplot as plt
from collections import OrderedDict
from thrifty import toads_data
from thrifty import util
from thrifty import matchmaker
    plot_carrier_histogram(splits)
    plot_timestamp_residuals(detections)
    plot_column_histogram_matrix(splits, 'offset')
    plot_offset_hist2d(splits)
    plot_column_matrix(splits, 'offset', linewidth=0.1)


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)

# Path: thrifty/toads_data.py
# class DetectionResult(object):
#     def __init__(self, timestamp, block, soa, carrier_info, corr_info,
#                  rxid=None, txid=None):
#     def serialize(self):
#     def deserialize(cls, string, with_rxid=False, with_txid=False):
# def _load_toads(stream, with_rxid=True, with_txid=True):
# def load_toad(stream):
# def load_toads(stream):
# def toads_array(detections, with_ids=True):
# 
# Path: thrifty/util.py
# def snr(peak_ampl, noise_rms):
# def fft_bin(idx, fft_len):
# def find_nearest(array, values):
# 
# Path: thrifty/matchmaker.py
# def match_toads(toads, window, min_match=2):
# def load_matches(file_):
# def save_matches(matches, file_):
# def extract_match_matrix(detections, matches, rxids, txids=None):
# def _main():


# Path: thrifty/toads_analysis.py
import argparse
import numpy as np
import matplotlib.pyplot as plt
from collections import OrderedDict
from thrifty import toads_data
from thrifty import util
from thrifty import matchmaker

    plot_carrier_histogram(splits)
    plot_timestamp_residuals(detections)
    plot_column_histogram_matrix(splits, 'offset')
    plot_offset_hist2d(splits)
    plot_column_matrix(splits, 'offset', linewidth=0.1)


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)