Reference

pyrf.devices.thinkrf

pyrf.config

class pyrf.config.SweepEntry(fstart=2400000000, fstop=2400000000, fstep=100000000, fshift=0, decimation=0, antenna=1, gain='vlow', ifgain=0, spp=1024, ppb=1, trigtype='none', level_fstart=50000000, level_fstop=10000000000, level_amplitude=-100)

Sweep entry for pyrf.devices.thinkrf.WSA4000.sweep_add()

Parameters:
  • fstart – starting frequency in Hz
  • fstop – ending frequency in Hz
  • shift – the frequency shift in Hz
  • decimation – the decimation value (0 or 4 - 1023)
  • antenna – the antenna (1 or 2)
  • gain – the RF gain value (‘high’, ‘medium’, ‘low’ or ‘vlow’)
  • ifgain – the IF gain in dB (-10 - 34)
  • spp – samples per packet
  • ppb – packets per block
  • trigtype – trigger type (‘none’ or ‘level’)
  • level_fstart – level trigger starting frequency in Hz
  • level_fstop – level trigger ending frequency in Hz
  • level_amplitude – level trigger minimum in dBm
class pyrf.config.TriggerSettings(trigtype='NONE', fstart=None, fstop=None, amplitude=None)

Trigger settings for pyrf.devices.thinkrf.WSA4000.trigger().

Parameters:
  • trigtype – “LEVEL” or “NONE” to disable
  • fstart – starting frequency in Hz
  • fstop – ending frequency in Hz
  • amplitude – minumum level for trigger in dBm
exception pyrf.config.TriggerSettingsError

pyrf.vrt

class pyrf.vrt.ContextPacket(pkt_type, word, socket)

A Context Packet received from pyrf.vrt.Stream.read_packet()

fields

a dict containing field names and values from the packet

is_context_packet(ptype=None)
Parameters:ptype – “Receiver”, “Digitizer” or None for any packet type
Returns:True if this packet matches the type passed
is_data_packet()
Returns:False
class pyrf.vrt.DataPacket(word, socket)

A Data Packet received from pyrf.vrt.Stream.read_packet()

data

a pyrf.vrt.IQData object containing the packet data

is_context_packet(ptype=None)
Returns:False
is_data_packet()
Returns:True
class pyrf.vrt.IQData(binary_data)

Data Packet values as a lazy collection of (I, Q) tuples read from binary_data.

This object behaves as an immutable python sequence, e.g. you may do any of the following:

points = len(iq_data)

i_and_q = iq_data[5]

for i, q in iq_data:
    print i, q
numpy_array()

Return a numpy array of I, Q values for this data similar to:

array([[ -44,    8],
       [ -40,   60],
       [ -12,   92],
       ...,
       [-132,   -8],
       [-124,   56],
       [ -44,   80]], dtype=int16)
exception pyrf.vrt.InvalidDataReceived
class pyrf.vrt.Stream(socket)

A VRT Packet Stream interface wrapping socket.

has_data()
Returns:True if there is data waiting on socket.
read_packet()

Read a complete packet from socket and return either a pyrf.vrt.ContextPacket or a pyrf.vrt.DataPacket.

pyrf.util

pyrf.util.read_data_and_reflevel(dut, points=1024)

Wait for and capture a data packet and a reference level packet.

Returns:(data_pkt, reflevel_pkt)
pyrf.util.socketread(socket, count, flags=None)

Retry socket read until count data received, like reading from a file.

pyrf.numpy_util

pyrf.numpy_util.compute_fft(dut, data_pkt, reflevel_pkt)

Return an array of dBm values by computing the FFT of the passed data and reference level.

Parameters:

This function uses only dut.ADC_DYNAMIC_RANGE, data_pkt.data and reflevel_pkt[‘reflevel’].

Returns:numpy array of dBm values as floats