# Path: pymoku/_frame_instrument.py
# class FrameQueue(Queue):
# class FrameBasedInstrument(_input_instrument.InputInstrument,
#                            _instrument.MokuInstrument):
#     def put(self, item, block=True, timeout=None):
#     def get(self, block=True, timeout=None):
#     def _init(self, maxsize):
#     def __init__(self):
#     def _set_frame_class(self, frame_class, **frame_kwargs):
#     def _flush(self):
#     def _set_buffer_length(self, buflen):
#     def _get_buffer_length(self):
#     def set_defaults(self):
#     def get_data(self, timeout=None, wait=True):
#     def set_framerate(self, fr):
#     def get_realtime_data(self, timeout=None, wait=True):
#     def _set_running(self, state):
#     def _make_frame_socket(self):
#     def _frame_worker(self):


import math
import struct
from pymoku import _frame_instrument
        # Calculates magnitude of a sample given I,Q and gain correction
        # factors
        def calculate_magnitude(I, Q, G, frontend_scale):
            if I is None or Q is None:
                return None
            else:
                return 2.0 * math.sqrt(
                    (I or 0)**2 + (Q or 0)**2) * front_end_scale / (G or 1)

        self.magnitude = [calculate_magnitude(I, Q, G, front_end_scale)
                          for I, Q, G in zip(self.i_sig,
                                             self.q_sig, gain_correction)]

        # Sometimes there's a transient condition at startup where we don't
        # have a valid output_amp. Return Nones in that case in preference to
        # exploding.
        self.magnitude_dB = [None if not x else
                             20.0 * math.log10(x / output_amp)
                             if output_amp else None for x in self.magnitude]

        self.phase = [None if (I is None or Q is None)
                      else (math.atan2(Q or 0, I or 0)) / (2.0 * math.pi)
                      for I, Q in zip(self.i_sig, self.q_sig)]

    def __json__(self):
        return {'magnitude': self.magnitude,
                'magnitude_dB': self.magnitude_dB,
                'phase': self.phase}



# Path: pymoku/_frame_instrument.py
# class FrameQueue(Queue):
# class FrameBasedInstrument(_input_instrument.InputInstrument,
#                            _instrument.MokuInstrument):
#     def put(self, item, block=True, timeout=None):
#     def get(self, block=True, timeout=None):
#     def _init(self, maxsize):
#     def __init__(self):
#     def _set_frame_class(self, frame_class, **frame_kwargs):
#     def _flush(self):
#     def _set_buffer_length(self, buflen):
#     def _get_buffer_length(self):
#     def set_defaults(self):
#     def get_data(self, timeout=None, wait=True):
#     def set_framerate(self, fr):
#     def get_realtime_data(self, timeout=None, wait=True):
#     def _set_running(self, state):
#     def _make_frame_socket(self):
#     def _frame_worker(self):


# Path: pymoku/_frequency_response_analyzer_data.py
import math
import struct
from pymoku import _frame_instrument

        # Calculates magnitude of a sample given I,Q and gain correction
        # factors
        def calculate_magnitude(I, Q, G, frontend_scale):
            if I is None or Q is None:
                return None
            else:
                return 2.0 * math.sqrt(
                    (I or 0)**2 + (Q or 0)**2) * front_end_scale / (G or 1)

        self.magnitude = [calculate_magnitude(I, Q, G, front_end_scale)
                          for I, Q, G in zip(self.i_sig,
                                             self.q_sig, gain_correction)]

        # Sometimes there's a transient condition at startup where we don't
        # have a valid output_amp. Return Nones in that case in preference to
        # exploding.
        self.magnitude_dB = [None if not x else
                             20.0 * math.log10(x / output_amp)
                             if output_amp else None for x in self.magnitude]

        self.phase = [None if (I is None or Q is None)
                      else (math.atan2(Q or 0, I or 0)) / (2.0 * math.pi)
                      for I, Q in zip(self.i_sig, self.q_sig)]

    def __json__(self):
        return {'magnitude': self.magnitude,
                'magnitude_dB': self.magnitude_dB,
                'phase': self.phase}



class FRAData(_frame_instrument.InstrumentData):