# 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
        return obj
    def set_fields(self, **kwargs):
        f = kwargs.get('frequency')
        if f is None:
            raise Exception('frequency array must be provided')
        if not isinstance(f, np.ndarray):
            f = np.array([f])
        data = np.zeros(f.size, dtype=self.dtype)
        data['frequency'] = f
        for key, val in kwargs.items():
            if key not in self.dtype.fields:
                continue
            if key == 'frequency':
                continue
            if not isinstance(val, np.ndarray):
                val = np.array([val])
            data[key] = val

        if data is None:
            return

        iq = kwargs.get('iq')
        mag = kwargs.get('magnitude')
        dbFS = kwargs.get('dbFS')

        if iq is not None and mag is None:
            mag = data['magnitude'] = np.abs(iq)
        if dbFS is not None and mag is None:
            mag = data['magnitude'] = dbmath.from_dB(dbFS)
        if mag is not None and dbFS is None:

# 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

        return obj
    def set_fields(self, **kwargs):
        f = kwargs.get('frequency')
        if f is None:
            raise Exception('frequency array must be provided')
        if not isinstance(f, np.ndarray):
            f = np.array([f])
        data = np.zeros(f.size, dtype=self.dtype)
        data['frequency'] = f
        for key, val in kwargs.items():
            if key not in self.dtype.fields:
                continue
            if key == 'frequency':
                continue
            if not isinstance(val, np.ndarray):
                val = np.array([val])
            data[key] = val

        if data is None:
            return

        iq = kwargs.get('iq')
        mag = kwargs.get('magnitude')
        dbFS = kwargs.get('dbFS')

        if iq is not None and mag is None:
            mag = data['magnitude'] = np.abs(iq)
        if dbFS is not None and mag is None:
            mag = data['magnitude'] = dbmath.from_dB(dbFS)
        if mag is not None and dbFS is None:

            data['dbFS'] = dbmath.to_dB(mag)