Index: trunk/www/areas/kst-plot/pykst/_modules/index.html =================================================================== --- trunk/www/areas/kst-plot/pykst/_modules/index.html (revision 1506421) +++ trunk/www/areas/kst-plot/pykst/_modules/index.html (revision 1506422) @@ -1,90 +1,90 @@
import sys
-import math
-import ctypes
+#import math
+#import ctypes
import atexit
import os
-
+import tempfile
+import time
+import subprocess
+import getpass
from ast import literal_eval
+import numpy as np
+
try:
- from PySide import QtCore, QtNetwork, QtGui
+ from PySide import QtNetwork, QtGui
except ImportError as err1:
- try:
- from PyQt4 import QtCore, QtNetwork, QtGui
- except ImportError as err2:
- print("ImportError: {} and {}. One of the two is required.".format(err1, err2))
- sys.exit()
+ try:
+ from PyQt4 import QtNetwork, QtGui
+ except ImportError as err2:
+ print "ImportError: {} and {}. One of the two is required.".format(err1, err2)
+ sys.exit()
QtGui.QApplication([""])
-from numpy import *
-import tempfile
-import time
-import subprocess
-def cleanTmpFile(file):
- os.remove(file.name)
+def clean_tmp_file(tmp_file):
+ os.remove(tmp_file.name)
def b2str(val):
- if isinstance(val, bool):
- return "True" if val else "False"
- else:
+ if isinstance(val, bool):
+ return "True" if val else "False"
return str(val)
-[docs]class Client:
- """ An interface to a running kst session.
+[docs]class Client(object):
+ """ An interface to a running kst session.
- A client provides a connection to a running kst session.
- The constructor creates a connection to either a running
- kst session with name <server_name>, or if none exists, a new one.
- If server_name is not specified, it creates a connection to either the
- kst session with the name ``kstScript``, or if none exists, a new one.
-
- The Client provides functions which effect the entire kst session,
- provides convenience functions to create objects within kst (eg,
- ``client.new_generated_vector(0, 1, 6)``), and provides
- convenience functions to access objects already within kst (eg,
- ``client.vector("V2")``. This is the suggested method.
+ A client provides a connection to a running kst session.
+ The constructor creates a connection to either a running
+ kst session with name <server_name>, or if none exists, a new one.
+ If server_name is not specified, it creates a connection with an
+ unnamed kst session, or if none exists, a new unnamed session.
+
+ The Client provides functions which effect the entire kst session,
+ provides convenience functions to create objects within kst (eg,
+ ``client.new_generated_vector(0, 1, 6)``), and provides
+ convenience functions to access objects already within kst (eg,
+ ``client.vector("V2")``. This is the suggested method.
- Alternatively, the constructor for every class inside pykst accepts
- an instance of Client which it uses to interact with a kst session.
+ Alternatively, the constructor for every class inside pykst accepts
+ an instance of Client which it uses to interact with a kst session.
- To connect to a kst session named ``kstSession`` (starting kst if necessary)::
+ To connect to a kst session named ``kstSession`` (starting kst if necessary)::
- import pykst as kst
- client = kst.Client("kstSession")
+ import pykst as kst
+ client = kst.Client("kstSession")
- """
-
- def __init__(self,server_name="kstScript"):
- self.ls=QtNetwork.QLocalSocket()
- self.ls.connectToServer(server_name)
- self.ls.waitForConnected(300)
- self.server_name=server_name
-
- if self.ls.state() == QtNetwork.QLocalSocket.UnconnectedState:
- subprocess.Popen(["kst2","--serverName="+str(server_name)])
- time.sleep(.5)
-
- while self.ls.state()==QtNetwork.QLocalSocket.UnconnectedState:
- self.ls.connectToServer(server_name)
- self.ls.waitForConnected(300)
-
- def send(self,command):
- """ Sends a command to kst and returns a response.
-
- You should never use
- this directly, as there is no guarantee that the internal command
- list kst uses won't change. Instead use the convenience classes
- included with pykst.
- """
- self.ls.write(command)
- self.ls.flush()
- self.ls.waitForReadyRead(300000)
- x=self.ls.readAll()
- return x
-
- def send_si(self, handle, command):
- self.send(b2str("beginEdit("+handle+")"))
- x = self.send(command)
- self.send(b2str("endEdit()"))
- return x
-
- def testCommand(self):
- self.send("testCommand()")
-
-[docs] def clear(self):
- """ Clears all objects from kst.
-
- Equivalent to file->close from the menubar inside kst.
"""
- self.send("clear()")
-
-[docs] def open_kst_file(self, filename):
- """ open a .kst file in kst. """
- self.send("fileOpen("+b2str(filename)+")")
-[docs] def save_kst_file(self, filename):
- """ save a .kst file in kst. """
- self.send("fileSave("+b2str(filename)+")")
+ def __init__(self, server_name=""):
-[docs] def export_graphics_file(self, filename, format=None, width=1280, height=1024, display = 2, all_tabs = False, autosave_period = 0):
- """
- export the kst session as a set of graphics files.
+ user_name = getpass.getuser()
- :param filename: the name of the file to be saved
- :param format: the format to be used. if None, the format is determined from the filename extension.
- :param width: width of the plot, in pixels, if required by the display setting.
- :param height: the height of the plot, in pixels, if required by the display setting.
- :param display: how the dimensions are interpreted.
- :param all_tabs: if True, all tabs are exported as <filename>_<tabname>.<ext>
- :param autosave_period: save the image every <autosave_period> seconds. If 0, only save once.
+ if server_name:
+ self.server_name = server_name + "--" + user_name
+ else:
+ self.server_name = user_name
+
+ self.local_socket = QtNetwork.QLocalSocket()
+ self.local_socket.connectToServer(self.server_name)
+ self.local_socket.waitForConnected(300)
+
+ if self.local_socket.state() == QtNetwork.QLocalSocket.UnconnectedState:
+ subprocess.Popen(["kst2", "--serverName="+str(self.server_name)])
+ time.sleep(.5)
+
+ while self.local_socket.state() == QtNetwork.QLocalSocket.UnconnectedState:
+ self.local_socket.connectToServer(self.server_name)
+ self.local_socket.waitForConnected(300)
+
+ def send(self, command):
+ """ Sends a command to kst and returns a response.
+
+ You should never use
+ this directly, as there is no guarantee that the internal command
+ list kst uses won't change. Instead use the convenience classes
+ included with pykst.
+ """
+ self.local_socket.write(command)
+ self.local_socket.flush()
+ self.local_socket.waitForReadyRead(300000)
+ return_message = self.local_socket.readAll()
+ return return_message
+
+ def send_si(self, handle, command):
+ self.send(b2str("beginEdit("+handle+")"))
+ return_message = self.send(command)
+ self.send(b2str("endEdit()"))
+ return return_message
- *display* determines the shape of the plot. Values are ::
+ def test_command(self):
+ self.send("testCommand()")
- 0 Width set by user, maintain aspect ratio
- 1 Height set by user, maintain aspect ratio
- 2 Width and Height set by user.
- 3 a Width x Width square plot.
+[docs] def clear(self):
+ """ Clears all objects from kst.
- """
+ Equivalent to file->close from the menubar inside kst.
+ """
+ self.send("clear()")
- if format is None:
- format = os.path.splitext(filename)[1][1:].strip().lower()
+[docs] def open_kst_file(self, filename):
+ """ open a .kst file in kst. """
+ self.send("fileOpen("+b2str(filename)+")")
- self.send("exportGraphics("+str(filename)+","+str(format)+","+str(width)+","+
- str(height)+","+str(display)+","+str(all_tabs)+","+str(autosave_period) + ")")
+[docs] def save_kst_file(self, filename):
+ """ save a .kst file in kst. """
+ self.send("fileSave("+b2str(filename)+")")
+[docs] def export_graphics_file(self, filename, graphics_format=None, width=1280, height=1024,
+ display=2, all_tabs=False, autosave_period=0):
+ """
+ export the kst session as a set of graphics files.
-[docs] def screen_back(self):
- """ Equivalent to "Range>Back One Screen" from the menubar inside kst. """
- self.send("screenBack()")
-
-[docs] def screen_forward(self):
- """ Equivalent to "Range>Forward One Screen" from the menubar inside kst. """
- self.send("screenForward()")
-
-[docs] def count_from_end(self):
- """ Equivalent to "Range>Count From End" from the menubar inside kst. """
- self.send("countFromEnd()")
-
-[docs] def read_to_end(self):
- """ Equivalent to "Range>Read To End" from the menubar inside kst. """
- self.send("readToEnd()")
-
-[docs] def set_paused(self):
- """ Equivalent to checking "Range>Pause" from the menubar inside kst."""
- self.send("setPaused()")
-
-[docs] def unset_paused(self):
- """ Equivalent to unchecking "Range>Pause" from the menubar inside kst."""
- self.send("unsetPaused()")
+ :param filename: the name of the file to be saved
+ :param graphics_format: the format to be used. if None, the format is determined from
+ the filename extension.
+ :param width: width of the plot, in pixels, if required by the display setting.
+ :param height: the height of the plot, in pixels, if required by the display setting.
+ :param display: how the dimensions are interpreted.
+ :param all_tabs: if True, all tabs are exported as <filename>_<tabname>.<ext>
+ :param autosave_period: save the image every <autosave_period> seconds.
+ If 0, only save once.
-[docs] def hide_window(self):
- """
- Hide the kst window.
+ *display* determines the shape of the plot. Values are ::
- pyKst operations which effect the display are far faster when the window is hidden.
+ 0 Width set by user, maintain aspect ratio
+ 1 Height set by user, maintain aspect ratio
+ 2 Width and Height set by user.
+ 3 a Width x Width square plot.
- Restore with show_window() or maximize_window()."""
+ """
- self.send("hide()")
+ if graphics_format is None:
+ graphics_format = os.path.splitext(filename)[1][1:].strip().lower()
-[docs] def quit(self):
- """
- Tell the kst window to terminate
+ self.send("exportGraphics("+str(filename)+","+str(graphics_format)+","+str(width)+","+
+ str(height)+","+str(display)+","+str(all_tabs)+","+str(autosave_period) + ")")
- After this, client will no longer be valid."""
- self.send("quit()")
+[docs] def screen_back(self):
+ """ Equivalent to "Range>Back One Screen" from the menubar inside kst. """
+ self.send("screenBack()")
-
+[docs] def screen_forward(self):
+ """ Equivalent to "Range>Forward One Screen" from the menubar inside kst. """
+ self.send("screenForward()")
-
+[docs] def count_from_end(self):
+ """ Equivalent to "Range>Count From End" from the menubar inside kst. """
+ self.send("countFromEnd()")
-
+[docs] def read_to_end(self):
+ """ Equivalent to "Range>Read To End" from the menubar inside kst. """
+ self.send("readToEnd()")
-[docs] def tab_count(self):
- """ Get the number of tabs open in the current document. """
- return self.send("tabCount()")
-
-[docs] def new_tab(self):
- """ Create a new tab in the current document and switch to it. """
- return self.send("newTab()")
-
-[docs] def set_tab(self,tab):
- """ Set the index of the current tab.
-
- tab must be greater or equal to 0 and less than tabCount().
- """
- self.send("setTab("+b2str(tab)+")")
+[docs] def set_paused(self):
+ """ Equivalent to checking "Range>Pause" from the menubar inside kst."""
+ self.send("setPaused()")
-[docs] def set_tab_text(self,new_name):
- """ Set the text of the current tab.
+[docs] def unset_paused(self):
+ """ Equivalent to unchecking "Range>Pause" from the menubar inside kst."""
+ self.send("unsetPaused()")
- """
- self.send("renameTab("+new_name+")")
+[docs] def hide_window(self):
+ """
+ Hide the kst window.
-[docs] def cleanup_layout(self, columns="Auto"):
- """ Cleanup layout in the current tab.
-
- If columns is not set, use auto-layout.
-
- """
- self.send("cleanupLayout("+b2str(columns)+")")
-
-[docs] def get_scalar_list(self):
- """ returns the scalar names from kst """
-
- x = self.send("getScalarList()")
- name_list=x.data().split('|')
- return [Scalar(self, name=n) for n in name_list]
+ pyKst operations which effect the display are far faster when the window is hidden.
-[docs] def new_generated_string(self, string, name=""):
- """ Create a new generated string in kst.
-
- See :class:`GeneratedString`
- """
- return GeneratedString(self, string, name)
+ Restore with show_window() or maximize_window()."""
-[docs] def generated_string(self, name):
- """ Returns a generated string from kst given its name.
-
- See :class:`GeneratedString`
- """
- return GeneratedString(self, "", name, new=False)
-
-[docs] def new_datasource_string(self, filename, field, name=""):
- """ Create a New Data Source String in kst.
-
- See :class:`DataSourceString`
- """
- return DataSourceString(self, filename, field, name)
+ self.send("hide()")
-[docs] def datasource_string(self, name):
- """ Returns a datasource string from kst given its name.
-
- See :class:`DataSourceString`
- """
- return DataSourceString(self, "", "", name, new=False)
-
-[docs] def new_generated_scalar(self, value, name=""):
- """ Create a New Generated Scalar in kst.
-
- See :class:`GeneratedScalar`
- """
- return GeneratedScalar(self, value, name)
+[docs] def quit(self):
+ """
+ Tell the kst window to terminate
-[docs] def generated_scalar(self, name):
- """ Returns a Generated Scalar from kst given its name.
-
- See :class:`GeneratedScalar`
- """
- return GeneratedScalar(self, "", name, new=False)
+ After this, client will no longer be valid."""
-[docs] def new_datasource_scalar(self, filename, field, name=""):
- """ Create a New DataSource Scalar in kst.
-
- See :class:`DataSourceScalar`
- """
- return DataSourceScalar(self, filename, field, name)
+ self.send("quit()")
-[docs] def datasource_scalar(self, name):
- """ Returns a DataSource Scalar from kst given its name.
-
- See :class:`DataSourceScalar`
- """
- return DataSourceScalar(self, "", "", name, new=False)
+
-[docs] def new_vector_scalar(self, filename, field, frame=-1, name=""):
- """ Create a New VectorScalar in kst.
-
- See :class:`VectorScalar`
- """
- return VectorScalar(self, filename, field, frame, name)
+
-[docs] def vector_scalar(self, name):
- """ Returns a VectorScalar from kst given its name.
-
- See :class:`VectorScalar`
- """
- return VectorScalar(self, "", "", 0, name, new=False)
+
-[docs] def new_data_vector(self, filename, field, start=0, num_frames=-1,
- skip=0, boxcarFirst=False, name="") :
- """ Create a New DataVector in kst.
-
- See :class:`DataVector`
- """
- return DataVector(self, filename, field, start, num_frames,
- skip, boxcarFirst, name)
-
-[docs] def data_vector(self, name):
- """ Returns a DataVector from kst given its name.
-
- See :class:`DataVector`
- """
- return DataVector(self, "", "", name=name, new=False)
+[docs] def tab_count(self):
+ """ Get the number of tabs open in the current document. """
+ return self.send("tabCount()")
-[docs] def new_generated_vector(self, x0, x1, n, name=""):
- """ Create a New GeneratedVector in kst.
-
- See :class:`GeneratedVector`
- """
- return GeneratedVector(self, x0, x1, n, name)
+[docs] def new_tab(self):
+ """ Create a new tab in the current document and switch to it. """
+ return self.send("newTab()")
-[docs] def generated_vector(self, name):
- """ Returns a GeneratedVector from kst given its name.
-
- See :class:`GeneratedVector`
- """
- return GeneratedVector(self, 0, 0, 0, name, new=False)
-
-[docs] def new_editable_vector(self, np_array = None, name=""):
- """ Create a New Editable Vector in kst.
-
- See :class:`EditableVector`
- """
- return EditableVector(self, np_array, name)
+[docs] def set_tab(self, tab):
+ """ Set the index of the current tab.
-[docs] def editable_vector(self, name):
- """ Returns an Editable Vector from kst given its name.
-
- See :class:`EditableVector`
- """
- return EditableVector(self, None, name, new=False)
+ tab must be greater or equal to 0 and less than tabCount().
+ """
+ self.send("setTab("+b2str(tab)+")")
+[docs] def set_tab_text(self, new_name):
+ """ Set the text of the current tab.
-[docs] def get_vector_list(self):
- """ returns vectors from kst. """
+ """
+ self.send("renameTab("+new_name+")")
- x = self.send("getVectorList()")
- name_list=x.data().split('|')
- return [VectorBase(self, name=n) for n in name_list]
+[docs] def cleanup_layout(self, columns="Auto"):
+ """ Cleanup layout in the current tab.
-[docs] def get_data_vector_list(self):
- """ returns data vectors from kst. """
+ If columns is not set, use auto-layout.
- x = self.send("getDataVectorList()")
- name_list=x.data().split('|')
- return [DataVector(self, "", "", name=n, new=False) for n in name_list]
+ """
+ self.send("cleanupLayout("+b2str(columns)+")")
-[docs] def get_generated_vector_list(self):
- """ returns generated vectors from kst. """
+[docs] def get_scalar_list(self):
+ """ returns the scalar names from kst """
- x = self.send("getGeneratedVectorList()")
- name_list=x.data().split('|')
- return [GeneratedVector(self, name=n, new=False) for n in name_list]
+ return_message = self.send("getScalarList()")
+ name_list = return_message.data().split('|')
+ return [Scalar(self, name=n) for n in name_list]
-[docs] def get_editable_vector_list(self):
- """ returns editable vectors from kst. """
+[docs] def new_generated_string(self, string, name=""):
+ """ Create a new generated string in kst.
- x = self.send("getEditableVectorList()")
- name_list=x.data().split('|')
- return [EditableVector(self, name=n, new=False) for n in name_list]
+ See :class:`GeneratedString`
+ """
+ return GeneratedString(self, string, name)
-
-[docs] def new_data_matrix(self, filename, field, start_x=0, start_y=0, num_x=-1, num_y=-1,
- min_x=0, min_y=0, dx=1, dy=1,name="") :
- """ Create a New DataMatrix in kst.
-
- See :class:`DataMatrix`
- """
- return DataMatrix(self, filename, field, start_x, start_y, num_x, num_y,
- min_x, min_y, dx, dy,name)
+[docs] def generated_string(self, name):
+ """ Returns a generated string from kst given its name.
-[docs] def data_matrix(self, name):
- """ Returns a DataMatrix from kst given its name.
-
- See :class:`DataMatrix`
- """
- return DataMatrix(self, "", "", name=name, new=False)
+ See :class:`GeneratedString`
+ """
+ return GeneratedString(self, "", name, new=False)
-[docs] def new_editable_matrix(self, np_array = None, name=""):
- """ Create a New Editable Matrix in kst.
-
- See :class:`EditableMatrix`
- """
- return EditableMatrix(self, np_array, name)
+[docs] def new_datasource_string(self, filename, field, name=""):
+ """ Create a New Data Source String in kst.
-[docs] def editable_matrix(self, name):
- """ Returns an Editable Matrix from kst given its name.
-
- See :class:`EditableMatrix`
- """
- return EditableMatrix(self, None, name, new=False)
+ See :class:`DataSourceString`
+ """
+ return DataSourceString(self, filename, field, name)
-[docs] def get_matrix_list(self):
- """ returns matrixes from kst. """
+[docs] def datasource_string(self, name):
+ """ Returns a datasource string from kst given its name.
- x = self.send("getMatrixList()")
- name_list=x.data().split('|')
- return [Matrix(self, name=n) for n in name_list]
+ See :class:`DataSourceString`
+ """
+ return DataSourceString(self, "", "", name, new=False)
+[docs] def new_generated_scalar(self, value, name=""):
+ """ Create a New Generated Scalar in kst.
-[docs] def new_curve(self, x_vector, y_vector, name=""):
- """ Create a New Curve in kst.
-
- See :class:`Curve`
- """
- return Curve(self, x_vector, y_vector, name)
+ See :class:`GeneratedScalar`
+ """
+ return GeneratedScalar(self, value, name)
-[docs] def curve(self, name):
- """ Returns a Curve from kst given its name.
-
- See :class:`Curve`
- """
- return Curve(self, "", "", name, new=False)
+[docs] def generated_scalar(self, name):
+ """ Returns a Generated Scalar from kst given its name.
-[docs] def new_image(self, matrix, name=""):
- """ Create a new Image in kst.
-
- See :class:`Image`
- """
- return Image(self, matrix, name)
+ See :class:`GeneratedScalar`
+ """
+ return GeneratedScalar(self, "", name, new=False)
-[docs] def image(self, name):
- """ Returns an Image from kst given its name.
-
- See :class:`Image`
- """
- return Image(self, "", "", name, new=False)
+[docs] def new_datasource_scalar(self, filename, field, name=""):
+ """ Create a New DataSource Scalar in kst.
-[docs] def new_equation(self, x_vector, equation, interpolate=True, name=""):
- """ Create a new Equation in kst.
-
- See :class:`Equation`
- """
- return Equation(self, x_vector, equation, interpolate, name)
+ See :class:`DataSourceScalar`
+ """
+ return DataSourceScalar(self, filename, field, name)
+[docs] def datasource_scalar(self, name):
+ """ Returns a DataSource Scalar from kst given its name.
-[docs] def equation(self, name):
- """ Returns an Equation from kst given its name.
-
- See :class:`Equation`
- """
- return Equation(self, "", "", name, new=False)
+ See :class:`DataSourceScalar`
+ """
+ return DataSourceScalar(self, "", "", name, new=False)
-[docs] def new_histogram(self, vector, bin_min=0, bin_max=1, num_bins=60,
- normalization = 0, auto_bin = True, name=""):
- """ Create a new histogram in kst.
-
- See :class:`Histogram`
- """
- return Histogram(self, vector, bin_min, bin_max, num_bins,
- normalization, auto_bin, name)
+[docs] def new_vector_scalar(self, filename, field, frame=-1, name=""):
+ """ Create a New VectorScalar in kst.
+ See :class:`VectorScalar`
+ """
+ return VectorScalar(self, filename, field, frame, name)
-[docs] def histogram(self, name):
- """ Returns a histogram from kst given its name.
-
- See :class:`Histogram`
- """
- return Histogram(self, "", 0,0,0, name=name, new=False)
+[docs] def vector_scalar(self, name):
+ """ Returns a VectorScalar from kst given its name.
-[docs] def new_cross_spectrum(self,
- V1, V2,
- fft_size=10,
- sample_rate = 1.0,
- name = ""):
- """ Create a cross spectrum object in kst.
+ See :class:`VectorScalar`
+ """
+ return VectorScalar(self, "", "", 0, name, new=False)
- See :class:`CrossSpectrum`
- """
- return CrossSpectrum(self, V1,V2, fft_size, sample_rate, name)
+[docs] def new_data_vector(self, filename, field, start=0, num_frames=-1,
+ skip=0, boxcarFirst=False, name=""):
+ """ Create a New DataVector in kst.
+ See :class:`DataVector`
+ """
+ return DataVector(self, filename, field, start, num_frames,
+ skip, boxcarFirst, name)
-[docs] def new_spectrum(self,
- vector,
- sample_rate = 1.0,
- interleaved_average = False,
- fft_length = 10,
- apodize = True,
- remove_mean = True,
- vector_units = "",
- rate_units = "Hz",
- apodize_function = 0,
- sigma = 1.0,
- output_type = 0,
- name=""):
- """ Create a new Spectrum in kst.
-
- See :class:`Spectrum`
- """
- return Spectrum(self,
- vector,
- sample_rate,
- interleaved_average,
- fft_length,
- apodize,
- remove_mean,
- vector_units,
- rate_units,
- apodize_function,
- sigma,
- output_type,
- name)
+[docs] def data_vector(self, name):
+ """ Returns a DataVector from kst given its name.
-[docs] def spectrum(self, name):
- """ Returns a spectrum from kst given its name.
-
- See :class:`Spectrum`
- """
- return Spectrum(self, "", name=name, new=False)
+ See :class:`DataVector`
+ """
+ return DataVector(self, "", "", name=name, new=False)
-[docs] def new_linear_fit(self, x_vector, y_vector, weightvector = 0, name = ""):
- """ Create a New Linear Fit in kst.
-
- See :class:`LinearFit`
- """
- return LinearFit(self, x_vector, y_vector, weightvector, name)
+[docs] def new_generated_vector(self, x0, x1, n, name=""):
+ """ Create a New GeneratedVector in kst.
-[docs] def linear_fit(self, name):
- """ Returns a linear fit from kst given its name.
-
- See :class:`LinearFit`
- """
- return LinearFit(self, "", "", 0, name, new=False)
+ See :class:`GeneratedVector`
+ """
+ return GeneratedVector(self, x0, x1, n, name)
+[docs] def generated_vector(self, name):
+ """ Returns a GeneratedVector from kst given its name.
-[docs] def new_polynomial_fit(self, order, x_vector, y_vector, weightvector = 0, name = ""):
- """ Create a New Polynomial Fit in kst.
-
- See :class:`PolynomialFit`
- """
- return PolynomialFit(self, order, x_vector, y_vector, weightvector, name)
+ See :class:`GeneratedVector`
+ """
+ return GeneratedVector(self, 0, 0, 0, name, new=False)
-[docs] def polynomial_fit(self, name):
- """ Returns a polynomial fit from kst given its name.
-
- See :class:`PolynomialFit`
- """
- return PolynomialFit(self, 0, "", "", 0, name, new=False)
+[docs] def new_editable_vector(self, np_array=None, name=""):
+ """ Create a New Editable Vector in kst.
+ See :class:`EditableVector`
+ """
+ return EditableVector(self, np_array, name)
-[docs] def new_sum_filter(self, y_vector, step_dX, name = ""):
- """ Create a cumulative sum filter inside kst.
+[docs] def editable_vector(self, name):
+ """ Returns an Editable Vector from kst given its name.
- See :class:`SumFilter`
- """
- return SumFilter(self, y_vector, step_dX, name)
+ See :class:`EditableVector`
+ """
+ return EditableVector(self, None, name, new=False)
-[docs] def new_flag_filter(self, y_vector, flag, mask="0xffffff", valid_is_zero=True, name = ""):
- """ Create a flag filter inside kst.
+[docs] def get_vector_list(self):
+ """ returns vectors from kst. """
- See :class:`FlagFilter`
- """
- return FlagFilter(self, y_vector, flag, mask, valid_is_zero, name)
+ return_message = self.send("getVectorList()")
+ name_list = return_message.data().split('|')
+ return [VectorBase(self, name=n) for n in name_list]
-[docs] def flag_filter(self, name):
- """ Returns a flag_filter from kst given its name.
+[docs] def get_data_vector_list(self):
+ """ returns data vectors from kst. """
- See :class:`FlagFilter`
- """
- return FlagFilter(self, "", "", name, new=False)
+ return_message = self.send("getDataVectorList()")
+ name_list = return_message.data().split('|')
+ return [DataVector(self, "", "", name=n, new=False) for n in name_list]
+[docs] def get_generated_vector_list(self):
+ """ returns generated vectors from kst. """
-[docs] def new_label(self, text, pos=(0.5,0.5), rot=0, font_size=12,
- bold=False, italic=False, font_color="black",
- font_family="Serif", name="") :
- """ Create a New Label in kst.
-
- See :class:`Label`
- """
- return Label(self, text, pos, rot, font_size, bold, italic,
- font_color, font_family, name)
+ return_message = self.send("getGeneratedVectorList()")
+ name_list = return_message.data().split('|')
+ return [GeneratedVector(self, name=n, new=False) for n in name_list]
-[docs] def label(self, name):
- """ Returns a Label from kst given its name.
-
- See :class:`Label`
- """
- return Label(self, "", name=name, new=False)
-
-[docs] def get_label_list(self):
- """ Get a list of all labels in kst.
+[docs] def get_editable_vector_list(self):
+ """ returns editable vectors from kst. """
- See :class:`Label`
- """
- x=self.send("getLabelList()")
- name_list = x.data()[1:-1].split("][")
- return [Label(self, name=n, new=False) for n in name_list]
+ return_message = self.send("getEditableVectorList()")
+ name_list = return_message.data().split('|')
+ return [EditableVector(self, name=n, new=False) for n in name_list]
-[docs] def new_box(self, pos=(0.1,0.1), size=(0.1,0.1), rot=0,
- fill_color="white", fill_style=1, stroke_style=1, stroke_width=1,
- stroke_brush_color="black", stroke_brush_style=1,
- strokeJoinStyle=1, stroke_cap_style=1, fix_aspect=False, name="") :
- """ Create a New Box in kst.
-
- See :class:`Box`
- """
- return Box(self, pos, size, rot, fill_color, fill_style, stroke_style,
- stroke_width, stroke_brush_color, stroke_brush_style,
- strokeJoinStyle, stroke_cap_style, fix_aspect, name)
+[docs] def new_data_matrix(self, filename, field, start_x=0, start_y=0, num_x=-1, num_y=-1,
+ min_x=0, min_y=0, dx=1, dy=1, name=""):
+ """ Create a New DataMatrix in kst.
-[docs] def box(self, name):
- """ Returns a Box from kst given its name.
-
- See :class:`Box`
- """
- return Box(self, name=name, new=False)
-
-[docs] def get_box_list(self):
- """ Get a list of all boxes in kst.
+ See :class:`DataMatrix`
+ """
+ return DataMatrix(self, filename, field, start_x, start_y, num_x, num_y,
+ min_x, min_y, dx, dy, name)
- See :class:`Box`
- """
- x=self.send("getBoxList()")
- name_list = x.data()[1:-1].split("][")
- return [Box(self, name=n, new=False) for n in name_list]
+[docs] def data_matrix(self, name):
+ """ Returns a DataMatrix from kst given its name.
+ See :class:`DataMatrix`
+ """
+ return DataMatrix(self, "", "", name=name, new=False)
-[docs] def new_legend(self, plot, name = "") :
- """ Create a new Legend in a plot in kst.
+[docs] def new_editable_matrix(self, np_array=None, name=""):
+ """ Create a New Editable Matrix in kst.
- See :class:'Legend'
- """
- return Legend(self, plot, name)
+ See :class:`EditableMatrix`
+ """
+ return EditableMatrix(self, np_array, name)
-[docs] def legend(self, name):
- """ Returns a Legend from kst given its name.
+[docs] def editable_matrix(self, name):
+ """ Returns an Editable Matrix from kst given its name.
- See :class:`Legend`
- """
- return Legend(self, name=name, new=False)
+ See :class:`EditableMatrix`
+ """
+ return EditableMatrix(self, None, name, new=False)
-[docs] def get_legend_list(self):
- """ Get a list of all legends in kst.
+[docs] def get_matrix_list(self):
+ """ returns matrixes from kst. """
- See :class:`Legend`
- """
- x=self.send("getLegendList()")
- name_list = x.data()[1:-1].split("][")
- return [Legend(self, name=n, new=False) for n in name_list]
+ return_message = self.send("getMatrixList()")
+ name_list = return_message.data().split('|')
+ return [Matrix(self, name=n) for n in name_list]
-[docs] def new_circle(self, pos=(0.1, 0.1), diameter=0.1,
- fill_color="white",fill_style=1,stroke_style=1,
- stroke_width=1,stroke_brush_color="grey",stroke_brush_style=1, name="") :
- """ Create a New Circle in kst.
-
- See :class:`Circle`
- """
- return Circle(self, pos, diameter, fill_color, fill_style, stroke_style,
- stroke_width, stroke_brush_color, stroke_brush_style, name)
-
-[docs] def circle(self, name):
- """ Returns a Circle from kst given its name.
-
- See :class:`Circle`
- """
- return Circle(self, name=name, new=False)
-
-[docs] def get_circle_list(self):
- """ Get a list of all ciircles in kst.
+[docs] def new_curve(self, x_vector, y_vector, name=""):
+ """ Create a New Curve in kst.
- See :class:`Circle`
- """
- x=self.send("getCircleList()")
- name_list = x.data()[1:-1].split("][")
- return [Circle(self, name=n, new=False) for n in name_list]
+ See :class:`Curve`
+ """
+ return Curve(self, x_vector, y_vector, name)
-[docs] def new_ellipse(self,pos=(0.1,0.1), size=(0.1,0.1),
- rot=0, fill_color="white", fill_style=1, stroke_style=1,
- stroke_width=1, stroke_brush_color="black", stroke_brush_style=1,
- fix_aspect=False, name="") :
- """ Create a New Ellipse in kst.
-
- See :class:`Ellipse`
- """
- return Ellipse(self,pos, size, rot, fill_color, fill_style, stroke_style,
- stroke_width, stroke_brush_color, stroke_brush_style,
- fix_aspect, name)
+[docs] def curve(self, name):
+ """ Returns a Curve from kst given its name.
-[docs] def ellipse(self, name):
- """ Returns an ellipse from kst given its name.
-
- See :class:`Ellipse`
- """
- return Ellipse(self, name=name, new=False)
-
-[docs] def get_ellipse_list(self):
- """ Get a list of all ellipse in kst.
+ See :class:`Curve`
+ """
+ return Curve(self, "", "", name, new=False)
- See :class:`Ellipse`
- """
- x=self.send("getEllipseList()")
- name_list = x.data()[1:-1].split("][")
- return [Ellipse(self, name=n, new=False) for n in name_list]
+[docs] def new_image(self, matrix, name=""):
+ """ Create a new Image in kst.
-[docs] def new_line(self,start=(0,0),end = (1,1),
- stroke_style=1,stroke_width=1,stroke_brush_color="black",
- stroke_brush_style=1,stroke_cap_style=1, name="") :
- """ Create a New Line in kst.
-
- See :class:`Line`
- """
- return Line(self,start,end, stroke_style, stroke_width,
- stroke_brush_color, stroke_brush_style, stroke_cap_style, name)
-
-[docs] def line(self, name):
- """ Returns a Line from kst given its name.
-
- See :class:`Line`
- """
- return Line(self, name=name, new=False)
+ See :class:`Image`
+ """
+ return Image(self, matrix, name)
-[docs] def get_line_list(self):
- """ Get a list of all lines in kst.
+[docs] def image(self, name):
+ """ Returns an Image from kst given its name.
- See :class:`Line`
- """
- x=self.send("getLineList()")
- name_list = x.data()[1:-1].split("][")
- return [Line(self, name=n, new=False) for n in name_list]
+ See :class:`Image`
+ """
+ return Image(self, "", "", name, new=False)
+[docs] def new_equation(self, x_vector, equation, interpolate=True, name=""):
+ """ Create a new Equation in kst.
-[docs] def new_arrow(self,start=(0,0),end = (1,1),
- arror_at_start = False, arrow_at_end = True, arrow_size = 12.0,
- stroke_style=1, stroke_width=1, stroke_brush_color="black",
- stroke_brush_style=1, stroke_cap_style=1, name="") :
- """ Create a New Arrow in kst.
-
- See :class:`Arrow`
- """
- return Arrow(self,start,end, arror_at_start, arrow_at_end, arrow_size,
- stroke_style, stroke_width, stroke_brush_color, stroke_brush_style,
- stroke_cap_style, name)
-
-[docs] def arrow(self, name):
- """ Returns an Arrow from kst given its name.
-
- See :class:`Arrow`
- """
- return Arrow(self, name=name, new=False)
-
-[docs] def get_arrow_list(self):
- """ Get a list of all arrows in kst.
+ See :class:`Equation`
+ """
+ return Equation(self, x_vector, equation, interpolate, name)
- See :class:`Arrow`
- """
- x=self.send("getArrowList()")
- name_list = x.data()[1:-1].split("][")
- return [Arrow(self, name=n, new=False) for n in name_list]
-
-[docs] def new_picture(self,filename,pos=(0.1,0.1), width=0.1,rot=0, name="") :
- """ Create a New Picture in kst.
-
- See :class:`Picture`
- """
- return Picture(self,filename, pos, width, rot, name)
-
-[docs] def picture(self, name):
- """ Returns a Picture from kst given its name.
-
- See :class:`Picture`
- """
- return Picture(self, "", name = name, new=False)
-
-[docs] def get_picture_list(self):
- """ Get a list of all pictures in kst.
-
- See :class:`Picture`
- """
- x=self.send("getPictureList()")
- name_list = x.data()[1:-1].split("][")
- return [Picture(self, name=n, new=False) for n in name_list]
-
-[docs] def new_SVG(self, filename, pos=(0.1,0.1), width=0.1, rot=0, name="") :
- """ Create a New SVG in kst.
-
- See :class:`SVG`
- """
- return SVG(self, filename, pos, width, rot, name)
-
-[docs] def SVG(self, name):
- """ Returns a SVG from kst given its name.
-
- See :class:`SVG`
- """
- return SVG(self, "", name = name, new=False)
-
-[docs] def get_SVG_list(self):
- """ Get a list of all SVGs in kst.
-
- See :class:`SVG`
- """
- x=self.send("getSVGList()")
- name_list = x.data()[1:-1].split("][")
- return [SVG(self, name=n, new=False) for n in name_list]
-
-[docs] def new_plot(self,pos=(0.1,0.1),size=(0,0),rot=0,font_size = 0, columns=0,
- fill_color="white", fill_style=1, stroke_style=1, stroke_width=1,
- stroke_brush_color="black", stroke_brush_style=1,
- strokeJoinStyle=1, stroke_cap_style=1, fix_aspect=False, auto_position = True, name="") :
- """ Create a New Plot in kst.
-
- See :class:`Plot`
- """
- return Plot(self, pos, size, rot, font_size, columns, fill_color, fill_style, stroke_style,
- stroke_width, stroke_brush_color, stroke_brush_style,
- strokeJoinStyle, stroke_cap_style, fix_aspect, auto_position, name)
-
-[docs] def plot(self, name):
- """ Returns a Plot from kst given its name.
-
- See :class:`Plot`
- """
- return Plot(self, name = name, new=False)
-
-[docs] def get_plot_list(self):
- """ Get a list of all plots in kst.
-
- See :class:`Plot`
- """
- x=self.send("getPlotList()")
- name_list = x.data()[1:-1].split("][")
- return [Plot(self, name=n, new=False) for n in name_list]
-
-[docs] def set_datasource_option(self, option, value, filename, data_source="Ascii File"):
- """ Sets the value of a data source configuration option.
-
- :param option: the name of the option - eg ""Data Start"
- :param value: True or False
- :param filename: the name of the file or 0 to set global default
- :param data_source: the type of data source
- Examples:
+[docs] def equation(self, name):
+ """ Returns an Equation from kst given its name.
- Tell kst that trial1.csv is a file with the field names in row 1 and units in row 2::
+ See :class:`Equation`
+ """
+ return Equation(self, "", "", name, new=False)
- import pykst as kst
- client = kst.Client()
- client.set_datasource_option("Column Delimiter", ",", "trial1.csv")
- client.set_datasource_option("Column Type", 2, "trial1.csv")
- client.set_datasource_option("Data Start", 3-1, "trial1.csv")
- client.set_datasource_option("Fields Line", 1-1, "trial1.csv")
- client.set_datasource_option("Read Fields", True, "trial1.csv")
- client.set_datasource_option("Units Line", 2-1, "trial1.csv")
- client.set_datasource_option("Read Units", True, "trial1.csv")
-
- Configuration options supported by the ASCII data source (default) are::
-
- "ASCII Time format"
- "Column Delimiter"
- "Column Type"
- "Column Width"
- "Column Width is const"
- "Comment Delimiters"
- "Data Rate for index"
- "Data Start"
- "Default INDEX Interpretation"
- "Fields Line"
- "Filename Pattern"
- "Index"
- "Limit file buffer size"
- "NaN value"
- "Read Fields"
- "Read Units"
- "Size of limited file buffer"
- "Units Line"
- "Use Dot"
- "Use threads when parsing Ascii data"
- "date/time offset"
- "relative offset"
- "updateType"
- "use an explicit date/time offset"
- "use file time/date as offset"
- "use relative file time offset"
+[docs] def new_histogram(self, vector, bin_min=0, bin_max=1, num_bins=60,
+ normalization=0, auto_bin=True, name=""):
+ """ Create a new histogram in kst.
+ See :class:`Histogram`
+ """
+ return Histogram(self, vector, bin_min, bin_max, num_bins,
+ normalization, auto_bin, name)
- """
- if (filename == 0):
- filename = "$DEFAULT"
-
- if isinstance(value, bool):
- self.send("setDatasourceBoolConfig("+data_source+","+filename+","+option+","+b2str(value)+")")
- elif isinstance(value, int):
- self.send("setDatasourceIntConfig("+data_source+","+filename+","+option+","+str(value)+")")
- else:
- v = value
- v.replace(',', '`')
- self.send("setDatasourceStringConfig("+data_source+","+filename+","+option+","+str(v)+")")
+[docs] def histogram(self, name):
+ """ Returns a histogram from kst given its name.
+
+ See :class:`Histogram`
+ """
+ return Histogram(self, "", 0, 0, 0, name=name, new=False)
+
+[docs] def new_cross_spectrum(self,
+ V1, V2,
+ fft_size=10,
+ sample_rate=1.0,
+ name=""):
+ """ Create a cross spectrum object in kst.
+
+ See :class:`CrossSpectrum`
+ """
+ return CrossSpectrum(self, V1, V2, fft_size, sample_rate, name)
+
+
+[docs] def new_spectrum(self,
+ vector,
+ sample_rate=1.0,
+ interleaved_average=False,
+ fft_length=10,
+ apodize=True,
+ remove_mean=True,
+ vector_units="",
+ rate_units="Hz",
+ apodize_function=0,
+ sigma=1.0,
+ output_type=0,
+ name=""):
+ """ Create a new Spectrum in kst.
+
+ See :class:`Spectrum`
+ """
+ return Spectrum(self,
+ vector,
+ sample_rate,
+ interleaved_average,
+ fft_length,
+ apodize,
+ remove_mean,
+ vector_units,
+ rate_units,
+ apodize_function,
+ sigma,
+ output_type,
+ name)
+
+[docs] def spectrum(self, name):
+ """ Returns a spectrum from kst given its name.
+
+ See :class:`Spectrum`
+ """
+ return Spectrum(self, "", name=name, new=False)
+
+[docs] def new_linear_fit(self, x_vector, y_vector, weightvector=0, name=""):
+ """ Create a New Linear Fit in kst.
+
+ See :class:`LinearFit`
+ """
+ return LinearFit(self, x_vector, y_vector, weightvector, name)
+
+[docs] def linear_fit(self, name):
+ """ Returns a linear fit from kst given its name.
+
+ See :class:`LinearFit`
+ """
+ return LinearFit(self, "", "", 0, name, new=False)
+
+
+[docs] def new_polynomial_fit(self, order, x_vector, y_vector, weightvector=0, name=""):
+ """ Create a New Polynomial Fit in kst.
+
+ See :class:`PolynomialFit`
+ """
+ return PolynomialFit(self, order, x_vector, y_vector, weightvector, name)
+
+[docs] def polynomial_fit(self, name):
+ """ Returns a polynomial fit from kst given its name.
+
+ See :class:`PolynomialFit`
+ """
+ return PolynomialFit(self, 0, "", "", 0, name, new=False)
+
+
+[docs] def new_sum_filter(self, y_vector, step_dX, name=""):
+ """ Create a cumulative sum filter inside kst.
+
+ See :class:`SumFilter`
+ """
+ return SumFilter(self, y_vector, step_dX, name)
+
+
+[docs] def new_flag_filter(self, y_vector, flag, mask="0xffffff", valid_is_zero=True, name=""):
+ """ Create a flag filter inside kst.
+
+ See :class:`FlagFilter`
+ """
+ return FlagFilter(self, y_vector, flag, mask, valid_is_zero, name)
+
+[docs] def flag_filter(self, name):
+ """ Returns a flag_filter from kst given its name.
+
+ See :class:`FlagFilter`
+ """
+ return FlagFilter(self, "", "", name, new=False)
+
+
+[docs] def new_label(self, text, pos=(0.5, 0.5), rot=0, font_size=12,
+ bold=False, italic=False, font_color="black",
+ font_family="Serif", name=""):
+ """ Create a New Label in kst.
+
+ See :class:`Label`
+ """
+ return Label(self, text, pos, rot, font_size, bold, italic,
+ font_color, font_family, name)
+
+[docs] def label(self, name):
+ """ Returns a Label from kst given its name.
+
+ See :class:`Label`
+ """
+ return Label(self, "", name=name, new=False)
+
+[docs] def get_label_list(self):
+ """ Get a list of all labels in kst.
+
+ See :class:`Label`
+ """
+ return_message = self.send("getLabelList()")
+ name_list = return_message.data()[1:-1].split("][")
+ return [Label(self, "", name=n, new=False) for n in name_list]
+[docs] def new_box(self, pos=(0.1, 0.1), size=(0.1, 0.1), rot=0,
+ fill_color="white", fill_style=1, stroke_style=1, stroke_width=1,
+ stroke_brush_color="black", stroke_brush_style=1,
+ stroke_join_style=1, stroke_cap_style=1, fix_aspect=False, name=""):
+ """ Create a New Box in kst.
-class NamedObject:
+ See :class:`Box`
+ """
+ return Box(self, pos, size, rot, fill_color, fill_style, stroke_style,
+ stroke_width, stroke_brush_color, stroke_brush_style,
+ stroke_join_style, stroke_cap_style, fix_aspect, name)
+
+[docs] def box(self, name):
+ """ Returns a Box from kst given its name.
+
+ See :class:`Box`
+ """
+ return Box(self, name=name, new=False)
+
+[docs] def get_box_list(self):
+ """ Get a list of all boxes in kst.
+
+ See :class:`Box`
+ """
+ return_message = self.send("getBoxList()")
+ name_list = return_message.data()[1:-1].split("][")
+ return [Box(self, name=n, new=False) for n in name_list]
+
+
+[docs] def new_legend(self, plot, name=""):
+ """ Create a new Legend in a plot in kst.
+
+ See :class:'Legend'
+ """
+ return Legend(self, plot, name)
+
+[docs] def legend(self, name):
+ """ Returns a Legend from kst given its name.
+
+ See :class:`Legend`
+ """
+ return Legend(self, 0, name=name, new=False)
+
+[docs] def get_legend_list(self):
+ """ Get a list of all legends in kst.
+
+ See :class:`Legend`
+ """
+ return_message = self.send("getLegendList()")
+ name_list = return_message.data()[1:-1].split("][")
+ return [Legend(self, 0, name=n, new=False) for n in name_list]
+
+
+[docs] def new_circle(self, pos=(0.1, 0.1), diameter=0.1,
+ fill_color="white", fill_style=1, stroke_style=1,
+ stroke_width=1, stroke_brush_color="grey", stroke_brush_style=1, name=""):
+ """ Create a New Circle in kst.
+
+ See :class:`Circle`
+ """
+ return Circle(self, pos, diameter, fill_color, fill_style, stroke_style,
+ stroke_width, stroke_brush_color, stroke_brush_style, name)
+
+[docs] def circle(self, name):
+ """ Returns a Circle from kst given its name.
+
+ See :class:`Circle`
+ """
+ return Circle(self, name=name, new=False)
+
+[docs] def get_circle_list(self):
+ """ Get a list of all ciircles in kst.
+
+ See :class:`Circle`
+ """
+ return_message = self.send("getCircleList()")
+ name_list = return_message.data()[1:-1].split("][")
+ return [Circle(self, name=n, new=False) for n in name_list]
+
+[docs] def new_ellipse(self, pos=(0.1, 0.1), size=(0.1, 0.1),
+ rot=0, fill_color="white", fill_style=1, stroke_style=1,
+ stroke_width=1, stroke_brush_color="black", stroke_brush_style=1,
+ fix_aspect=False, name=""):
+ """ Create a New Ellipse in kst.
+
+ See :class:`Ellipse`
+ """
+ return Ellipse(self, pos, size, rot, fill_color, fill_style, stroke_style,
+ stroke_width, stroke_brush_color, stroke_brush_style,
+ fix_aspect, name)
+
+[docs] def ellipse(self, name):
+ """ Returns an ellipse from kst given its name.
+
+ See :class:`Ellipse`
+ """
+ return Ellipse(self, name=name, new=False)
+
+[docs] def get_ellipse_list(self):
+ """ Get a list of all ellipse in kst.
+
+ See :class:`Ellipse`
+ """
+ return_message = self.send("getEllipseList()")
+ name_list = return_message.data()[1:-1].split("][")
+ return [Ellipse(self, name=n, new=False) for n in name_list]
+
+[docs] def new_line(self, start=(0, 0), end=(1, 1),
+ stroke_style=1, stroke_width=1, stroke_brush_color="black",
+ stroke_brush_style=1, stroke_cap_style=1, name=""):
+ """ Create a New Line in kst.
+
+ See :class:`Line`
+ """
+ return Line(self, start, end, stroke_style, stroke_width,
+ stroke_brush_color, stroke_brush_style, stroke_cap_style, name)
+
+[docs] def line(self, name):
+ """ Returns a Line from kst given its name.
+
+ See :class:`Line`
+ """
+ return Line(self, name=name, new=False)
+
+[docs] def get_line_list(self):
+ """ Get a list of all lines in kst.
+
+ See :class:`Line`
+ """
+ return_message = self.send("getLineList()")
+ name_list = return_message.data()[1:-1].split("][")
+ return [Line(self, name=n, new=False) for n in name_list]
+
+
+[docs] def new_arrow(self, start=(0, 0), end=(1, 1),
+ arror_at_start=False, arrow_at_end=True, arrow_size=12.0,
+ stroke_style=1, stroke_width=1, stroke_brush_color="black",
+ stroke_brush_style=1, stroke_cap_style=1, name=""):
+ """ Create a New Arrow in kst.
+
+ See :class:`Arrow`
+ """
+ return Arrow(self, start, end, arror_at_start, arrow_at_end, arrow_size,
+ stroke_style, stroke_width, stroke_brush_color, stroke_brush_style,
+ stroke_cap_style, name)
+
+[docs] def arrow(self, name):
+ """ Returns an Arrow from kst given its name.
+
+ See :class:`Arrow`
+ """
+ return Arrow(self, name=name, new=False)
+
+[docs] def get_arrow_list(self):
+ """ Get a list of all arrows in kst.
+
+ See :class:`Arrow`
+ """
+ return_message = self.send("getArrowList()")
+ name_list = return_message.data()[1:-1].split("][")
+ return [Arrow(self, name=n, new=False) for n in name_list]
+
+[docs] def new_picture(self, filename, pos=(0.1, 0.1), width=0.1, rot=0, name=""):
+ """ Create a New Picture in kst.
+
+ See :class:`Picture`
+ """
+ return Picture(self, filename, pos, width, rot, name)
+
+[docs] def picture(self, name):
+ """ Returns a Picture from kst given its name.
+
+ See :class:`Picture`
+ """
+ return Picture(self, "", name=name, new=False)
+
+[docs] def get_picture_list(self):
+ """ Get a list of all pictures in kst.
+
+ See :class:`Picture`
+ """
+ return_message = self.send("getPictureList()")
+ name_list = return_message.data()[1:-1].split("][")
+ return [Picture(self, "", name=n, new=False) for n in name_list]
+
+[docs] def new_SVG(self, filename, pos=(0.1, 0.1), width=0.1, rot=0, name=""):
+ """ Create a New SVG in kst.
+
+ See :class:`SVG`
+ """
+ return SVG(self, filename, pos, width, rot, name)
+
+[docs] def SVG(self, name):
+ """ Returns a SVG from kst given its name.
+
+ See :class:`SVG`
+ """
+ return SVG(self, "", name=name, new=False)
+
+[docs] def get_SVG_list(self):
+ """ Get a list of all SVGs in kst.
+
+ See :class:`SVG`
+ """
+ return_message = self.send("getSVGList()")
+ name_list = return_message.data()[1:-1].split("][")
+ return [SVG(self, "", name=n, new=False) for n in name_list]
+
+[docs] def new_plot(self, pos=(0.1, 0.1), size=(0, 0), rot=0, font_size=0, columns=0,
+ fill_color="white", fill_style=1, stroke_style=1, stroke_width=1,
+ stroke_brush_color="black", stroke_brush_style=1,
+ stroke_join_style=1, stroke_cap_style=1, fix_aspect=False,
+ auto_position=True, name=""):
+ """ Create a New Plot in kst.
+
+ See :class:`Plot`
+ """
+ return Plot(self, pos, size, rot, font_size, columns, fill_color, fill_style, stroke_style,
+ stroke_width, stroke_brush_color, stroke_brush_style,
+ stroke_join_style, stroke_cap_style, fix_aspect, auto_position, name)
+
+[docs] def plot(self, name):
+ """ Returns a Plot from kst given its name.
+
+ See :class:`Plot`
+ """
+ return Plot(self, name=name, new=False)
+
+[docs] def get_plot_list(self):
+ """ Get a list of all plots in kst.
+
+ See :class:`Plot`
+ """
+ return_message = self.send("getPlotList()")
+ name_list = return_message.data()[1:-1].split("][")
+ return [Plot(self, name=n, new=False) for n in name_list]
+
+[docs] def set_datasource_option(self, option, value, filename, data_source="Ascii File"):
+ """ Sets the value of a data source configuration option.
+
+ :param option: the name of the option - eg ""Data Start"
+ :param value: True or False
+ :param filename: the name of the file or 0 to set global default
+ :param data_source: the type of data source
+
+ Examples:
+
+ Tell kst that trial1.csv is a file with the field names in row 1 and units in row 2::
+
+ import pykst as kst
+ client = kst.Client()
+ client.set_datasource_option("Column Delimiter", ",", "trial1.csv")
+ client.set_datasource_option("Column Type", 2, "trial1.csv")
+ client.set_datasource_option("Data Start", 3-1, "trial1.csv")
+ client.set_datasource_option("Fields Line", 1-1, "trial1.csv")
+ client.set_datasource_option("Read Fields", True, "trial1.csv")
+ client.set_datasource_option("Units Line", 2-1, "trial1.csv")
+ client.set_datasource_option("Read Units", True, "trial1.csv")
+
+ Configuration options supported by the ASCII data source (default) are::
+
+ "ASCII Time format"
+ "Column Delimiter"
+ "Column Type"
+ "Column Width"
+ "Column Width is const"
+ "Comment Delimiters"
+ "Data Rate for index"
+ "Data Start"
+ "Default INDEX Interpretation"
+ "Fields Line"
+ "Filename Pattern"
+ "Index"
+ "Limit file buffer size"
+ "NaN value"
+ "Read Fields"
+ "Read Units"
+ "Size of limited file buffer"
+ "Units Line"
+ "Use Dot"
+ "Use threads when parsing Ascii data"
+ "date/time offset"
+ "relative offset"
+ "updateType"
+ "use an explicit date/time offset"
+ "use file time/date as offset"
+ "use relative file time offset"
+
+
+ """
+
+ if filename == 0:
+ filename = "$DEFAULT"
+
+ if isinstance(value, bool):
+ self.send("setDatasourceBoolConfig("+data_source+","+filename+","+option+","+
+ b2str(value)+")")
+ elif isinstance(value, int):
+ self.send("setDatasourceIntConfig("+data_source+","+filename+","+option+","+
+ str(value)+")")
+ else:
+ v = value
+ v.replace(',', '`')
+ self.send("setDatasourceStringConfig("+data_source+","+filename+","+option+","+
+ str(v)+")")
+
+
+
+class NamedObject(object):
""" Convenience class. You should not use it directly."""
- def __init__(self,client):
- self.client=client
-
- def set_name(self,name):
- """ Set the name of the object inside kst. """
- self.client.send_si(self.handle, b2str("setName("+b2str(name)+")"))
-
+ def __init__(self, client):
+ self.client = client
+ self.handle = ""
+
+ def set_name(self, name):
+ """ Set the name of the object inside kst. """
+ self.client.send_si(self.handle, b2str("setName("+b2str(name)+")"))
+
def name(self):
- """ Returns the name of the object from inside kst. """
- return self.client.send_si(self.handle, "name()")
+ """ Returns the name of the object from inside kst. """
+ return self.client.send_si(self.handle, "name()")
def description_tip(self):
- """ Returns a string describing the object """
- return self.client.send_si(self.handle, "descriptionTip()")
+ """ Returns a string describing the object """
+ return self.client.send_si(self.handle, "descriptionTip()")
def test_command(self):
- return self.client.send_si(self.handle, "testCommand()")
+ return self.client.send_si(self.handle, "testCommand()")
+
+
+class Object(NamedObject):
+ """ Convenience class. You should not use it directly."""
+ def __init__(self, client):
+ NamedObject.__init__(self, client)
+
+ def type_str(self):
+ """ Returns the type of the object from inside kst. """
+ return self.client.send_si(self.handle, "type()")
+
+
+class String(Object):
+ """ Convenience class. You should not use it directly."""
+ def __init__(self, client):
+ Object.__init__(self, client)
+
+ def value(self):
+ """ Returns the string. """
+ return self.client.send_si(self.handle, "value()")
+
+[docs]class GeneratedString(String):
+ """ A string constant inside kst.
+
+ This class represents a string you would create via
+ "Create>String>Generated" from the menubar inside kst.
+
+ :param string: The value of the string.
+
+ To import the string "Hello World" into kst::
+
+ import pykst as kst
+ client = kst.Client()
+ s = client.new_generatedString("Hello World")
+
+ """
+ def __init__(self, client, string, name="", new=True):
+ String.__init__(self, client)
+
+ if new:
+ self.client.send("newGeneratedString()")
+ self.handle = self.client.send("endEdit()")
+ self.handle.remove(0, self.handle.indexOf("ing ")+4)
+
+ self.set_value(string)
+ self.set_name(name)
+ else:
+ self.handle = name
+
+[docs] def set_value(self, val):
+ """ set the value of the string inside kst. """
+ self.client.send_si(self.handle, b2str("setValue("+b2str(val)+")"))
+
+[docs]class DataSourceString(String):
+ """ A string read from a data source inside kst.
+
+ This class represents a string you would create via
+ "Create>String>Read from Data Source" from the menubar inside kst.
-
-class Object(NamedObject) :
- """ Convenience class. You should not use it directly."""
- def __init__(self,client) :
- NamedObject.__init__(self,client)
-
- def type_str(self):
- """ Returns the type of the object from inside kst. """
- return self.client.send_si(self.handle, "type()")
-
-
-class String(Object) :
- """ Convenience class. You should not use it directly."""
- def __init__(self,client) :
- Object.__init__(self,client)
-
- def value(self) :
- """ Returns the string. """
- return self.client.send_si(self.handle, "value()")
-
-[docs]class GeneratedString(String) :
- """ A string constant inside kst.
-
- This class represents a string you would create via
- "Create>String>Generated" from the menubar inside kst.
-
- :param string: The value of the string.
-
- To import the string "Hello World" into kst::
-
- import pykst as kst
- client = kst.Client()
- s = client.new_generatedString("Hello World")
-
- """
- def __init__(self,client,string,name="", new=True) :
- String.__init__(self,client)
-
- if new:
- self.client.send("newGeneratedString()")
- self.handle=self.client.send("endEdit()")
- self.handle.remove(0,self.handle.indexOf("ing ")+4)
-
- self.set_value(string)
- self.set_name(name)
- else:
- self.handle = name
-
-[docs] def set_value(self,val):
- """ set the value of the string inside kst. """
- self.client.send_si(self.handle, b2str("setValue("+b2str(val)+")"))
-
-[docs]class DataSourceString(String) :
- """ A string read from a data source inside kst.
-
- This class represents a string you would create via
- "Create>String>Read from Data Source" from the menubar inside kst.
-
- :param filename: The name of the file/data source to read the string from.
- :param field: the name of the field in the data source.
-
- To read "File path" from the data source "tmp.dat" into kst::
-
- import pykst as kst
- client = kst.Client()
- s = client.new_datasource_string("tmp.dat", "File Path")
-
- """
- def __init__(self,client,filename,field,name="", new=True) :
- String.__init__(self,client)
-
- if new:
- self.client.send("newDataString()")
- self.handle=self.client.send("endEdit()")
- self.handle.remove(0,self.handle.indexOf("ing ")+4)
- self.change(filename, field)
- else:
- self.handle = name
-
-[docs] def change(self,filename,field):
- """ Change a DataSource String.
-
- Change the file and field of a DataSourceString in kst.
-
:param filename: The name of the file/data source to read the string from.
:param field: the name of the field in the data source.
+
+ To read "File path" from the data source "tmp.dat" into kst::
+
+ import pykst as kst
+ client = kst.Client()
+ s = client.new_datasource_string("tmp.dat", "File Path")
+
"""
- self.client.send_si(self.handle, b2str("change("+b2str(filename)+","+b2str(field)+")"))
+ def __init__(self, client, filename, field, name="", new=True):
+ String.__init__(self, client)
+ if new:
+ self.client.send("newDataString()")
+ self.handle = self.client.send("endEdit()")
+ self.handle.remove(0, self.handle.indexOf("ing ")+4)
+ self.change(filename, field)
+ else:
+ self.handle = name
+
+[docs] def change(self, filename, field):
+ """ Change a DataSource String.
+
+ Change the file and field of a DataSourceString in kst.
+
+ :param filename: The name of the file/data source to read the string from.
+ :param field: the name of the field in the data source.
+ """
+ self.client.send_si(self.handle, b2str("change("+b2str(filename)+","+b2str(field)+")"))
+
+
+class Scalar(Object):
+ """ Convenience class. You should not use it directly."""
+ def __init__(self, client, name=""):
+ Object.__init__(self, client)
+
+ self.handle = name
+
+ def value(self):
+ """ Returns the scalar. """
+ return self.client.send_si(self.handle, "value()")
+
+[docs]class GeneratedScalar(Scalar):
+ """ A scalar constant inside kst.
+
+ This class represents a scalar you would create via
+ "Create>Scalar>Generate" from the menubar inside kst.
+
+ :param value: the value to assign to the scalar constant.
+
+ To import the scalar of value 42 into kst::
+
+ import pykst as kst
+ client = kst.Client()
+ s = client.new_generated_scalar(42)
+
+ """
+ def __init__(self, client, value, name="", new=True):
+ Scalar.__init__(self, client)
+
+ if new:
+ self.client.send("newGeneratedScalar()")
+ self.handle = self.client.send("endEdit()")
+ self.handle.remove(0, self.handle.indexOf("ing ")+4)
+
+ self.set_value(value)
+ self.set_name(name)
+ else:
+ self.handle = name
+
+[docs] def set_value(self, val):
+ """ set the value of the string inside kst. """
+ self.client.send_si(self.handle, b2str("setValue("+b2str(val)+")"))
+
+
+[docs]class DataSourceScalar(Scalar):
+ """ A scalar read from a data source inside kst.
+
+ This class represents a scalar you would create via
+ "Create>Scalar>Read from Data Source" from the menubar inside kst.
-class Scalar(Object) :
- """ Convenience class. You should not use it directly."""
- def __init__(self,client, name="") :
- Object.__init__(self,client)
-
- self.handle = name
-
- def value(self) :
- """ Returns the scalar. """
- return self.client.send_si(self.handle, "value()")
-
-[docs]class GeneratedScalar(Scalar) :
- """ A scalar constant inside kst.
-
- This class represents a scalar you would create via
- "Create>Scalar>Generate" from the menubar inside kst.
-
- :param value: the value to assign to the scalar constant.
-
- To import the scalar of value 42 into kst::
-
- import pykst as kst
- client = kst.Client()
- s = client.new_generated_scalar(42)
-
- """
- def __init__(self, client, value, name="", new=True) :
- Scalar.__init__(self,client)
-
- if new:
- self.client.send("newGeneratedScalar()")
- self.handle=self.client.send("endEdit()")
- self.handle.remove(0,self.handle.indexOf("ing ")+4)
-
- self.set_value(value)
- self.set_name(name)
- else:
- self.handle = name
-
-[docs] def set_value(self,val):
- """ set the value of the string inside kst. """
- self.client.send_si(self.handle, b2str("setValue("+b2str(val)+")"))
-
-
-[docs]class DataSourceScalar(Scalar) :
- """ A scalar read from a data source inside kst.
-
- This class represents a scalar you would create via
- "Create>Scalar>Read from Data Source" from the menubar inside kst.
-
- :param filename: The name of the file/data source to read the scalar from.
- :param field: the name of the field in the data source.
-
- To read "CONST1" from the data source "tmp.dat" into kst::
-
- import pykst as kst
- client = kst.Client()
- x = client.new_datasource_scalar("tmp.dat", "CONST1")
-
- """
- def __init__(self,client,filename,field,name="", new=True) :
- Scalar.__init__(self,client)
-
- if new:
- self.client.send("newDataScalar()")
- self.handle=self.client.send("endEdit()")
- self.handle.remove(0,self.handle.indexOf("ing ")+4)
-
- self.change(filename, field)
- else:
- self.handle = name
-
-[docs] def change(self,filename,field):
- """ Change a DataSource Scalar.
-
- Change the file and field of a DataSourceScalar in kst.
-
:param filename: The name of the file/data source to read the scalar from.
:param field: the name of the field in the data source.
+
+ To read "CONST1" from the data source "tmp.dat" into kst::
+
+ import pykst as kst
+ client = kst.Client()
+ x = client.new_datasource_scalar("tmp.dat", "CONST1")
+
"""
- self.client.send_si(self.handle, "change("+filename+","+field+")")
+ def __init__(self, client, filename, field, name="", new=True):
+ Scalar.__init__(self, client)
+
+ if new:
+ self.client.send("newDataScalar()")
+ self.handle = self.client.send("endEdit()")
+ self.handle.remove(0, self.handle.indexOf("ing ")+4)
+
+ self.change(filename, field)
+ else:
+ self.handle = name
+
+[docs] def change(self, filename, field):
+ """ Change a DataSource Scalar.
+
+ Change the file and field of a DataSourceScalar in kst.
+
+ :param filename: The name of the file/data source to read the scalar from.
+ :param field: the name of the field in the data source.
+ """
+ self.client.send_si(self.handle, "change("+filename+","+field+")")
+
+[docs] def file(self):
+ """ Returns the data source file name. """
+ return self.client.send_si(self.handle, "file()")
+
+[docs] def field(self):
+ """ Returns the field. """
+ return self.client.send_si(self.handle, "field()")
+
+
+[docs]class VectorScalar(Scalar):
+ """ A scalar in kst read from a vector from a data source.
+
+ This class represents a scalar you would create via
+ "Create>Scalar>Read from vector" from the menubar inside kst.
-[docs] def file(self) :
- """ Returns the data source file name. """
- return self.client.send_si(self.handle, "file()")
-
-[docs] def field(self) :
- """ Returns the field. """
- return self.client.send_si(self.handle, "field()")
-
-
-[docs]class VectorScalar(Scalar) :
- """ A scalar in kst read from a vector from a data source.
-
- This class represents a scalar you would create via
- "Create>Scalar>Read from vector" from the menubar inside kst.
-
- :param filename: The name of the file/data source to read the scalar from.
- :param field: the name of the vector in the data source.
- :param frame: which frame of the vector to read the scalar from.
- frame = -1 (the default) reads from the end of the file.
-
- To read the last value of the vector INDEX from the file "tmp.dat"
- into kst::
-
- import pykst as kst
- client = kst.Client()
- x = client.new_vector_scalar("tmp.dat", "INDEX", -1)
-
- """
- def __init__(self, client, filename, field, frame=-1, name="", new=True) :
- Scalar.__init__(self,client)
-
- if new:
- self.client.send("newVectorScalar()")
- self.handle=self.client.send("endEdit()")
- self.handle.remove(0,self.handle.indexOf("ing ")+4)
-
- self.change(filename, field, frame)
- else:
- self.handle = name
-
-[docs] def change(self,filename,field,frame):
- """ Change a Vector Scalar in kst.
-
- Change the file, field and frame of a VectorScalar in kst.
-
:param filename: The name of the file/data source to read the scalar from.
- :param field: the name of the vector in the data source.
- :param frame: which frame of the vector to read the scalar from.
- frame = -1 reads from the end of the file.
- """
- self.client.send_si(self.handle, b2str("change("+b2str(filename)+","+b2str(field)+","+b2str(frame)+")"))
-
-[docs] def file(self) :
- """ Returns the data source file name. """
- return self.client.send_si(self.handle, "file()")
-
-[docs] def field(self) :
- """ Returns the field. """
- return self.client.send_si(self.handle, "field()")
-
-[docs] def frame(self) :
- """ Returns the fame. """
- return self.client.send_si(self.handle, "frame()")
+ :param field: the name of the vector in the data source.
+ :param frame: which frame of the vector to read the scalar from.
+ frame = -1 (the default) reads from the end of the file.
+
+ To read the last value of the vector INDEX from the file "tmp.dat"
+ into kst::
+
+ import pykst as kst
+ client = kst.Client()
+ x = client.new_vector_scalar("tmp.dat", "INDEX", -1)
+
+ """
+ def __init__(self, client, filename, field, frame=-1, name="", new=True):
+ Scalar.__init__(self, client)
+
+ if new:
+ self.client.send("newVectorScalar()")
+ self.handle = self.client.send("endEdit()")
+ self.handle.remove(0, self.handle.indexOf("ing ")+4)
+
+ self.change(filename, field, frame)
+ else:
+ self.handle = name
+
+[docs] def change(self, filename, field, frame):
+ """ Change a Vector Scalar in kst.
+
+ Change the file, field and frame of a VectorScalar in kst.
+
+ :param filename: The name of the file/data source to read the scalar from.
+ :param field: the name of the vector in the data source.
+ :param frame: which frame of the vector to read the scalar from.
+ frame = -1 reads from the end of the file.
+ """
+ self.client.send_si(self.handle, b2str("change("+b2str(filename)+","+
+ b2str(field)+","+b2str(frame)+")"))
+
+[docs] def file(self):
+ """ Returns the data source file name. """
+ return self.client.send_si(self.handle, "file()")
+
+[docs] def field(self):
+ """ Returns the field. """
+ return self.client.send_si(self.handle, "field()")
+
+[docs] def frame(self):
+ """ Returns the fame. """
+ return self.client.send_si(self.handle, "frame()")
class VectorBase(Object):
- """ Convenience class. You should not use it directly."""
- def __init__(self,client,name="") :
- Object.__init__(self,client)
- self.handle = name
-
- def value(self,index):
- """ Returns element i of this vector. """
- return self.client.send_si(self.handle, "value("+b2str(index)+")")
-
- def length(self):
- """ Returns the number of samples in the vector. """
- return self.client.send_si(self.handle, "length()")
-
- def min(self):
- """ Returns the minimum value in the vector. """
- return self.client.send_si(self.handle, "min()")
-
- def mean(self):
- """ Returns the mean of the vector. """
- return self.client.send_si(self.handle, "mean()")
-
- def max(self):
- """ Returns the maximum value in the vector. """
- return self.client.send_si(self.handle, "max()")
-
- def get_numpy_array(self) :
- """ get a numpy array which contains the kst vector values """
- with tempfile.NamedTemporaryFile() as f:
- self.client.send_si(self.handle, "store(" + f.name + ")")
- array = fromfile(f.name, dtype = float64)
-
- return array
+ """ Convenience class. You should not use it directly."""
+ def __init__(self, client, name=""):
+ Object.__init__(self, client)
+ self.handle = name
+
+ def value(self, index):
+ """ Returns element i of this vector. """
+ return self.client.send_si(self.handle, "value("+b2str(index)+")")
+
+ def length(self):
+ """ Returns the number of samples in the vector. """
+ return self.client.send_si(self.handle, "length()")
+
+ def min(self):
+ """ Returns the minimum value in the vector. """
+ return self.client.send_si(self.handle, "min()")
+
+ def mean(self):
+ """ Returns the mean of the vector. """
+ return self.client.send_si(self.handle, "mean()")
+
+ def max(self):
+ """ Returns the maximum value in the vector. """
+ return self.client.send_si(self.handle, "max()")
+
+ def get_numpy_array(self):
+ """ get a numpy array which contains the kst vector values """
+ with tempfile.NamedTemporaryFile() as f:
+ self.client.send_si(self.handle, "store(" + f.name + ")")
+ array = np.fromfile(f.name, dtype=np.float64)
+
+ return array
[docs]class DataVector(VectorBase):
- """ A vector in kst, read from a data source.
-
- This class represents a vector you would create via
- "Create>Vector>Read from Data Source" from the menubar inside kst.
-
- The parameters of this function mirror the parameters within
- "Create>Vector>Read from Data Source".
-
- :param filename: The name of the file/data source to read the scalar from.
- :param field: the name of the vector in the data source.
- :param start: The starting index of the vector.
- start = -1 for count from end.
- :param num_frames: The number of frames to read.
- num_frames = -1 for read to end.
- :param skip: The number of frames per sample read.
- skip = 0 to read every sample.
- :param boxcarFirst: apply a boxcar filter before skiping.
-
- To create a vector from "tmp.dat" with field "INDEX" from
- frame 3 to frame 10, reading a sample every other frame without
- a boxcar filter::
-
- import pykst as kst
- client = kst.Client()
- v = client.new_data_vector("tmp.dat", "INDEX", 3, 10, 2, False)
-
- """
- def __init__(self, client, filename, field, start=0, num_frames=-1,
- skip=0, boxcarFirst=False, name="", new=True) :
- VectorBase.__init__(self,client)
-
- if new:
- self.client.send("newDataVector()")
- self.handle=self.client.send("endEdit()")
- self.handle.remove(0,self.handle.indexOf("ing ")+4)
- self.change(filename, field, start, num_frames, skip, boxcarFirst)
- else:
- self.handle = name
-
-[docs] def change(self, filename, field, start, num_frames, skip, boxcarFirst):
- """ Change the parameters of a data vector.
-
- :param filename: The name of the file/data source to read the scalar from.
- :param field: the name of the vector in the data source.
- :param start: The starting index of the vector.
- start = -1 for count from end.
- :param num_frames: The number of frames to read.
- num_frames = -1 for read to end.
- :param skip: The number of frames per sample read.
- skip = 0 to read every sample.
- :param boxcarFirst: apply a boxcar filter before skiping.
-
- """
- self.client.send_si(self.handle, "change("+filename+","+field+","
- +b2str(start)+","+b2str(num_frames)+","+b2str(skip)
- +","+b2str(boxcarFirst)+")")
+ """ A vector in kst, read from a data source.
+
+ This class represents a vector you would create via
+ "Create>Vector>Read from Data Source" from the menubar inside kst.
-[docs] def change_frames(self, start, num_frames, skip, boxcarFirst):
- """ Change the parameters of a data vector.
+ The parameters of this function mirror the parameters within
+ "Create>Vector>Read from Data Source".
+ :param filename: The name of the file/data source to read the scalar from.
+ :param field: the name of the vector in the data source.
:param start: The starting index of the vector.
start = -1 for count from end.
:param num_frames: The number of frames to read.
num_frames = -1 for read to end.
:param skip: The number of frames per sample read.
- skip = 0 to read every sample.
+ skip = 0 to read every sample.
:param boxcarFirst: apply a boxcar filter before skiping.
+ To create a vector from "tmp.dat" with field "INDEX" from
+ frame 3 to frame 10, reading a sample every other frame without
+ a boxcar filter::
+
+ import pykst as kst
+ client = kst.Client()
+ v = client.new_data_vector("tmp.dat", "INDEX", 3, 10, 2, False)
+
"""
- self.client.send_si(self.handle, "changeFrames("
- +b2str(start)+","+b2str(num_frames)+","+b2str(skip)
- +","+b2str(boxcarFirst)+")")
-
-[docs] def field(self):
- """ Returns the fieldname. """
- return self.client.send_si(self.handle, "field()")
-
-[docs] def filename(self):
- """ Returns the filename. """
- return self.client.send_si(self.handle, "filename()")
-
-[docs] def start(self):
- """ Returns the index of first frame in the vector.
- -1 means count from end. """
- return self.client.send_si(self.handle, "start()")
-
-[docs] def n_frames(self):
- """ Returns the number of frames to be read. -1 means read to end. """
- return self.client.send_si(self.handle, "NFrames()")
-
-[docs] def skip(self):
- """ Returns number of frames to be skipped between samples read. """
- return self.client.send_si(self.handle, "skip()")
-
-[docs] def boxcar_first(self):
- """ True if boxcar filtering has been applied before skipping. """
- return self.client.send_si(self.handle, "boxcarFirst()")
+ def __init__(self, client, filename, field, start=0, num_frames=-1,
+ skip=0, boxcarFirst=False, name="", new=True):
+ VectorBase.__init__(self, client)
+
+ if new:
+ self.client.send("newDataVector()")
+ self.handle = self.client.send("endEdit()")
+ self.handle.remove(0, self.handle.indexOf("ing ")+4)
+ self.change(filename, field, start, num_frames, skip, boxcarFirst)
+ else:
+ self.handle = name
+
+[docs] def change(self, filename, field, start, num_frames, skip, boxcarFirst):
+ """ Change the parameters of a data vector.
+
+ :param filename: The name of the file/data source to read the scalar from.
+ :param field: the name of the vector in the data source.
+ :param start: The starting index of the vector.
+ start = -1 for count from end.
+ :param num_frames: The number of frames to read.
+ num_frames = -1 for read to end.
+ :param skip: The number of frames per sample read.
+ skip = 0 to read every sample.
+ :param boxcarFirst: apply a boxcar filter before skiping.
+
+ """
+ self.client.send_si(self.handle, "change("+filename+","+field+","
+ +b2str(start)+","+b2str(num_frames)+","+b2str(skip)
+ +","+b2str(boxcarFirst)+")")
+
+[docs] def change_frames(self, start, num_frames, skip, boxcarFirst):
+ """ Change the parameters of a data vector.
+
+ :param start: The starting index of the vector.
+ start = -1 for count from end.
+ :param num_frames: The number of frames to read.
+ num_frames = -1 for read to end.
+ :param skip: The number of frames per sample read.
+ skip = 0 to read every sample.
+ :param boxcarFirst: apply a boxcar filter before skiping.
+
+ """
+ self.client.send_si(self.handle, "changeFrames("
+ +b2str(start)+","+b2str(num_frames)+","+b2str(skip)
+ +","+b2str(boxcarFirst)+")")
+
+[docs] def field(self):
+ """ Returns the fieldname. """
+ return self.client.send_si(self.handle, "field()")
+
+[docs] def filename(self):
+ """ Returns the filename. """
+ return self.client.send_si(self.handle, "filename()")
+
+[docs] def start(self):
+ """ Returns the index of first frame in the vector.
+ -1 means count from end. """
+ return self.client.send_si(self.handle, "start()")
+
+[docs] def n_frames(self):
+ """ Returns the number of frames to be read. -1 means read to end. """
+ return self.client.send_si(self.handle, "NFrames()")
+
+[docs] def skip(self):
+ """ Returns number of frames to be skipped between samples read. """
+ return self.client.send_si(self.handle, "skip()")
+
+[docs] def boxcar_first(self):
+ """ True if boxcar filtering has been applied before skipping. """
+ return self.client.send_si(self.handle, "boxcarFirst()")
#!/usr/bin/python2.7
import pykst as kst
import numpy as _np
_current_plot = None
_client = None
_subplots = {}
class _CurveInfo:
def __init__(self):
self.reset()
self.line_width = 1
self.line_style = ""
self.color = "auto"
self.marker_size=0
self.label = None
def reset(self):
self.x = None
self.y = None
self.f = None
def _add_curve_to_plot(P, C):
global _client
colors = {'b': "blue", 'r':"red", 'g':"green", 'c':"cyan",
'm':"magenta", 'y':"yellow", 'k':"black", 'w':"white"}
points = {'.':(3,3), ',':(13,12), 'v':(9,10), '^':(10,10), 's':(6,7),
'*':(8,9), '+':(7,10), 'D':(12,10), 'x':(0,9), 'o':(3,10)}
V1 = _client.new_editable_vector(C.x, name="X")
V2 = _client.new_editable_vector(C.y, name="Y")
c1 = _client.new_curve(V1, V2)
if isinstance(C.f, basestring):
if '--' in C.f:
c1.set_line_style(1)
elif '-.' in C.f:
c1.set_line_style(3)
elif ':' in C.f:
c1.set_line_style(2)
for color_key in colors.keys():
if color_key in C.f:
c1.set_color(colors[color_key])
for point_key in points.keys():
if point_key in C.f:
c1.set_has_lines(False)
c1.set_has_points(True)
c1.set_point_type(points[point_key][0])
c1.set_point_size(points[point_key][1])
c1.set_line_width(C.line_width)
if C.color != "auto":
c1.set_color(C.color)
if (C.line_style == "-"):
c1.set_line_style(0)
elif (C.line_style == "--"):
c1.set_line_style(1)
elif (C.line_style == ":"):
c1.set_line_style(2)
elif (C.line_style == "-."):
c1.set_line_style(3)
if (C.marker_size > 0):
c1.set_point_size(C.marker_size)
if (C.label is not None):
c1.set_name(C.label)
P.add(c1)
[docs]def semilogx(*args, **kwargs):
"""
Add a curve to the current axis (or make a new one)
with log scaling on the X axis. All parameters are the same as :func:`plot()`.
"""
plot(*args, **kwargs)
_current_plot.set_log_x()
[docs]def semilogy(*args, **kwargs):
"""
Add a curve to the current axis (or make a new one)
with log scaling on the Y axis. All parameters are the same as :func:`plot()`.
"""
plot(*args, **kwargs)
_current_plot.set_log_y()
[docs]def loglog(*args, **kwargs):
"""
Add a curve to the current axis (or make a new one)
with log-log scaling. All parameters are the same as :func:`plot()`.
"""
plot(*args, **kwargs)
_current_plot.set_log_y()
_current_plot.set_log_x()
[docs]def xlabel(s):
"""
Set the *x* axis label of the current axis.
"""
_current_plot.set_bottom_label(s)
[docs]def ylabel(s):
"""
Set the *y* axis label of the current axis.
"""
_current_plot.set_left_label(s)
[docs]def title(s):
"""
Set the *top* axis label of the current axis.
"""
_current_plot.set_top_label(s)
[docs]def show():
"""
This method does nothing, but exists for compatibility
with matplotlib scripts.
"""
pass
[docs]def savefig(fname, **kwargs):
"""
Export the kst session as a series of graphics files. If there is
only 1 tab, then the file will be called *fname*. If there are multiple
tabs, the files will be called, for example, fname_1.png, fname_2.png, etc.
The plot will be have the same aspect ratio as the kst session, and, for
pixel based formats, will be 1280 pixels wide.
The format is determined by the *format* kwarg, or by the *fname* extension
if *format* is not defined.
All formats supported by kst are supported, including, among many others, png,
jpg, eps, svg, and pdf.
"""
if "format" in kwargs:
format = kwargs["format"]
else:
format = None
_client.export_graphics_file(fname, format, 1280, 1024, 0)
[docs]def figure():
"""
Creates a new tab in kst.
"""
global _client
global _current_plot
global _subplots
if _client is None:
_client=kst.Client()
_client.new_tab()
_current_plot = None
_subplots = {}
[docs]def plot(*args, **kwargs):
"""
Plot lines and/or markers to a kst window. *args* is a variable length
argument, allowing for multiple *x*, *y* pairs with an
optional format string. For example, each of the following is
legal::
plot(x, y) # plot x and y using default line style and color
plot(x, y, 'bo') # plot x and y using blue circle markers
plot(y) # plot y using x as index array 0..N-1
plot(y, 'r+') # ditto, but with red plusses
An arbitrary number of *x*, *y*, *fmt* groups can be
specified, as in::
a.plot(x1, y1, 'g^', x2, y2, 'g-')
By default, each line is assigned a different color in kst.
The following format string characters are accepted to control
the line style or marker:
================ ===============================
character description
================ ===============================
``'-'`` solid line style
``'--'`` dashed line style
``'-.'`` dash-dot line style
``':'`` dotted line style
``'.'`` point marker
``','`` pixel marker
``'o'`` circle marker
``'v'`` triangle_down marker
``'^'`` triangle_up marker
``'s'`` square marker
``'*'`` star marker
``'+'`` plus marker
``'x'`` x marker
``'D'`` diamond marker
================ ===============================
The following color abbreviations are supported:
========== ========
character color
========== ========
'b' blue
'g' green
'r' red
'c' cyan
'm' magenta
'y' yellow
'k' black
'w' white
========== ========
Line styles and colors are combined in a single format string, as in
``'bo'`` for blue circles.
The *kwargs* can be used to set the color, the line width, the line type,
and the legend label. You can specify colors using full names (``'green'``),
or hex strings (``'#008000'``).
Some examples::
plot([1,2,3], [1,2,3], 'go-', label='line 1', linewidth=2)
plot([1,2,3], [1,4,9], 'rs', label='line 2')
axis([0, 4, 0, 10])
legend()
If you make multiple lines with one plot command, the kwargs
apply to all those lines, e.g.::
plot(x1, y1, x2, y2, linewidth=2)
Both lines will have a width of 2.
You do not need to use format strings, which are just
abbreviations. All of the line properties can be controlled
by keyword arguments. For example, you can set the color,
marker, linestyle, and markercolor with::
plot(x, y, color='green', linestyle='dashed', marker='o',
color='blue', markersize=12).
Supported kwargs are::
color
label
linestyle
linewidth
markersize
"""
global _current_plot
global _client
if _client is None:
_client=kst.Client()
if _current_plot is None:
_current_plot = _client.new_plot()
C = _CurveInfo()
if "linewidth" in kwargs:
C.line_width = kwargs["linewidth"]
if "color" in kwargs:
C.color = kwargs["color"]
if "linestyle" in kwargs:
C.line_style = kwargs["linestyle"]
if "markersize" in kwargs:
C.marker_size = kwargs["markersize"]
if "label" in kwargs:
C.label = kwargs["label"]
for arg in args:
if isinstance(arg, basestring):
C.f = arg
if (C.y is None) & (isinstance(C.x, _np.ndarray)):
C.y = C.x
C.x = _np.linspace(0, C.y.size-1, C.y.size)
if (isinstance(C.x, _np.ndarray)):
_add_curve_to_plot(_current_plot, C)
C.reset()
else:
if (isinstance(C.y, _np.ndarray)):
_add_curve_to_plot(_current_plot, C)
C.reset()
if isinstance(C.x, _np.ndarray):
C.y = _np.asanyarray(arg, dtype=_np.float64)
else:
C.x = _np.asanyarray(arg, dtype=_np.float64)
if (C.y is None) & (isinstance(C.x, _np.ndarray)):
C.y = C.x
C.x = _np.asanyarray([0.0, C.y.size-1.0], dtype=_np.float64)
if (isinstance(C.x, _np.ndarray)):
_add_curve_to_plot(_current_plot, C)
[docs]def subplot(*args, **kwargs):
"""
Return a subplot axes positioned by the given grid definition.
Typical call signature::
subplot(nrows, ncols, plot_number)
Where *nrows* and *ncols* are used to notionally split the figure
into ``nrows * ncols`` sub-axes, and *plot_number* is used to identify
the particular subplot that this function is to create within the notional
grid. *plot_number* starts at 1, increments across rows first and has a
maximum of ``nrows * ncols``.
In the case when *nrows*, *ncols* and *plot_number* are all less than 10,
a convenience exists, such that the a 3 digit number can be given instead,
where the hundreds represent *nrows*, the tens represent *ncols* and the
units represent *plot_number*. For instance::
subplot(211)
produces a subaxes in a figure which represents the top plot (i.e. the
first) in a 2 row by 1 column notional grid (no grid actually exists,
but conceptually this is how the returned subplot has been positioned).
.. note::
unlike *matplotlib.pyplot.subplot()*, creating a new subplot with a position
which is entirely inside a pre-existing axes will not delete the previous
plot.
Keyword arguments:
*axisbg*:
The background color of the subplot, which can be any valid
color specifier.
"""
global _current_plot
global _client
global _subplots
w = 0
h = 0
x = 0
y = 0
n = 0
if (len(args) == 1):
h = args[0]/100
w = (args[0]%100)/10
n = args[0]%10
elif (len(args) == 3):
h = args[0]
w = args[1]
n = args[2]
else:
w = h = n = 1
x = (n-1)%w
y = (n-1)/w
serial = y + x*100 + h*10000 + w*1000000
#print args[0], w,h,x,y, serial
size = (1.0/w, 1.0/h)
pos = (x/float(w)+0.5/w,y/float(h)+0.5/h)
#print pos, size
if serial in _subplots:
_current_plot = _subplots[serial]
else:
if _client is None:
_client=kst.Client()
_current_plot = _client.new_plot(pos, size)
_subplots[serial] = _current_plot
if "axisbg" in kwargs:
_current_plot.set_fill_color(kwargs["axisbg"])
' + _('Hide Search Matches') + '
') .appendTo($('#searchbox')); } }, /** * init the domain index toggle buttons */ initIndexTable : function() { var togglers = $('img.toggler').click(function() { var src = $(this).attr('src'); var idnum = $(this).attr('id').substr(7); $('tr.cg-' + idnum).toggle(); if (src.substr(-9) == 'minus.png') $(this).attr('src', src.substr(0, src.length-9) + 'plus.png'); else $(this).attr('src', src.substr(0, src.length-8) + 'minus.png'); }).css('display', ''); if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) { togglers.click(); } }, /** * helper function to hide the search marks again */ hideSearchWords : function() { $('#searchbox .highlight-link').fadeOut(300); $('span.highlighted').removeClass('highlighted'); }, /** * make the url absolute */ makeURL : function(relativeURL) { return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL; }, /** * get the current relative url */ getCurrentURL : function() { var path = document.location.pathname; var parts = path.split(/\//); $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() { if (this == '..') parts.pop(); }); var url = parts.join('/'); return path.substring(url.lastIndexOf('/') + 1, path.length - 1); }, initOnKeyListeners: function() { $(document).keyup(function(event) { var activeElementType = document.activeElement.tagName; // don't navigate when in search box or textarea if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT') { switch (event.keyCode) { case 37: // left var prevHref = $('link[rel="prev"]').prop('href'); if (prevHref) { window.location.href = prevHref; return false; } case 39: // right var nextHref = $('link[rel="next"]').prop('href'); if (nextHref) { window.location.href = nextHref; return false; } } } }); } }; // quick alias for translations _ = Documentation.gettext; $(document).ready(function() { Documentation.init(); }); \ No newline at end of file Index: trunk/www/areas/kst-plot/pykst/_static/searchtools.js =================================================================== --- trunk/www/areas/kst-plot/pykst/_static/searchtools.js (revision 1506421) +++ trunk/www/areas/kst-plot/pykst/_static/searchtools.js (revision 1506422) @@ -1,758 +1,758 @@ /* * searchtools.js_t * ~~~~~~~~~~~~~~~~ * * Sphinx JavaScript utilities for the full-text search. * - * :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS. + * :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ /* Non-minified version JS is _stemmer.js if file is provided */ /** * Porter Stemmer */ var Stemmer = function() { var step2list = { ational: 'ate', tional: 'tion', enci: 'ence', anci: 'ance', izer: 'ize', bli: 'ble', alli: 'al', entli: 'ent', eli: 'e', ousli: 'ous', ization: 'ize', ation: 'ate', ator: 'ate', alism: 'al', iveness: 'ive', fulness: 'ful', ousness: 'ous', aliti: 'al', iviti: 'ive', biliti: 'ble', logi: 'log' }; var step3list = { icate: 'ic', ative: '', alize: 'al', iciti: 'ic', ical: 'ic', ful: '', ness: '' }; var c = "[^aeiou]"; // consonant var v = "[aeiouy]"; // vowel var C = c + "[^aeiouy]*"; // consonant sequence var V = v + "[aeiou]*"; // vowel sequence var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0 var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1 var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1 var s_v = "^(" + C + ")?" + v; // vowel in stem this.stemWord = function (w) { var stem; var suffix; var firstch; var origword = w; if (w.length < 3) return w; var re; var re2; var re3; var re4; firstch = w.substr(0,1); if (firstch == "y") w = firstch.toUpperCase() + w.substr(1); // Step 1a re = /^(.+?)(ss|i)es$/; re2 = /^(.+?)([^s])s$/; if (re.test(w)) w = w.replace(re,"$1$2"); else if (re2.test(w)) w = w.replace(re2,"$1$2"); // Step 1b re = /^(.+?)eed$/; re2 = /^(.+?)(ed|ing)$/; if (re.test(w)) { var fp = re.exec(w); re = new RegExp(mgr0); if (re.test(fp[1])) { re = /.$/; w = w.replace(re,""); } } else if (re2.test(w)) { var fp = re2.exec(w); stem = fp[1]; re2 = new RegExp(s_v); if (re2.test(stem)) { w = stem; re2 = /(at|bl|iz)$/; re3 = new RegExp("([^aeiouylsz])\\1$"); re4 = new RegExp("^" + C + v + "[^aeiouwxy]$"); if (re2.test(w)) w = w + "e"; else if (re3.test(w)) { re = /.$/; w = w.replace(re,""); } else if (re4.test(w)) w = w + "e"; } } // Step 1c re = /^(.+?)y$/; if (re.test(w)) { var fp = re.exec(w); stem = fp[1]; re = new RegExp(s_v); if (re.test(stem)) w = stem + "i"; } // Step 2 re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/; if (re.test(w)) { var fp = re.exec(w); stem = fp[1]; suffix = fp[2]; re = new RegExp(mgr0); if (re.test(stem)) w = stem + step2list[suffix]; } // Step 3 re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/; if (re.test(w)) { var fp = re.exec(w); stem = fp[1]; suffix = fp[2]; re = new RegExp(mgr0); if (re.test(stem)) w = stem + step3list[suffix]; } // Step 4 re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/; re2 = /^(.+?)(s|t)(ion)$/; if (re.test(w)) { var fp = re.exec(w); stem = fp[1]; re = new RegExp(mgr1); if (re.test(stem)) w = stem; } else if (re2.test(w)) { var fp = re2.exec(w); stem = fp[1] + fp[2]; re2 = new RegExp(mgr1); if (re2.test(stem)) w = stem; } // Step 5 re = /^(.+?)e$/; if (re.test(w)) { var fp = re.exec(w); stem = fp[1]; re = new RegExp(mgr1); re2 = new RegExp(meq1); re3 = new RegExp("^" + C + v + "[^aeiouwxy]$"); if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) w = stem; } re = /ll$/; re2 = new RegExp(mgr1); if (re.test(w) && re2.test(w)) { re = /.$/; w = w.replace(re,""); } // and turn initial Y back to y if (firstch == "y") w = firstch.toLowerCase() + w.substr(1); return w; } } /** * Simple result scoring code. */ var Scorer = { // Implement the following function to further tweak the score for each result // The function takes a result array [filename, title, anchor, descr, score] // and returns the new score. /* score: function(result) { return result[4]; }, */ // query matches the full name of an object objNameMatch: 11, // or matches in the last dotted part of the object name objPartialMatch: 6, // Additive scores depending on the priority of the object objPrio: {0: 15, // used to be importantResults 1: 5, // used to be objectResults 2: -5}, // used to be unimportantResults // Used when the priority is not in the mapping. objPrioDefault: 0, // query found in title title: 15, // query found in terms term: 5 }; var splitChars = (function() { var result = {}; var singles = [96, 180, 187, 191, 215, 247, 749, 885, 903, 907, 909, 930, 1014, 1648, 1748, 1809, 2416, 2473, 2481, 2526, 2601, 2609, 2612, 2615, 2653, 2702, 2706, 2729, 2737, 2740, 2857, 2865, 2868, 2910, 2928, 2948, 2961, 2971, 2973, 3085, 3089, 3113, 3124, 3213, 3217, 3241, 3252, 3295, 3341, 3345, 3369, 3506, 3516, 3633, 3715, 3721, 3736, 3744, 3748, 3750, 3756, 3761, 3781, 3912, 4239, 4347, 4681, 4695, 4697, 4745, 4785, 4799, 4801, 4823, 4881, 5760, 5901, 5997, 6313, 7405, 8024, 8026, 8028, 8030, 8117, 8125, 8133, 8181, 8468, 8485, 8487, 8489, 8494, 8527, 11311, 11359, 11687, 11695, 11703, 11711, 11719, 11727, 11735, 12448, 12539, 43010, 43014, 43019, 43587, 43696, 43713, 64286, 64297, 64311, 64317, 64319, 64322, 64325, 65141]; var i, j, start, end; for (i = 0; i < singles.length; i++) { result[singles[i]] = true; } var ranges = [[0, 47], [58, 64], [91, 94], [123, 169], [171, 177], [182, 184], [706, 709], [722, 735], [741, 747], [751, 879], [888, 889], [894, 901], [1154, 1161], [1318, 1328], [1367, 1368], [1370, 1376], [1416, 1487], [1515, 1519], [1523, 1568], [1611, 1631], [1642, 1645], [1750, 1764], [1767, 1773], [1789, 1790], [1792, 1807], [1840, 1868], [1958, 1968], [1970, 1983], [2027, 2035], [2038, 2041], [2043, 2047], [2070, 2073], [2075, 2083], [2085, 2087], [2089, 2307], [2362, 2364], [2366, 2383], [2385, 2391], [2402, 2405], [2419, 2424], [2432, 2436], [2445, 2446], [2449, 2450], [2483, 2485], [2490, 2492], [2494, 2509], [2511, 2523], [2530, 2533], [2546, 2547], [2554, 2564], [2571, 2574], [2577, 2578], [2618, 2648], [2655, 2661], [2672, 2673], [2677, 2692], [2746, 2748], [2750, 2767], [2769, 2783], [2786, 2789], [2800, 2820], [2829, 2830], [2833, 2834], [2874, 2876], [2878, 2907], [2914, 2917], [2930, 2946], [2955, 2957], [2966, 2968], [2976, 2978], [2981, 2983], [2987, 2989], [3002, 3023], [3025, 3045], [3059, 3076], [3130, 3132], [3134, 3159], [3162, 3167], [3170, 3173], [3184, 3191], [3199, 3204], [3258, 3260], [3262, 3293], [3298, 3301], [3312, 3332], [3386, 3388], [3390, 3423], [3426, 3429], [3446, 3449], [3456, 3460], [3479, 3481], [3518, 3519], [3527, 3584], [3636, 3647], [3655, 3663], [3674, 3712], [3717, 3718], [3723, 3724], [3726, 3731], [3752, 3753], [3764, 3772], [3774, 3775], [3783, 3791], [3802, 3803], [3806, 3839], [3841, 3871], [3892, 3903], [3949, 3975], [3980, 4095], [4139, 4158], [4170, 4175], [4182, 4185], [4190, 4192], [4194, 4196], [4199, 4205], [4209, 4212], [4226, 4237], [4250, 4255], [4294, 4303], [4349, 4351], [4686, 4687], [4702, 4703], [4750, 4751], [4790, 4791], [4806, 4807], [4886, 4887], [4955, 4968], [4989, 4991], [5008, 5023], [5109, 5120], [5741, 5742], [5787, 5791], [5867, 5869], [5873, 5887], [5906, 5919], [5938, 5951], [5970, 5983], [6001, 6015], [6068, 6102], [6104, 6107], [6109, 6111], [6122, 6127], [6138, 6159], [6170, 6175], [6264, 6271], [6315, 6319], [6390, 6399], [6429, 6469], [6510, 6511], [6517, 6527], [6572, 6592], [6600, 6607], [6619, 6655], [6679, 6687], [6741, 6783], [6794, 6799], [6810, 6822], [6824, 6916], [6964, 6980], [6988, 6991], [7002, 7042], [7073, 7085], [7098, 7167], [7204, 7231], [7242, 7244], [7294, 7400], [7410, 7423], [7616, 7679], [7958, 7959], [7966, 7967], [8006, 8007], [8014, 8015], [8062, 8063], [8127, 8129], [8141, 8143], [8148, 8149], [8156, 8159], [8173, 8177], [8189, 8303], [8306, 8307], [8314, 8318], [8330, 8335], [8341, 8449], [8451, 8454], [8456, 8457], [8470, 8472], [8478, 8483], [8506, 8507], [8512, 8516], [8522, 8525], [8586, 9311], [9372, 9449], [9472, 10101], [10132, 11263], [11493, 11498], [11503, 11516], [11518, 11519], [11558, 11567], [11622, 11630], [11632, 11647], [11671, 11679], [11743, 11822], [11824, 12292], [12296, 12320], [12330, 12336], [12342, 12343], [12349, 12352], [12439, 12444], [12544, 12548], [12590, 12592], [12687, 12689], [12694, 12703], [12728, 12783], [12800, 12831], [12842, 12880], [12896, 12927], [12938, 12976], [12992, 13311], [19894, 19967], [40908, 40959], [42125, 42191], [42238, 42239], [42509, 42511], [42540, 42559], [42592, 42593], [42607, 42622], [42648, 42655], [42736, 42774], [42784, 42785], [42889, 42890], [42893, 43002], [43043, 43055], [43062, 43071], [43124, 43137], [43188, 43215], [43226, 43249], [43256, 43258], [43260, 43263], [43302, 43311], [43335, 43359], [43389, 43395], [43443, 43470], [43482, 43519], [43561, 43583], [43596, 43599], [43610, 43615], [43639, 43641], [43643, 43647], [43698, 43700], [43703, 43704], [43710, 43711], [43715, 43738], [43742, 43967], [44003, 44015], [44026, 44031], [55204, 55215], [55239, 55242], [55292, 55295], [57344, 63743], [64046, 64047], [64110, 64111], [64218, 64255], [64263, 64274], [64280, 64284], [64434, 64466], [64830, 64847], [64912, 64913], [64968, 65007], [65020, 65135], [65277, 65295], [65306, 65312], [65339, 65344], [65371, 65381], [65471, 65473], [65480, 65481], [65488, 65489], [65496, 65497]]; for (i = 0; i < ranges.length; i++) { start = ranges[i][0]; end = ranges[i][1]; for (j = start; j <= end; j++) { result[j] = true; } } return result; })(); function splitQuery(query) { var result = []; var start = -1; for (var i = 0; i < query.length; i++) { if (splitChars[query.charCodeAt(i)]) { if (start !== -1) { result.push(query.slice(start, i)); start = -1; } } else if (start === -1) { start = i; } } if (start !== -1) { result.push(query.slice(start)); } return result; } /** * Search Module */ var Search = { _index : null, _queued_query : null, _pulse_status : -1, init : function() { var params = $.getQueryParameters(); if (params.q) { var query = params.q[0]; $('input[name="q"]')[0].value = query; this.performSearch(query); } }, loadIndex : function(url) { $.ajax({type: "GET", url: url, data: null, dataType: "script", cache: true, complete: function(jqxhr, textstatus) { if (textstatus != "success") { document.getElementById("searchindexloader").src = url; } }}); }, setIndex : function(index) { var q; this._index = index; if ((q = this._queued_query) !== null) { this._queued_query = null; Search.query(q); } }, hasIndex : function() { return this._index !== null; }, deferQuery : function(query) { this._queued_query = query; }, stopPulse : function() { this._pulse_status = 0; }, startPulse : function() { if (this._pulse_status >= 0) return; function pulse() { var i; Search._pulse_status = (Search._pulse_status + 1) % 4; var dotString = ''; for (i = 0; i < Search._pulse_status; i++) dotString += '.'; Search.dots.text(dotString); if (Search._pulse_status > -1) window.setTimeout(pulse, 500); } pulse(); }, /** * perform a search for something (or wait until index is loaded) */ performSearch : function(query) { // create the required interface elements this.out = $('#search-results'); this.title = $('\ <%username%>\ \ <%time.delta%>\
\\ reply ▿\ proposal ▹\ \ \ \
\ \\ <#proposal_diff#>\\
PyKst is a python interface to kst. With PyKst, scripts can control and share data with a kst session.
You will want the version of pykst.py that goes with your version of kst2. Until packaging (and the API) are settled, this may mean compiling kst2 from source.
pykst.py can use either PySide or PyQT4. Make sure one is installed, and edit the begining of pykst.py accordingly (make sure the one you want to use is enabled, and the other is commented out.)
Then run setup.py to install things properly. In linux this is:
sudo python2.7 setup.py install
PyKst depends on python2.7 or greater, and modern versions of NumPy and SciPy.
PyKst can be used control kst, as one would with the GUI. The following (minimal) example tells kst to plot sin(x) from -10 to 10. The results are identical to having used create->equation from within kst:
import pykst as kst
# start a kst session with the arbitrary name "TestSinX"
client=kst.Client("TestSinX")
# inside kst, create the x vector and the equation
v1 = client.new_generated_vector(-10, 10, 1000)
e1 = client.new_equation(v1, "sin(x)")
# inside kst, create a curve, a plot, and add the curve to the plot
c1 = client.new_curve(e1.x(), e1.y())
p1 = client.new_plot()
p1.add(c1)
kst can be also be used to plot numpy arrays, as in this example:
#!/usr/bin/python2.7
import pykst as kst
import numpy as np
# create a pair of numpy arrays
x = np.linspace( -10, 10, 1000)
y = np.sin(x)
# start a kst session with the arbitrary name "NumpyVector"
client=kst.Client("NumpyVector")
# copy the numpy arrays into kst
V1 = client.new_editable_vector(x, name="X") # the name is for the label
V2 = client.new_editable_vector(y, name="sin(X)") # the name is for the label
# inside kst, create a curve, a plot, and add the curve to the plot
c1 = client.new_curve(V1, V2)
p1 = client.new_plot()
p1.add(c1)
Alternativly, one can use a (tiny) subset of matplotlib.pyplot called pykstplot. This interface is conceptually incompatible with the native interface, and is described at the end of this document. As an example:
#!/usr/bin/python2.7
import pykstplot as plt
#import matplotlib.pyplot as plt
import numpy as np
x = np.linspace( -10, 10, 100)
y = np.sin(x)
z = np.cos(x)
plt.subplot(221)
plt.plot(x,y*y, linewidth=2, color = "green", linestyle="-.", label="greenline")
plt.subplot(122)
plt.plot(x,y,"k.")
plt.subplot(223)
plt.plot(x,z,"m*", markersize=6, color="blue")
plt.subplot(221, axisbg="lightblue")
plt.plot(x,z)
plt.xlabel("X axis")
plt.ylabel("Y axis")
plt.title("Title")
plt.figure()
plt.plot([1,3,7,15])
plt.show()
#plt.savefig("pltdemo.eps")
“
pykst.
Client
(server_name='kstScript')[source]¶pykst.
Client
(server_name='')[source]¶
An interface to a running kst session.
A client provides a connection to a running kst session.
The constructor creates a connection to either a running
kst session with name <server_name>, or if none exists, a new one.
-If server_name is not specified, it creates a connection to either the
-kst session with the name kstScript
, or if none exists, a new one.
The Client provides functions which effect the entire kst session,
provides convenience functions to create objects within kst (eg,
client.new_generated_vector(0, 1, 6)
), and provides
convenience functions to access objects already within kst (eg,
client.vector("V2")
. This is the suggested method.
Alternatively, the constructor for every class inside pykst accepts an instance of Client which it uses to interact with a kst session.
To connect to a kst session named kstSession
(starting kst if necessary):
import pykst as kst
client = kst.Client("kstSession")
cleanup_layout
(columns='Auto')[source]¶Cleanup layout in the current tab.
If columns is not set, use auto-layout.
clear
()[source]¶Clears all objects from kst.
Equivalent to file->close from the menubar inside kst.
data_matrix
(name)[source]¶Returns a DataMatrix from kst given its name.
See DataMatrix
data_vector
(name)[source]¶Returns a DataVector from kst given its name.
See DataVector
datasource_scalar
(name)[source]¶Returns a DataSource Scalar from kst given its name.
See DataSourceScalar
datasource_string
(name)[source]¶Returns a datasource string from kst given its name.
See DataSourceString
editable_matrix
(name)[source]¶Returns an Editable Matrix from kst given its name.
See EditableMatrix
editable_vector
(name)[source]¶Returns an Editable Vector from kst given its name.
See EditableVector
export_graphics_file
(filename, format=None, width=1280, height=1024, display=2, all_tabs=False, autosave_period=0)[source]¶export_graphics_file
(filename, graphics_format=None, width=1280, height=1024, display=2, all_tabs=False, autosave_period=0)[source]¶
export the kst session as a set of graphics files.
Parameters: |
|
---|
display determines the shape of the plot. Values are
0 Width set by user, maintain aspect ratio
1 Height set by user, maintain aspect ratio
2 Width and Height set by user.
3 a Width x Width square plot.
flag_filter
(name)[source]¶Returns a flag_filter from kst given its name.
See FlagFilter
generated_scalar
(name)[source]¶Returns a Generated Scalar from kst given its name.
See GeneratedScalar
generated_string
(name)[source]¶Returns a generated string from kst given its name.
See GeneratedString
generated_vector
(name)[source]¶Returns a GeneratedVector from kst given its name.
See GeneratedVector
hide_window
()[source]¶Hide the kst window.
pyKst operations which effect the display are far faster when the window is hidden.
Restore with show_window() or maximize_window().
new_SVG
(filename, pos=(0.1, 0.1), width=0.1, rot=0, name='')[source]¶Create a New SVG in kst.
See SVG
new_arrow
(start=(0, 0), end=(1, 1), arror_at_start=False, arrow_at_end=True, arrow_size=12.0, stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, stroke_cap_style=1, name='')[source]¶Create a New Arrow in kst.
See Arrow
new_box
(pos=(0.1, 0.1), size=(0.1, 0.1), rot=0, fill_color='white', fill_style=1, stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, strokeJoinStyle=1, stroke_cap_style=1, fix_aspect=False, name='')[source]¶new_box
(pos=(0.1, 0.1), size=(0.1, 0.1), rot=0, fill_color='white', fill_style=1, stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, stroke_join_style=1, stroke_cap_style=1, fix_aspect=False, name='')[source]¶
Create a New Box in kst.
See Box
new_circle
(pos=(0.1, 0.1), diameter=0.1, fill_color='white', fill_style=1, stroke_style=1, stroke_width=1, stroke_brush_color='grey', stroke_brush_style=1, name='')[source]¶Create a New Circle in kst.
See Circle
new_cross_spectrum
(V1, V2, fft_size=10, sample_rate=1.0, name='')[source]¶Create a cross spectrum object in kst.
See CrossSpectrum
new_data_matrix
(filename, field, start_x=0, start_y=0, num_x=-1, num_y=-1, min_x=0, min_y=0, dx=1, dy=1, name='')[source]¶Create a New DataMatrix in kst.
See DataMatrix
new_data_vector
(filename, field, start=0, num_frames=-1, skip=0, boxcarFirst=False, name='')[source]¶Create a New DataVector in kst.
See DataVector
new_datasource_scalar
(filename, field, name='')[source]¶Create a New DataSource Scalar in kst.
See DataSourceScalar
new_datasource_string
(filename, field, name='')[source]¶Create a New Data Source String in kst.
See DataSourceString
new_editable_matrix
(np_array=None, name='')[source]¶Create a New Editable Matrix in kst.
See EditableMatrix
new_editable_vector
(np_array=None, name='')[source]¶Create a New Editable Vector in kst.
See EditableVector
new_ellipse
(pos=(0.1, 0.1), size=(0.1, 0.1), rot=0, fill_color='white', fill_style=1, stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, fix_aspect=False, name='')[source]¶Create a New Ellipse in kst.
See Ellipse
new_equation
(x_vector, equation, interpolate=True, name='')[source]¶Create a new Equation in kst.
See Equation
new_flag_filter
(y_vector, flag, mask='0xffffff', valid_is_zero=True, name='')[source]¶Create a flag filter inside kst.
See FlagFilter
new_generated_scalar
(value, name='')[source]¶Create a New Generated Scalar in kst.
See GeneratedScalar
new_generated_string
(string, name='')[source]¶Create a new generated string in kst.
See GeneratedString
new_generated_vector
(x0, x1, n, name='')[source]¶Create a New GeneratedVector in kst.
See GeneratedVector
new_histogram
(vector, bin_min=0, bin_max=1, num_bins=60, normalization=0, auto_bin=True, name='')[source]¶Create a new histogram in kst.
See Histogram
new_label
(text, pos=(0.5, 0.5), rot=0, font_size=12, bold=False, italic=False, font_color='black', font_family='Serif', name='')[source]¶Create a New Label in kst.
See Label
new_line
(start=(0, 0), end=(1, 1), stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, stroke_cap_style=1, name='')[source]¶Create a New Line in kst.
See Line
new_linear_fit
(x_vector, y_vector, weightvector=0, name='')[source]¶Create a New Linear Fit in kst.
See LinearFit
new_picture
(filename, pos=(0.1, 0.1), width=0.1, rot=0, name='')[source]¶Create a New Picture in kst.
See Picture
new_plot
(pos=(0.1, 0.1), size=(0, 0), rot=0, font_size=0, columns=0, fill_color='white', fill_style=1, stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, strokeJoinStyle=1, stroke_cap_style=1, fix_aspect=False, auto_position=True, name='')[source]¶new_plot
(pos=(0.1, 0.1), size=(0, 0), rot=0, font_size=0, columns=0, fill_color='white', fill_style=1, stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, stroke_join_style=1, stroke_cap_style=1, fix_aspect=False, auto_position=True, name='')[source]¶
Create a New Plot in kst.
See Plot
new_polynomial_fit
(order, x_vector, y_vector, weightvector=0, name='')[source]¶Create a New Polynomial Fit in kst.
See PolynomialFit
new_spectrum
(vector, sample_rate=1.0, interleaved_average=False, fft_length=10, apodize=True, remove_mean=True, vector_units='', rate_units='Hz', apodize_function=0, sigma=1.0, output_type=0, name='')[source]¶Create a new Spectrum in kst.
See Spectrum
new_sum_filter
(y_vector, step_dX, name='')[source]¶Create a cumulative sum filter inside kst.
See SumFilter
new_vector_scalar
(filename, field, frame=-1, name='')[source]¶Create a New VectorScalar in kst.
See VectorScalar
polynomial_fit
(name)[source]¶Returns a polynomial fit from kst given its name.
See PolynomialFit
set_datasource_option
(option, value, filename, data_source='Ascii File')[source]¶Sets the value of a data source configuration option.
Parameters: |
|
---|
Examples:
Tell kst that trial1.csv is a file with the field names in row 1 and units in row 2:
import pykst as kst
client = kst.Client()
client.set_datasource_option("Column Delimiter", ",", "trial1.csv")
client.set_datasource_option("Column Type", 2, "trial1.csv")
client.set_datasource_option("Data Start", 3-1, "trial1.csv")
client.set_datasource_option("Fields Line", 1-1, "trial1.csv")
client.set_datasource_option("Read Fields", True, "trial1.csv")
client.set_datasource_option("Units Line", 2-1, "trial1.csv")
client.set_datasource_option("Read Units", True, "trial1.csv")
Configuration options supported by the ASCII data source (default) are:
"ASCII Time format"
"Column Delimiter"
"Column Type"
"Column Width"
"Column Width is const"
"Comment Delimiters"
"Data Rate for index"
"Data Start"
"Default INDEX Interpretation"
"Fields Line"
"Filename Pattern"
"Index"
"Limit file buffer size"
"NaN value"
"Read Fields"
"Read Units"
"Size of limited file buffer"
"Units Line"
"Use Dot"
"Use threads when parsing Ascii data"
"date/time offset"
"relative offset"
"updateType"
"use an explicit date/time offset"
"use file time/date as offset"
"use relative file time offset"
set_tab
(tab)[source]¶Set the index of the current tab.
tab must be greater or equal to 0 and less than tabCount().
vector_scalar
(name)[source]¶Returns a VectorScalar from kst given its name.
See VectorScalar
Scalars, Vectors, Matrices, and Strings (Primitives) can be used in your scripts to share data with kst. All methods are pass-by-value: for example, if you get a value of a scalar and change it, the data inside kst is not changed. You need to explicitly call setValue().
pykst.
DataSourceScalar
(client, filename, field, name='', new=True)[source]¶A scalar read from a data source inside kst.
-This class represents a scalar you would create via +
This class represents a scalar you would create via “Create>Scalar>Read from Data Source” from the menubar inside kst.
Parameters: |
|
---|
To read “CONST1” from the data source “tmp.dat” into kst:
import pykst as kst
client = kst.Client()
x = client.new_datasource_scalar("tmp.dat", "CONST1")
change
(filename, field)[source]¶Change a DataSource Scalar.
Change the file and field of a DataSourceScalar in kst.
Parameters: |
|
---|
description_tip
()¶Returns a string describing the object
name
()¶Returns the name of the object from inside kst.
set_name
(name)¶Set the name of the object inside kst.
type_str
()¶Returns the type of the object from inside kst.
value
()¶Returns the scalar.
pykst.
VectorScalar
(client, filename, field, frame=-1, name='', new=True)[source]¶A scalar in kst read from a vector from a data source.
-This class represents a scalar you would create via +
This class represents a scalar you would create via “Create>Scalar>Read from vector” from the menubar inside kst.
Parameters: |
|
---|
To read the last value of the vector INDEX from the file “tmp.dat” into kst:
import pykst as kst
client = kst.Client()
x = client.new_vector_scalar("tmp.dat", "INDEX", -1)
change
(filename, field, frame)[source]¶Change a Vector Scalar in kst.
Change the file, field and frame of a VectorScalar in kst.
Parameters: |
|
---|
description_tip
()¶Returns a string describing the object
name
()¶Returns the name of the object from inside kst.
set_name
(name)¶Set the name of the object inside kst.
type_str
()¶Returns the type of the object from inside kst.
value
()¶Returns the scalar.
pykst.
GeneratedScalar
(client, value, name='', new=True)[source]¶A scalar constant inside kst.
-This class represents a scalar you would create via +
This class represents a scalar you would create via “Create>Scalar>Generate” from the menubar inside kst.
Parameters: | value – the value to assign to the scalar constant. |
---|
To import the scalar of value 42 into kst:
import pykst as kst
client = kst.Client()
s = client.new_generated_scalar(42)
description_tip
()¶Returns a string describing the object
name
()¶Returns the name of the object from inside kst.
set_name
(name)¶Set the name of the object inside kst.
type_str
()¶Returns the type of the object from inside kst.
value
()¶Returns the scalar.
pykst.
DataVector
(client, filename, field, start=0, num_frames=-1, skip=0, boxcarFirst=False, name='', new=True)[source]¶A vector in kst, read from a data source.
-This class represents a vector you would create via +
This class represents a vector you would create via “Create>Vector>Read from Data Source” from the menubar inside kst.
-The parameters of this function mirror the parameters within +
The parameters of this function mirror the parameters within “Create>Vector>Read from Data Source”.
Parameters: |
|
---|
To create a vector from “tmp.dat” with field “INDEX” from -frame 3 to frame 10, reading a sample every other frame without +
To create a vector from “tmp.dat” with field “INDEX” from +frame 3 to frame 10, reading a sample every other frame without a boxcar filter:
import pykst as kst
client = kst.Client()
-v = client.new_data_vector("tmp.dat", "INDEX", 3, 10, 2, False)
+v = client.new_data_vector("tmp.dat", "INDEX", 3, 10, 2, False)
change
(filename, field, start, num_frames, skip, boxcarFirst)[source]¶Change the parameters of a data vector.
Parameters: |
|
---|
change_frames
(start, num_frames, skip, boxcarFirst)[source]¶Change the parameters of a data vector.
Parameters: |
|
---|
description_tip
()¶Returns a string describing the object
get_numpy_array
()¶get a numpy array which contains the kst vector values
length
()¶Returns the number of samples in the vector.
max
()¶Returns the maximum value in the vector.
mean
()¶Returns the mean of the vector.
min
()¶Returns the minimum value in the vector.
name
()¶Returns the name of the object from inside kst.
set_name
(name)¶Set the name of the object inside kst.
start
()[source]¶Returns the index of first frame in the vector. +
Returns the index of first frame in the vector. -1 means count from end.
type_str
()¶Returns the type of the object from inside kst.
value
(index)¶Returns element i of this vector.
pykst.
GeneratedVector
(client, x0=0, x1=1, n=100, name='', new=True)[source]¶Create a generated vector in kst.
-This class represents a vector you would create via +
This class represents a vector you would create via “Create>Vector>Generate” from the menubar inside kst.
Parameters: |
|
---|
To create the vector {0, 0.2, 0.4, 0.6, 0.8, 1.0}:
import pykst as kst
client = kst.Client()
-v = client.new_generated_vector(0, 1, 6)
+v = client.new_generated_vector(0, 1, 6)
change
(x0, x1, n)[source]¶Change the parameters of a Generated Vector inside kst.
Parameters: |
|
---|
description_tip
()¶Returns a string describing the object
get_numpy_array
()¶get a numpy array which contains the kst vector values
length
()¶Returns the number of samples in the vector.
max
()¶Returns the maximum value in the vector.
mean
()¶Returns the mean of the vector.
min
()¶Returns the minimum value in the vector.
name
()¶Returns the name of the object from inside kst.
set_name
(name)¶Set the name of the object inside kst.
type_str
()¶Returns the type of the object from inside kst.
value
(index)¶Returns element i of this vector.
pykst.
EditableVector
(client, np_array=None, name='', new=True)[source]¶A vector in kst, which is editable from python.
This vector in kst can be created from a numpy array, (with ‘’load()’‘) or edited point by point (with ‘’setValue()’‘). “Create>Vector>Generate” from the menubar inside kst.
Parameters: | np_array – initialize the vector in kst to this (optional) 1D numpy array. |
---|
To create a from the num py array np:
import pykst as kst
client = kst.Client()
v = client.new_editable_vector(np)
description_tip
()¶Returns a string describing the object
get_numpy_array
()¶get a numpy array which contains the kst vector values
length
()¶Returns the number of samples in the vector.
max
()¶Returns the maximum value in the vector.
mean
()¶Returns the mean of the vector.
min
()¶Returns the minimum value in the vector.
name
()¶Returns the name of the object from inside kst.
set_name
(name)¶Set the name of the object inside kst.
type_str
()¶Returns the type of the object from inside kst.
value
(index)¶Returns element i of this vector.
pykst.
DataMatrix
(client, filename, field, start_x=0, start_y=0, num_x=-1, num_y=-1, min_x=0, min_y=0, dx=1, dy=1, name='', new=True)[source]¶Create a Data Matrix which reads from a data source inside kst.
-This class represents a matrix you would create via +
This class represents a matrix you would create via “Create>Vector>Read from Data Source” from the menubar inside kst. -The parameters of this function mirror the parameters within +The parameters of this function mirror the parameters within “Create>Matrix>Read from Data Source”.
Parameters: |
|
---|
To create a matrix from ‘foo.png’ with field ‘1’:
import pykst as kst
client = kst.Client()
-v = client.new_data_matrix("foo.png", "1")
+v = client.new_data_matrix("foo.png", "1")
change
(filename, field, start_x=0, start_y=0, num_x=-1, num_y=-1, min_x=0, min_y=0, dx=1, dy=1)[source]¶Change the parameters if a Data Matrix inside kst.
Parameters: |
|
---|
description_tip
()¶Returns a string describing the object
dx
()¶Returns the X spacing of the matrix, for when the matrix is used in an image.
dy
()¶Returns the Y spacing of the matrix, for when the matrix is used in an image.
get_numpy_array
()¶get a numpy array which contains the kst matrix values
height
()¶Returns the Y dimension of the matrix.
length
()¶Returns the number of elements in the matrix.
max
()¶Returns the maximum value in the matrix.
mean
()¶Returns the mean of the matrix.
min
()¶Returns the minimum value in the matrix.
min_x
()¶Returns the minimum X location of the matrix, for when the matrix is used in an image.
+Returns the minimum X location of the matrix, for when the matrix +is used in an image.
min_y
()¶Returns the minimum X location of the matrix, for when the matrix is used in an image.
+Returns the minimum X location of the matrix, for when the matrix +is used in an image.
name
()¶Returns the name of the object from inside kst.
set_name
(name)¶Set the name of the object inside kst.
type_str
()¶Returns the type of the object from inside kst.
value
(i_x, i_y)¶Returns element (i_x, i_y} of this matrix.
width
()¶Returns the X dimension of the matrix.
pykst.
DataSourceString
(client, filename, field, name='', new=True)[source]¶A string read from a data source inside kst.
-This class represents a string you would create via +
This class represents a string you would create via “Create>String>Read from Data Source” from the menubar inside kst.
Parameters: |
|
---|
To read “File path” from the data source “tmp.dat” into kst:
import pykst as kst
client = kst.Client()
s = client.new_datasource_string("tmp.dat", "File Path")
change
(filename, field)[source]¶Change a DataSource String.
Change the file and field of a DataSourceString in kst.
Parameters: |
|
---|
description_tip
()¶Returns a string describing the object
name
()¶Returns the name of the object from inside kst.
set_name
(name)¶Set the name of the object inside kst.
type_str
()¶Returns the type of the object from inside kst.
value
()¶Returns the string.
pykst.
GeneratedString
(client, string, name='', new=True)[source]¶A string constant inside kst.
-This class represents a string you would create via +
This class represents a string you would create via “Create>String>Generated” from the menubar inside kst.
Parameters: | string – The value of the string. |
---|
To import the string “Hello World” into kst:
import pykst as kst
client = kst.Client()
s = client.new_generatedString("Hello World")
description_tip
()¶Returns a string describing the object
name
()¶Returns the name of the object from inside kst.
set_name
(name)¶Set the name of the object inside kst.
type_str
()¶Returns the type of the object from inside kst.
value
()¶Returns the string.
Data Objects are objects which transform primitives into other primitives.
pykst.
Equation
(client, xvector, equation, interpolate=True, name='', new=True)[source]¶An equation inside kst.
Parameters: |
|
---|
Vectors inside kst are refered to as [vectorname] or [scalarname].
description_tip
()¶Returns a string describing the object
name
()¶Returns the name of the object from inside kst.
set_inpterpolate
(interpolate)[source]¶set whether all vectors are interpolated to the highest resolution vector.
set_name
(name)¶Set the name of the object inside kst.
type_str
()¶Returns the type of the object from inside kst.
pykst.
Spectrum
(client, vector, sample_rate=1.0, interleaved_average=False, fft_length=10, apodize=True, remove_mean=True, vector_units='', rate_units='Hz', apodize_function=0, sigma=1.0, output_type=0, name='', new=True)[source]¶An spectrum inside kst.
Parameters: |
|
---|
The apodize function is:
0: default 1: Bartlett
2: Window 3: Connes
4: Cosine 5: Gaussian
6: Hamming 7: Hann
8: Welch 9: Uniform
The output type is:
0: Amplitude Spectral Density 1: Power Spectral Density
2: AmplitudeSpectrum 3: Power Spectrum
apodize_function
()[source]¶the index of the apodize function.
The apodize funcition is:
0: default 1: Bartlett
2: Window 3: Connes
4: Cosine 5: Gaussian
6: Hamming 7: Hann
8: Welch 9: Uniform
description_tip
()¶Returns a string describing the object
name
()¶Returns the name of the object from inside kst.
output_type
()[source]¶the index of the spectrum output type.
The output type is:
0: Amplitude Spectral Density 1: Power Spectral Density
2: AmplitudeSpectrum 3: Power Spectrum
set_name
(name)¶Set the name of the object inside kst.
type_str
()¶Returns the type of the object from inside kst.
pykst.
Histogram
(client, vector, bin_min, bin_max, num_bins, normalization=0, auto_bin=False, name='', new=True)[source]¶A Histogram inside kst.
Parameters: |
|
---|
The normalization types are:
0: Number in the bin 1: Percent in the bin
2: Fraction in the bin 3: Peak is normalized to 1.0
change
(vector, bin_min, bin_max, num_bins, normalization=0, auto_bin=False)[source]¶Change Histogram parameters.
Parameters: |
|
---|
description_tip
()¶Returns a string describing the object
name
()¶Returns the name of the object from inside kst.
set_name
(name)¶Set the name of the object inside kst.
type_str
()¶Returns the type of the object from inside kst.
pykst.
LinearFit
(client, xvector, yvector, weightvector=0, name='', new=True)[source]¶A linear fit inside kst.
If weightvector is 0, then the fit is unweighted.
covariance
()¶a vector containing the Covariance of the fit
description_tip
()¶Returns a string describing the object
fit
()¶a vector containing the fit
name
()¶Returns the name of the object from inside kst.
parameters
()¶a vector containing the Parameters of the fit
reduced_chi2
()¶a scalar containing the Parameters of the fit
residuals
()¶a vector containing the Parameters of the fit
set_name
(name)¶Set the name of the object inside kst.
type_str
()¶Returns the type of the object from inside kst.
pykst.
PolynomialFit
(client, order, xvector, yvector, weightvector=0, name='', new=True)[source]¶A Polynomial fit inside kst.
Parameters: | order – The order of the fit |
---|
covariance
()¶a vector containing the Covariance of the fit
description_tip
()¶Returns a string describing the object
fit
()¶a vector containing the fit
name
()¶Returns the name of the object from inside kst.
parameters
()¶a vector containing the Parameters of the fit
reduced_chi2
()¶a scalar containing the Parameters of the fit
residuals
()¶a vector containing the Parameters of the fit
set_name
(name)¶Set the name of the object inside kst.
type_str
()¶Returns the type of the object from inside kst.
pykst.
FlagFilter
(client, yvector, flag, mask='0xffffff', valid_is_zero=True, name='', new=True)[source]¶a flagged vector inside kst
The output is the input when flag == 0, or NaN if flag is non-0.
description_tip
()¶Returns a string describing the object
name
()¶Returns the name of the object from inside kst.
output
()¶a vector containing the output of the filter
set_name
(name)¶Set the name of the object inside kst.
type_str
()¶Returns the type of the object from inside kst.
Relations are objects which can be added to a plot.
pykst.
Curve
(client, x_vector, y_vector, name='', new=True)[source]¶A Curve inside kst.
-This class represents a string you would create via -“Create>Curve” from the menubar inside kst. The parameters of this +
This class represents a string you would create via +“Create>Curve” from the menubar inside kst. The parameters of this function mirror the parameters within “Create>Curve”.
Parameters: |
|
---|
Use the convenience function in client to create a curve in kst session +
Use the convenience function in client to create a curve in kst session “client” of vectors v1 and v2:
c1 = client.new_curve(v1, v2)
description_tip
()¶Returns a string describing the object
max_x
()¶Returns the max X value of the curve or image.
max_y
()¶Returns the max Y value of the curve or image.
min_x
()¶Returns the min X value of the curve or image.
min_y
()¶Returns the min Y value of the curve or image.
name
()¶Returns the name of the object from inside kst.
set_bar_fill_color
(color)[source]¶Set the fill color of the histogram bars, if any.
-Colors are given by a name such as red
or a hex number such
+
Colors are given by a name such as red
or a hex number such
as #FF0000
.
set_color
(color)[source]¶Set the color of the points and lines.
-Colors are given by a name such as red
or a hex number such
+
Colors are given by a name such as red
or a hex number such
as #FF0000
.
set_head_color
(color)[source]¶Set the color of the Head marker, if any.
-Colors are given by a name such as red
or a hex number such
+
Colors are given by a name such as red
or a hex number such
as #FF0000
.
set_line_style
(lineStyle)[source]¶Sets the line type.
-0 is SolidLine, 1 is DashLine, 2 is DotLine, 3 is DashDotLine, +
0 is SolidLine, 1 is DashLine, 2 is DotLine, 3 is DashDotLine, and 4 isDashDotDotLine,
set_name
(name)¶Set the name of the object inside kst.
set_point_density
(density)[source]¶Sets the point density.
When show_points is true, this option can be used to only show a subset of the points, for example, to use point types to discriminate between different curves.. This does not effect ‘lines’, where every point is always connected.
density can be from 0 (all points) to 4.
set_point_type
(point_type)[source]¶Sets the point type.
The available point types are:
-0: X 1: open square
-2: open circle, 3: filled circle
+0: X 1: open square
+2: open circle, 3: filled circle
4: downward open triangle 5: upward open triangle
-6: filled square 7: +
+6: filled square 7: +
8: * 9: downward filled triangle
10: upward filled triangle 11: open diamond
12: filled diamond
set_x_error
(vector, vectorminus=0)[source]¶Set the X Error flags for the curve.
The error bars are symetric if vectorminus is not set.
set_y_error
(vector, vectorminus=0)[source]¶Set the Y Error flags for the curve.
The error bars are symetric if vectorminus is not set.
show_edit_dialog
()¶shows the edit dialog for the curve or image.
type_str
()¶Returns the type of the object from inside kst.
x_error_vector
()[source]¶Returns the +x error vector of the curve.
FIXME: should figure out what kind of vector this is and return that.
x_minus_error_vector
()[source]¶Returns the -x error vector of the curve.
FIXME: should figure out what kind of vector this is and return that.
x_vector
()[source]¶Returns the x vector of the curve.
FIXME: should figure out what kind of vector this is and return that.
y_error_vector
()[source]¶Returns the +y error vector of the curve.
FIXME: should figure out what kind of vector this is and return that.
pykst.
Image
(client, matrix, name='', new=True)[source]¶An image inside kst.
-This class represents an image you would create via -“Create>Image” from the menubar inside kst. The parameters of this +
This class represents an image you would create via +“Create>Image” from the menubar inside kst. The parameters of this function mirror the parameters within “Create>Curve”.
Parameters: | matrix – The matrix which defines the image. |
---|
Use the convenience function in client to create an image in kst session +
Use the convenience function in client to create an image in kst session “client” of Matrix m:
i1 = client.new_image(m)
description_tip
()¶Returns a string describing the object
max_x
()¶Returns the max X value of the curve or image.
max_y
()¶Returns the max Y value of the curve or image.
min_x
()¶Returns the min X value of the curve or image.
min_y
()¶Returns the min Y value of the curve or image.
name
()¶Returns the name of the object from inside kst.
set_auto_range
(saturated=0)[source]¶Automatically set the z range of the color map
Parameters: | saturated – The colormap range is set so that this fraction of the points in the matrix are saturated. |
---|
Equal numbers of points are saturated at both ends of the color map.
set_name
(name)¶Set the name of the object inside kst.
set_palette
(palette)[source]¶set the palette, selected by index.
The available palettes are:
0: Grey
-1: Red
+1: Red
2: Spectrum
3: EOS-A
4: EOS-B
5: 8 colors
6: Cyclical Spectrum
Note: this is not the same order as the dialog.
show_edit_dialog
()¶shows the edit dialog for the curve or image.
type_str
()¶Returns the type of the object from inside kst.
Annotations along with interactive items (see the next section) can be used to turn kst into a graphing calculator, a tetris client, and maybe even a web browser...
pykst.
Label
(client, text, pos=(0.5, 0.5), rot=0, font_size=12, bold=False, italic=False, font_color='black', font_family='Serif', name='', new=True)[source]¶A floating label inside kst.
+A label inside kst.
Parameters: |
|
---|
Scalars and scalar equations can be displayed live in labels. +
Scalars and scalar equations can be displayed live in labels. When the scalar is updated, the label is updated.
The format is:
Scalar: [scalarname] eg [GYRO1:Mean(X4)]
Vector Element: [vectorName[index]] eg [GYRO1 (V2)[4]]
Equation: [=equation] eg [=[GYRO1:Mean(X4)]/[GYRO1:Sigma (X4)]]
These numerical fields can be formatted by appending a C printf format embedded in { } immediately after the field. For example:
[GYRO1:Mean(X4)]{%4.2f}
Labels in kst support a derrivitive subset of LaTeX. For example, to display
-the equation for the area of a circle, you could set the label to A=2\pir^2
.
-Unlike LaTeX, it is not necessary to enter math mode using $
. Also,
-unlike LaTeX, variables are not automatically displayed in italic font.
-If desired, this must be done explicitly using \textit{}
.
Greek letters: \name or \Name. eg: \alpha
Other symbols: \approx, \cdot, \ge, \geq, \inf, \approx, \cdot,
-\ge, \geq, \inf, \int, \le, \leq, \ne, \n, \partial, \prod, \pm,
-\sum, \sqrt
Font effects: \textcolor{colorname}{colored text}, \textbf{bold text},
-\textit{italicized text}, \underline{underlined text},
-\overline{overlined text}.
Other:x^y
, x_y
, \t
, \n
, \[
This class represents a label you would create via “Create>Annotations>Label” +
Labels in kst support a derrivitive subset of LaTeX. For example, to display
+the equation for the area of a circle, you could set the label to A=2\pir^2
.
+Unlike LaTeX, it is not necessary to enter math mode using $
. Also,
+unlike LaTeX, variables are not automatically displayed in italic font.
+If desired, this must be done explicitly using \\textit{}
.
Greek letters: \\name or \\Name. eg: \\alpha
Other symbols: \\approx, \\cdot, \\ge, \\geq, \\inf, \\approx, \\cdot,
+\\ge, \\geq, \\inf, \\int, \\le, \\leq, \\ne, \\n, \\partial, \\prod, \\pm,
+\\sum, \\sqrt
Font effects: \\textcolor{colorname}{colored text}, \\textbf{bold text},
+\\textit{italicized text}, \\underline{underlined text},
+\\overline{overlined text}.
Other:x^y
, x_y
, \\t
, \\n
, \\[
This class represents a label you would create via “Create>Annotations>Label” from the menubar inside kst.
Use the convenience function in Client to create a label “Test Label” in kst:
import pykst as kst
client = kst.Client()
L = client.new_label("Test Label", (0.25, 0.25), font_size=18)
description_tip
()¶Returns a string describing the object
name
()¶Returns the name of the object from inside kst.
remove
()¶This removes the object from Kst.
set_font_color
(color)[source]¶Colors are given by a name such as red
or a hex number such
+
Colors are given by a name such as red
or a hex number such
as #FF0000
set_label_font_size
(size)[source]¶size of the label in points, when the printed at the reference size.
set_lock_pos_to_data
(lock=True)¶if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.
If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.
set_name
(name)¶Set the name of the object inside kst.
set_parent_auto
()¶Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.
By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.
set_parent_toplevel
()¶Set the parent of the viewitem to the toplevel view.
By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.
set_pos
(pos)¶Set the center position of the item.
Parameters: | pos – a 2 element tuple (x,y) specifying the position.
-The Top Left of the parent is (0,0).
-The Bottom Right of the parent is (1,1) |
+
---|---|
Parameters: | pos – a 2 element tuple (x, y) specifying the position.
+The Top Left of the parent is (0, 0).
+The Bottom Right of the parent is (1, 1) |
set_rotation
(rot)¶Set the rotation of the item.
This is equivalent to setting Dimensions>Rotation within a view item dialog.
set_text
(text)[source]¶Set text displayed by the label.
-Scalars and scalar equations can be displayed live in labels. +
Scalars and scalar equations can be displayed live in labels. When the scalar is updated, the label is updated. The format is:
Scalar: [scalarname] eg [GYRO1:Mean(X4)]
Vector Element: [vectorName[index]] eg [GYRO1 (V2)[4]]
Equation: [=equation] eg [=[GYRO1:Mean(X4)]/[GYRO1:Sigma (X4)]]
Labels in kst support a derrivitive subset of LaTeX. For example, -to display the equation for the area of a circle, you could set the +
Labels in kst support a derrivitive subset of LaTeX. For example,
+to display the equation for the area of a circle, you could set the
label to A=2\pir^2
. Unlike LaTeX, it is not necessary to enter
-math mode using $
. Also, unlike LaTeX, variables are not
-automatically displayed in italic font. If desired, this must be done
-explicitly using \textit{}
.
Greek letters: \name or \Name. eg: \alpha
Other symbols: \approx, \cdot, \ge, \geq, \inf, \approx, \cdot,
-\ge, \geq, \inf, \int, \le, \leq, \ne, \n, \partial, \prod, \pm,
-\sum, \sqrt
Font effects: \textcolor{colorname}{colored text}, \textbf{bold text},
-\textit{italicized text}, \underline{underlined text},
-\overline{overlined text}.
Other:x^y
, x_y
, \t
, \n
, \[
$
. Also, unlike LaTeX, variables are not
+automatically displayed in italic font. If desired, this must be done
+explicitly using \\textit{}
.
+Greek letters: \\name or \\Name. eg: \\alpha
Other symbols: \\approx, \\cdot, \\ge, \\geq, \\inf, \\approx, \\cdot,
+\\ge, \\geq, \\inf, \\int, \\le, \\leq, \\ne, \\n, \\partial, \\prod, \\pm,
+\\sum, \\sqrt
Font effects: \\textcolor{colorname}{colored text}, \\textbf{bold text},
+\\textit{italicized text}, \\underline{underlined text},
+\\overline{overlined text}.
Other:x^y
, x_y
, \\t
, \\n
, \\[
subplot
(*args)¶Set the item position according to the given grid definition.
Typical call signature:
subplot(nrows, ncols, plot_number)
Where nrows and ncols are used to notionally split the figure
into nrows * ncols
sub-axes, and plot_number is used to identify
the particular subplot that this function is to create within the notional
grid. plot_number starts at 1, increments across rows first and has a
maximum of nrows * ncols
.
In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:
subplot(211)
place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).
pykst.
Legend
(client, plot, name='', new=True)[source]¶A legend in a plot in kst.
: param plot: a plot in kst. Use the convenience function in Client to create a legend in kst:
import pykst as kst
client = kst.Client()
...
P1 = client.new_plot()
L1 = client.new_legend(P1)
description_tip
()¶Returns a string describing the object
name
()¶Returns the name of the object from inside kst.
remove
()¶This removes the object from Kst.
set_fill_color
(color)¶Set the fill/background color.
-Colors are given by a name such as red
or a hex number such
+
Colors are given by a name such as red
or a hex number such
as #FF0000
.
set_fill_style
(style)¶Set the background fill style.
-This is equivalent to setting the index of Apperance>Fill>Style within +
This is equivalent to setting the index of Apperance>Fill>Style within a view item dialog in kst.:
0: NoBrush 1: SolidPattern
2: Dense1Pattern 3: Dense2Pattern
4: Dense3Pattern 5: Dense4Pattern
6: Dense5Pattern 7: Dense6Pattern
8: Dense7Pattern 9: HorPattern
-11: VerPattern 12: CrossPattern,
+11: VerPattern 12: CrossPattern,
13: BDiagPattern 14: FDiagPattern.
set_font_color
(color)[source]¶Colors are given by a name such as red
or a hex number such
as #FF0000
set_lock_pos_to_data
(lock=True)¶if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.
If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.
set_name
(name)¶Set the name of the object inside kst.
set_parent_auto
()¶Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.
By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.
set_parent_toplevel
()¶Set the parent of the viewitem to the toplevel view.
By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.
set_pos
(pos)¶Set the center position of the item.
Parameters: | pos – a 2 element tuple (x,y) specifying the position.
-The Top Left of the parent is (0,0).
-The Bottom Right of the parent is (1,1) |
+
---|---|
Parameters: | pos – a 2 element tuple (x, y) specifying the position.
+The Top Left of the parent is (0, 0).
+The Bottom Right of the parent is (1, 1) |
set_rotation
(rot)¶Set the rotation of the item.
This is equivalent to setting Dimensions>Rotation within a view item dialog.
set_stroke_brush_color
(color)¶Set the color for lines for the item.
-Colors are given by a name such as red
or a hex number
+
Colors are given by a name such as red
or a hex number
such as #FF0000
.
set_stroke_brush_style
(style)¶Set the brush style for lines for the item.
-This is equivalent to setting the index of Apperance>Stroke>Brush Style +
This is equivalent to setting the index of Apperance>Stroke>Brush Style within a view item dialog in kst.
-This sets the brush type for lines in the item, and not for the fill, +
This sets the brush type for lines in the item, and not for the fill,
so values other than 1
(SolidPattern) only make sense for wide lines
and are rarely used:
0: NoBrush 1: SolidPattern
2: Dense1Pattern 3: Dense2Pattern
4: Dense3Pattern 5: Dense4Pattern
6: Dense5Pattern 7: Dense6Pattern
8: Dense7Pattern 9: HorPattern
-11: VerPattern 12: CrossPattern,
+11: VerPattern 12: CrossPattern,
13: BDiagPattern 14: FDiagPattern.
set_stroke_cap_style
(style)¶Set the cap style for the ends of lines in the item.
-This is equivalent to setting the index of Apperance>Stroke>Cap Style +
This is equivalent to setting the index of Apperance>Stroke>Cap Style within a view item dialog in kst.
0 is FlatCap, 1 is SquareCap, and 2 is RoundCap.
set_stroke_join_style
(style)¶Set the style by which lines are joined in the item.
-This is equivalent to setting the index of Apperance>Stroke>Join Style +
This is equivalent to setting the index of Apperance>Stroke>Join Style within a view item dialog in kst.
0 is MiterJoin, 1 is BevelJoin, 2 is RoundJoin, and 3 is SvgMiterJoin.
set_stroke_style
(style)¶Set the stroke style of lines for the item.
-This is equivalent to setting the index of Apperance>Stroke>Style +
This is equivalent to setting the index of Apperance>Stroke>Style within a view item dialog in kst:
0: SolidLine 1: DashLine
-2: DotLine 3: DashDotLine
+2: DotLine 3: DashDotLine
4: DashDotDotLine 5: CustomDashLine
set_stroke_width
(width)¶Set the width of lines for the item.
subplot
(*args)¶Set the item position according to the given grid definition.
Typical call signature:
subplot(nrows, ncols, plot_number)
Where nrows and ncols are used to notionally split the figure
into nrows * ncols
sub-axes, and plot_number is used to identify
the particular subplot that this function is to create within the notional
grid. plot_number starts at 1, increments across rows first and has a
maximum of nrows * ncols
.
In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:
subplot(211)
place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).
pykst.
Box
(client, pos=(0.1, 0.1), size=(0.1, 0.1), rot=0, fill_color='white', fill_style=1, stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, strokeJoinStyle=1, stroke_cap_style=1, fix_aspect=False, name='', new=True)[source]¶pykst.
Box
(client, pos=(0.1, 0.1), size=(0.1, 0.1), rot=0, fill_color='white', fill_style=1, stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, stroke_join_style=1, stroke_cap_style=1, fix_aspect=False, name='', new=True)[source]¶
A floating box inside kst.
Parameters: |
|
---|
Colors are given by a name such as red
or a hex number such
+
Colors are given by a name such as red
or a hex number such
as #FF0000
.
This class represents a box you would create via “Create>Annotations>Box” +
This class represents a box you would create via “Create>Annotations>Box” from the menubar inside kst.
Use the convenience function in Client to create a box in kst:
import pykst as kst
client = kst.Client()
...
B = client.new_box((0.25, 0.25), (0.2, 0.1), fill_color="blue")
description_tip
()¶Returns a string describing the object
name
()¶Returns the name of the object from inside kst.
remove
()¶This removes the object from Kst.
set_fill_color
(color)¶Set the fill/background color.
-Colors are given by a name such as red
or a hex number such
+
Colors are given by a name such as red
or a hex number such
as #FF0000
.
set_fill_style
(style)¶Set the background fill style.
-This is equivalent to setting the index of Apperance>Fill>Style within +
This is equivalent to setting the index of Apperance>Fill>Style within a view item dialog in kst.:
0: NoBrush 1: SolidPattern
2: Dense1Pattern 3: Dense2Pattern
4: Dense3Pattern 5: Dense4Pattern
6: Dense5Pattern 7: Dense6Pattern
8: Dense7Pattern 9: HorPattern
-11: VerPattern 12: CrossPattern,
+11: VerPattern 12: CrossPattern,
13: BDiagPattern 14: FDiagPattern.
set_fixed_aspect_ratio
(fixed=True)¶if True, fix the aspect ratio of the item to its current value.
-This is equivalent to checking Dimensions>Fix aspect ratio within a +
This is equivalent to checking Dimensions>Fix aspect ratio within a view item dialog in kst.
set_lock_pos_to_data
(lock=True)¶if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.
If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.
set_name
(name)¶Set the name of the object inside kst.
set_parent_auto
()¶Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.
By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.
set_parent_toplevel
()¶Set the parent of the viewitem to the toplevel view.
By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.
set_pos
(pos)¶Set the center position of the item.
Parameters: | pos – a 2 element tuple (x,y) specifying the position.
-The Top Left of the parent is (0,0).
-The Bottom Right of the parent is (1,1) |
+
---|---|
Parameters: | pos – a 2 element tuple (x, y) specifying the position.
+The Top Left of the parent is (0, 0).
+The Bottom Right of the parent is (1, 1) |
set_rotation
(rot)¶Set the rotation of the item.
This is equivalent to setting Dimensions>Rotation within a view item dialog.
set_size
(size)¶Set the size of the item.
Parameters: | size – a 2 element tuple (w,h) specifying the size. |
+
---|---|
Parameters: | size – a 2 element tuple (w, h) specifying the size. |
Elements go from 0 to 1. If the aspect ratio is fixed, then h
+
Elements go from 0 to 1. If the aspect ratio is fixed, then h
is ignored.
This is equivalent to setting Dimensions>Position within a view +
This is equivalent to setting Dimensions>Position within a view item dialog in kst.
set_stroke_brush_color
(color)¶Set the color for lines for the item.
-Colors are given by a name such as red
or a hex number
+
Colors are given by a name such as red
or a hex number
such as #FF0000
.
set_stroke_brush_style
(style)¶Set the brush style for lines for the item.
-This is equivalent to setting the index of Apperance>Stroke>Brush Style +
This is equivalent to setting the index of Apperance>Stroke>Brush Style within a view item dialog in kst.
-This sets the brush type for lines in the item, and not for the fill, +
This sets the brush type for lines in the item, and not for the fill,
so values other than 1
(SolidPattern) only make sense for wide lines
and are rarely used:
0: NoBrush 1: SolidPattern
2: Dense1Pattern 3: Dense2Pattern
4: Dense3Pattern 5: Dense4Pattern
6: Dense5Pattern 7: Dense6Pattern
8: Dense7Pattern 9: HorPattern
-11: VerPattern 12: CrossPattern,
+11: VerPattern 12: CrossPattern,
13: BDiagPattern 14: FDiagPattern.
set_stroke_cap_style
(style)¶Set the cap style for the ends of lines in the item.
-This is equivalent to setting the index of Apperance>Stroke>Cap Style +
This is equivalent to setting the index of Apperance>Stroke>Cap Style within a view item dialog in kst.
0 is FlatCap, 1 is SquareCap, and 2 is RoundCap.
set_stroke_join_style
(style)¶Set the style by which lines are joined in the item.
-This is equivalent to setting the index of Apperance>Stroke>Join Style +
This is equivalent to setting the index of Apperance>Stroke>Join Style within a view item dialog in kst.
0 is MiterJoin, 1 is BevelJoin, 2 is RoundJoin, and 3 is SvgMiterJoin.
set_stroke_style
(style)¶Set the stroke style of lines for the item.
-This is equivalent to setting the index of Apperance>Stroke>Style +
This is equivalent to setting the index of Apperance>Stroke>Style within a view item dialog in kst:
0: SolidLine 1: DashLine
-2: DotLine 3: DashDotLine
+2: DotLine 3: DashDotLine
4: DashDotDotLine 5: CustomDashLine
set_stroke_width
(width)¶Set the width of lines for the item.
subplot
(*args)¶Set the item position according to the given grid definition.
Typical call signature:
subplot(nrows, ncols, plot_number)
Where nrows and ncols are used to notionally split the figure
into nrows * ncols
sub-axes, and plot_number is used to identify
the particular subplot that this function is to create within the notional
grid. plot_number starts at 1, increments across rows first and has a
maximum of nrows * ncols
.
In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:
subplot(211)
place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).
pykst.
Circle
(client, pos=(0.1, 0.1), diameter=0.1, fill_color='white', fill_style=1, stroke_style=1, stroke_width=1, stroke_brush_color='grey', stroke_brush_style=1, name='', new=True)[source]¶A floating circle inside kst.
Parameters: |
|
---|
Colors are given by a name such as red
or a hex number such
+
Colors are given by a name such as red
or a hex number such
as #FF0000
.
This class represents a circle you would create via +
This class represents a circle you would create via “Create>Annotations>Circle” from the menubar inside kst.
Use the convenience function in Client to create a circle in kst:
import pykst as kst
client = kst.Client()
...
Cr = client.new_circle((0.5, 0.5), 0.2, fill_color="red")
description_tip
()¶Returns a string describing the object
name
()¶Returns the name of the object from inside kst.
remove
()¶This removes the object from Kst.
set_fill_color
(color)¶Set the fill/background color.
-Colors are given by a name such as red
or a hex number such
+
Colors are given by a name such as red
or a hex number such
as #FF0000
.
set_fill_style
(style)¶Set the background fill style.
-This is equivalent to setting the index of Apperance>Fill>Style within +
This is equivalent to setting the index of Apperance>Fill>Style within a view item dialog in kst.:
0: NoBrush 1: SolidPattern
2: Dense1Pattern 3: Dense2Pattern
4: Dense3Pattern 5: Dense4Pattern
6: Dense5Pattern 7: Dense6Pattern
8: Dense7Pattern 9: HorPattern
-11: VerPattern 12: CrossPattern,
+11: VerPattern 12: CrossPattern,
13: BDiagPattern 14: FDiagPattern.
set_lock_pos_to_data
(lock=True)¶if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.
If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.
set_name
(name)¶Set the name of the object inside kst.
set_parent_auto
()¶Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.
By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.
set_parent_toplevel
()¶Set the parent of the viewitem to the toplevel view.
By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.
set_pos
(pos)¶Set the center position of the item.
Parameters: | pos – a 2 element tuple (x,y) specifying the position.
-The Top Left of the parent is (0,0).
-The Bottom Right of the parent is (1,1) |
+
---|---|
Parameters: | pos – a 2 element tuple (x, y) specifying the position.
+The Top Left of the parent is (0, 0).
+The Bottom Right of the parent is (1, 1) |
set_rotation
(rot)¶Set the rotation of the item.
This is equivalent to setting Dimensions>Rotation within a view item dialog.
set_stroke_brush_color
(color)¶Set the color for lines for the item.
-Colors are given by a name such as red
or a hex number
+
Colors are given by a name such as red
or a hex number
such as #FF0000
.
set_stroke_brush_style
(style)¶Set the brush style for lines for the item.
-This is equivalent to setting the index of Apperance>Stroke>Brush Style +
This is equivalent to setting the index of Apperance>Stroke>Brush Style within a view item dialog in kst.
-This sets the brush type for lines in the item, and not for the fill, +
This sets the brush type for lines in the item, and not for the fill,
so values other than 1
(SolidPattern) only make sense for wide lines
and are rarely used:
0: NoBrush 1: SolidPattern
2: Dense1Pattern 3: Dense2Pattern
4: Dense3Pattern 5: Dense4Pattern
6: Dense5Pattern 7: Dense6Pattern
8: Dense7Pattern 9: HorPattern
-11: VerPattern 12: CrossPattern,
+11: VerPattern 12: CrossPattern,
13: BDiagPattern 14: FDiagPattern.
set_stroke_style
(style)¶Set the stroke style of lines for the item.
-This is equivalent to setting the index of Apperance>Stroke>Style +
This is equivalent to setting the index of Apperance>Stroke>Style within a view item dialog in kst:
0: SolidLine 1: DashLine
-2: DotLine 3: DashDotLine
+2: DotLine 3: DashDotLine
4: DashDotDotLine 5: CustomDashLine
set_stroke_width
(width)¶Set the width of lines for the item.
subplot
(*args)¶Set the item position according to the given grid definition.
Typical call signature:
subplot(nrows, ncols, plot_number)
Where nrows and ncols are used to notionally split the figure
into nrows * ncols
sub-axes, and plot_number is used to identify
the particular subplot that this function is to create within the notional
grid. plot_number starts at 1, increments across rows first and has a
maximum of nrows * ncols
.
In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:
subplot(211)
place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).
pykst.
Ellipse
(client, pos=(0.1, 0.1), size=(0.1, 0.1), rot=0, fill_color='white', fill_style=1, stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, fix_aspect=False, name='', new=True)[source]¶A floating ellipse inside kst.
Parameters: |
|
---|
Colors are given by a name such as red
or a hex number such
+
Colors are given by a name such as red
or a hex number such
as #FF0000
.
This class represents an ellipse you would create via +
This class represents an ellipse you would create via “Create>Annotations>Ellipse” from the menubar inside kst.
Use the convenience function in Client to create an Ellipse in kst:
import pykst as kst
client = kst.Client()
...
E = client.new_ellipse((0.25, 0.25), (0.2, 0.1), fill_color="green")
description_tip
()¶Returns a string describing the object
name
()¶Returns the name of the object from inside kst.
remove
()¶This removes the object from Kst.
set_fill_color
(color)¶Set the fill/background color.
-Colors are given by a name such as red
or a hex number such
+
Colors are given by a name such as red
or a hex number such
as #FF0000
.
set_fill_style
(style)¶Set the background fill style.
-This is equivalent to setting the index of Apperance>Fill>Style within +
This is equivalent to setting the index of Apperance>Fill>Style within a view item dialog in kst.:
0: NoBrush 1: SolidPattern
2: Dense1Pattern 3: Dense2Pattern
4: Dense3Pattern 5: Dense4Pattern
6: Dense5Pattern 7: Dense6Pattern
8: Dense7Pattern 9: HorPattern
-11: VerPattern 12: CrossPattern,
+11: VerPattern 12: CrossPattern,
13: BDiagPattern 14: FDiagPattern.
set_fixed_aspect_ratio
(fixed=True)¶if True, fix the aspect ratio of the item to its current value.
-This is equivalent to checking Dimensions>Fix aspect ratio within a +
This is equivalent to checking Dimensions>Fix aspect ratio within a view item dialog in kst.
set_lock_pos_to_data
(lock=True)¶if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.
If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.
set_name
(name)¶Set the name of the object inside kst.
set_parent_auto
()¶Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.
By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.
set_parent_toplevel
()¶Set the parent of the viewitem to the toplevel view.
By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.
set_pos
(pos)¶Set the center position of the item.
Parameters: | pos – a 2 element tuple (x,y) specifying the position.
-The Top Left of the parent is (0,0).
-The Bottom Right of the parent is (1,1) |
+
---|---|
Parameters: | pos – a 2 element tuple (x, y) specifying the position.
+The Top Left of the parent is (0, 0).
+The Bottom Right of the parent is (1, 1) |
set_rotation
(rot)¶Set the rotation of the item.
This is equivalent to setting Dimensions>Rotation within a view item dialog.
set_size
(size)¶Set the size of the item.
Parameters: | size – a 2 element tuple (w,h) specifying the size. |
+
---|---|
Parameters: | size – a 2 element tuple (w, h) specifying the size. |
Elements go from 0 to 1. If the aspect ratio is fixed, then h
+
Elements go from 0 to 1. If the aspect ratio is fixed, then h
is ignored.
This is equivalent to setting Dimensions>Position within a view +
This is equivalent to setting Dimensions>Position within a view item dialog in kst.
set_stroke_brush_color
(color)¶Set the color for lines for the item.
-Colors are given by a name such as red
or a hex number
+
Colors are given by a name such as red
or a hex number
such as #FF0000
.
set_stroke_brush_style
(style)¶Set the brush style for lines for the item.
-This is equivalent to setting the index of Apperance>Stroke>Brush Style +
This is equivalent to setting the index of Apperance>Stroke>Brush Style within a view item dialog in kst.
-This sets the brush type for lines in the item, and not for the fill, +
This sets the brush type for lines in the item, and not for the fill,
so values other than 1
(SolidPattern) only make sense for wide lines
and are rarely used:
0: NoBrush 1: SolidPattern
2: Dense1Pattern 3: Dense2Pattern
4: Dense3Pattern 5: Dense4Pattern
6: Dense5Pattern 7: Dense6Pattern
8: Dense7Pattern 9: HorPattern
-11: VerPattern 12: CrossPattern,
+11: VerPattern 12: CrossPattern,
13: BDiagPattern 14: FDiagPattern.
set_stroke_style
(style)¶Set the stroke style of lines for the item.
-This is equivalent to setting the index of Apperance>Stroke>Style +
This is equivalent to setting the index of Apperance>Stroke>Style within a view item dialog in kst:
0: SolidLine 1: DashLine
-2: DotLine 3: DashDotLine
+2: DotLine 3: DashDotLine
4: DashDotDotLine 5: CustomDashLine
set_stroke_width
(width)¶Set the width of lines for the item.
subplot
(*args)¶Set the item position according to the given grid definition.
Typical call signature:
subplot(nrows, ncols, plot_number)
Where nrows and ncols are used to notionally split the figure
into nrows * ncols
sub-axes, and plot_number is used to identify
the particular subplot that this function is to create within the notional
grid. plot_number starts at 1, increments across rows first and has a
maximum of nrows * ncols
.
In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:
subplot(211)
place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).
pykst.
Line
(client, start=(0, 0), end=(1, 1), stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, stroke_cap_style=1, name='', new=True)[source]¶A floating line inside kst.
Parameters: |
(0, 0) is top left of the window, and (1, 1) is bottom right.
|
---|
Colors are given by a name such as red
or a hex number such
+
Colors are given by a name such as red
or a hex number such
as #FF0000
.
This class represents a line you would create via “Create>Annotations>Line” from the menubar inside kst.
+This class represents a line you would create via “Create>Annotations>Line” +from the menubar inside kst.
Colors are given by a name such as red
or a hex number such as #FF0000
”.
Use the convenience function in Client to create a line in kst:
import pykst as kst
client = kst.Client()
...
Ln = client.new_line((0.25, 0.25), (0.5, 0.5))
description_tip
()¶Returns a string describing the object
name
()¶Returns the name of the object from inside kst.
remove
()¶This removes the object from Kst.
set_endpoints
(start=(0, 0), end=(1, 1))[source]¶set the endpoints of the line.
-If lock_pos_to_data has been set True, and the item parent is a plot, then the coordinates are -in terms the data’s coordinates. Otherwise, the coordinates, between 0 and 1, are relative to -the dimensions of the parent object.
+If lock_pos_to_data has been set True, and the item parent is a plot, then +the coordinates are in terms the data’s coordinates. Otherwise, the coordinates, +between 0 and 1, are relative to the dimensions of the parent object.
set_length
(length)[source]¶set the length of the line.
-The length, between 0 and 1, is as a fraction of the width of the parent item.
+The length, between 0 and 1, is as a fraction of the width of the parent item.
set_lock_pos_to_data
(lock=True)¶if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.
If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.
set_name
(name)¶Set the name of the object inside kst.
set_parent_auto
()¶Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.
By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.
set_parent_toplevel
()¶Set the parent of the viewitem to the toplevel view.
By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.
set_pos
(pos)¶Set the center position of the item.
Parameters: | pos – a 2 element tuple (x,y) specifying the position.
-The Top Left of the parent is (0,0).
-The Bottom Right of the parent is (1,1) |
+
---|---|
Parameters: | pos – a 2 element tuple (x, y) specifying the position.
+The Top Left of the parent is (0, 0).
+The Bottom Right of the parent is (1, 1) |
set_rotation
(rot)¶Set the rotation of the item.
This is equivalent to setting Dimensions>Rotation within a view item dialog.
set_stroke_brush_color
(color)¶Set the color for lines for the item.
-Colors are given by a name such as red
or a hex number
+
Colors are given by a name such as red
or a hex number
such as #FF0000
.
set_stroke_brush_style
(style)¶Set the brush style for lines for the item.
-This is equivalent to setting the index of Apperance>Stroke>Brush Style +
This is equivalent to setting the index of Apperance>Stroke>Brush Style within a view item dialog in kst.
-This sets the brush type for lines in the item, and not for the fill, +
This sets the brush type for lines in the item, and not for the fill,
so values other than 1
(SolidPattern) only make sense for wide lines
and are rarely used:
0: NoBrush 1: SolidPattern
2: Dense1Pattern 3: Dense2Pattern
4: Dense3Pattern 5: Dense4Pattern
6: Dense5Pattern 7: Dense6Pattern
8: Dense7Pattern 9: HorPattern
-11: VerPattern 12: CrossPattern,
+11: VerPattern 12: CrossPattern,
13: BDiagPattern 14: FDiagPattern.
set_stroke_cap_style
(style)¶Set the cap style for the ends of lines in the item.
-This is equivalent to setting the index of Apperance>Stroke>Cap Style +
This is equivalent to setting the index of Apperance>Stroke>Cap Style within a view item dialog in kst.
0 is FlatCap, 1 is SquareCap, and 2 is RoundCap.
set_stroke_style
(style)¶Set the stroke style of lines for the item.
-This is equivalent to setting the index of Apperance>Stroke>Style +
This is equivalent to setting the index of Apperance>Stroke>Style within a view item dialog in kst:
0: SolidLine 1: DashLine
-2: DotLine 3: DashDotLine
+2: DotLine 3: DashDotLine
4: DashDotDotLine 5: CustomDashLine
set_stroke_width
(width)¶Set the width of lines for the item.
subplot
(*args)¶Set the item position according to the given grid definition.
Typical call signature:
subplot(nrows, ncols, plot_number)
Where nrows and ncols are used to notionally split the figure
into nrows * ncols
sub-axes, and plot_number is used to identify
the particular subplot that this function is to create within the notional
grid. plot_number starts at 1, increments across rows first and has a
maximum of nrows * ncols
.
In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:
subplot(211)
place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).
pykst.
Arrow
(client, start=(0, 0), end=(1, 1), arror_at_start=False, arrow_at_end=True, arrow_size=12.0, stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, stroke_cap_style=1, name='', new=True)[source]¶A floating arrow inside kst.
Parameters: |
|
---|
Colors are given by a name such as red
or a hex number such
+
Colors are given by a name such as red
or a hex number such
as #FF0000
.
This class represents an arrow you would create via +
This class represents an arrow you would create via “Create>Annotations>Arrow” from the menubar inside kst.
Use the convenience function in Client to create an arrow in kst:
import pykst as kst
client = kst.Client()
...
Ln = client.new_arrow((0.25, 0.25), 0.2, rot=15, arror_at_start=True)
description_tip
()¶Returns a string describing the object
name
()¶Returns the name of the object from inside kst.
remove
()¶This removes the object from Kst.
set_endpoints
(start=(0, 0), end=(1, 1))[source]¶set the endpoints of the arrow.
-If lock_pos_to_data has been set True, and the item parent is a plot, then the coordinates are -in terms the data’s coordinates. Otherwise, the coordinates, between 0 and 1, are relative to -the dimensions of the parent object.
+If lock_pos_to_data has been set True, and the item parent is a plot, then the +coordinates are in terms the data’s coordinates. Otherwise, the coordinates, +between 0 and 1, are relative to the dimensions of the parent object.
set_lock_pos_to_data
(lock=True)¶if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.
If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.
set_name
(name)¶Set the name of the object inside kst.
set_parent_auto
()¶Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.
By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.
set_parent_toplevel
()¶Set the parent of the viewitem to the toplevel view.
By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.
set_pos
(pos)¶Set the center position of the item.
Parameters: | pos – a 2 element tuple (x,y) specifying the position.
-The Top Left of the parent is (0,0).
-The Bottom Right of the parent is (1,1) |
+
---|---|
Parameters: | pos – a 2 element tuple (x, y) specifying the position.
+The Top Left of the parent is (0, 0).
+The Bottom Right of the parent is (1, 1) |
set_rotation
(rot)¶Set the rotation of the item.
This is equivalent to setting Dimensions>Rotation within a view item dialog.
set_stroke_brush_color
(color)¶Set the color for lines for the item.
-Colors are given by a name such as red
or a hex number
+
Colors are given by a name such as red
or a hex number
such as #FF0000
.
set_stroke_brush_style
(style)¶Set the brush style for lines for the item.
-This is equivalent to setting the index of Apperance>Stroke>Brush Style +
This is equivalent to setting the index of Apperance>Stroke>Brush Style within a view item dialog in kst.
-This sets the brush type for lines in the item, and not for the fill, +
This sets the brush type for lines in the item, and not for the fill,
so values other than 1
(SolidPattern) only make sense for wide lines
and are rarely used:
0: NoBrush 1: SolidPattern
2: Dense1Pattern 3: Dense2Pattern
4: Dense3Pattern 5: Dense4Pattern
6: Dense5Pattern 7: Dense6Pattern
8: Dense7Pattern 9: HorPattern
-11: VerPattern 12: CrossPattern,
+11: VerPattern 12: CrossPattern,
13: BDiagPattern 14: FDiagPattern.
set_stroke_cap_style
(style)¶Set the cap style for the ends of lines in the item.
-This is equivalent to setting the index of Apperance>Stroke>Cap Style +
This is equivalent to setting the index of Apperance>Stroke>Cap Style within a view item dialog in kst.
0 is FlatCap, 1 is SquareCap, and 2 is RoundCap.
set_stroke_style
(style)¶Set the stroke style of lines for the item.
-This is equivalent to setting the index of Apperance>Stroke>Style +
This is equivalent to setting the index of Apperance>Stroke>Style within a view item dialog in kst:
0: SolidLine 1: DashLine
-2: DotLine 3: DashDotLine
+2: DotLine 3: DashDotLine
4: DashDotDotLine 5: CustomDashLine
set_stroke_width
(width)¶Set the width of lines for the item.
subplot
(*args)¶Set the item position according to the given grid definition.
Typical call signature:
subplot(nrows, ncols, plot_number)
Where nrows and ncols are used to notionally split the figure
into nrows * ncols
sub-axes, and plot_number is used to identify
the particular subplot that this function is to create within the notional
grid. plot_number starts at 1, increments across rows first and has a
maximum of nrows * ncols
.
In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:
subplot(211)
place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).
pykst.
Picture
(client, filename, pos=(0.1, 0.1), width=0.1, rot=0, name='', new=True)[source]¶A floating image inside kst.
Parameters: |
|
---|
This class represents a picture you would create via +
This class represents a picture you would create via “Create>Annotations>Picture” from the menubar inside kst.
Use the convenience function in Client to create a picture in kst:
import pykst as kst
client = kst.Client()
...
pic = client.new_picture("image.jpg", (0.25, 0.25), 0.2)
BUG: the aspect ratio of the picture is wrong.
description_tip
()¶Returns a string describing the object
name
()¶Returns the name of the object from inside kst.
remove
()¶This removes the object from Kst.
set_fixed_aspect_ratio
(fixed=True)¶if True, fix the aspect ratio of the item to its current value.
-This is equivalent to checking Dimensions>Fix aspect ratio within a +
This is equivalent to checking Dimensions>Fix aspect ratio within a view item dialog in kst.
set_lock_pos_to_data
(lock=True)¶if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.
If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.
set_name
(name)¶Set the name of the object inside kst.
set_parent_auto
()¶Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.
By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.
set_parent_toplevel
()¶Set the parent of the viewitem to the toplevel view.
By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.
set_picture
(pic)[source]¶BUG: aspect ratio is not changed. There is no parellel for this +
BUG: aspect ratio is not changed. There is no parellel for this function within the kst GUI.
set_pos
(pos)¶Set the center position of the item.
Parameters: | pos – a 2 element tuple (x,y) specifying the position.
-The Top Left of the parent is (0,0).
-The Bottom Right of the parent is (1,1) |
+
---|---|
Parameters: | pos – a 2 element tuple (x, y) specifying the position.
+The Top Left of the parent is (0, 0).
+The Bottom Right of the parent is (1, 1) |
set_rotation
(rot)¶Set the rotation of the item.
This is equivalent to setting Dimensions>Rotation within a view item dialog.
set_size
(size)¶Set the size of the item.
Parameters: | size – a 2 element tuple (w,h) specifying the size. |
+
---|---|
Parameters: | size – a 2 element tuple (w, h) specifying the size. |
Elements go from 0 to 1. If the aspect ratio is fixed, then h
+
Elements go from 0 to 1. If the aspect ratio is fixed, then h
is ignored.
This is equivalent to setting Dimensions>Position within a view +
This is equivalent to setting Dimensions>Position within a view item dialog in kst.
subplot
(*args)¶Set the item position according to the given grid definition.
Typical call signature:
subplot(nrows, ncols, plot_number)
Where nrows and ncols are used to notionally split the figure
into nrows * ncols
sub-axes, and plot_number is used to identify
the particular subplot that this function is to create within the notional
grid. plot_number starts at 1, increments across rows first and has a
maximum of nrows * ncols
.
In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:
subplot(211)
place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).
pykst.
SVG
(client, filename, pos=(0.1, 0.1), width=0.1, rot=0, name='', new=True)[source]¶A floating svg image inside kst.
Parameters: |
|
---|
This class represents a picture you would create via +
This class represents a picture you would create via “Create>Annotations>SVG” from the menubar inside kst.
Use the convenience function in Client to create an SVG picture in kst:
import pykst as kst
client = kst.Client()
...
svg1 = client.new_SVG("image.svg", (0.25, 0.25), 0.2)
description_tip
()¶Returns a string describing the object
name
()¶Returns the name of the object from inside kst.
remove
()¶This removes the object from Kst.
set_fixed_aspect_ratio
(fixed=True)¶if True, fix the aspect ratio of the item to its current value.
-This is equivalent to checking Dimensions>Fix aspect ratio within a +
This is equivalent to checking Dimensions>Fix aspect ratio within a view item dialog in kst.
set_lock_pos_to_data
(lock=True)¶if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.
If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.
set_name
(name)¶Set the name of the object inside kst.
set_parent_auto
()¶Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.
By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.
set_parent_toplevel
()¶Set the parent of the viewitem to the toplevel view.
By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.
set_pos
(pos)¶Set the center position of the item.
Parameters: | pos – a 2 element tuple (x,y) specifying the position.
-The Top Left of the parent is (0,0).
-The Bottom Right of the parent is (1,1) |
+
---|---|
Parameters: | pos – a 2 element tuple (x, y) specifying the position.
+The Top Left of the parent is (0, 0).
+The Bottom Right of the parent is (1, 1) |
set_rotation
(rot)¶Set the rotation of the item.
This is equivalent to setting Dimensions>Rotation within a view item dialog.
set_size
(size)¶Set the size of the item.
Parameters: | size – a 2 element tuple (w,h) specifying the size. |
+
---|---|
Parameters: | size – a 2 element tuple (w, h) specifying the size. |
Elements go from 0 to 1. If the aspect ratio is fixed, then h
+
Elements go from 0 to 1. If the aspect ratio is fixed, then h
is ignored.
This is equivalent to setting Dimensions>Position within a view +
This is equivalent to setting Dimensions>Position within a view item dialog in kst.
subplot
(*args)¶Set the item position according to the given grid definition.
Typical call signature:
subplot(nrows, ncols, plot_number)
Where nrows and ncols are used to notionally split the figure
into nrows * ncols
sub-axes, and plot_number is used to identify
the particular subplot that this function is to create within the notional
grid. plot_number starts at 1, increments across rows first and has a
maximum of nrows * ncols
.
In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:
subplot(211)
place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).
pykst.
Plot
(client, pos=(0, 0), size=(0, 0), rot=0, font_size=0, columns=0, fill_color='white', fill_style=1, stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, strokeJoinStyle=1, stroke_cap_style=1, fix_aspect=False, auto_position=True, name='', new=True)[source]¶pykst.
Plot
(client, pos=(0, 0), size=(0, 0), rot=0, font_size=0, columns=0, fill_color='white', fill_style=1, stroke_style=1, stroke_width=1, stroke_brush_color='black', stroke_brush_style=1, stroke_join_style=1, stroke_cap_style=1, fix_aspect=False, auto_position=True, name='', new=True)[source]¶
A plot inside kst.
Parameters: |
|
---|
Colors are given by a name such as red
or a hex number such
+
Colors are given by a name such as red
or a hex number such
as #FF0000
.
This class represents a Plot you would create via +
This class represents a Plot you would create via “Create>Annotations>Plot” from the menubar inside kst.
To create an plot in kst and plot a curve curve1
:
import pykst as kst
client = kst.Client()
...
-P1 = client.new_plot((0.25, 0.25), (0.5,0.5))
+P1 = client.new_plot((0.25, 0.25), (0.5, 0.5))
P1.add(curve1)
description_tip
()¶Returns a string describing the object
name
()¶Returns the name of the object from inside kst.
normalize_x_to_y
()[source]¶Adjust the X zoom range so X and Y have the same scale +
Adjust the X zoom range so X and Y have the same scale per unit (square pixels)
remove
()¶This removes the object from Kst.
set_fill_color
(color)¶Set the fill/background color.
-Colors are given by a name such as red
or a hex number such
+
Colors are given by a name such as red
or a hex number such
as #FF0000
.
set_fill_style
(style)¶Set the background fill style.
-This is equivalent to setting the index of Apperance>Fill>Style within +
This is equivalent to setting the index of Apperance>Fill>Style within a view item dialog in kst.:
0: NoBrush 1: SolidPattern
2: Dense1Pattern 3: Dense2Pattern
4: Dense3Pattern 5: Dense4Pattern
6: Dense5Pattern 7: Dense6Pattern
8: Dense7Pattern 9: HorPattern
-11: VerPattern 12: CrossPattern,
+11: VerPattern 12: CrossPattern,
13: BDiagPattern 14: FDiagPattern.
set_fixed_aspect_ratio
(fixed=True)¶if True, fix the aspect ratio of the item to its current value.
-This is equivalent to checking Dimensions>Fix aspect ratio within a +
This is equivalent to checking Dimensions>Fix aspect ratio within a view item dialog in kst.
set_global_font
(family='', font_size=0, bold=False, italic=False)[source]¶Set the global plot font.
-By default, the axis labels all use this, unless they have been set +
By default, the axis labels all use this, unless they have been set to use their own.
If the parameter ‘family’ is empty, the font family will be unchanged. If the parameter ‘font_size’ is 0, the font size will be unchanged. The font will be bold if parameter ‘bold’ is set to ‘bold’ or ‘True’. -The font will be italic if parameter ‘italic’ is set to ‘italic’ +The font will be italic if parameter ‘italic’ is set to ‘italic’ or ‘True’.
set_lock_pos_to_data
(lock=True)¶if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.
If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.
set_name
(name)¶Set the name of the object inside kst.
set_parent_auto
()¶Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.
By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.
set_parent_toplevel
()¶Set the parent of the viewitem to the toplevel view.
By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.
set_pos
(pos)¶Set the center position of the item.
Parameters: | pos – a 2 element tuple (x,y) specifying the position.
-The Top Left of the parent is (0,0).
-The Bottom Right of the parent is (1,1) |
+
---|---|
Parameters: | pos – a 2 element tuple (x, y) specifying the position.
+The Top Left of the parent is (0, 0).
+The Bottom Right of the parent is (1, 1) |
set_rotation
(rot)¶Set the rotation of the item.
This is equivalent to setting Dimensions>Rotation within a view item dialog.
set_size
(size)¶Set the size of the item.
Parameters: | size – a 2 element tuple (w,h) specifying the size. |
+
---|---|
Parameters: | size – a 2 element tuple (w, h) specifying the size. |
Elements go from 0 to 1. If the aspect ratio is fixed, then h
+
Elements go from 0 to 1. If the aspect ratio is fixed, then h
is ignored.
This is equivalent to setting Dimensions>Position within a view +
This is equivalent to setting Dimensions>Position within a view item dialog in kst.
set_stroke_brush_color
(color)¶Set the color for lines for the item.
-Colors are given by a name such as red
or a hex number
+
Colors are given by a name such as red
or a hex number
such as #FF0000
.
set_stroke_brush_style
(style)¶Set the brush style for lines for the item.
-This is equivalent to setting the index of Apperance>Stroke>Brush Style +
This is equivalent to setting the index of Apperance>Stroke>Brush Style within a view item dialog in kst.
-This sets the brush type for lines in the item, and not for the fill, +
This sets the brush type for lines in the item, and not for the fill,
so values other than 1
(SolidPattern) only make sense for wide lines
and are rarely used:
0: NoBrush 1: SolidPattern
2: Dense1Pattern 3: Dense2Pattern
4: Dense3Pattern 5: Dense4Pattern
6: Dense5Pattern 7: Dense6Pattern
8: Dense7Pattern 9: HorPattern
-11: VerPattern 12: CrossPattern,
+11: VerPattern 12: CrossPattern,
13: BDiagPattern 14: FDiagPattern.
set_stroke_cap_style
(style)¶Set the cap style for the ends of lines in the item.
-This is equivalent to setting the index of Apperance>Stroke>Cap Style +
This is equivalent to setting the index of Apperance>Stroke>Cap Style within a view item dialog in kst.
0 is FlatCap, 1 is SquareCap, and 2 is RoundCap.
set_stroke_join_style
(style)¶Set the style by which lines are joined in the item.
-This is equivalent to setting the index of Apperance>Stroke>Join Style +
This is equivalent to setting the index of Apperance>Stroke>Join Style within a view item dialog in kst.
0 is MiterJoin, 1 is BevelJoin, 2 is RoundJoin, and 3 is SvgMiterJoin.
set_stroke_style
(style)¶Set the stroke style of lines for the item.
-This is equivalent to setting the index of Apperance>Stroke>Style +
This is equivalent to setting the index of Apperance>Stroke>Style within a view item dialog in kst:
0: SolidLine 1: DashLine
-2: DotLine 3: DashDotLine
+2: DotLine 3: DashDotLine
4: DashDotDotLine 5: CustomDashLine
set_stroke_width
(width)¶Set the width of lines for the item.
set_x_ac
(r)[source]¶Set X zoom range to fixed range, centered around the mean.
Similar to AC coupling on an oscilloscope.
set_x_axis_display
(display='yyyy/MM/dd h:mm:ss ap')[source]¶if the x axis has been interpreted as time, set the display.
Display Types:
year: display the decimal year
qttextdtehhmmss: <Qt Text Date> HH:MM:SS.SS
qtlocaldatehhmmss: <Qt Local Date> HH:MM:SS.SS
jd: Julian Date
mjd: Modified Julian Date
All others: custom format
The custom format is defined as:
d the day as number without a leading zero (1 to 31)
dd the day as number with a leading zero (01 to 31)
-ddd the abbreviated localized day name (e.g. 'Mon' to 'Sun'). Uses the system locale to localize the name, i.e. QLocale::system().
-dddd the long localized day name (e.g. 'Monday' to 'Qt::Sunday'). Uses the system locale to localize the name, i.e. QLocale::system().
+ddd the abbreviated localized day name (e.g. 'Mon' to 'Sun').
+ Uses the system locale to localize the name, i.e. QLocale::system().
+dddd the long localized day name (e.g. 'Monday' to 'Qt::Sunday').
+ Uses the system locale to localize the name, i.e. QLocale::system().
M the month as number without a leading zero (1-12)
MM the month as number with a leading zero (01-12)
-MMM the abbreviated localized month name (e.g. 'Jan' to 'Dec'). Uses the system locale to localize the name, i.e. QLocale::system().
-MMMM the long localized month name (e.g. 'January' to 'December'). Uses the system locale to localize the name, i.e. QLocale::system().
+MMM the abbreviated localized month name (e.g. 'Jan' to 'Dec').
+ Uses the system locale to localize the name, i.e. QLocale::system().
+MMMM the long localized month name (e.g. 'January' to 'December').
+ Uses the system locale to localize the name, i.e. QLocale::system().
yy the year as two digit number (00-99)
yyyy the year as four digit number
h the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)
hh the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)
H the hour without a leading zero (0 to 23, even with AM/PM display)
HH the hour with a leading zero (00 to 23, even with AM/PM display)
m the minute without a leading zero (0 to 59)
mm the minute with a leading zero (00 to 59)
s the second without a leading zero (0 to 59)
ss the second with a leading zero (00 to 59)
z the milliseconds without leading zeroes (0 to 999)
zzz the milliseconds with leading zeroes (000 to 999)
AP or A use AM/PM display. A/AP will be replaced by either "AM" or "PM".
ap or a use am/pm display. a/ap will be replaced by either "am" or "pm".
t the timezone (for example "CEST")
set_x_axis_interpretation
(interp='ctime')[source]¶Interpret the x axis as time
Parameters: | interp – interpret the time as follows |
---|
interp can be:
ctime: Standard unix C time
year: Decimal year
jd: Julian Date
mjd: Modified Julian Date
excel: Time as used by MS Excel
set_y_ac
(r)[source]¶Set Y zoom range to fixed range, centered around the mean.
Similar to AC coupling on an oscilloscope.
set_y_axis_reversed
(reversed=True)[source]¶set_y_axis_reversed
(axis_reversed=True)[source]¶
set the Y axis to decreasing from bottom to top.
subplot
(*args)¶Set the item position according to the given grid definition.
Typical call signature:
subplot(nrows, ncols, plot_number)
Where nrows and ncols are used to notionally split the figure
into nrows * ncols
sub-axes, and plot_number is used to identify
the particular subplot that this function is to create within the notional
grid. plot_number starts at 1, increments across rows first and has a
maximum of nrows * ncols
.
In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:
subplot(211)
place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).
Interactive items are controls which are part of a kst view and use QtNetwork.QLocalSocket to notify the script when the user has interacted with them. They can only be created through scripts.
pykst.
Button
(client, text, socket, posX=0.1, posY=0.1, sizeX=0.1, sizeY=0.1, rot=0)[source]¶This represents a button inside a View. When the button is pressed, it sends a message via a socket.
-socket is a QtNetwork.QLocalSocket that is not connected to anything. The message “clicked” will be sent -when the button is pressed. See the bonjourMonde example.
+This represents a button inside a View. When the button is pressed, it sends a +message via a socket.
+socket is a QtNetwork.QLocalSocket that is not connected to anything. The message +“clicked” will be sent when the button is pressed. See the bonjourMonde example.
description_tip
()¶Returns a string describing the object
name
()¶Returns the name of the object from inside kst.
remove
()¶This removes the object from Kst.
set_fill_color
(color)¶Set the fill/background color.
-Colors are given by a name such as red
or a hex number such
+
Colors are given by a name such as red
or a hex number such
as #FF0000
.
set_fill_style
(style)¶Set the background fill style.
-This is equivalent to setting the index of Apperance>Fill>Style within +
This is equivalent to setting the index of Apperance>Fill>Style within a view item dialog in kst.:
0: NoBrush 1: SolidPattern
2: Dense1Pattern 3: Dense2Pattern
4: Dense3Pattern 5: Dense4Pattern
6: Dense5Pattern 7: Dense6Pattern
8: Dense7Pattern 9: HorPattern
-11: VerPattern 12: CrossPattern,
+11: VerPattern 12: CrossPattern,
13: BDiagPattern 14: FDiagPattern.
set_fixed_aspect_ratio
(fixed=True)¶if True, fix the aspect ratio of the item to its current value.
-This is equivalent to checking Dimensions>Fix aspect ratio within a +
This is equivalent to checking Dimensions>Fix aspect ratio within a view item dialog in kst.
set_lock_pos_to_data
(lock=True)¶if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.
If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.
set_name
(name)¶Set the name of the object inside kst.
set_parent_auto
()¶Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.
By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.
set_parent_toplevel
()¶Set the parent of the viewitem to the toplevel view.
By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.
set_pos
(pos)¶Set the center position of the item.
Parameters: | pos – a 2 element tuple (x,y) specifying the position.
-The Top Left of the parent is (0,0).
-The Bottom Right of the parent is (1,1) |
+
---|---|
Parameters: | pos – a 2 element tuple (x, y) specifying the position.
+The Top Left of the parent is (0, 0).
+The Bottom Right of the parent is (1, 1) |
set_rotation
(rot)¶Set the rotation of the item.
This is equivalent to setting Dimensions>Rotation within a view item dialog.
set_size
(size)¶Set the size of the item.
Parameters: | size – a 2 element tuple (w,h) specifying the size. |
+
---|---|
Parameters: | size – a 2 element tuple (w, h) specifying the size. |
Elements go from 0 to 1. If the aspect ratio is fixed, then h
+
Elements go from 0 to 1. If the aspect ratio is fixed, then h
is ignored.
This is equivalent to setting Dimensions>Position within a view +
This is equivalent to setting Dimensions>Position within a view item dialog in kst.
set_stroke_brush_color
(color)¶Set the color for lines for the item.
-Colors are given by a name such as red
or a hex number
+
Colors are given by a name such as red
or a hex number
such as #FF0000
.
set_stroke_brush_style
(style)¶Set the brush style for lines for the item.
-This is equivalent to setting the index of Apperance>Stroke>Brush Style +
This is equivalent to setting the index of Apperance>Stroke>Brush Style within a view item dialog in kst.
-This sets the brush type for lines in the item, and not for the fill, +
This sets the brush type for lines in the item, and not for the fill,
so values other than 1
(SolidPattern) only make sense for wide lines
and are rarely used:
0: NoBrush 1: SolidPattern
2: Dense1Pattern 3: Dense2Pattern
4: Dense3Pattern 5: Dense4Pattern
6: Dense5Pattern 7: Dense6Pattern
8: Dense7Pattern 9: HorPattern
-11: VerPattern 12: CrossPattern,
+11: VerPattern 12: CrossPattern,
13: BDiagPattern 14: FDiagPattern.
set_stroke_cap_style
(style)¶Set the cap style for the ends of lines in the item.
-This is equivalent to setting the index of Apperance>Stroke>Cap Style +
This is equivalent to setting the index of Apperance>Stroke>Cap Style within a view item dialog in kst.
0 is FlatCap, 1 is SquareCap, and 2 is RoundCap.
set_stroke_join_style
(style)¶Set the style by which lines are joined in the item.
-This is equivalent to setting the index of Apperance>Stroke>Join Style +
This is equivalent to setting the index of Apperance>Stroke>Join Style within a view item dialog in kst.
0 is MiterJoin, 1 is BevelJoin, 2 is RoundJoin, and 3 is SvgMiterJoin.
set_stroke_style
(style)¶Set the stroke style of lines for the item.
-This is equivalent to setting the index of Apperance>Stroke>Style +
This is equivalent to setting the index of Apperance>Stroke>Style within a view item dialog in kst:
0: SolidLine 1: DashLine
-2: DotLine 3: DashDotLine
+2: DotLine 3: DashDotLine
4: DashDotDotLine 5: CustomDashLine
set_stroke_width
(width)¶Set the width of lines for the item.
subplot
(*args)¶Set the item position according to the given grid definition.
Typical call signature:
subplot(nrows, ncols, plot_number)
Where nrows and ncols are used to notionally split the figure
into nrows * ncols
sub-axes, and plot_number is used to identify
the particular subplot that this function is to create within the notional
grid. plot_number starts at 1, increments across rows first and has a
maximum of nrows * ncols
.
In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:
subplot(211)
place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).
pykst.
LineEdit
(client, text, socket, posX=0.1, posY=0.1, sizeX=0.1, sizeY=0.1, rot=0)[source]¶This represents a line edit inside a View. When the lineedit’s value is changed, it sends a message via a socket.
-socket is a QtNetwork.QLocalSocket that is not connected to anything. The message “valueSet:VAL” where VAL is some text -will be sent when the text is changed. See the ksNspire example.
+This represents a line edit inside a View. When the lineedit’s value is changed, +it sends a message via a socket.
+socket is a QtNetwork.QLocalSocket that is not connected to anything. The message +“valueSet:VAL” where VAL is some text will be sent when the text is changed. +See the ksNspire example.
description_tip
()¶Returns a string describing the object
name
()¶Returns the name of the object from inside kst.
remove
()¶This removes the object from Kst.
set_fill_color
(color)¶Set the fill/background color.
-Colors are given by a name such as red
or a hex number such
+
Colors are given by a name such as red
or a hex number such
as #FF0000
.
set_fill_style
(style)¶Set the background fill style.
-This is equivalent to setting the index of Apperance>Fill>Style within +
This is equivalent to setting the index of Apperance>Fill>Style within a view item dialog in kst.:
0: NoBrush 1: SolidPattern
2: Dense1Pattern 3: Dense2Pattern
4: Dense3Pattern 5: Dense4Pattern
6: Dense5Pattern 7: Dense6Pattern
8: Dense7Pattern 9: HorPattern
-11: VerPattern 12: CrossPattern,
+11: VerPattern 12: CrossPattern,
13: BDiagPattern 14: FDiagPattern.
set_fixed_aspect_ratio
(fixed=True)¶if True, fix the aspect ratio of the item to its current value.
-This is equivalent to checking Dimensions>Fix aspect ratio within a +
This is equivalent to checking Dimensions>Fix aspect ratio within a view item dialog in kst.
set_lock_pos_to_data
(lock=True)¶if lock is True, and the item is in a plot, then the position of the item will be locked to the data coordinates in the plot. The item will move with zooming and scrolling.
If lock is False, or the item is not in a plot, then the item will be fixed to the geometry of the window, and zooming/scrolling will not change its position.
set_name
(name)¶Set the name of the object inside kst.
set_parent_auto
()¶Set the parent of the viewitem to an existing view item which fully contains it. Once reparented, moving/resizing the parent will also move/resize the child.
By default view items created by pyKst are parented by the toplevel view unless this method is called, or if the item is moved/resized in the GUI.
set_parent_toplevel
()¶Set the parent of the viewitem to the toplevel view.
By default view items created by pyKst are parented by the toplevel view unless set_parent_auto() is called, or if the item is moved/resized in the GUI.
set_pos
(pos)¶Set the center position of the item.
Parameters: | pos – a 2 element tuple (x,y) specifying the position.
-The Top Left of the parent is (0,0).
-The Bottom Right of the parent is (1,1) |
+
---|---|
Parameters: | pos – a 2 element tuple (x, y) specifying the position.
+The Top Left of the parent is (0, 0).
+The Bottom Right of the parent is (1, 1) |
set_rotation
(rot)¶Set the rotation of the item.
This is equivalent to setting Dimensions>Rotation within a view item dialog.
set_size
(size)¶Set the size of the item.
Parameters: | size – a 2 element tuple (w,h) specifying the size. |
+
---|---|
Parameters: | size – a 2 element tuple (w, h) specifying the size. |
Elements go from 0 to 1. If the aspect ratio is fixed, then h
+
Elements go from 0 to 1. If the aspect ratio is fixed, then h
is ignored.
This is equivalent to setting Dimensions>Position within a view +
This is equivalent to setting Dimensions>Position within a view item dialog in kst.
set_stroke_brush_color
(color)¶Set the color for lines for the item.
-Colors are given by a name such as red
or a hex number
+
Colors are given by a name such as red
or a hex number
such as #FF0000
.
set_stroke_brush_style
(style)¶Set the brush style for lines for the item.
-This is equivalent to setting the index of Apperance>Stroke>Brush Style +
This is equivalent to setting the index of Apperance>Stroke>Brush Style within a view item dialog in kst.
-This sets the brush type for lines in the item, and not for the fill, +
This sets the brush type for lines in the item, and not for the fill,
so values other than 1
(SolidPattern) only make sense for wide lines
and are rarely used:
0: NoBrush 1: SolidPattern
2: Dense1Pattern 3: Dense2Pattern
4: Dense3Pattern 5: Dense4Pattern
6: Dense5Pattern 7: Dense6Pattern
8: Dense7Pattern 9: HorPattern
-11: VerPattern 12: CrossPattern,
+11: VerPattern 12: CrossPattern,
13: BDiagPattern 14: FDiagPattern.
set_stroke_cap_style
(style)¶Set the cap style for the ends of lines in the item.
-This is equivalent to setting the index of Apperance>Stroke>Cap Style +
This is equivalent to setting the index of Apperance>Stroke>Cap Style within a view item dialog in kst.
0 is FlatCap, 1 is SquareCap, and 2 is RoundCap.
set_stroke_join_style
(style)¶Set the style by which lines are joined in the item.
-This is equivalent to setting the index of Apperance>Stroke>Join Style +
This is equivalent to setting the index of Apperance>Stroke>Join Style within a view item dialog in kst.
0 is MiterJoin, 1 is BevelJoin, 2 is RoundJoin, and 3 is SvgMiterJoin.
set_stroke_style
(style)¶Set the stroke style of lines for the item.
-This is equivalent to setting the index of Apperance>Stroke>Style +
This is equivalent to setting the index of Apperance>Stroke>Style within a view item dialog in kst:
0: SolidLine 1: DashLine
-2: DotLine 3: DashDotLine
+2: DotLine 3: DashDotLine
4: DashDotDotLine 5: CustomDashLine
set_stroke_width
(width)¶Set the width of lines for the item.
subplot
(*args)¶Set the item position according to the given grid definition.
Typical call signature:
subplot(nrows, ncols, plot_number)
Where nrows and ncols are used to notionally split the figure
into nrows * ncols
sub-axes, and plot_number is used to identify
the particular subplot that this function is to create within the notional
grid. plot_number starts at 1, increments across rows first and has a
maximum of nrows * ncols
.
In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:
subplot(211)
place the plot in the top grid location (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).
pykstplot re-implements a tiny subset of matplotlib.pyplot. It is included by importing pykstplot, and is conceptually incompatible with pykst.
pykstplot.
loglog
(*args, **kwargs)[source]¶Add a curve to the current axis (or make a new one)
with log-log scaling. All parameters are the same as plot()
.
pykstplot.
plot
(*args, **kwargs)[source]¶Plot lines and/or markers to a kst window. args is a variable length argument, allowing for multiple x, y pairs with an optional format string. For example, each of the following is legal:
plot(x, y) # plot x and y using default line style and color
plot(x, y, 'bo') # plot x and y using blue circle markers
plot(y) # plot y using x as index array 0..N-1
plot(y, 'r+') # ditto, but with red plusses
An arbitrary number of x, y, fmt groups can be specified, as in:
a.plot(x1, y1, 'g^', x2, y2, 'g-')
By default, each line is assigned a different color in kst.
The following format string characters are accepted to control the line style or marker:
character description '-'
solid line style '--'
dashed line style '-.'
dash-dot line style ':'
dotted line style '.'
point marker ','
pixel marker 'o'
circle marker 'v'
triangle_down marker '^'
triangle_up marker 's'
square marker '*'
star marker '+'
plus marker 'x'
x marker 'D'
diamond marker
The following color abbreviations are supported:
character color ‘b’ blue ‘g’ green ‘r’ red ‘c’ cyan ‘m’ magenta ‘y’ yellow ‘k’ black ‘w’ white
Line styles and colors are combined in a single format string, as in
'bo'
for blue circles.
The kwargs can be used to set the color, the line width, the line type,
and the legend label. You can specify colors using full names ('green'
),
or hex strings ('#008000'
).
Some examples:
plot([1,2,3], [1,2,3], 'go-', label='line 1', linewidth=2)
plot([1,2,3], [1,4,9], 'rs', label='line 2')
axis([0, 4, 0, 10])
legend()
If you make multiple lines with one plot command, the kwargs apply to all those lines, e.g.:
plot(x1, y1, x2, y2, linewidth=2)
Both lines will have a width of 2.
You do not need to use format strings, which are just abbreviations. All of the line properties can be controlled by keyword arguments. For example, you can set the color, marker, linestyle, and markercolor with:
plot(x, y, color='green', linestyle='dashed', marker='o',
color='blue', markersize=12).
Supported kwargs are:
color
label
linestyle
linewidth
markersize
pykstplot.
savefig
(fname, **kwargs)[source]¶Export the kst session as a series of graphics files. If there is only 1 tab, then the file will be called fname. If there are multiple tabs, the files will be called, for example, fname_1.png, fname_2.png, etc.
The plot will be have the same aspect ratio as the kst session, and, for pixel based formats, will be 1280 pixels wide.
The format is determined by the format kwarg, or by the fname extension if format is not defined.
All formats supported by kst are supported, including, among many others, png, jpg, eps, svg, and pdf.
pykstplot.
semilogx
(*args, **kwargs)[source]¶Add a curve to the current axis (or make a new one)
with log scaling on the X axis. All parameters are the same as plot()
.
pykstplot.
semilogy
(*args, **kwargs)[source]¶Add a curve to the current axis (or make a new one)
with log scaling on the Y axis. All parameters are the same as plot()
.
pykstplot.
show
()[source]¶This method does nothing, but exists for compatibility with matplotlib scripts.
pykstplot.
subplot
(*args, **kwargs)[source]¶Return a subplot axes positioned by the given grid definition.
Typical call signature:
subplot(nrows, ncols, plot_number)
Where nrows and ncols are used to notionally split the figure
into nrows * ncols
sub-axes, and plot_number is used to identify
the particular subplot that this function is to create within the notional
grid. plot_number starts at 1, increments across rows first and has a
maximum of nrows * ncols
.
In the case when nrows, ncols and plot_number are all less than 10, a convenience exists, such that the a 3 digit number can be given instead, where the hundreds represent nrows, the tens represent ncols and the units represent plot_number. For instance:
subplot(211)
produces a subaxes in a figure which represents the top plot (i.e. the first) in a 2 row by 1 column notional grid (no grid actually exists, but conceptually this is how the returned subplot has been positioned).
Note
unlike matplotlib.pyplot.subplot(), creating a new subplot with a position which is entirely inside a pre-existing axes will not delete the previous plot.
Keyword arguments:
- axisbg:
- The background color of the subplot, which can be any valid color specifier.
Please activate JavaScript to enable the search functionality.
From here you can search these documents. Enter your search words into the box below and click "search". Note that the search function will automatically search for all of the words. Pages containing fewer words won't appear in the result list.
\ Sort by:\ best rated\ newest\ oldest\
\\
Add a comment\ (markup):
\``code``
, \ code blocks:::
and an indented block after blank line