functions module

functions module gives general functions for users and developers.

Functions related to global variables, such as main window, are given in glb module.

Most of functions can be directly imported from lys Package:

from lys import home
lys.functions.append(*args, canvas=None, exclude=[], **kwargs)[source]

Append waves to the front canvas.

Parameters:
  • args (list of Wave or arraylike) – The waves to be added. If the item is not Wave, then it is automatically converted to Wave.

  • canvas (CanvasBase) – The canvas to which the wave are appended. If canvas is None, then front canvas is used.

  • exclude (list of canvas) – If the front canvas is in exclude, then it is ignored and next canvas is used.

  • kwargs – The keywords arguments that is passed to Append method of canvas.

lys.functions.display(*args, lib=None, **kwargs)[source]

Display Waves as graph.

Parameters:
  • args (list of Wave or arraylike) – The waves to be added. If the item is not Wave, then it is automatically converted to Wave.

  • lib ('matplotlib' or 'pyqtgraph') – The library used to create canvas.

  • kwargs – The keywords arguments that is passed to Append method of canvas. Typically vector=True and contour=True is specified to show vector and contour plots.

Returns:

The graph that contains the waves.

Return type:

Graph

lys.functions.edit(data)[source]

Edit the data in Table.

Parameters:

data (str or Wave or arraylike) – The data to be edited. If data is str, it is interpreted as file path.

lys.functions.frontCanvas(exclude=[])[source]

Get the front canvas.

Parameters:

exclude (list of canvas) – If the front canvas is in exclude, the it will be ignored.

Returns:

The front canvas

Return type:

canvas

lys.functions.home()[source]

Return home directory of lys.

All settings related to lys will be saved in .lys directory.

Returns:

path to home directory

Return type:

str

lys.functions.load(file, *args, **kwargs)[source]

Load various files.

Loadable file extensions are given by loadableFiles()

This function can be extended by registerFileLoader()

Parameters:
  • file (str) – file path

  • *args (any) – positional arguments

  • **kwargs (any) – keyword arguments

Returns:

return value depends on file type

Return type:

Any

Example:

import numpy as np
from lys import load, registerFileLoader, loadableFiles

np.savetxt("data.txt", np.array([1,2]))  # prepare txt file

registerFileLoader(".txt", np.loadtxt)   # Add file loader for .txt file using numpy.loadtxt.
print(loadableFiles())                   # List of loadable files, including .txt

arr = load("data.txt")                   # After registration, :func:`load` function can load .txt files as numpy array.
print(type(arr))                         # <class 'numpy.ndarray'>
lys.functions.loadableFiles()[source]

Returns list of extensions loadable by load().

Returns:

List of extensions

Return type:

list of str

lys.functions.lysPath(path)[source]

Return relative path to the home directory.

If the path is not in the home directory, the absolute path will be returned.

Parameters:

path (str) – The path to be converted.

Returns:

The relative path to the home directory.

Return type:

str

lys.functions.multicut(data, returnInstance=False, subWindow=True)[source]

Analyze the data by MultiCut.

Parameters:

data (Wave or DaskWave or arraylike) – The data to be analyzed.

lys.functions.registerFileLoader(type, func)[source]

Register file loader.

This function extend load() function and enables lys to load various file types.

Users should implement file loader and register it by this function.

Parameters:
  • type (str) – file extention, such as “.txt”

  • func (function) – function to load file.

lys.functions.registerFittingFunction(func, name=None)[source]

Register fitting function for lys fitting module.

The fitting can be started when Ctrl+F is pressed on the graphs with 1D data.

Parameters:
  • func (callable) – The function.

  • name (str) – The name of the function. If it is None, then func.__name__ is used.