How to use the stonesoup.types.state.State function in stonesoup

To help you get started, we’ve selected a few stonesoup examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dstl / Stone-Soup / stonesoup / platform / base.py View on Github external
no effect, but will return successfully.

        """
        # Compute time_interval
        try:
            time_interval = timestamp - self.state.timestamp
        except TypeError:
            # TypeError: (timestamp or prior.timestamp) is None
            time_interval = None

        # Return without moving static platforms
        if self.transition_model is None:
            self.state.timestamp = timestamp
            return self

        self.state = State(
            state_vector=self.transition_model.function(
                state_vector=self.state.state_vector,
                timestamp=timestamp,
                time_interval=time_interval,
                **kwargs),
            timestamp=timestamp)
github dstl / Stone-Soup / stonesoup / types / prediction.py View on Github external
from .state import State, GaussianState, ParticleState


class Prediction(Type):
    """ Prediction type

    This is the base prediction class. """


class MeasurementPrediction(Type):
    """ Prediction type

    This is the base measurement prediction class. """


class StatePrediction(State, Prediction):
    """ StatePrediction type

    Most simple state prediction type, which only has time and a state vector.
    """


class StateMeasurementPrediction(State, MeasurementPrediction):
    """ MeasurementPrediction type

    Most simple measurement prediction type, which only has time and a state
    vector.
    """


class GaussianStatePrediction(Prediction, GaussianState):
    """ GaussianStatePrediction type
github dstl / Stone-Soup / stonesoup / types / groundtruth.py View on Github external
# -*- coding: utf-8 -*-
from ..base import Property
from .state import State, StateMutableSequence


class GroundTruthState(State):
    """Ground Truth State type"""
    metadata = Property(dict, default=None,
                        doc='Dictionary of metadata items for Detections.')

    def __init__(self, state_vector, *args, **kwargs):
        super().__init__(state_vector, *args, **kwargs)
        if self.metadata is None:
            self.metadata = {}


class GroundTruthPath(StateMutableSequence):
    """Ground Truth Path type

    A :class:`~.StateMutableSequence` representing a track.
    """
github dstl / Stone-Soup / stonesoup / types / state.py View on Github external
# Don't proxy special/private attributes to `state`
            raise AttributeError(
                "{!r} object has no attribute {!r}".format(
                    type(self).__name__, item))
        else:
            return getattr(self.state, item)

    def insert(self, index, value):
        return self.states.insert(index, value)

    @property
    def state(self):
        return self.states[-1]


class GaussianState(State):
    """Gaussian State type

    This is a simple Gaussian state object, which, as the name suggests,
    is described by a Gaussian state distribution.
    """
    covar = Property(CovarianceMatrix, doc='Covariance matrix of state.')

    def __init__(self, state_vector, covar, *args, **kwargs):
        covar = CovarianceMatrix(covar)
        super().__init__(state_vector, covar, *args, **kwargs)
        if self.state_vector.shape[0] != self.covar.shape[0]:
            raise ValueError(
                "state vector and covar should have same dimensions")

    @property
    def mean(self):
github dstl / Stone-Soup / stonesoup / types / orbitalstate.py View on Github external
# -*- coding: utf-8 -*-
import datetime
import numpy as np
import string as strg

from ..base import Property
from .array import CovarianceMatrix, StateVector
from .state import State


