Python Programming in TopSpin
←
→
Page content transcription
If your browser does not render page correctly, please read the page content below
Python Programming
in TopSpin
Copyright (C) 2006 by Bruker BioSpin GmbH
Version: Feb. 1st, 2006
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or
transmitted, in any form, or by any means without the prior consent of the publisher.
1Contents
1.Introduction....................................................................................................................................... 3
2.Quick Start.........................................................................................................................................3
3.Python Functions For TopSpin..........................................................................................................3
21. Introduction
TopSpin includes the Jython (Java) implementation of the Python programming language. This manual is not
a Jython or Python book. In order to learn the language, please refer to the following documents (there might
be others available not listed here):
– The online documentation of Barry Feigenbaum
http://www-128.ibm.com/developerworks/java/edu/j-dw-java-jython1-i.html
– The book Jython Essentials by Samuele Pedroni, Noel Rappin, O'Reilly
– The book Jython for Java Programmers by Robert W. Bill, New Riders.
Here we describe how you can extend TopSpin with your own functionalities by writing Python modules or
scripts. We will use the terms Python module, program, and Pythons script synonymously.
Python is a modern programming language which was embedded in TopSpin so as to provide the user with a
sophisticated tool allowing him to add his own functions to TopSpin.
Python programs (modules, scripts) written for TopSpin are capable of
- executing TopSpin commands
- opening dialog windows for user input or to print messages
- opening NMR data sets for further processing
- fetching and setting NMR parameters
- reading TopSpin NMR data for further manipulation by the Python program
- displaying arrays of data calculated in a Python program
- using the Java swing classes which provide a rich set of functions with virtually no limit in user interface
and graphics programming
- and much more.
2. Quick Start
Enter the TopSpin command edpy in the command line. Result: A window is opened showing the currently
available Python programs including the Bruker example programs. Please use those as a reference for your
own programs. From the edpy window you can create a new Python program and start it up.
Editing a new or an existing Python program without using the edpy window: Enter the command edpy
.
Executing an existing Python program without using the edpy window: Enter the command xpy , or just . The latter method only works if is not already the name
of a TopSpin internal command or an AU program.
Making an external Python program available in TopSpin: Enter the command edpy and choose Import...
from the File menu.
3. Python Functions For TopSpin
In your own Python programs you may use all the statements and functions described in the literature listed
in chapter 1 of this manual.
In addition you can employ functions provided by TopSpin dealing with NMR commands, data, parameters,
etc. They are listed in the following function table.
This table contains examples for each function. It is quite easy to execute them:
Step 1: Enter the command help python to open this manual.
Step 2: Enter the command edpy pytest. An empty text editor will be opened. Select an example in the
3manual by marking the example text and copying it to the clipboard (e.g. with CTRL C, or with Edit-->Copy
of the Acrobat Reader menubar). Click into the editor and paste the example text there with CTRL V. Click
on the Execute button of the editor. That's all.
Note:
Many of these functions operate on the current dataset (e.g. fetching/storing parameters, processing data). In
a Python program, the current dataset is defined as follows:
When the script is started, the current dataset is the dataset of the currently active TopSpin data window. If
no such window is open, the current dataset is undefined. In order to define the current dataset inside the
Python program, use the appropriate dataset functions decribed the following table, e.g. RE().
Python Function Description
Output and Confirm Dialogs
MSG(message = "", title=None) A modal dialog with a Close button:
message = the message to be shown
title = Optional. The title of the dialog window
The Python program will not continue until the Close
button is clicked.
ERRMSG(message = "", title=None, A modal or non-modal dialog with a Close button and
details=None, modal=0) a Details button:
message = the message to be shown
Example 1: title = Optional. The title of the dialog window
ERRMSG("Test Message Non Modal") details = Optional. A message that is displayed when
clicking of the Details button of the dialog.
Example 2: modal = Optional. The Python program will not
ERRMSG("Test Message Modal", modal=1) continue until the Close button is clicked if modal = 1.
Otherwise it will continue, while the dialog stays on
the screen.
value = CONFIRM(title=None, message="") A confirm dialog with an OK button and a Cancel
button:
Example: title = The title of the dialog window
if CONFIRM("Delete", "Delete this message = the message to be shown
file?")== 0: value = 1 if OK clicked, otherwise 0
EXIT()
value = SELECT(title=None, message="", A confirm dialog with an arbitrary number of buttons:
buttons=["OK_M", "CANCEL_M"], title = the title of the dialog window
mnemonics=None) message = the message to be shown
buttons = a list of button labels
Example 1: mnemonic=Optional. A list of characters, shortcuts for
value = SELECT("Delete", "Delete these the buttons.
files?", ["Delete Selected", "Delete value = the number of the pressed button (0, 1, ...), or
All", "Close"]) negative if ESCAPE pressed, or the dialog window's
if value == 2 or value < 0: close icon in the upper right corner.
EXIT()
Example 2:
value = SELECT("Delete", "Delete these
files?",\
["Delete Selected", "Delete
4Python Function Description
All", "Close"], ['s', 'a', 'c'])
VIEWTEXT(title="", header="", text="", A modal or non-modal viewer for big text, e.g. as
modal=1) read in from a file (for short text better use MSG()):
title = the title of the text window
Example: header = a header text near the top of the window
mytext=""" text = the text
This is modal = Option. 1=modal window (default), 0 = non
my multi-line modal.
example text
"""
VIEWTEXT("MyTitle", "MyHeader",
mytext)
SHOW_STATUS(message="") Displays a message in TopSpin's status line.
Example:
SHOW_STATUS("Script XYZ In Progress.")
Input Dialogs
result = INPUT_DIALOG(title=None, A general input dialog window with an arbitrary
header=None, items=None, values=None, number of text input lines, and 2 buttons to press:
comments=None, types=None,
buttons=None, shortcuts=None, title = the dialog title
columns=30) header = an additional multiline header, lines to
be separated by “\n”
Example 1: items = list of label names for text input fields (or
result = INPUT_DIALOG("MyTitle", "This None)
is an example\nNumber 1.", ["Solvent =
", "Nucleus = "], ["CDCl3", "1H"], values = list of initial values for the text input
["",""], ["1", "1"]) fields (or None)
if result None: comments = list of comments to be appended to
MSG(result[0] + "\n" + result[1]) the text input fields (or None), may have several
lines to be separated by “\n”
Example 2:
result = INPUT_DIALOG("MyTitle", "This
types = the list of text input field sizes (1=single
is an example\nNumber 1.", ["Solvent = line, >1 multiple line field)
", "Nucleus = "], ["CDCl3", "1H"], buttons = list of button labels. If None, an OK and
["",""], ["1", "1"], Cancel button are shown.
["Accept","Close"], ['a','c'], 10) shortcuts = list of button shortcuts.
if result None:
MSG(result[0] + "\n" + result[1]) columns = number of text columns (width of
input fields), default = 30.
result = the list of values in the text fields, if the
user pressed OK, or None if the user pressed
ESC, or Cancel, or the Window's close icon.
result = DATASET_DIALOG(title=None, A dialog window for a user to enter a TopSpin dataset
values=None) with the following buttons: OK, FIND, BROWSE,
CANCEL.
Example 1:
result = DATASET_DIALOG("MyTitle", title = the dialog title
CURDATA()) values = Optional. Initial values of the text input fields
if result None: result = the list of dataset specifiers [name, expno,
5Python Function Description
MSG(result[0] + "\n" + result[1] + procno, directory, user] entered or selected by the
"\n" + result[2] + "\n" + result[3] + user.
"\n" + result[4])
result = FIND_DIALOG() A „find“ dialog window for a user search for TopSpin
data setes
Example 1:
result = FIND_DIALOG() result = The list of full dataset paths. The list consists
datapaths = "" of those data sets selected by the user from the search
if result == None: result. None is returned if nothing found or the user
EXIT() cancelled the dialog.
for datapath in result:
datapaths += datapath + "\n"
MSG(datapaths)
System Functions
CMDTHREAD Not a function, but a variable of type CmdThread
representing the thread in which a Python script
executes. Provides access to the thread state.
result = EXEC_PYSCRIPT(pyscript, arg) Executes a Python script in its own thread (i.e. in
background):
Example: pyscript = the script text
script = """ arg = an optional argument (any Object)
f = open("c:/foo.txt", 'w') result = the thread of type CmdThread
f.write("test line\\n")
f.close()
"""
EXEC_PYSCRIPT(script)
result = EXEC_PYFILE(pyfile, arg) Executes a Python program in its own thread (i.e. in
background):
Example: pyfile = the absolute path of the file containing the
EXEC_PYSCRIPT(script) script text, or the name of the Python program in the
data base
arg = an optional argument (any Object)
result = the thread of type CmdThread
EXIT() Terminates the current Python script. Not required at
the end of the Python program.
Example:
if CONFIRM("Delete", "Delete this
file?")== 0:
EXIT()
host = GETHOSTNAME() Returns the host name of the PC where TopSpin is
currently running.
Example:
host = GETHOSTNAME()
MSG("result="+host)
sys.argv The arguments passed to a Python script.
Example: Assume you start a Python script myscript by typing
Prints the number of arguments, and the arguments xpy myscript a b c or just myscript a b c into
when starting the script. TopSpin's command line. The 3 arguments a b c
(separated by space characters) can be retrieved in the
6Python Function Description
args = "number of args = " + script by using sys.argv This is an arry of Strings:
str(len(sys.argv)) + "\n" sys.argv[0] = the complete path of the script
args += "arglist:\n" sys.argv[1] = the first argument (if present)
for arg in sys.argv:
sys.argv[2] = the second argument (if present)
args += arg + "\n"
MSG(args) Etc.
len(sys.argv) = the number of actual arguments + 1.
SLEEP(seconds) Pauses execution of the current Python program by the
specified number of seconds. Shortcut for Python's
Example: time.sleep() function.
SLEEP(2)
ct = XCMD(cmd, wait = Executes an arbitrary TopSpin command:
WAIT_TILL_DONE, arg = None)
cmd = Command name
wait = Optional. WAIT_TILL_DONE or
NO_WAIT_TILL_DONE.
Example 1: arg = optional argument for the command (depends
Prints result as a String: ft return 0 if succeeded, on the command whether such an argument is
-1 if failed. evaluated)
ct = an Object of type CmdThread, allowing access to
ct = XCMD("ft") the result with ct.getResult(). The result type
MSG("result="+str(ct.getResult())
depends on the command. The result is undefined for
wait = NO_WAIT_TILL_DONE
Example 2:
Terminates script if Cancle pressed in SI Dialog.
If cmd is a processing command (e.g. "ft"),
if XCMD("SI").getResult() == None: XCMD("").getResult()is -1 when
EXIT() execution failed.
FT()
If cmd is a parameter name (e.g. "SI"), then usually a
dialog window is opened to enter the parameter.
XCMD("Python Function Description
Example 2:
RE(["exam1d_13C", "2", "1",
"c:/bruker/topspin", "guest"], "n")
Example 3:
Reads 7 data sets (expno = 1...7) into a new
window.
for i in range(7):
data = ["exam1d_13C", str(i+1),
"1", "c:/x y", "guest"]
NEWWIN()
RE(data)
RE_PATH(dataset = None, show = "y") Makes the specified data set the current dataset:
dataset = the complete disk path name of a TopSpin
Example: dataset
RE("c:/bruker/topspin/data/guest/nmr/e show = Optional: y = dataset is displayed (default), n
xam1d_13C/2/pdata/1") = dataset is not displayed.
value = CURDATA(cmdthread = None) Returns the current dataset of a Python script:
cmdthread = Optional: The thread in which the script
Example: is running. Default is the current script.
curdat = CURDATA() value = the list of dataset specifiers [name, expno,
MSG("name="+curdat[0] + ", procno=" procno, directory, user]
+curdat[2])
RE_IEXNO(dataset = None, show = "y") Increments the EXPNO of the specified dataset and
makes it the current one:
Example: dataset = Optional: list of TopSpin dataset specifiers
MSG("expno–before ="+CURDATA()[1]) [name, expno, procno, directory, user]
RE_IEXPNO() Default is the current dataset.
MSG("expno–after ="+CURDATA()[1]) show = Optional: y = dataset is displayed (default), n
= dataset is not displayed.
Does not create a new EXPNO if the new one doesn't
exist!
RE_IPROCNO(dataset = None, show = "y") Increments the PROCNO of the specified dataset and
makes it the current one:
Example: dataset = Optional: list of TopSpin dataset specifiers
MSG("procno–before ="+CURDATA()[2]) [name, expno, procno, directory, user]
RE_IPROCNO() Default is the current dataset.
MSG("procno–after ="+CURDATA()[2]) show = Optional: y = dataset is displayed (default), n
= dataset is not displayed.
Does not create a new EXPNO if the new one doesn't
exist!
RSER(fidnum = None, expno = None, show Reads the specified fid number from the current data
= "y") set (must be a 2D/3D/... data set with raw data), stores
it under the specified EXPNO, and makes this the
Example: current data set.
RSER("27", "777") fidnum = the fid number as a String (1, 2, ...)
FT() expno = the destination expno as a String
show = Optional: y = expno is displayed (default), n =
expno is not displayed.
8Python Function Description
RSR(row = None, procno = None, show = Reads the specified row from the current data set
"y") (must be 2D data set with processed data), stores it
under the specified PROCNO, and makes this the
Example: current data set.
RSR("27", "999") row = the row number as a String
procno = the destination procno as a String
show = Optional: y = procno is displayed (default), n
= expno is not displayed.
RSC(col = None, procno = None, show = Reads the specified column from the current data set
"y") (must be 2D data set with processed data), stores it
under the specified PROCNO, and makes this the
Example: current data set.
RSC("27", "999") col = the column number as a String
procno = the destination procno as a String
show = Optional: y = procno is displayed (default), n
= expno is not displayed.
Saving The Current NMR Dataset
WR(dataset = None, override = "y") Writes (copies) the current dataset to the specified
destination data set:
Example 1: dataset = list of TopSpin dataset specifiers [name,
WR(["exam1d_13C", "2", "1", "c:/", expno, procno, directory, user] for the destination,
"guest"]) must be different from the source
override = Optional: y = new destination dataset is
Example 2: overridden silently if existing (default), n = a confirm
WR(["exam1d_13C", "2", "1", "c:/", dialog is displayed.
"guest"], "n")
The destination does NOT become the current data
set. Use RE to make it the current if needed.
WR_PATH(dataset = None, override = "y") Saves (copies) the current dataset to the specified
destination data set:
Example 1: dataset = the complete disk path name of a TopSpin
WR("c:/data/guest/nmr/exam1d_13C/2/pda dataset, must be different from the source
ta/1") override = Optional: y = new destination dataset is
overridden silently if existing (default), n = a confirm
Example 2: dialog is displayed.
WR("c:/data/guest/nmr/exam1d_13C/2/pda
ta/1", "n") The destination does NOT become the current data
set. Use RE to make it the current if needed.
Fetching And Storing NMR Parameters
value = GETPAR(name, axis = 0) Gets the value of a TopSpin parameter from the
current data set:
Example 1: name = the parameter name
computes 2*SI and prints result: axis = Optional. 0 (acquisition axis = default)
SIstring = GETPAR("SI") 1, 2, 3, ... (F1, F2, F3, ... axis for nD data)
twoTimesSI = 2*int(SIstring) value = parameter value as a String
MSG("result="+str(twoTimesSI))
Note: In order to perform calculations with value,
Example 2:
value must be converted from String to its proper
computes 1/(2*D1) and prints result:
d1String = GETPAR("D 1") type, e.g. using the Python functions int() or float().
9Python Function Description
j = 1.0 / 2*float(d1String)
MSG("result="+str(j))
Alternate method of invoking GETPAR():
Example 3:
computes 1/(2*D1) and prints result:
d1String = GETPAR("D 1")
Instead of specifying the axis as the second argument,
j = 1.0 / 2*float(d1String) the axis can be encoded into the parameter name:
MSG("result="+str(j))
GETPAR("1 SI") corresponds to GETPAR("SI",
Example 4: 1)
computes 2*SI (from F1 direction of nD data) and prints
result: This is similar to the TopSpin command line syntax. It
also allows one to get access to status parameters:
SIstring = GETPAR("SI", 1)
twoTimesSI = 2*int(SIstring) GETPAR("2s SI") corresponds to
MSG("result="+str(twoTimesSI)) GETPARSTAT("SI", 2)
value = GETPARSTAT(name, axis = 0) Gets the value of a TopSpin status parameter (i.e. as
stored in the status parameters files acqus/procs).
Usage: See GETPAR above.
result = GETACQUDIM() Gets the dimension of the acquisition data of the
current data set.
Example: result = the dimension as an integer 1, 2, ..., or -1 in
MSG(str(GETACQUDIM())) case of an error (no acquisition data present)
result = GETPROCDIM() Gets the dimension of the processed data of the
current data set.
Example: result = the dimension as an integer 1, 2, ... or -1 in
MSG(str(GETPROCDIM())) case of an error (no processed data present)
PUTPAR(name, value) Sets the value of a TopSpin parameter for the current
data set:
Example 1: name = the parameter name, possibly including axis
Sets the size for the acquisition direction (for data dimension > 1) and status, similar to the
PUTPAR("SI", "2048") TopSpin command line syntax
value = the parameter's value as a String
Example 2:
Sets the status parameter for the acquisition
direction
PUTPAR("status SI", "2048")
Example 3:
Sets the size for the F1 axis
PUTPAR("1 SI", "2048")
Example 4:
Sets the status parameter for the F1 direction
PUTPAR("1s SI", "2048")
Example 5:
Sets the array parameter P1
PUTPAR("P 1", "0.5")
TopSpin Internal Windows
10Python Function Description
result = NEWWIN(width = -1, height = -1) Opens an empty new internal TopSpin window.
Example 1: width = Optiona: window width (pixels)
NEWWIN() height = Optiona: window height (pixels)
RE(["exam1d_13C", "2", "1", result = a JPanel object, a container for e.g. NMR data
"c:/bruker/topspin", "guest"]) or other components.
Example 2: RE() type functions will load their datasets into the
NEWWIN(300, 400)
last opened window, regardless what other windows
are open.
result = GETWINID(userPanel = None) Gets the unique ID String of an internal TopSpin
window.
Example 1:
Prints the id of a new window userPanel = Optional: The user panel of the window,
MSG(GETWINID(NEWWIN())) as e.g. returned by NEWWIN(). If not specified, the id
of the window is returned which was the current one
Example 2: at the time the script was started (default window).
Prints the id of the default window. result = the unique ID String, or None if no window
MSG(GETWINID()) existing for this script.
CLOSEWIN(dataset = None) Closes the internal TopSpin window containing the
specified dataset. Has no effect if no such window
Example 1: exists.
CLOSEWIN(["exam1d_13C", "2", "1",
"c:/bruker/topspin", "guest"]) dataset = a list of dataset specifiers [name, expno,
procno, dir, user]
Example 2:
Closes the window containg the current dataset. RE() type functions will load their datasets into the
CLOSEWIN(CURDATA())
last opened window.
ARRANGE(mode = "$v") Arranges all open internal TopSpin windows.
Example: mode = $v (default, arrange vertically = in stack), $h
ARRANGE() (arrange horizontally = in side-by-side), $m ((arrange
as a grid)
Example 2:
ARRANGE("$h")
ARRANGE_WIN(winid, x, y, width, height) Arranges the nternal window with the specified ID.
Example 1: winid = window identifier as returned by
id = GETWINID(NEWWIN()) GETWINID()
ARRANGE_WIN(id, 20, 30, 300, 400) x = x coordinate
y = y coordinate
Example 2: width = window width (pixels)
Loads the data set into the current window (creates height = window height (pixels)
a new one if none exists) and arranges the window
RE(["exam1d_13C", "2", "1", x/y/width/height must be specified as integers. The
"c:/bruker/topspin", "guest"]) point (0, 0) is the upper left corner of a window, the
id = GETWINID()
ARRANGE_WIN(id, 20, 30, 300, 400)
point (width-1, height-1) is the lower right corner.
result = ALL_WINDOWS() Returns the all currently open internal windows (in
their creation order)
11Python Function Description
Example:
Prints the window Ids of all open windows. result = list of windows which have type InFrame. In
for win in ALL_WINDOWS(): order to get the user panel of an InFrame (which is
MSG(GETWINID(win.getUserPanelData()) required e.g. by GETWINID(), use the function
) getUserPanelData() of InFrame.
result = SELECTED_WINDOW() Returns the currently selected window, which is the
window on which the user recently clicked.
Example:
Prints the window Id of the selected window. result = a window of type InFrame. In order to get the
win = SELECTED_WINDOW() user panel of an InFrame (which is required e.g. by
MSG(GETWINID(win.getUserPanelData())) GETWINID(), use the function getUserPanelData()
of InFrame.
SET_SELECTED_WIN(winid) Makes the window with the specified ID the current
window of this script. All further actions will happen
Example 1: in this window.
SET_SELECTED_WIN("2")
FT() winid = the unique window ID. The script is
cancelled if the id does not exist.
Array Functions
SAVE_ARRAY_AS_1R1I(reals, imags) Replaces the real or imaginary part of a 1D spectrum
(= the contents of the 1r and/or 1i files) by new values.
Example:
Fills 1r with a ramp, leaves 1i as it is. reals = list of float numbers to replace 1r
curdat = ["exam1d_13C", "1", "1", imags = list of float numbers to replace 1i
"c:/bruker/topspin", "guest"]
RE(curdat) Note:
reals = []
imags = None
The array may have a size different from the existing
for i in range(int(GETPAR("status file sizes. The status SI parameter is automatically
SI"))): updated.
reals.append(i)
SAVE_ARRAY_AS_1R1I(reals, imags)
RE(curdat)
result = GETPROCDATA(fromppm, Reads a region of the current processed data set into a
toppm, type = None) Python list (for 1D data only):
fromppm = region start in ppm
Example 1: toppm = region end in ppm
result = GETPROCDATA(-0.5, 0.5) type = Optional: dataconst.PROCDATA_IMAG
text = "" to read imaginary data. Default is real.
for i in range(len(result)): result = list of float numbers or None if data file not
text += str(i) + " " + found (files 1r or 1i doesn't exist). The list is always
str(result[i]) + "\n" ordered from left to right, where “left” is the file start,
VIEWTEXT("GETPROCDATA Test", "Read
regardless in which order the region limits are
Real Data", text)
specified .
Example 2:
result = GETPROCDATA(-0.5, 0.5, To read the entire spectrum, specifiy large limits, e.g.
dataconst.PROCDATA_IMAG) From -500 to 500 ppm.
result = GETPROCDATA2D(from1, to1, Reads a region of the current processed data set into a
from2, to2, type = None) Python list (for 2D data only):
12Python Function Description
from1, from2 = region start in ppm
Example 1: to1, to2 = region end in ppm
result = GETPROCDATA(6.0, 8.0, 40.0 type = Optional: dataconst.PROCDATA_IMAG
60.0) to read imaginary data. Default is real.
text = "" result = list of list of float numbers or None if data file
for i in range(len(result)):
not found (files 2rr or 2ii doesn't exist). A list is
text += str(i) + " " +
str(result[i]) + "\n" always ordered from left to right, where “left” is the
VIEWTEXT("GETPROCDATA Test", "Read file start, regardless in which order the region limits
Real Data", text) are specified .
(UNTESTED, PRELIMINARY) To read the entire spectrum, specifiy large limits, e.g.
From -500 to 500 ppm.
DISPLAY_DATALIST(ydata, props = Displays a list of data arrays. Note that TopSpin
None, title = "", subwindows = 0) supports printing and exporting the graphs generated
with this function.
Example 1:
Displays 2 ramps without subwindows. ydata = A list of arrays. Each array must contain float
array1 = [] numbers.
array2 = [] props = Optional. A list of display properties, one for
for i in range(100): each array. See GET_DISPLAY_PROPS() function.
array1.append(float(i)) title = the window title
array2.append(100-float(i))
DISPLAY_DATALIST([array1, array2])
subwindows = 1: display each array in a separate
subwindow. 0: display the arrays without using
Example 2:
subwindows.
Displays 2 ramps with a window title and
subwindows.
array1 = []
array2 = []
for i in range(100):
array1.append(float(i))
array2.append(100-float(i))
DISPLAY_DATALIST([array1, array2],
None, "Example", 1)
Example 3:
Displays 2 ramps using display properties
array1 = []
array2 = []
for i in range(100):
array1.append(float(i))
array2.append(float(2*i))
props1 = GET_DISPLAY_PROPS(8.0, 1.0,
"rad","x", "y", "Example", "line")
props2 = GET_DISPLAY_PROPS(8.0, 1.0,
"rad","x", "y", "Example", "dots")
DISPLAY_DATALIST([array1, array2],
[props1, props2])
DISPLAY_DATALIST_XY(ydata, xdata, Displays a list of data arrays where y and x values are
props = None, title = "", subwindows = 0) given.
Example 1: ydata = A list of arrays. Each array must contain float
Displays 2 ramps without subwindows. numbers.
array1 = [] xdata = The x axis values for ydata.
13Python Function Description
array2 = [] props = Optional. A list of display properties (axis and
xvalues1 = [] other), one for each array. See
for i in range(100): GET_DISPLAY_PROPS() function. If props = None,
xvalues1.append(float(i*i))
the x axis units are points.
for i in range(100):
array1.append(float(i)) title = the window title
array2.append(float(i*i)) subwindows = 1: display each array in a separate
DISPLAY_DATALIST_XY([array1, array2], subwindow. 0: display the arrays without using
[xvalues1, xvalues1]) subwindows.
GET_DISPLAY_PROPS(xStart = None, Returns display properties as optionally used by the
xEnd = None, xUnit = None, xLegend=None, DISPLAY_DATALIST functions.
yLegend=None,
info=None, drawMode="line") xStart – left x axis limit, e.g. 0.0
xEnd – right x axis limit, e.g. 10.5. If xEnd < xStart,
Example: axis labelling is reversed.
GET_DISPLAY_PROPS(2.0, 8.0, "rad","x", xUnit – x axis unit, e.g. "ppm"
"y", "Example", "line") xLegend – extra text displayed below x axis
yLegend – extra text displayed left of y axis
info – extra text displayed in the upper left of the data
window
drawMode – "dots" or "line". In the first case the data
points are displayed in form of small circles, without
connecting lines. In the second case the data points are
drawn in form of a polyline.
Acquisition, Processing And Analysis Functions
Examples: TopSpin provides functions for most of the TopSpin
FT(), EFP(), ZG(), APK(), XFB() etc. commands for acquisition, processing and analysis.
The name of a function is derived from the respective
command by using capital letters.
In case a desired function is missing please use:
XCMD("TopSpin Command")
e.g.
XCMD("abs n")
4.
14You can also read