# Module `redvox.api900.sensors.magnetometer_sensor`

This module contains classes and methods for working with magnetometer sensors.

Expand source code

    """
    This module contains classes and methods for working with magnetometer sensors.
    """

    import typing

    import numpy

    import redvox.api900.constants as constants
    import redvox.api900.lib.api900_pb2 as api900_pb2
    from redvox.api900.sensors.unevenly_sampled_channel import UnevenlySampledChannel
    from redvox.api900.sensors.xyz_unevenly_sampled_sensor import XyzUnevenlySampledSensor

    class MagnetometerSensor(XyzUnevenlySampledSensor):
        """
        Initializes this class.
        :param unevenly_sampled_channel: An instance of an UnevenlySampledChanel which contains magnetometer
        X, Y, and Z payload components.
        """

        def __init__(self, unevenly_sampled_channel: typing.Optional[UnevenlySampledChannel] = None):
            super().__init__(unevenly_sampled_channel,
                             api900_pb2.MAGNETOMETER_X,
                             api900_pb2.MAGNETOMETER_Y,
                             api900_pb2.MAGNETOMETER_Z)

        def _payload_values(self) -> numpy.ndarray:
            """
            returns the sensor payload as a numpy ndarray
            :return: magnetometer payload as a numpy ndarray
            """
            return self._unevenly_sampled_channel.get_multi_payload([
                api900_pb2.MAGNETOMETER_X,
                api900_pb2.MAGNETOMETER_Y,
                api900_pb2.MAGNETOMETER_Z
            ])

        def set_payload_values(self,
                               x_values: typing.Union[typing.List[float], numpy.ndarray],
                               y_values: typing.Union[typing.List[float], numpy.ndarray],
                               z_values: typing.Union[typing.List[float], numpy.ndarray]) -> 'MagnetometerSensor':
            """
            Sets this channel's payload with the provided equal length x, y, and z payload values.
            :param x_values: The x values.
            :param y_values: The y values.
            :param z_values: The z values.
            :return: An instance of the sensor.
            """
            self._set_payload_values(x_values, y_values, z_values, constants.PayloadType.FLOAT64_PAYLOAD)
            return self

## Classes

`class MagnetometerSensor (unevenly_sampled_channel: Optional[UnevenlySampledChannel] = None)`

  Initializes this class. :param unevenly_sampled_channel: An instance of an UnevenlySampledChanel which contains magnetometer X, Y, and Z payload components.

  Initializes this class. :param unevenly_sampled_channel: An instance of an UnevenlySampledChannel. :param x_type: The X channel type enum. :param y_type: The Y channel type enum. :param z_type: The Z channel type enum.

  Expand source code

      class MagnetometerSensor(XyzUnevenlySampledSensor):
          """
          Initializes this class.
          :param unevenly_sampled_channel: An instance of an UnevenlySampledChanel which contains magnetometer
          X, Y, and Z payload components.
          """

          def __init__(self, unevenly_sampled_channel: typing.Optional[UnevenlySampledChannel] = None):
              super().__init__(unevenly_sampled_channel,
                               api900_pb2.MAGNETOMETER_X,
                               api900_pb2.MAGNETOMETER_Y,
                               api900_pb2.MAGNETOMETER_Z)

          def _payload_values(self) -> numpy.ndarray:
              """
              returns the sensor payload as a numpy ndarray
              :return: magnetometer payload as a numpy ndarray
              """
              return self._unevenly_sampled_channel.get_multi_payload([
                  api900_pb2.MAGNETOMETER_X,
                  api900_pb2.MAGNETOMETER_Y,
                  api900_pb2.MAGNETOMETER_Z
              ])

          def set_payload_values(self,
                                 x_values: typing.Union[typing.List[float], numpy.ndarray],
                                 y_values: typing.Union[typing.List[float], numpy.ndarray],
                                 z_values: typing.Union[typing.List[float], numpy.ndarray]) -> 'MagnetometerSensor':
              """
              Sets this channel's payload with the provided equal length x, y, and z payload values.
              :param x_values: The x values.
              :param y_values: The y values.
              :param z_values: The z values.
              :return: An instance of the sensor.
              """
              self._set_payload_values(x_values, y_values, z_values, constants.PayloadType.FLOAT64_PAYLOAD)
              return self

  ### Ancestors

  - XyzUnevenlySampledSensor
  - UnevenlySampledSensor

  ### Methods

  `def set_payload_values(self, x_values: Union[List[float], numpy.ndarray], y_values: Union[List[float], numpy.ndarray], z_values: Union[List[float], numpy.ndarray]) ‑> MagnetometerSensor`

    Sets this channel's payload with the provided equal length x, y, and z payload values. :param x_values: The x values. :param y_values: The y values. :param z_values: The z values. :return: An instance of the sensor.

    Expand source code

        def set_payload_values(self,
                               x_values: typing.Union[typing.List[float], numpy.ndarray],
                               y_values: typing.Union[typing.List[float], numpy.ndarray],
                               z_values: typing.Union[typing.List[float], numpy.ndarray]) -> 'MagnetometerSensor':
            """
            Sets this channel's payload with the provided equal length x, y, and z payload values.
            :param x_values: The x values.
            :param y_values: The y values.
            :param z_values: The z values.
            :return: An instance of the sensor.
            """
            self._set_payload_values(x_values, y_values, z_values, constants.PayloadType.FLOAT64_PAYLOAD)
            return self

  ### Inherited members

  - `XyzUnevenlySampledSensor`:
    - `diff`
    - `metadata`
    - `metadata_as_dict`
    - `payload_type`
    - `payload_values_x`
    - `payload_values_x_mean`
    - `payload_values_x_median`
    - `payload_values_x_std`
    - `payload_values_y`
    - `payload_values_y_mean`
    - `payload_values_y_median`
    - `payload_values_y_std`
    - `payload_values_z`
    - `payload_values_z_mean`
    - `payload_values_z_median`
    - `payload_values_z_std`
    - `sample_interval_mean`
    - `sample_interval_median`
    - `sample_interval_std`
    - `sensor_name`
    - `set_metadata`
    - `set_metadata_as_dict`
    - `set_sensor_name`
    - `set_timestamps_microseconds_utc`
    - `timestamps_microseconds_utc`