# Path: pymoku/_instrument.py
# REG_CTL = 0
# REG_STAT = 1
# REG_ID1 = 2
# REG_ID2 = 3
# REG_PAUSE = 4
# REG_OUTLEN = 5
# REG_FILT = 6
# REG_FRATE = 7
# REG_SCALE = 8
# REG_OFFSET = 9
# REG_OFFSETA = 10
# REG_STRCTL0 = 11
# REG_STRCTL1 = 12
# REG_AINCTL = 13
# REG_PRETRIG = 15
# REG_CAL_ADC0, REG_CAL_ADC1, REG_CAL_DAC0, REG_CAL_DAC1 = list(range(16, 20))
# REG_TEMP_DAC = 14
# REG_MMAP_ACCESS = 62
# REG_STATE = 63
# ADC_SMP_RATE = 500e6
# DAC_SMP_RATE = 1e9
# CHN_BUFLEN = 2**14
# COMMIT = 0x80000000
# INSTR_RST = 0x00000001
# ROLL = 1
# SWEEP = 2
# FULL_FRAME = 0
# RDR_CUBIC = 0
# RDR_MINMAX = 1
# RDR_DECI = 2
# RDR_DDS = 3
# RELAY_DC = 1
# RELAY_LOWZ = 2
# RELAY_LOWG = 4
# def _usgn(i, width):
# def _sgn(i, width):
# def _upsgn(i, width):
# def to_reg_signed(_offset, _len, allow_set=None, allow_range=None,
#                   xform=lambda obj, x: x):
#     def __ss(obj, val, old):
# def to_reg_unsigned(_offset, _len, allow_set=None, allow_range=None,
#                     xform=lambda obj, x: x):
#     def __us(obj, val, old):
# def to_reg_bool(_offset):
# def from_reg_signed(_offset, _len, xform=lambda obj, x: x):
#     def __sg(obj, reg):
# def from_reg_unsigned(_offset, _len, xform=lambda obj, x: x):
#     def __ug(obj, reg):
# def from_reg_bool(_offset):
# def needs_commit(func):
#     def wrapper(self, *args, **kwargs):
#     def __init__(self):
#     def _register_accessors(self, accessor_dict):
#     def _accessor_get(self, reg, get_xform):
#     def _accessor_set(self, reg, set_xform, data):
#     def __getattr__(self, name):
#     def __setattr__(self, name, value):
#     def set_defaults(self):
#     def attach_moku(self, moku):
#     def _commit(self, update_state=True):
#     def commit(self):
#     def check_uncommitted_state(self):
#     def _sync_registers(self):
#     def _on_reg_sync(self):
#     def _dump_remote_regs(self):
#     def _set_running(self, state):
#     def _set_instrument_active(self, active):
#     def _set_frontend(self, channel, fiftyr, atten, ac):
#     def _get_frontend(self, channel):
#     def _dac_gains(self):
#     def _dac_offsets(self):
#     def _adc_gains(self):
#     def _adc_offsets(self):
#     def _set_pause(self, pause):
#     def _get_pause(self):
#     def _load_feature(self, index):
#     def _set_mmap_access(self, access):
# class MokuInstrument(object):
# 
# 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 struct
import math
from pymoku import _instrument
from pymoku import _frame_instrument
from bisect import bisect_right
        return [scale_str, scale_const]

    def _get_xaxis_fmt(self, x, pos):
        # This function returns a format string for the x-axis ticks and
        # x-coordinates along the frequency scale use this to set an x-axis
        # format during plotting of SpectrumAnalyzer frames

        if self._stateid not in self._scales:
            return

        scales = self._scales[self._stateid]
        f1, f2 = scales['fspan']

        fscale_str, fscale_const = self._get_freq_scale(f2)

        return {'xaxis': '%.1f %s' % (x * fscale_const, fscale_str),
                'xcoord': '%.3f %s' % (x * fscale_const, fscale_str)}

    def get_xaxis_fmt(self, x, pos):
        """ Function suitable to use as argument to a matplotlib
            FuncFormatter for X (time) axis """
        return self._get_xaxis_fmt(x, pos)['xaxis']

    def get_xcoord_fmt(self, x):
        """ Function suitable to use as argument to a matplotlib
            FuncFormatter for X (time) coordinate """
        return self._get_xaxis_fmt(x, None)['xcoord']

    def _get_yaxis_fmt(self, y, pos):


