# Path: rtlsdr_scanner/constants.py
# WINFUNC = ["Bartlett", numpy.bartlett,
#            "Blackman", numpy.blackman,
#            "Hamming", numpy.hamming,
#            "Hanning", numpy.hanning]
# 
# Path: rtlsdr_scanner/misc.py
# def db_to_level(dB):
#     return math.pow(10, dB / 10.0)
# 
# def level_to_db(level):
#     return 10 * math.log10(level)


from collections import OrderedDict
from decimal import Decimal
from operator import itemgetter, mul
from matplotlib.dates import seconds
from rtlsdr_scanner.constants import WINFUNC
from rtlsdr_scanner.misc import db_to_level, level_to_db
from rtlsdr_scanner.utils_mpl import utc_to_mpl
import numpy
    powers = map(spectrum.get, freqs)

    return freqs, powers


def split_spectrum_sort(spectrum):
    freqs = spectrum.keys()
    freqs.sort()
    powers = map(spectrum.get, freqs)

    return freqs, powers


def slice_spectrum(spectrum, start, end):
    if spectrum is None or start is None or end is None or len(spectrum) < 1:
        return None

    sweep = spectrum[max(spectrum)]
    if len(sweep) == 0:
        return None

    if min(sweep) > start or max(sweep) < end:
        length = len(spectrum)
        if length > 1:
            sweep = spectrum.values()[length - 2]
        else:
            return None

    sweepTemp = {}
    for f, p in sweep.iteritems():

# Path: rtlsdr_scanner/constants.py
# WINFUNC = ["Bartlett", numpy.bartlett,
#            "Blackman", numpy.blackman,
#            "Hamming", numpy.hamming,
#            "Hanning", numpy.hanning]
# 
# Path: rtlsdr_scanner/misc.py
# def db_to_level(dB):
#     return math.pow(10, dB / 10.0)
# 
# def level_to_db(level):
#     return 10 * math.log10(level)


# Path: rtlsdr_scanner/spectrum.py
from collections import OrderedDict
from decimal import Decimal
from operator import itemgetter, mul
from matplotlib.dates import seconds
from rtlsdr_scanner.constants import WINFUNC
from rtlsdr_scanner.misc import db_to_level, level_to_db
from rtlsdr_scanner.utils_mpl import utc_to_mpl
import numpy

    powers = map(spectrum.get, freqs)

    return freqs, powers


def split_spectrum_sort(spectrum):
    freqs = spectrum.keys()
    freqs.sort()
    powers = map(spectrum.get, freqs)

    return freqs, powers


def slice_spectrum(spectrum, start, end):
    if spectrum is None or start is None or end is None or len(spectrum) < 1:
        return None

    sweep = spectrum[max(spectrum)]
    if len(sweep) == 0:
        return None

    if min(sweep) > start or max(sweep) < end:
        length = len(spectrum)
        if length > 1:
            sweep = spectrum.values()[length - 2]
        else:
            return None

    sweepTemp = {}
    for f, p in sweep.iteritems():

        if start <= f <= end: