Sweep

class Sweep(x: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], y: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], data: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], labels: dict | None = None, tags: dict | None = None)

2D parameter sweep with x and y 1D array parameters and data 2D array result

Attributes:
xarray_like

1D array with x-axis values – usually the primary parameter being swept.

yarray_like

1D array with y-axis values – usually the secondary parameter.

dataarray_like

2D array with shape == (x.size, y.size) containing the main result data.

labelsdict

Plot labels: ‘title’, ‘x’, ‘y’ and ‘data’.

tagsdict

Any additional user defined variables.

Attributes

_plain_labels

Labels with latex symbols stripped out

callsig

Methods

__getitem__(item)

Same rules as numpy indexing

_convolved(sigma[, axis])

Return a copy where the data is convolved with a Gaussian function

_plot_slice(axis, x, y, value[, ax])

_slice_x(x)

Return a slice of data nearest to x and the found values of x.

_slice_y(y)

Return a slice of data nearest to y and the found values of y.

_with_data(x, y, data)

_xy_grids()

Expand x and y into 2D arrays matching data.

colorbar(**kwargs)

Draw a colorbar with the label of Sweep.data

cropped([x, y])

Return a copy with data cropped to the limits in the x and/or y axes

interpolated([mul, size, kind])

Return a copy with interpolate data using scipy.interpolate.interp1d

mirrored([axis])

Return a copy with data mirrored in around specified axis

plot([ax])

Plot a 2D colormap of Sweep.data

plot_slice_x(x, **kwargs)

plot_slice_y(y, **kwargs)

save_txt(filename)

Save text file with 3 columns: x, y, data.

__getitem__(item: Tuple[int, int] | int) Sweep

Same rules as numpy indexing

colorbar(**kwargs)

Draw a colorbar with the label of Sweep.data

cropped(x: Tuple[float, float] | None = None, y: Tuple[float, float] | None = None) Sweep

Return a copy with data cropped to the limits in the x and/or y axes

A call with x=[-1, 2] will leave data only where -1 <= x <= 2.

Parameters:
x, yTuple[float, float]

Min and max data limit.

Returns:
Sweep
interpolated(mul: int | Tuple[int, int] | None = None, size: int | Tuple[int, int] | None = None, kind: Literal['linear', 'nearest', 'nearest-up', 'zero', 'slinear', 'quadratic', 'cubic', 'previous', 'next'] = 'linear') Sweep

Return a copy with interpolate data using scipy.interpolate.interp1d

Call with mul=2 to double the size of the x-axis and interpolate data to match. To interpolate in both axes pass a tuple, e.g. mul=(4, 2).

Parameters:
mulUnion[int, Tuple[int, int]]

Number of times the size of the axes should be multiplied.

sizeUnion[int, Tuple[int, int]]

New size of the axes. Zero will leave size unchanged.

kind

Forwarded to scipy.interpolate.interp1d.

Returns:
Sweep
mirrored(axis: Literal['x', 'y'] = 'x') Sweep

Return a copy with data mirrored in around specified axis

Only makes sense if the axis starts at 0.

Parameters:
axis‘x’ or ‘y’
Returns:
Sweep
plot(ax: Axes | None = None, **kwargs) QuadMesh

Plot a 2D colormap of Sweep.data

Parameters:
axOptional[plt.Axes]

The axis to plot on.

**kwargs

Forwarded to matplotlib.pyplot.pcolormesh().

save_txt(filename: str) None

Save text file with 3 columns: x, y, data.

Parameters:
filenamestr