keithley2600.result_table
Submodule defining classes to store, plot, and save measurement results.
Module Contents
Classes
Class to hold a column title. |
|
Class that holds measurement data. All data is stored internally as a numpy array |
|
Class to handle, store and load transfer and output characteristic data of FETs. |
|
Plots the data from a given |
- class keithley2600.result_table.ColumnTitle(name: str, unit: str | None = None, unit_fmt: str = '[{}]')
Class to hold a column title.
- Parameters:
name – Column name.
unit – Column unit.
unit_fmt – Formatting directive for units when generating string representations. By default, units are enclosed in square brackets (e.g., “Gate voltage [V]”).
- class keithley2600.result_table.ResultTable(column_titles: List[str] | None = None, units: List[str] | None = None, data: Sequence[float] | None = None, params: Dict[str, Any] | None = None)
Class that holds measurement data. All data is stored internally as a numpy array with the first index designating rows and the second index designating columns.
Columns must have titles and can have units. It is possible to access the data in a column by its title in a dictionary type notation.
- Parameters:
column_titles (list) – List of column titles.
units (list) – List of column units.
data – Numpy array holding the data with the first index designating rows and the second index designating columns. If
data
isNone
, an empty array with the required number of columns is created.params – Dictionary of measurement parameters.
- Examples:
Create a
ResultTable
to hold current-vs-time data:>>> import time >>> import numpy as np >>> from keithley2600 import ResultTable >>> # create dictionary of relevant measurement parameters >>> pars = {'recorded': time.asctime(), 'sweep_type': 'iv'} >>> # create ResultTable with two columns >>> rt = ResultTable(['Voltage', 'Current'], ['V', 'A'], params=pars) >>> # create a live plot of the data >>> fig = rt.plot(live=True)
Create a
Keithley2600
instance and record some data:>>> from keithley2600 import Keithley2600 >>> k = Keithley2600('TCPIP0::192.168.2.121::INSTR') >>> for v in range(11): # measure IV characteristics from 0 to 10 V ... k.apply_voltage(k.smua, 10) ... i = k.smua.measure.i() ... rt.append_row([v, i]) ... time.sleep(1)
Print a preview of data to the console:
>>> print(rt) Voltage [V] Current [A] 0.0000e+00 1.0232e-04 1.0000e+00 2.2147e-04 2.0000e+00 3.6077e-04 3.0000e+00 5.2074e-04 4.0000e+00 6.9927e-04
Save the recorded data to a tab-delimited text file:
>>> rt.save('~/Desktop/stress_test.txt')
- has_unit(col: int | str) bool
Returns
True
column units have been set andFalse
otherwise.- Parameters:
col – Column index or name.
- Returns:
True
if column_units have been set,False
otherwise.
- get_unit(col: int | str) str
Get unit of column
col
.- Parameters:
col – Column index or name.
- Returns:
Unit of column.
- set_unit(col: int | str, unit: str) None
Set unit of column
col
.- Parameters:
col – Column index or name.
unit – Unit string.
- append_row(data: Sequence[float]) None
Appends a single row to the data array.
- Parameters:
data – Sequence with the same number of elements as columns in the data array.
- append_rows(data: Sequence[float]) None
Appends multiple rows to the data array.
- Parameters:
data – List of lists or numpy array with dimensions matching the data array.
- append_column(data: Sequence[float], name: str, unit: str | None = None) None
Appends a single column to the data array.
- Parameters:
data – Sequence with the same number of elements as rows in the data array.
name – Name of new column.
unit – Unit of values in new column.
- append_columns(data: Sequence[float], column_titles: List[str], units: List[str] | None = None) None
Appends multiple columns to data array.
- Parameters:
data – List of columns to append.
column_titles – List of column titles (strings).
units – List of units for new columns (strings).
- get_row(i: int) numpy.ndarray
- Parameters:
i – Index of row.
- Returns:
Numpy array with data from row
i
.
- get_column(i: int) numpy.ndarray
- Parameters:
i – Index of column.
- Returns:
Numpy array with data from column
i
.
- save(filename: str, ext: str = '.txt') None
Saves the result table to a text file. The file format is:
The _header contains all measurement parameters as comments.
Column titles contain column_names and column_units of measured quantity.
Delimited columns contain the data.
Files are saved with the specified extension (default: ‘.txt’). The classes default delimiters are used to separate columns and rows.
- Parameters:
filename – Path of file to save. Relative paths are interpreted with respect to the current working directory.
ext – File extension. Defaults to ‘.txt’.
- save_csv(filename: str) None
Saves the result table to a csv file. The file format is:
The _header contains all measurement parameters as comments.
Column titles contain column_names and column_units of measured quantity.
Comma delimited columns contain the data.
Files are saved with the extension ‘.csv’ and other extensions are overwritten.
- Parameters:
filename – Path of file to save. Relative paths are interpreted with respect to the current working directory.
- load(filename: str) None
Loads data from csv or tab delimited tex file. The _header is searched for measurement parameters.
- Parameters:
filename – Absolute or relative path of file to load.
- plot(x_clmn: int = 0, y_clmns: List[str] | None = None, func: Callable = lambda x: ..., live: bool = False, **kwargs) ResultTablePlot
Plots the data. This method should not be called from a thread. The column containing the x-axis data is specified (defaults to first column), all other data is plotted on the y-axis. This method requires Matplotlib to be installed and accepts, in addition to the arguments documented here, the same keyword arguments as
matplotlib.pyplot.plot()
.Column titles are taken as legend labels.
plot()
tries to determine a common y-axis unit and name from all given labels.- Parameters:
x_clmn (int or str) – Integer or name of column containing the x-axis data.
y_clmns – List of column numbers or column names for y-axis data. If not given, all columns will be plotted against the x-axis column.
func – Function to apply to y-data before plotting.
live – If
True
, update the plot when new data is added. Plotting will be carried out in the main (GUI) thread, therefore take care not to block the thread. This can be achieved for instance by adding data in a background thread which carries out the measurement, or by calling matplotlib.pyplot.pause after adding data to give the GUI time to update.
- Returns:
ResultTablePlot
instance with Matplotlib figure.- Raises:
ImportError – If import of matplotlib fails.
- __getitem__(key: str) numpy.ndarray
Gets values in column with name
key
.- Parameters:
key – Column name.
- Returns:
Column content as numpy array.
- class keithley2600.result_table.FETResultTable(column_titles: List[str] | None = None, units: List[str] | None = None, data: Sequence[float] | None = None, params: Dict[str, Any] | None = None)
Bases:
ResultTable
Class to handle, store and load transfer and output characteristic data of FETs.
TransistorSweepData
inherits fromResultTable
and overrides the plot method.- plot(*args, **kwargs) ResultTablePlot
Plots the transfer or output curves. Overrides
ResultTable.plot()
. Absolute values are plotted, on a linear scale for output characteristics and a logarithmic scale for transfer characteristics. Takes the same arguments asResultTable.plot()
.- Returns:
ResultTablePlot
instance with Matplotlib figure.- Raises:
ImportError – If import of matplotlib fails.
- has_unit(col: int | str) bool
Returns
True
column units have been set andFalse
otherwise.- Parameters:
col – Column index or name.
- Returns:
True
if column_units have been set,False
otherwise.
- get_unit(col: int | str) str
Get unit of column
col
.- Parameters:
col – Column index or name.
- Returns:
Unit of column.
- set_unit(col: int | str, unit: str) None
Set unit of column
col
.- Parameters:
col – Column index or name.
unit – Unit string.
- append_row(data: Sequence[float]) None
Appends a single row to the data array.
- Parameters:
data – Sequence with the same number of elements as columns in the data array.
- append_rows(data: Sequence[float]) None
Appends multiple rows to the data array.
- Parameters:
data – List of lists or numpy array with dimensions matching the data array.
- append_column(data: Sequence[float], name: str, unit: str | None = None) None
Appends a single column to the data array.
- Parameters:
data – Sequence with the same number of elements as rows in the data array.
name – Name of new column.
unit – Unit of values in new column.
- append_columns(data: Sequence[float], column_titles: List[str], units: List[str] | None = None) None
Appends multiple columns to data array.
- Parameters:
data – List of columns to append.
column_titles – List of column titles (strings).
units – List of units for new columns (strings).
- get_row(i: int) numpy.ndarray
- Parameters:
i – Index of row.
- Returns:
Numpy array with data from row
i
.
- get_column(i: int) numpy.ndarray
- Parameters:
i – Index of column.
- Returns:
Numpy array with data from column
i
.
- save(filename: str, ext: str = '.txt') None
Saves the result table to a text file. The file format is:
The _header contains all measurement parameters as comments.
Column titles contain column_names and column_units of measured quantity.
Delimited columns contain the data.
Files are saved with the specified extension (default: ‘.txt’). The classes default delimiters are used to separate columns and rows.
- Parameters:
filename – Path of file to save. Relative paths are interpreted with respect to the current working directory.
ext – File extension. Defaults to ‘.txt’.
- save_csv(filename: str) None
Saves the result table to a csv file. The file format is:
The _header contains all measurement parameters as comments.
Column titles contain column_names and column_units of measured quantity.
Comma delimited columns contain the data.
Files are saved with the extension ‘.csv’ and other extensions are overwritten.
- Parameters:
filename – Path of file to save. Relative paths are interpreted with respect to the current working directory.
- load(filename: str) None
Loads data from csv or tab delimited tex file. The _header is searched for measurement parameters.
- Parameters:
filename – Absolute or relative path of file to load.
- __getitem__(key: str) numpy.ndarray
Gets values in column with name
key
.- Parameters:
key – Column name.
- Returns:
Column content as numpy array.
- class keithley2600.result_table.ResultTablePlot(result_table: ResultTable, x_clmn: int = 0, y_clmns: List[int | str] = None, func: Callable = lambda x: ..., live: bool = False, **kwargs)
Plots the data from a given
ResultTable
instance. Axes labels are automatically generated from column titles and units. This class requires Matplotlib to be installed. In addition to the arguments documented here, class:ResultTable accepts the same keyword arguments asmatplotlib.pyplot.plot()
.- Parameters:
result_table (
ResultTable
) –ResultTable
instance with data to plot.x_clmn (int or str) – Integer or name of column containing the x-axis data.
y_clmns (list(int or str)) – List of column numbers or column names for y-axis data. If not given, all columns will be plotted against the x-axis column.
func – Function to apply to y-data before plotting.
live – If
True
, update the plot when new data is added (default:False
). Plotting will be carried out in the main (GUI) thread, therefore take care not to block the thread. This can be achieved for instance by adding data in a background thread which carries out the measurement, or by calling matplotlib.pyplot.pause after adding data to give the GUI time to update.
- update() None
Updates the plot with the data of the corresponding
ResultTable
. This will be called periodically when :param:live
isTrue
.