# Path: wwb_scanner/core.py
# class JSONMixin(object):
#     @classmethod
#     def from_json(cls, data, **kwargs):
#         if isinstance(data, basestring):
#             data = json.loads(data)
#         kwargs.update(data)
#         kwargs['__from_json__'] = True
#         obj = cls(**kwargs)
#         obj._deserialize(**kwargs)
#         return obj
#     def instance_from_json(self, data, **kwargs):
#         if isinstance(data, basestring):
#             data = json.loads(data)
#         kwargs.update(data)
#         self._deserialize(**kwargs)
#     def to_json(self, **kwargs):
#         d = self._serialize()
#         return json.dumps(d, **kwargs)
#     def _serialize(self):
#         raise NotImplementedError('method must be implemented by subclasses')
#     def _deserialize(self, **kwargs):
#         pass
# 
# Path: wwb_scanner/utils/dbmath.py
# REF_DB = 1.#1e-4
# def amplitude_to_dB(a, ref=REF_DB):
# def dB_to_amplitude(dB, ref=REF_DB):
# def power_to_dB(p, ref=REF_DB):
# def dB_to_power(dB, ref=REF_DB):
# def to_dB(p, ref=REF_DB):
# def from_dB(dB, ref=REF_DB):


import numpy as np
import jsonfactory
from scipy.interpolate import CubicSpline
from wwb_scanner.core import JSONMixin
from wwb_scanner.utils import dbmath


class SampleArray(JSONMixin):
    dtype = np.dtype([
        ('frequency', np.float64),
        ('iq', np.complex128),
        ('magnitude', np.float64),
        ('dbFS', np.float64)
    ])
    def __init__(self, data=None, keep_sorted=True):
        self.keep_sorted = keep_sorted
        if data is None:
            data = np.empty([0], dtype=self.dtype)
        self.data = data
        if keep_sorted:

# Path: wwb_scanner/core.py
# class JSONMixin(object):
#     @classmethod
#     def from_json(cls, data, **kwargs):
#         if isinstance(data, basestring):
#             data = json.loads(data)
#         kwargs.update(data)
#         kwargs['__from_json__'] = True
#         obj = cls(**kwargs)
#         obj._deserialize(**kwargs)
#         return obj
#     def instance_from_json(self, data, **kwargs):
#         if isinstance(data, basestring):
#             data = json.loads(data)
#         kwargs.update(data)
#         self._deserialize(**kwargs)
#     def to_json(self, **kwargs):
#         d = self._serialize()
#         return json.dumps(d, **kwargs)
#     def _serialize(self):
#         raise NotImplementedError('method must be implemented by subclasses')
#     def _deserialize(self, **kwargs):
#         pass
# 
# Path: wwb_scanner/utils/dbmath.py
# REF_DB = 1.#1e-4
# def amplitude_to_dB(a, ref=REF_DB):
# def dB_to_amplitude(dB, ref=REF_DB):
# def power_to_dB(p, ref=REF_DB):
# def dB_to_power(dB, ref=REF_DB):
# def to_dB(p, ref=REF_DB):
# def from_dB(dB, ref=REF_DB):


# Path: wwb_scanner/scan_objects/samplearray.py
import numpy as np
import jsonfactory
from scipy.interpolate import CubicSpline
from wwb_scanner.core import JSONMixin
from wwb_scanner.utils import dbmath



class SampleArray(JSONMixin):
    dtype = np.dtype([
        ('frequency', np.float64),
        ('iq', np.complex128),
        ('magnitude', np.float64),
        ('dbFS', np.float64)
    ])
    def __init__(self, data=None, keep_sorted=True):
        self.keep_sorted = keep_sorted
        if data is None:
            data = np.empty([0], dtype=self.dtype)
        self.data = data
        if keep_sorted:

            self.data = np.sort(self.data, order='frequency')