Function Plugin API

Function plugins live in the config/transformations folder. PhysPlot loads these files from disk, so their filenames may start with numbers for menu ordering, but their public API should stay simple and predictable.

Required Module Variables

DISPLAY_NAME: str

The name shown in the mathematical transformation dropdown.

Required Function

transform(values) → numpy.ndarray

Transform one numeric column and return the transformed values.

Parameters:

values (array-like) – One-dimensional numeric input values, usually a numpy.ndarray copied from the selected table column.

Returns:

One-dimensional numeric output values with the same row order as the input.

Return type:

numpy.ndarray

Plugin Files Included with PhysPlot

File

Display name

Core behavior

config/transformations/01_identity.py

x

Returns the input values unchanged.

config/transformations/02_square.py

x^2

Squares each value.

config/transformations/03_cube.py

x^3

Cubes each value.

config/transformations/04_reciprocal.py

1/x

Returns the reciprocal of each value.

config/transformations/05_log10.py

log10(x)

Applies base-10 logarithm.

config/transformations/06_log.py

ln(x)

Applies natural logarithm.

config/transformations/07_exponential.py

e^x

Applies the exponential function.

config/transformations/08_cos.py

cos(x)

Applies cosine.

config/transformations/09_sin.py

sin(x)

Applies sine.

config/transformations/10_tan.py

tan(x)

Applies tangent.

config/transformations/11_arccos.py

arccos(x)

Applies inverse cosine.

config/transformations/12_arcsin.py

arcsin(x)

Applies inverse sine.

config/transformations/13_arctan.py

arctan(x)

Applies inverse tangent.

config/transformations/14_xrd_baseline_remove.py

XRD: Baseline Remove

Estimates and subtracts a smooth baseline from diffraction-style data.

Implementation Notes

Each function file should import only what it needs. For most transformations, numpy is enough. Avoid editing table widgets or figure-editor windows inside a function plugin; PhysPlot handles reading the selected column, writing the output column, and refreshing the plot.

Files with spaces in their names cannot be imported as normal Python modules. Prefer filenames such as 15_my_function.py.

Transformation Resolution

Built-in transforms and config/transformations plugins are resolved by the backend, so recorded plugin steps replay without the GUI.

Column transformations: registered built-ins plus config/transformations plugins.

Built-in transformations are registered in TRANSFORMS. Any other name is resolved against the transformation plugin folders returned by physplot.user_paths.plugin_search_dirs("transformations") (the editable Documents/PhysPlot/config/transformations first, then the bundled config/transformations). A plugin is a .py file defining transform(values) and, optionally, DISPLAY_NAME. It is matched by file stem ("02_square") first, then by DISPLAY_NAME ("x^2"), so a sequence that records a plugin transformation replays headlessly with no GUI imports.

discover_plugin_transforms() → list[dict][source]

Return every usable plugin in the transformation folders.

Each entry has name (the file stem, which is what sequences record), display_name, path and the loaded module. A user file overrides a bundled file with the same name. Plugins that fail to import, lack transform, or reuse a built-in transformation name are skipped with a message on stderr.

find_plugin_transform(name: str) → dict | None[source]

Resolve a plugin transformation by file stem, then by DISPLAY_NAME.

get_transform(name: str)[source]

Return a registered transformation, falling back to plugin transformations.

Plugin transformations are wrapped as f(series, multiplier=1.0, offset=0.0, **params) returning transform(values, **params) * multiplier + offset, which matches the Simple Mode controls.