|
| 1 | +.. _api_objects: |
| 2 | + |
| 3 | +Objects |
| 4 | +======= |
| 5 | + |
| 6 | +Data objects for signals and images, re-exported from Sigima. |
| 7 | + |
| 8 | +.. automodule:: datalab_kernel.objects |
| 9 | + :members: |
| 10 | + :undoc-members: |
| 11 | + :show-inheritance: |
| 12 | + |
| 13 | +SignalObj |
| 14 | +--------- |
| 15 | + |
| 16 | +The ``SignalObj`` class represents 1D signal data with X/Y arrays, |
| 17 | +optional error bars, metadata, units, and labels. |
| 18 | + |
| 19 | +See `Sigima SignalObj documentation <https://sigima.readthedocs.io/en/latest/api/objects.html>`_ |
| 20 | +for complete details. |
| 21 | + |
| 22 | +Basic usage: |
| 23 | + |
| 24 | +.. code-block:: python |
| 25 | +
|
| 26 | + from datalab_kernel.objects import SignalObj, create_signal |
| 27 | + import numpy as np |
| 28 | +
|
| 29 | + # Using create_signal (recommended) |
| 30 | + signal = create_signal( |
| 31 | + "My Signal", |
| 32 | + np.linspace(0, 10, 100), |
| 33 | + np.sin(np.linspace(0, 10, 100)), |
| 34 | + units=("s", "V"), |
| 35 | + labels=("Time", "Voltage"), |
| 36 | + ) |
| 37 | +
|
| 38 | + # Direct instantiation |
| 39 | + signal = SignalObj() |
| 40 | + signal.set_xydata(x_array, y_array) |
| 41 | + signal.title = "My Signal" |
| 42 | +
|
| 43 | +
|
| 44 | +ImageObj |
| 45 | +-------- |
| 46 | + |
| 47 | +The ``ImageObj`` class represents 2D image data with metadata, |
| 48 | +coordinate system, units, and labels. |
| 49 | + |
| 50 | +See `Sigima ImageObj documentation <https://sigima.readthedocs.io/en/latest/api/objects.html>`_ |
| 51 | +for complete details. |
| 52 | + |
| 53 | +Basic usage: |
| 54 | + |
| 55 | +.. code-block:: python |
| 56 | +
|
| 57 | + from datalab_kernel.objects import ImageObj, create_image |
| 58 | + import numpy as np |
| 59 | +
|
| 60 | + # Using create_image (recommended) |
| 61 | + image = create_image( |
| 62 | + "My Image", |
| 63 | + np.random.rand(256, 256), |
| 64 | + units=("mm", "mm", "counts"), |
| 65 | + labels=("X", "Y", "Intensity"), |
| 66 | + ) |
| 67 | +
|
| 68 | + # Direct instantiation |
| 69 | + image = ImageObj() |
| 70 | + image.data = data_2d |
| 71 | + image.title = "My Image" |
| 72 | +
|
| 73 | +
|
| 74 | +create_signal |
| 75 | +------------- |
| 76 | + |
| 77 | +Factory function for creating signal objects. |
| 78 | + |
| 79 | +.. code-block:: python |
| 80 | +
|
| 81 | + create_signal( |
| 82 | + title: str, |
| 83 | + x: np.ndarray | None = None, |
| 84 | + y: np.ndarray | None = None, |
| 85 | + dx: np.ndarray | None = None, |
| 86 | + dy: np.ndarray | None = None, |
| 87 | + metadata: dict | None = None, |
| 88 | + units: tuple[str, str] | None = None, |
| 89 | + labels: tuple[str, str] | None = None, |
| 90 | + ) -> SignalObj |
| 91 | +
|
| 92 | +**Parameters:** |
| 93 | + |
| 94 | +- ``title``: Signal title |
| 95 | +- ``x``: X data array |
| 96 | +- ``y``: Y data array |
| 97 | +- ``dx``: X error bars (optional) |
| 98 | +- ``dy``: Y error bars (optional) |
| 99 | +- ``metadata``: Additional metadata dictionary |
| 100 | +- ``units``: Tuple of (x_unit, y_unit) |
| 101 | +- ``labels``: Tuple of (x_label, y_label) |
| 102 | + |
| 103 | + |
| 104 | +create_image |
| 105 | +------------ |
| 106 | + |
| 107 | +Factory function for creating image objects. |
| 108 | + |
| 109 | +.. code-block:: python |
| 110 | +
|
| 111 | + create_image( |
| 112 | + title: str, |
| 113 | + data: np.ndarray | None = None, |
| 114 | + metadata: dict | None = None, |
| 115 | + units: tuple | None = None, |
| 116 | + labels: tuple | None = None, |
| 117 | + ) -> ImageObj |
| 118 | +
|
| 119 | +**Parameters:** |
| 120 | + |
| 121 | +- ``title``: Image title |
| 122 | +- ``data``: 2D data array |
| 123 | +- ``metadata``: Additional metadata dictionary |
| 124 | +- ``units``: Tuple of (x_unit, y_unit, z_unit) |
| 125 | +- ``labels``: Tuple of (x_label, y_label, z_label) |
0 commit comments