Skip to content

senxor.utils

senxor.utils

Utilities for Senxor devices.

list_senxor(interface='serial', **kwargs)

list_senxor() -> list[SerialPort]
list_senxor(interface: Literal['serial']) -> list[SerialPort]

List available Senxor devices.

Parameters:

Name Type Description Default

interface

Literal['serial']

The interface type to list devices for, by default "serial"

'serial'

**kwargs

Additional arguments for backward compatibility.

{}

Returns:

Type Description
Sequence[IDevice]

A list of available Senxor devices.

Raises:

Type Description
ValueError

If the interface type is not supported.

connect(device=None, *, auto_open=True, **kwargs)

connect(device: SerialPort, *, auto_open: bool = True) -> Senxor[SerialPort]
connect(device: None, *, auto_open: bool = True) -> Senxor[SerialPort]

Connect to a Senxor device.

Parameters:

Name Type Description Default

device

ListPortInfo | None

The device to connect to, by default None If None, the first serial device is connected.

None

auto_open

bool

Whether to automatically open the device, by default True

True

**kwargs

Additional arguments to pass to the Senxor constructor.

{}

Returns:

Type Description
Senxor

The Senxor device.

Raises:

Type Description
ValueError

If the device type is not supported.

Examples:

>>> from senxor import list_senxor, connect
>>> devices = list_senxor("serial")
>>> senxor = connect(devices[0])
>>> senxor.open()

remap(image, in_range=None, out_range=None, dtype=np.uint8)

Remap image intensity to a desired range and data type using NumPy.

It's equivalent to normalize(..., dtype=np.uint8).

Parameters:

Name Type Description Default

image

ndarray

The image to remap.

required

in_range

tuple | None

The input range of the image. If None, the image's min/max are used.

None

out_range

tuple | None

The output range of the image.

None

dtype

Any

The data type of the image.

uint8

Returns:

Type Description
ndarray

The remapped image.