# 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



class _FRAChannelData():

    def __init__(self, input_signal, gain_correction,
                 front_end_scale, output_amp):

        # Extract the length of the signal (this varies with number of
        # sweep points)
        sig_len = len(gain_correction)

        # De-interleave IQ values
        self.i_sig, self.q_sig = zip(*zip(*[iter(input_signal)] * 2))
        self.i_sig = self.i_sig[:sig_len]
        self.q_sig = self.q_sig[:sig_len]

        # 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

# 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




class _FRAChannelData():

    def __init__(self, input_signal, gain_correction,
                 front_end_scale, output_amp):

        # Extract the length of the signal (this varies with number of
        # sweep points)
        sig_len = len(gain_correction)

        # De-interleave IQ values
        self.i_sig, self.q_sig = zip(*zip(*[iter(input_signal)] * 2))
        self.i_sig = self.i_sig[:sig_len]
        self.q_sig = self.q_sig[:sig_len]

        # 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: