mla_gui¶
- class mlaapi.mla_gui.ErrPanel(parent)¶
Class for having a panel around the error status field. This way we can set the background color and flash it.
- class mlaapi.mla_gui.IMPStatusBar(parent)¶
- class mlaapi.mla_gui.ImGUI(parent, settings, id=-1, title='', pos=wx.Point(-1, -1), size=wx.Size(-1, -1), style=675290688)¶
This class contains the menu bar and handles the panels.
- hide_all_panels(evt=None)¶
Note
The panels are not closed, only hidden. When a panel is shown again, it will look the same as before it was hidden.
Examples
>>> main.gui.hide_all_panels()
See also
mla_gui.ImGUI.show_panel()
- set_docksize(panel, size)¶
A dock can contain one or more docked panels. This function sets the size of the dock that contains a specified panel.
- Parameters:
panel – panel
size – integer size of the dock in pixels
Examples
>>> main.gui.set_docksize(main.message_log, 300) >>> main.gui.set_docksize(main.shell, main.gui.GetSize()[0]/2) #Use half the horizontal window size
- show_panel(panel, pos=None)¶
- Parameters:
panel – panel to show
pos – string or list of strings that specify the position. The string should represent a member function call of a AuiPaneInfo object. See the examples and the link under References.
Examples
>>> main.gui.show_panel(main.scopepanel) >>> main.gui.show_panel(main.shell) >>> main.gui.show_panel(main.scriptpanel) >>> main.gui.show_panel(main.shell, pos='Left()') >>> main.gui.show_panel(main.message_log, pos='Bottom().Dock()') >>> main.gui.show_panel(main.lockinpanel) >>> main.gui.show_panel(main.lockin_setup_panel) >>> main.gui.show_panel(main.frequency_count_panel) >>> main.gui.show_panel(main.fsweeppanel) >>> main.gui.show_panel(main.message_log, pos=('Dock()', 'Bottom()', 'Layer(1)'))
See also
mla_gui.ImGUI.hide_all_panels()
References
http://wxpython.org/Phoenix/docs/html/lib.agw.aui.framemanager.AuiPaneInfo.html
- class mlaapi.mla_gui.MyAuiManager(*args, **keys)¶
- ClosePane(pane_info)¶
Destroys or hides the pane depending on its flags.
- Parameters:
pane_info – a
AuiPaneInfo
instance.
Override because ClosePane will dock a floating pane for some reason, and we don’t want that. So we let ClosePane do its thing, and then we set the pane as floating again. Possibly there’s a better way… //Riccardo 2018-04-11
Script panel¶
- class mlaapi.scriptpanel.ScriptPanel(parent, mla, shell, scriptplot, id=-1, stdout=None, stderr=None)¶
The ScriptPanel contains a text editor and a toolbar to open, save and execute scripts.
- open_file(filename)¶
Open a file in the script editor. The file will not be executed.
- Parameters:
filename – Full path, or path relative to the system ‘mla_scripts’ folder.
Note
When a script runs, the path to the current script is stored in the variable __scriptfile__.
Note
If a file is already opened it will be closed without saving.
Examples
>>> main.scriptpanel.open_file('my_script.py') >>> main.scriptpanel.open_file('built-in emperature_test.py') >>> main.scriptpanel.open_file('c:\myscripts\myscript.py') >>> main.scriptpanel.open_file(__scriptfile__)
Scripting utilities¶
This module collects various utility functions that can be useful in the script editor in the MLA software.
- mlaapi.scriptutils.generate_filename(foldername_format='%Y-%m-%d', filename_format='%H_%M_%S')¶
Generate the complete path to a new file in the user data folder containing the data as folder name and time as filename. New subfolders are created if necessary.
- Parameters:
foldername_format – string, will be passed to time.strftime() to generate the folder name
filename_format – string, will be passed to time.strftime() to generate the file name
- Returns:
The full path to a new file.
- Return type:
string
Examples
>>> scriptutils.generate_filename() + '.png' 'C:\IMP Sessions and Settings\sessions\2015-09-04\08_45_30.png' >>> scriptutils.generate_filename(foldername_format='sample_1', filename_format=rig2_%Y-%m-%d__%H_%M_%S) + '.txt' 'C:\IMP Sessions and Settings\sessions\sample_1\rig2_2015-09-04__08_56_37.txt'
Shell panel¶
- class mlaapi.impgui.ShellPanel(parent, id=-1)¶
Panel that contains a python shell.
- add_text(txt)¶
Adds a text to the prompt of the python shell. The text command is not executed.
- Parameters:
txt – string
Examples
>>> main.shell.add_text('mla.run_calibration_sequence()')
- mlaapi.impgui.flash_color(widget, color='yes', time=0.8, reset_color='#FFFFFF')¶
Change background color of a wx widget for a certain amount of time
- Parameters:
widget (a wx window object (e.g. ex.TextCtrl)) –
color (string) – ‘yes’ (default) for a green color ‘no’ for red or any argument accepted by widget.SetBackgroundColour
time (float) – Time in seconds before resetting color
reset_color (color) – Color which will be set after time (default: “#FFFFFFF”)
Lockin setup panel¶
Oscilloscope panel¶
- class mlaapi.scopepanel.PlotPanel(parent, eh, name, position, layer, n_channels, n_lockin_ports, id=-1)¶
Class for the Oscilloscope plot panel with time and spectrim plots.
- set_limits(x1_min, x1_max, y1_min, y1_max, x2_min, x2_max, y2_min, y2_max)¶
Set the axes limits of the time and freqeuncy plots.
- Parameters:
x1_min – float [ms]
x1_max – float [ms]
y1_min – float [V]
y1_max – float [V]
x2_min – float [kHz]
x2_max – float [kHz]
y2_min – float [dBV]
y2_max – float [dBV]
Examples
>>> main.scopepanel.set_limits(0, 0.1, -1, 1, 0, 200, -140, 10)
Lockin plot panel¶
- class mlaapi.lockin_plotpanel.Frequency_counting_panel(parent, eh, name, position, layer, n_channels, id=-1)¶
- set_subplot_layout(nr, nc)¶
Set how many rows and columns of subplots the panel should have.
- Parameters:
nrows – integer number of rows
ncols – integer number of columns
Examples
>>> main.lockinpanel.set_subplot_layout(nrows=2, ncols=2)
- class mlaapi.lockin_plotpanel.LockinPlotPanel(parent, eh, name, position, layer, n_channels, id=-1)¶
- class mlaapi.lockin_plotpanel.PlotPanel(parent, eh, name, position, layer, n_channels, id=-1)¶
Class for handling lockin plots
- set_axis_properties(row, col, tone_indices=None, quantity='Amplitude', yscale_type='Linear', ymin=None, ymax=None, legend_pos=-1, history_length=30, title='')¶
Set the properies of one of the subplots in the plot panel.
- Parameters:
row – integer, identifies which subplot to configure
col – integer, identifies which subplot to configure
tone_indices – list of integers, set which tones to plot
quantity – “Amplitude”, “Phase”, “I” or “Q”, see table below
yscale_type – “Linear”, Log” or “Wrap”, see table below
ymin – float, minimum value of the y-axis
ymax – float, maximum value of the y-axis
legend_pos – integer -1-10, position of the legend, see table below
history_length – float [seconds], how long history to plot (i.e. the scale of the x-axis)
quantity
Description
Amplitude
amplitude
Phase
phase
I
In-phase component
Q
Quadrature-phase component
yscale_type
Description
Linear
Linear
Log
Logarithmic
Wrap
Wrap at limits
legend_pos
Description
-1
No legend
0
best
1
upper right
2
upper left
3
lower left
4
lower right
5
right
6
center left
7
center right
8
lower center
9
upper center
10
center
Examples
>>> main.lockinpanel.set_axis_properties(row=0, col=0, tone_indices = [1, 3, 7], quantity = "Amplitude", yscale_type = "Log", ymin = 1e-6, ymax = 10, legend_pos = 1)
- set_subplot_layout(nrows=None, ncols=None)¶
Set how many rows and columns of subplots the panel should have.
- Parameters:
nrows – integer number of rows
ncols – integer number of columns
Examples
>>> main.lockinpanel.set_subplot_layout(nrows=2, ncols=2)
- class mlaapi.lockin_plotpanel.PlotPanelBase(parent, eh, name, position, layer, id=-1)¶
- class mlaapi.lockin_plotpanel.UserPlotPanel(parent, eh, name, position, layer, id=-1)¶
Line colors¶
The colors in the “Lockin history” plot are selected from a predefined list to ensure maximal color contrast between each line. However, depending on the physical or logical topology of the measurement setup other color schemes may be desired. To edit the colors, set the mla_globals.lockin_colors variable from the shell or a script. Below are a few examples:
# Cycle the colors red, green, blue, cyan, magenta, yellow, white
mla_globals.lockin_colors = 'rgbcmyw'
# Cycle the colors red, green, blue
mla_globals.lockin_colors = ('#ff0000','#00ff00', '#0000ff')
# Cycle the colors cyan, magenta, yellow
mla_globals.lockin_colors = ((0, 1, 1), (1, 0, 1), (1, 1, 0))
# Get a unique color for each frequency from the jet colormap. See all available colormaps here:
# http://matplotlib.org/examples/color/colormaps_reference.html
mla_globals.lockin_colors = matplotlib.cm.jet(np.linspace(0,1,mla.lockin.nr_input_freq))