# 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 time
import numbers
import numpy as np
from wwb_scanner.core import JSONMixin
from wwb_scanner.utils import dbmath
    def iq(self, value):
        if value is None:
            return
        if self.init_complete:
            old = self.iq
            if old == value:
                return
        if isinstance(value, (list, tuple)):
            i, q = value
            value = np.complex128(float(i) + 1j*float(q))
        ix = self.spectrum_index
        self.spectrum.sample_data['iq'][ix] = value
        if not self.init_complete:
            return
        self.spectrum.on_sample_change(sample=self, iq=value, old=old)
    @property
    def magnitude(self):
        ix = self.spectrum_index
        if ix is None:
            return None
        return self.spectrum.sample_data['magnitude'][ix]
    @magnitude.setter
    def magnitude(self, value):
        if value is None:
            return
        if not isinstance(value, numbers.Number):
            return
        if self.init_complete:
            old = self.magnitude
            if old == value:

# 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/sample.py
import time
import numbers
import numpy as np
from wwb_scanner.core import JSONMixin
from wwb_scanner.utils import dbmath

    def iq(self, value):
        if value is None:
            return
        if self.init_complete:
            old = self.iq
            if old == value:
                return
        if isinstance(value, (list, tuple)):
            i, q = value
            value = np.complex128(float(i) + 1j*float(q))
        ix = self.spectrum_index
        self.spectrum.sample_data['iq'][ix] = value
        if not self.init_complete:
            return
        self.spectrum.on_sample_change(sample=self, iq=value, old=old)
    @property
    def magnitude(self):
        ix = self.spectrum_index
        if ix is None:
            return None
        return self.spectrum.sample_data['magnitude'][ix]
    @magnitude.setter
    def magnitude(self, value):
        if value is None:
            return
        if not isinstance(value, numbers.Number):
            return
        if self.init_complete:
            old = self.magnitude
            if old == value:

                return