class OrbitalState(State):

    r"""The orbital state base type. This is the building block of the
    orbital branch and follows the principle that you shouldn't have to
    worry too much what parameterisation you're using, the object
    stores the relevant information internally and can cope with
    whatever conversions are necessary.

    The :attr:`State.state_vector` is held as :math:`[\mathbf{r},
    \mathbf{v}]`, the "Orbital State Vector" as traditionally
    understood in orbital mechanics, where :math:`\mathbf{r}` is the
    Cartesian position in the primary-centered inertial frame while
    :math:`\mathbf{v}` is the corresponding velocity vector. All other
    parameters are accessed via functions.

    Construct using the appropriate :attr:`State.state_vector`
    :math:`X_{t_{0}}` at epoch :attr:`State.timestamp` :math:`t_0` and
github dstl / Stone-Soup / stonesoup / simulator / simple.py View on Github external
from ..models.transition import TransitionModel
from ..reader import GroundTruthReader
from ..types.detection import TrueDetection, Clutter
from ..types.groundtruth import GroundTruthPath, GroundTruthState
from ..types.numeric import Probability
from ..types.state import GaussianState, State
from .base import DetectionSimulator, GroundTruthSimulator
from stonesoup.buffered_generator import BufferedGenerator


class SingleTargetGroundTruthSimulator(GroundTruthSimulator):
    """Target simulator that produces a single target"""
    transition_model = Property(
        TransitionModel, doc="Transition Model used as propagator for track.")
    initial_state = Property(
        State,
        doc="Initial state to use to generate ground truth")
    timestep = Property(
        datetime.timedelta,
        default=datetime.timedelta(seconds=1),
        doc="Time step between each state. Default one second.")
    number_steps = Property(
        int, default=100, doc="Number of time steps to run for")

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.index = 0

    @BufferedGenerator.generator_method
    def groundtruth_paths_gen(self):
        time = self.initial_state.timestamp or datetime.datetime.now()
github dstl / Stone-Soup / stonesoup / types / update.py View on Github external
from .base import Type
from .hypothesis import Hypothesis
from .state import State, GaussianState, ParticleState


class Update(Type):
    """ Update type

    The base update class. Updates are returned by :class:'~.Updater' objects
    and contain the information that was used to perform the updating"""

    hypothesis = Property(Hypothesis,
                          doc="Hypothesis used for updating")


class StateUpdate(Update, State):
    """ StateUpdate type

    Most simple state update type, where everything only has time
    and a state vector. Requires a prior state that was updated,
    and the hypothesis used to update the prior.
    """


class GaussianStateUpdate(Update, GaussianState):
    """ GaussianStateUpdate type

    This is a simple Gaussian state update object, which, as the name
    suggests, is described by a Gaussian distribution.
    """
github dstl / Stone-Soup / stonesoup / platform / base.py View on Github external
# -*- coding: utf-8 -*-

from ..base import Base, Property
from ..types.state import State
from ..models.transition import TransitionModel


class Platform(Base):
    """Platform base class

    A platform represents a random object defined as a :class:`~.State`
    that moves according to a given :class:`~.TransitionModel`.
    """

    state = Property(State, doc="The platform state at any given point")
    transition_model = Property(
        TransitionModel, doc="Transition model")

    def move(self, timestamp=None, **kwargs):
        """Propagate the platform position using the :attr:`transition_model`.

        Parameters
        ----------
        timestamp: :class:`datetime.datetime`, optional
            A timestamp signifying when the end of the maneuver \
            (the default is `None`)

        Notes
        -----
        This methods updates the value of :attr:`position`.
github dstl / Stone-Soup / stonesoup / types / prediction.py View on Github external
class MeasurementPrediction(Type):
    """ Prediction type

    This is the base measurement prediction class. """


class StatePrediction(State, Prediction):
    """ StatePrediction type

    Most simple state prediction type, which only has time and a state vector.
    """


class StateMeasurementPrediction(State, MeasurementPrediction):
    """ MeasurementPrediction type

    Most simple measurement prediction type, which only has time and a state
    vector.
    """


class GaussianStatePrediction(Prediction, GaussianState):
    """ GaussianStatePrediction type

    This is a simple Gaussian state prediction object, which, as the name
    suggests, is described by a Gaussian distribution.
    """


class GaussianMeasurementPrediction(MeasurementPrediction, GaussianState):
github dstl / Stone-Soup / stonesoup / sensor / radar.py View on Github external
"""Rotate the sensor's antenna

        This method computes and updates the sensor's `dwell_center` property.

        Parameters
        ----------
        timestamp: :class:`datetime.datetime`
            A timestamp signifying when the rotation completes
        """

        # Compute duration since last rotation
        duration = timestamp - self.dwell_center.timestamp

        # Update dwell center
        rps = self.rpm/60  # rotations per sec
        self.dwell_center = State(
            StateVector([[self.dwell_center.state_vector[0, 0]
                          + duration.total_seconds()*rps*2*np.pi]]),
            timestamp
        )