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: Optional[str] = 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]”).
-
__repr__(self) → str¶ Return repr(self).
-
__str__(self) → str¶ Return str(self).
-
class
keithley2600.result_table.ResultTable(column_titles: Optional[List[str]] = None, units: Optional[List[str]] = None, data: Optional[Sequence[float]] = None, params: Optional[Dict[str, Any]] = 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
dataisNone, an empty array with the required number of columns is created.params – Dictionary of measurement parameters.
- Examples
Create a
ResultTableto 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
Keithley2600instance 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')
-
property
nrows(self) → int¶ Number of rows of the ResultTable.
-
property
ncols(self) → int¶ Number of columns of the ResultTable.
-
property
shape(self) → Tuple[int, int]¶ A tuple representing the dimensionality of the ResultTable.
-
property
column_names(self) → List[str]¶ List of strings with column names.
-
property
column_units(self) → List[str]¶ List of strings with column units.
-
has_unit(self, col: Union[int, str]) → bool¶ Returns
Truecolumn units have been set andFalseotherwise.- Parameters
col – Column index or name.
- Returns
Trueif column_units have been set,Falseotherwise.
-
get_unit(self, col: Union[int, str]) → str¶ Get unit of column
col.- Parameters
col – Column index or name.
- Returns
Unit of column.
-
set_unit(self, col: Union[int, str], unit: str) → None¶ Set unit of column
col.- Parameters
col – Column index or name.
unit – Unit string.
-
clear_data(self) → None¶ Clears all data.
-
append_row(self, 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(self, 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(self, data: Sequence[float], name: str, unit: Optional[str] = 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(self, data: Sequence[float], column_titles: List[str], units: Optional[List[str]] = 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(self, i: int) → np.ndarray¶ - Parameters
i – Index of row.
- Returns
Numpy array with data from row
i.
-
get_column(self, i: int) → np.ndarray¶ - Parameters
i – Index of column.
- Returns
Numpy array with data from column
i.
-
save(self, 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(self, 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(self, 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(self, x_clmn: int = 0, y_clmns: Optional[List[str]] = None, func: Callable = lambda x: 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
ResultTablePlotinstance with Matplotlib figure.- Raises
ImportError – If import of matplotlib fails.
-
__repr__(self) → str¶ Return repr(self).
-
__str__(self) → str¶ Return str(self).
-
__getitem__(self, key: str) → np.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: Optional[List[str]] = None, units: Optional[List[str]] = None, data: Optional[Sequence[float]] = None, params: Optional[Dict[str, Any]] = None)¶ Bases:
keithley2600.result_table.ResultTableClass to handle, store and load transfer and output characteristic data of FETs.
TransistorSweepDatainherits fromResultTableand overrides the plot method.-
plot(self, *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
ResultTablePlotinstance with Matplotlib figure.- Raises
ImportError – If import of matplotlib fails.
-
property
nrows(self) → int¶ Number of rows of the ResultTable.
-
property
ncols(self) → int¶ Number of columns of the ResultTable.
-
property
shape(self) → Tuple[int, int]¶ A tuple representing the dimensionality of the ResultTable.
-
property
column_names(self) → List[str]¶ List of strings with column names.
-
property
column_units(self) → List[str]¶ List of strings with column units.
-
has_unit(self, col: Union[int, str]) → bool¶ Returns
Truecolumn units have been set andFalseotherwise.- Parameters
col – Column index or name.
- Returns
Trueif column_units have been set,Falseotherwise.
-
get_unit(self, col: Union[int, str]) → str¶ Get unit of column
col.- Parameters
col – Column index or name.
- Returns
Unit of column.
-
set_unit(self, col: Union[int, str], unit: str) → None¶ Set unit of column
col.- Parameters
col – Column index or name.
unit – Unit string.
-
clear_data(self) → None¶ Clears all data.
-
append_row(self, 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(self, 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(self, data: Sequence[float], name: str, unit: Optional[str] = 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(self, data: Sequence[float], column_titles: List[str], units: Optional[List[str]] = 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(self, i: int) → np.ndarray¶ - Parameters
i – Index of row.
- Returns
Numpy array with data from row
i.
-
get_column(self, i: int) → np.ndarray¶ - Parameters
i – Index of column.
- Returns
Numpy array with data from column
i.
-
save(self, 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(self, 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(self, 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.
-
__repr__(self) → str¶ Return repr(self).
-
__str__(self) → str¶ Return str(self).
-
__getitem__(self, key: str) → np.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[Union[int, str]] = None, func: Callable = lambda x: x, live: bool = False, **kwargs)¶ Plots the data from a given
ResultTableinstance. 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) –ResultTableinstance 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.
-
show(self) → None¶ Shows the plot.
-
update(self) → None¶ Updates the plot with the data of the corresponding
ResultTable. This will be called periodically when :param:liveisTrue.