Skippylab¶
Skippylab documentation contents¶
skippylab package¶
Subpackages¶
skippylab.instruments package¶
Submodules¶
skippylab.instruments.function_generators module¶
Function generators
skippylab.instruments.gpibcontrollers module¶
Wrapper around the PrologixGPIBEthernet adapter, to transparently manage instruments which are connected via GPIB and the respective controller
skippylab.instruments.oscilloscopes module¶
Communicate with oscilloscope via vxi11 protocol over LAN network
-
class
skippylab.instruments.oscilloscopes.
AbstractBaseOscilloscope
(ip='169.254.68.19', loglevel=20)[source]¶ Bases:
object
A oscilloscope with a high sampling rate in the order of several gigasamples. Defines the scope API the DAQ reiles on
-
ACQUIRE_ONE
= 'SEQ'¶
-
CONTINOUS_RUN
= 'RUNSTop'¶
-
MAXTRIALS
= 5¶
-
samplingrate
¶ Get the current sampling rate
Returns: float (GSamples/sec)
-
select_channel
(channel)[source]¶ Select a channel for the data acquisition
Parameters: channel (int) – Channel number Returns: None
-
string_encoding
= 'iso-8859-1'¶
-
-
class
skippylab.instruments.oscilloscopes.
RhodeSchwarzRTO1044
(ip)[source]¶ Bases:
skippylab.instruments.oscilloscopes.AbstractBaseOscilloscope
Made by Rhode&Schwarz, scope with sampling rate up to 20GSamples/s
-
samplingrate
¶ Get the current sampling rate
Returns: float (GSamples/sec)
-
-
class
skippylab.instruments.oscilloscopes.
TektronixDPO4104B
(ip, loglevel=20)[source]¶ Bases:
skippylab.instruments.oscilloscopes.AbstractBaseOscilloscope
Oscilloscope of type DPO4104B manufactured by Tektronix
-
acquire
¶
-
acquire_mode
¶
-
acquire_waveform
(header=None, return_digitizer_levels=False)[source]¶ Get the waveform data
Keyword Arguments: Returns: np.ndarray
-
average_waveform
(n=10)[source]¶ Acquire some waveforms and take the average
- Keyword Args.
- n (int): number of waveforms to average over
Returns: tuple(np.array). xs, ys
-
binary_formats
= {'RI': '!b'}¶
-
binary_header_pattern
= re.compile('#(?P<bin_head>[0-9]*)')¶
-
data
¶
-
data_start
¶
-
data_stop
¶
-
data_width
¶
-
static
decode_ascii_waveform
(response)[source]¶ Search the response for waveform data when in ascii format
Parameters: response (str) – Hopefully the result of a CURVE command or similar Returns: np.ndarray
-
decode_binary_waveform
(response, header)[source]¶ Decaode a waveform in binary format. To do so, the header is required to know about the exact format.
Parameters: Returns: np.ndarray
-
static
decode_header
(response, return_last_index=False, absolute_timing=False)[source]¶ Parse a response searching for waveform header data
Parameters: head (str) – hopefully the result of some WAVFrm or similar command
Keyword Arguments: Returns: dict/tuple
-
histbox
¶
-
histend
¶
-
histogram
¶ Return a histogram which might be recorded by the scope
-
histstart
¶
-
make_n_acquisitions
(n, trials=20, return_only_charge=False, single_acquisition=True, return_digitizer_levels=False)[source]¶ Acquire n waveforms
Parameters: n (int) – Number of waveforms to acquire
Keyword Arguments: - trials (int) – Set breaking condition when to abort acquisition
- return_only_charge (bool) – don’t get the wf, but only integrated charge instead
- single_acquisition (bool) – use the scopes single acquisition mode
- return_digitizer_levels (bool) – return the waveform data in digitizer levels, not volts. Saves space for storage, since int8 can be used for 1-bit representation. ..and there is no float8 for obvious reasons.
Returns: [wf_1,wf_2,…]
Return type:
-
pull
(buff_header=True, use_buffered_acq_window=True, use_channel_info=True)[source]¶ Fit in the API for the DAQ. Returns waveform data
Keyword Arguments: - buff_header (bool) – buffer the header for subsequent acquisition without changing the parameters of the acquistion (much faster)
- Default value of this should be False, however requires DAQ API change (FIXME!) –
- use_buffered_acq_window (bool) – set this flag to cache the length of the acquisition window internally so that it does not get resetted when switching channels
- use_channel_info (bool) – select the channel on each submit
Returns: dict
-
reset_acquisition_window
()[source]¶ Reset the acquisition window to the maximum possible acquisition window Returns:In
None
-
samplingrate
¶ The samplingrate in GSamples/S
Returns: float
-
select_channel
(channel)[source]¶ Select the channel for the readout
Parameters: channel (int) – Channel number (1-4) Returns: None
-
set_acquisition_window
(start, stop)[source]¶ Set the acquisition window in bin number
Parameters: Returns: None
-
set_acquisition_window_from_internal_buffer
()[source]¶ Use the internal buffer to set the data acquisition window. Might be necessary if the channel was switched in the meantime
Returns: None
-
set_feature_acquisition_window
(leading, trailing, n_waveforms=20)[source]¶ Set the acquisition window around the most prominent feature in the waveform
Parameters: - Keyword Args
- n_waveforms (int): average over n_waveforms to identify the most prominent feature
Returns: None
-
show_waveforms
(n=5)[source]¶ Demonstration function: Will use pylab show to plot some acquired waveforms
Keyword Arguments: n (int) – number of waveforms to show Returns: None
-
source
¶
-
time_binwidth
¶ Get the binwidth of the time - that is sampling rate
Returns: float
-
trigger_frequency_enabled
¶
-
triggerrate
¶ The rate the scope is triggering. The scope in principle provides this number, however we have to work around it as it does not work reliably
Keyword Arguments: interval (int) – time interval to integrate measurement over in seconds Returns: float
-
waveform_bins
¶ Get the time bin numbers for the waveform voltage data
Returns: np.ndarray
-
waveform_enc
¶
-
waveform_times
¶ Get the time for the waveform bins
Returns: np.ndarray
-
-
class
skippylab.instruments.oscilloscopes.
UnknownOscilloscope
(ip='169.254.68.19', loglevel=20)[source]¶ Bases:
skippylab.instruments.oscilloscopes.AbstractBaseOscilloscope
Use for testing and debugging
skippylab.instruments.powersupplies module¶
Connection to power supply unit
-
class
skippylab.instruments.powersupplies.
KeysightE3631APowerSupply
(ip='10.25.124.252', gpib_address=5, loglevel=20)[source]¶ Bases:
object
A low voltage power supply with two channels, +6V and +- 25V manufactured by Keysight. The power supply does not have an ethernet port, so the connection is done via GPIB and a prologix GPIB Ethernet connector
-
error_state
¶ Read out the error register of the power supply
Returns: str
-
measure_current
(channel)[source]¶ Measure current on givven channel
Parameters: channel (str) – Returns: float
-
output
¶
-
Module contents¶
skippylab.scpi package¶
Submodules¶
skippylab.scpi.commands module¶
A namespace for oscilloscope string commands. The commands are send as ASCII to the scope using a socket connection
-
class
skippylab.scpi.commands.
KeysightE3631APowerSupplyCommands
[source]¶ Bases:
object
Namespace for the commands of the KeysightE3631APowerSupply
-
APPLY
= 'APPLY'¶
-
CHANNEL
= 'INST'¶
-
CURRENT
= 'CURRENT'¶
-
DC
= 'DC'¶
-
ERROR_STATEQ
= 'SYST:ERR?'¶
-
MEASURE
= 'MEASURE'¶
-
N25
= 'N25V'¶
-
OFF
= 'OFF'¶
-
ON
= 'ON'¶
-
OUTPUT
= 'OUTPUT:STATE'¶
-
P25
= 'P25V'¶
-
P6
= 'P6V'¶
-
VOLT
= 'VOLT'¶
-
-
class
skippylab.scpi.commands.
RhodeSchwarzRTO1044Commands
[source]¶ Bases:
object
Namespace for the commands for the RhodeSchwarz oscilloscope
-
CH1
= 'CHAN1'¶
-
CH2
= 'CHAN2'¶
-
CH3
= 'CHAN3'¶
-
CH4
= 'CHAN4'¶
-
CURVE
= 'DATA:VALues?'¶
-
N_ACQUISITONS
= 'ACQuire:CURRent?'¶
-
RUN
= 'RUN'¶
-
SINGLE
= 'SINGLE'¶
-
STOP
= 'STOP'¶
-
WAVEFORM
= 'DATA?'¶
-
WF_HEADER
= 'DATA:HEADer?'¶
-
-
class
skippylab.scpi.commands.
TektronixDPO4104BCommands
[source]¶ Bases:
object
Namespace for the commands for the TektronixDP04104B
-
ACQUISITON_MODE
= 'ACQuire:STOPAfter'¶
-
CH1
= 'CH1'¶
-
CH2
= 'CH2'¶
-
CH3
= 'CH3'¶
-
CH4
= 'CH4'¶
-
N_ACQUISITIONS
= 'ACQuire:NUMACq?'¶
-
OFF
= 'OFF'¶
-
ON
= 'ON'¶
-
ONE
= '1'¶
-
TRIGGER_FREQUENCYQ
= 'TRIGger:FREQuency?'¶
-
TRIGGER_FREQUENCY_ENABLED
= 'DISplay:TRIGFrequency'¶
-
WF
= 'WAVFrm?'¶
-
WF_BYTEWIDTH
= 'DATA:WIDTH'¶
-
WF_HEADER
= 'WFMOutpre:BYT_Nr?;:WFMOutpre:ENCdg?; :WFMOutpre:NR_Pt?; :WFMOutpre:XZEro?; :WFMOutpre:XINcr?; :WFMOutpre:YZEro?; :WFMOutpre:YOFf?; :WFMOutpre:YMUlt?; :WFMOutpre:XUNit?; :WFMOutpre:YUNit?; '¶
-
WF_NOHEAD
= 'CURVE?'¶
-
ZERO
= '0'¶
-
-
skippylab.scpi.commands.
add_arg
(cmd, arg)[source]¶ Add an argument to a command string. Concat the two.
Parameters: Returns: str
-
skippylab.scpi.commands.
clean_response
(response)[source]¶ Remove some EOL remainders from the resulting scope response
Parameters: response (str) – response from the scope Returns: str
-
skippylab.scpi.commands.
concat
(*cmd)[source]¶ Combine several commands
Parameters: cmd – list of commands Returns: str
-
skippylab.scpi.commands.
histbox_coordinates
(left, top, right, bottom)[source]¶ Create a string for the box coordinates for the histogram set up by the scope itself. The result can be send to the scope to set the box.
Parameters: Returns: str
-
skippylab.scpi.commands.
parse_curve_data
(header, curve)[source]¶ Make sense out of that what is returned by CURVE. This works only if the scope is set to return the data in ASCII, not binary.
Parameters: Returns: np.ndarray xs, np.ndarray values
Return type:
-
skippylab.scpi.commands.
query
(cmd)¶
Module contents¶
Submodules¶
skippylab.daq module¶
Use the scope as a DAQ
-
class
skippylab.daq.
DAQ
[source]¶ Bases:
object
A virtual DAQ using an oscilloscope
-
acquire
(*pullargs, **pullkwargs)[source]¶ Go through the instrument list and trigger their pull methods to build an event
Keyword Arguments: **pullkwargs (dict) – will be passed on the individual pull methods Returns: pyosci.Event
-
acquire_n_events
(n_events, trigger_hook=<function DAQ.<lambda>>, trigger_hook_args=(None, ), pull_args=(), pull_kwargs={})[source]¶ Continuous acquisition. Acquires n events. Yields events. Use trigger hook to define a function to decide when data is returned.
Parameters: Yields: Event
-
register_instrument
(instrument, label='instrument')[source]¶ Register an instrument and assign a channel to it. Instruments must have a pull() method which allows to pull data from them at a certain event.
Parameters: - instrument (ducktype) – needs to be configured already and must have a pull() method
- channel_name (int) – identify the instrument under this registered channel
Returns: None
-
skippylab.loggers module¶
Prepare logging functionality for the module
skippylab.plotting module¶
Convenient plot functions
-
skippylab.plotting.
plot_histogram
(bincenters, bincontent, fig=None, savename='test.png', remove_empty_bins=True)[source]¶ Plot a histogram returned by TektronixDPO4104B.get_histogram Use pylab.plot
Parameters: - bincenters (np.ndarray); bincenters (x) –
- bincontent (np.ndarray) – bincontent (y)
Keyword Arguments:
skippylab.tools module¶
Convenient operations
-
skippylab.tools.
average_wf
(waveforms)[source]¶ Get the average waveform
Parameters: waveforms (iterable of np.ndarrays) – Returns: np.ndarray
-
skippylab.tools.
integrate_wf
(waveform, xs, xstep, method=<Mock name='mock.integrate.simps' id='140063488474416'>, impedance=50)[source]¶ Integrate a waveform, i.e. a voltage curve. If the desired result shall be indeed a charge, please make sure to give xs in seconds and impedance in Ohm accordingly. xstep needs to be in seconds as well.
Parameters: - waveform (np.ndarray) – voltage values
- xs (np.ndarray) – timing values
- xstep (float) – timing bin size
Keyword Arguments: - method (func) – integration method
- impedance (float) – needed to calculate actual charge
Returns: float
-
skippylab.tools.
load_waveform
(filename, converter=<function <lambda>>)[source]¶ load a waveform from a file
Parameters: filenaame (str) – An existing filename Keyword Arguments: converter (func) – If the data is saved in digitizer levels, use the converter function to convert to Volts Returns: tuple (dict, np.ndarray)
Module contents¶
Package to read out TektronixDPO4104B oscilloscope