# Path: pymoku/_instrument.py
# REG_CTL = 0
# REG_STAT = 1
# REG_ID1 = 2
# REG_ID2 = 3
# REG_PAUSE = 4
# REG_OUTLEN = 5
# REG_FILT = 6
# REG_FRATE = 7
# REG_SCALE = 8
# REG_OFFSET = 9
# REG_OFFSETA = 10
# REG_STRCTL0 = 11
# REG_STRCTL1 = 12
# REG_AINCTL = 13
# REG_PRETRIG = 15
# REG_CAL_ADC0, REG_CAL_ADC1, REG_CAL_DAC0, REG_CAL_DAC1 = list(range(16, 20))
# REG_TEMP_DAC = 14
# REG_MMAP_ACCESS = 62
# REG_STATE = 63
# ADC_SMP_RATE = 500e6
# DAC_SMP_RATE = 1e9
# CHN_BUFLEN = 2**14
# COMMIT = 0x80000000
# INSTR_RST = 0x00000001
# ROLL = 1
# SWEEP = 2
# FULL_FRAME = 0
# RDR_CUBIC = 0
# RDR_MINMAX = 1
# RDR_DECI = 2
# RDR_DDS = 3
# RELAY_DC = 1
# RELAY_LOWZ = 2
# RELAY_LOWG = 4
# def _usgn(i, width):
# def _sgn(i, width):
# def _upsgn(i, width):
# def to_reg_signed(_offset, _len, allow_set=None, allow_range=None,
#                   xform=lambda obj, x: x):
#     def __ss(obj, val, old):
# def to_reg_unsigned(_offset, _len, allow_set=None, allow_range=None,
#                     xform=lambda obj, x: x):
#     def __us(obj, val, old):
# def to_reg_bool(_offset):
# def from_reg_signed(_offset, _len, xform=lambda obj, x: x):
#     def __sg(obj, reg):
# def from_reg_unsigned(_offset, _len, xform=lambda obj, x: x):
#     def __ug(obj, reg):
# def from_reg_bool(_offset):
# def needs_commit(func):
#     def wrapper(self, *args, **kwargs):
#     def __init__(self):
#     def _register_accessors(self, accessor_dict):
#     def _accessor_get(self, reg, get_xform):
#     def _accessor_set(self, reg, set_xform, data):
#     def __getattr__(self, name):
#     def __setattr__(self, name, value):
#     def set_defaults(self):
#     def attach_moku(self, moku):
#     def _commit(self, update_state=True):
#     def commit(self):
#     def check_uncommitted_state(self):
#     def _sync_registers(self):
#     def _on_reg_sync(self):
#     def _dump_remote_regs(self):
#     def _set_running(self, state):
#     def _set_instrument_active(self, active):
#     def _set_frontend(self, channel, fiftyr, atten, ac):
#     def _get_frontend(self, channel):
#     def _dac_gains(self):
#     def _dac_offsets(self):
#     def _adc_gains(self):
#     def _adc_offsets(self):
#     def _set_pause(self, pause):
#     def _get_pause(self):
#     def _load_feature(self, index):
#     def _set_mmap_access(self, access):
# class MokuInstrument(object):
# 
# 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/_specan_data.py
import struct
import math
from pymoku import _instrument
from pymoku import _frame_instrument
from bisect import bisect_right

        return [scale_str, scale_const]

    def _get_xaxis_fmt(self, x, pos):
        # This function returns a format string for the x-axis ticks and
        # x-coordinates along the frequency scale use this to set an x-axis
        # format during plotting of SpectrumAnalyzer frames

        if self._stateid not in self._scales:
            return

        scales = self._scales[self._stateid]
        f1, f2 = scales['fspan']

        fscale_str, fscale_const = self._get_freq_scale(f2)

        return {'xaxis': '%.1f %s' % (x * fscale_const, fscale_str),
                'xcoord': '%.3f %s' % (x * fscale_const, fscale_str)}

    def get_xaxis_fmt(self, x, pos):
        """ Function suitable to use as argument to a matplotlib
            FuncFormatter for X (time) axis """
        return self._get_xaxis_fmt(x, pos)['xaxis']

    def get_xcoord_fmt(self, x):
        """ Function suitable to use as argument to a matplotlib
            FuncFormatter for X (time) coordinate """
        return self._get_xaxis_fmt(x, None)['xcoord']

    def _get_yaxis_fmt(self, y, pos):


        if self._stateid not in self._scales: