soa package¶
Submodules¶
soa.analyse module¶
soa.devices module¶
-
class
soa.devices.
Agilent8156A
(address=None)[source]¶ Bases:
object
-
get_calibration_factor
()[source]¶ Return the calibration factor.
Returns: Calibration factor in dB. Return type: float
-
restore_defaults
()[source]¶ Sends *CLS and *RST to the device, restoring most defaults.
The *CLS command clears the following: - error queue, - standard event status register (ESR), - status byte register (STB). *RST clears most parameters apart from the GPIB settings.
-
set_calibration_factor
(calib=2.9)[source]¶ Sets the calibration factor for the instrument.
Parameters: calib (number) – Calibration factor in dB.
-
set_output
(attenuation)[source]¶ Sets the output attenuation (without changing shutter).
Parameters: attenuation (number) – Attenuation in dB, cannot be lower than calibration_factor.
-
set_wavelength
(wavelength)[source]¶ Sets the wavelength for the instrument.
The value is used to make the compensation for the wavelength dependence of the filter, using the wavelength calibration data.
Parameters: wavelength (number) – Wavelength in nm (from 1200 to 1650).
-
-
class
soa.devices.
Agilent86100C
(address=None)[source]¶ Bases:
object
-
autoscale
()[source]¶ Evaluates current input signal, autoscales, prints result.
Autoscale sets the following: • Channel Display, Scale, and Offset • Trigger and Level • Time Base Scale and Position Autoscale turns off the following: • Measurements on sources that are turned off • Functions • Windows • Memories
-
measurement
(channel=4)[source]¶ Makes a measurement on a selected channel.
Parameters: channel (int) – Channel to make measurement on. Returns: - list of values in volts, where:
- “99.999E+36” represents a hole in the acquisition data, “99.999E+33” represents a clipped-high level, “99.999E+30” represents a clipped-low level.
Return type: List[float]
-
restore_defaults
()[source]¶ Sends *CLS and *RST to the device, restoring most defaults.
The *CLS clears all status and error registers *RST clears most parameters apart from the GPIB settings.
-
set_acquire
(average=None, count=None, points=None)[source]¶ Sets parameters related to acquiring data.
Parameters: - average (bool) – Enables or disables averaging. When ON, the analyzer acquires multiple data values for each time bucket, and averages them. When OFF, averaging is disabled. To set number of averages, use param count.
- count (int) – Sets the number of averages for the waveforms. Specifies the number of data values to be averaged for each time bucket before the acquisition is considered complete for that time bucket. count must be from 1 to 4096.
- points (int or str) – Sets the requested memory depth for an acquisition. You can set the points value to AUTO, which allows the analyzer to select the number of points based upon the sample rate and time base scale. points range is 16 to 16,384 points.
-
set_channel
(channel=4, display=None, offset=None, range_=None)[source]¶ Sets parameters related to channels (and y-axis).
Parameters: - channel (int) – Channel to configure.
- display (bool) – Turns the display of the specified channel on or off.
- offset (number) – Sets the voltage that is represented at the center of the display for the selected channel.
- range (number) – Defines the full-scale vertical axis of the selected channel in volts.
-
set_timebase
(position=None, range_=None, reference=None)[source]¶ Sets parameters related to timebase.
Parameters: - position (number) – in seconds - Sets the time interval between the trigger event and the delay reference point. The delay reference point is set with the TIMebase:REFerence command. The <position_value> argument’s maximum value depends on the time-per-division setting. Must be greater or equal 2.4e-8.
- range (number) – Sets the full-scale horizontal time in seconds. The range value is ten times the time-per-division value. Range is always set in units of time (seconds), not in bits. <full_scale_range> is the full-scale horizontal time in seconds.
- reference (str) – Sets the delay reference to the left or center side of the display. Must be “left” or “center”.
-
-
class
soa.devices.
AnritsuMS9740A
(address=None)[source]¶ Bases:
object
-
ana_rms
(spectrum_level, spectrum_deviation_factor)[source]¶ Executes the RMS spectrum analysis method.
Parameters: - spectrum_level (number) – In dB, between 0.1 and 50.0.
- spectrum_deviation_factor (number) – K: Standard deviation factor, between 1.0 and 10.0.
Returns: center wavelength (nm) spectrum width (nm) standard deviation
Return type: List[float, float, float]
-
screen_capture
()[source]¶ Takes a single sweep of the screen content and returns.
Returns: - Each number is a sample at a wavelength,
- depending on set_x, and length depends on set_sampling_points.
Return type: List[float]
-
set_VBW
(VBW)[source]¶ Sets VBW (video band width).
Parameters: VBW (int or str) – VBW in Hz, must be one of the following: 10|100|200|1000|2000|10000|100000|1000000, or 10HZ|100HZ|200HZ|1KHZ|2KHZ|10KHZ|100KHZ|1MHZ.
-
set_resolution
(resolution)[source]¶ Sets resolution.
Parameters: resolution (float) – Resolution in nm must be only one of the following: 0.03|0.05|0.07|0.1|0.2|0.5|1.0.
-
set_sampling_points
(n)[source]¶ Sets the number of sampling points.
Parameters: n (int) – number of sampling points, must be one of the numbers: 51|101|251|501|1001|2001|5001|10001|20001|50001
-
-
class
soa.devices.
Lightwave3220
(address=None, current_limit=None)[source]¶ Bases:
object
-
set_output
(current, switch_output_on=True)[source]¶ Sets the current output to specified value.
Parameters: - current (number) –
- switch_output_on (bool) – If True, it will turn on the output after specifying the current, otherwise it will stay in the initial state, whether on or off.
-
sweep_current
(start, stop, step, seconds)[source]¶ Turns on the current source and sweeps the output current.
Parameters: - start (number) – Starting point of sweep in mA.
- stop (number) – Sweep does not include this value in mA.
- step (number) – Size of step in mA.
- seconds (number) – Time between steps.
-
-
class
soa.devices.
Lightwave7900B
(address=None)[source]¶ Bases:
object
-
set_channel_power
(channel, power)[source]¶ Sets power on a specified channel.
Parameters: - channel (int) –
- power (float) –
-
set_channel_wavelength
(channel, wavelength)[source]¶ Sets wavelength on a specified channel.
Parameters: - channel (int) –
- wavelength (float) –
-
start_channels
(channels=(1, ))[source]¶ Selects and starts specified channels.
Parameters: channels – Tuple of integers between 1 and 8.
-
sweep_channel_power
(channel, start, stop, step, seconds)[source]¶ Turns on a channel and sweeps the power output.
Parameters: - channel (int) –
- start (number) – Starting point of sweep.
- stop (number) – Sweep does not include this value.
- step (number) – Size of step.
- seconds (number) – Time between steps.
-
-
class
soa.devices.
TektronixAWG7122B
(address=None)[source]¶ Bases:
object
-
restore_defaults
()[source]¶ Sends *CLS and *RST to the device, restoring most defaults.
The *CLS command clears the following: - error queue, - standard event status register (ESR), - status byte register (STB). *RST clears most parameters apart from the GPIB settings.
-
send_waveform
(signal, markers=None, sampling_freq=12000000000.0, amplitude=1.0, channel=1, name='konrad', suppress_messages=False)[source]¶ Sends waveform to the device and turns on specified channel.
Parameters: - signal (Any[float]) – List of at least 1 float values, each value must be between -1 and 1, where the max values are equivalent to max set amplitude.
- markers (Any[int]) – List of integers, either 0 or 1, which will determine if the markers are high or low. For now, this code supports setting both markers to the same value only. Must be the same length as signal.
- sampling_freq (int) – Sampling frequency for the AWG. Combined with the length of signal, it determines the output signal frequency, i.e. output_frequency = sampling_frequency/len(signal) Must be between 10 MHz and 12 GHz.
- name (str) – Name of the waveform.
- amplitude (number) – Sets Vpp range of the signal. E.g. if signal is [0.0, 1.0] and amplitude is 0.5, the output signal will be [0.0 V, 0.25 V].
- suppress_messages (bool) – If True, info and warning messages will not be shown.
-
soa.distort_tf module¶
-
soa.distort_tf.
find_x_init
(tf)[source]¶ This method calculates the state-vector from a long -1 drive signal. Must call before sending / receiving signals to / from transfer function model
Args: - tf = transfer function
Returns: - X0 = system’s state-vector result for steady state
-
soa.distort_tf.
gen_tfs
(num_facs=[1], a0_facs=[1], a1_facs=[1], a2_facs=[1], a3_facs=[1], a4_facs=[1], a5_facs=[1], a6_facs=[1], a7_facs=[1], a8_facs=[1], a9_facs=[1], all_combos=False)[source]¶
-
soa.distort_tf.
getTransferFunctionOutput
(tf, U, T, atol=1e-12)[source]¶ This method sends a drive signal to a transfer function model and gets the output
Args: - tf = transfer function - U = signal to drive transfer function with - T = array of time values - X0 = initial value - atol = scipy ode func parameter
Returns: - PV = resultant output signal of transfer function
soa.get_fopdt_params module¶
soa.optimisation module¶
-
class
soa.optimisation.
PSO
(t, init_OP, n, iter_max, rep_max, init_v_f, max_v_f, w_init=0.9, w_final=None, c1=0.2, c2=0.2, adapt_accel=True, sect_to_optimise='whole_signal', areas_to_suppress='None', off_suppress_f=0.2, on_suppress_f=0.8, embed_init_signal=True, path_to_embedded_signal=None, directory='Unknown', cost_f='Unknown', st_importance_factor=None, sim_model=None, awg=None, osc=None, awg_res=8, min_val=-1.0, max_val=1.0, record_extra_info=False, linux=True, SP=None)[source]¶ Bases:
object
Optimises parameters using particle swarm optimisation (PSO) algorithm
-
soa.optimisation.
run_test
(directory_for_run, tf_for_run, t, init_OP, n, iter_max, rep_max, init_v_f, max_v_f, w_init, w_final, adapt_accel, areas_to_suppress, on_suppress_f, embed_init_signal, path_to_embedded_signal, cost_f, st_importance_factor, record_extra_info, linux, sp, pso_objs)[source]¶ This function defines the test we want to run for each job in a list of python multiprocessing jobs. It is not essential to use this function to run a loop of different PSO runs, but this will execute the PSO runs in parallel and therefore significantly speed up your experiments.
soa.signalprocessing module¶
-
class
soa.signalprocessing.
cost
(t, PV=None, cost_function_label=None, st_importance_factor=None, SP=None)[source]¶ Bases:
object
This class evaluates the cost of a signal output PV given some target output SP. The higher the cost, the poorer the signal performed. There are various ways to evaluate cost, each of which value different aspects of the signal quality in different ways
Parameters to enter: - PV = process variable i.e. an array of signal amplitudes - SP = set point i.e. an array of target signal amplitudes
Parameters to return: - meanSquaredError = the sum of the difference between PV and SP squared - zweeLeePerformanceCriterion = weighted sum of the stepinfo information (rise time, settling time, overshoot and steady state error). Set beta value to determine how cost should be evaluated. Beta < 0.7 prioritises quick rise time and settling time, Beta > 0.7 prioritises low overshoot and steady state error
-
class
soa.signalprocessing.
generateSignal
(num_points=240, t_start=0.0, t_stop=2e-08, save_signal=True, directory=None)[source]¶ Bases:
object
Args: - num_points = number of points you want in signal - t_start = time to start signal period - t_stop = time to stop signal period - save_signal = True or False for saving generated signal - directory = where to save generated signal
-
misic
(off_v=-0.5, on_v=0.5, impulse_v=0.2, duty_cycle=0.5, num_misic_bits=100, bit_rate=2.4e-10, signal_name='misic1')[source]¶ Generates misic driving signal
Args: - off_v = voltage in off state - on_v = voltage in on state - impulse_v = voltage of misic impulses - duty_cycle = fraction of time period signal is on - num_misic_bits = total number of bits in misic signal (paper used 100) - bit_rate = (enter in ps i.e. units of e-12) rate at which misic impulses/bits are repeated (in paper, misic pulses repeated every 240 ps == 4.16 Gb/s) - signal_name = name you want to save signal data under. Can be misic1, misic2, misic3, misic4, misic5 or misic6
-
pisic
(off_v=-0.5, on_v=0.5, impulse_v=0.2, duty_impulse=0.05, duty_cycle=0.5, signal_name='pisic')[source]¶ Generates pisic driving signal
Args: - off_v = voltage in off state - on_v = voltage in on state - impulse_v = pre-impulse voltage (added to on_v at signal leading edge) - duty_impulse = fraction of time period pre impulse be should on for - duty_cycle = fraction of time period signal should be on for - signal_name = name you want to save signal data under
-
-
class
soa.signalprocessing.
soaOutput
(awg, osc, num_points=240, t_start=0.0, t_stop=2e-08, save_signal=True, directory=None)[source]¶ Bases:
object
Class for getting and analysing soa output
Args: - awg = awg object - osc = osc object - num_points = number of points in signal - time_start = time signal period starts - time_stop = time signal period stops - save_siganl = if want to save soa output signal - directory = where to save data#