Base Data Types¶
Stone Soup base data types.
- class stonesoup.types.array.Matrix(*args, **kwargs)[source]
Matrix wrapper for
numpy.ndarray
This class returns a view to a
numpy.ndarray
It’s called same as tonumpy.asarray()
.
- class stonesoup.types.array.StateVector(*args, **kwargs)[source]
State vector wrapper for
numpy.ndarray
This class returns a view to a
numpy.ndarray
, but ensures that its initialised as an \(N \times 1\) vector. It’s called same asnumpy.asarray()
. The StateVector will attempt to convert the data given to a \(N \times 1\) vector if it can easily be done. E.g.,StateVector([1., 2., 3.])
,StateVector ([[1., 2., 3.,]])
, andStateVector([[1.], [2.], [3.]])
will all return the same 3x1 StateVector.It also overrides the behaviour of indexing such that my_state_vector[1] returns the second element (as int, float etc), rather than a StateVector of size (1, 1) as would be the case without this override. Behaviour of indexing with lists, slices or other indexing is unaffected (as you would expect those to return StateVectors). This override avoids the need for client to specifically index with zero as the second element (my_state_vector[1, 0]) to get a native numeric type. Iterating through the StateVector returns a sequence of numbers, rather than a sequence of 1x1 StateVectors. This makes the class behave as would be expected and avoids ‘gotchas’.
Note that code using the pattern my_state_vector[1, 0] will continue to work.
When slicing would result in return of a invalid shape for a StateVector (i.e. not (n, 1)) then a
Matrix
view will be returned.Note
It is not recommended to use a StateVector for indexing another vector. Doing so will lead to unexpected effects. Use a
tuple
,list
ornp.ndarray
for this.- flatten(order='C')[source]
Return a copy of the array collapsed into one dimension.
- Parameters
order ({'C', 'F', 'A', 'K'}, optional) – ‘C’ means to flatten in row-major (C-style) order. ‘F’ means to flatten in column-major (Fortran- style) order. ‘A’ means to flatten in column-major order if a is Fortran contiguous in memory, row-major order otherwise. ‘K’ means to flatten a in the order the elements occur in memory. The default is ‘C’.
- Returns
y – A copy of the input array, flattened to one dimension.
- Return type
ndarray
See also
ravel
Return a flattened array.
flat
A 1-D flat iterator over the array.
Examples
>>> a = np.array([[1,2], [3,4]]) >>> a.flatten() array([1, 2, 3, 4]) >>> a.flatten('F') array([1, 3, 2, 4])
- ravel([order])[source]
Return a flattened array.
Refer to numpy.ravel for full documentation.
See also
numpy.ravel
equivalent function
ndarray.flat
a flat iterator on the array.
- class stonesoup.types.association.Association(objects: Set)[source]
Association type
An association between objects
- Parameters
objects (
Set
) – Set of objects being associated
- objects: Set
Set of objects being associated
- class stonesoup.types.detection.Detection(state_vector: StateVector, timestamp: datetime.datetime = None, measurement_model: MeasurementModel = None, metadata: MutableMapping = None)[source]
Detection type
- Parameters
state_vector (
StateVector
) – State vector.timestamp (
datetime.datetime
, optional) – Timestamp of the state. Default None.measurement_model (
MeasurementModel
, optional) – The measurement model used to generate the detection (the default isNone
)metadata (
MutableMapping
, optional) – Dictionary of metadata items for Detections.
- measurement_model: stonesoup.models.measurement.base.MeasurementModel
The measurement model used to generate the detection (the default is
None
)
- metadata: MutableMapping
Dictionary of metadata items for Detections.
- class stonesoup.types.groundtruth.GroundTruthState(state_vector: StateVector, timestamp: datetime.datetime = None, metadata: MutableMapping = None)[source]
Ground Truth State type
- Parameters
state_vector (
StateVector
) – State vector.timestamp (
datetime.datetime
, optional) – Timestamp of the state. Default None.metadata (
MutableMapping
, optional) – Dictionary of metadata items for Detections.
- metadata: MutableMapping
Dictionary of metadata items for Detections.
- class stonesoup.types.groundtruth.GroundTruthPath(states: MutableSequence[GroundTruthState] = None, id: str = None)[source]
Ground Truth Path type
A
StateMutableSequence
representing a track.- Parameters
states (
MutableSequence[GroundTruthState]
, optional) – List of groundtruth states to initialise path with. Default None which initialises with an empty list.id (
str
, optional) – The unique path ID. Default None where random UUID is generated.
- states: MutableSequence[stonesoup.types.groundtruth.GroundTruthState]
List of groundtruth states to initialise path with. Default None which initialises with an empty list.
- id: str
The unique path ID. Default None where random UUID is generated.
- class stonesoup.types.hypothesis.Hypothesis[source]
Hypothesis base type
A Hypothesis has sub-types:
‘SingleHypothesis’, which consists of a prediction for a single Track and a single Measurement that might be associated with it
‘MultipleHypothesis’, which consists of a prediction for a single Track and multiple Measurements of which one might be associated with it
- class stonesoup.types.multihypothesis.MultipleHypothesis(single_hypotheses: Sequence[SingleHypothesis] = None, normalise: bool = False, total_weight: float = 1)[source]
Multiple Hypothesis base type
A Multiple Hypothesis is a container to store a collection of hypotheses.
- Parameters
single_hypotheses (
Sequence[SingleHypothesis]
, optional) – The initial list ofSingleHypothesis
. Default None which initialises with empty list.normalise (
bool
, optional) – Normalise probabilities ofSingleHypothesis
. Default is False.total_weight (
float
, optional) – When normalising, weights will sum to this. Default is 1.
- single_hypotheses: Sequence[stonesoup.types.hypothesis.SingleHypothesis]
The initial list of
SingleHypothesis
. Default None which initialises with empty list.
- normalise: bool
Normalise probabilities of
SingleHypothesis
. Default is False.
- total_weight: float
When normalising, weights will sum to this. Default is 1.
- class stonesoup.types.metric.Metric(title: str, value: Any, generator: Any)[source]
Metric type
- Parameters
title (
str
) – Name of the metricvalue (
Any
) – Value of the metricgenerator (
Any
) – Generator used to create the metric
- title: str
Name of the metric
- value: Any
Value of the metric
- generator: Any
Generator used to create the metric
- class stonesoup.types.particle.Particle(state_vector: StateVector, weight: float, parent: Particle = None)[source]
Particle type
A particle type which contains a state and weight
- Parameters
state_vector (
StateVector
) – State vectorweight (
float
) – Weight of particleparent (
Particle
, optional) – Parent particle
- state_vector: stonesoup.types.array.StateVector
State vector
- weight: float
Weight of particle
- parent: stonesoup.types.particle.Particle
Parent particle
- class stonesoup.types.prediction.Prediction(transition_model: TransitionModel = None)[source]
Prediction type
This is the base prediction class.
- Parameters
transition_model (
TransitionModel
, optional) – The transition model used to make the prediction
- classmethod from_state(state: State, *args: Any, prediction_type: Optional[Union[Prediction, MeasurementPrediction]] = None, **kwargs: Any) → Union[stonesoup.types.prediction.Prediction, stonesoup.types.prediction.MeasurementPrediction]
Return new (Measurement)Prediction instance of suitable type using existing properties
- Parameters
state (State) –
State
to use existing properties from, and identify prediction type from*args (Sequence) – Arguments to pass to newly created prediction, replacing those with same name on
state
parameter.prediction_type (
Prediction
orMeasurementPrediction
, optional) – Type to use for prediction, overriding one fromclass_mapping
.**kwargs (Mapping) – New property names and associate value for use in newly created prediction, replacing those on the
state
parameter.
- transition_model: stonesoup.models.transition.base.TransitionModel
The transition model used to make the prediction
- class stonesoup.types.sensordata.SensorData[source]
Sensor Data type
- class stonesoup.types.state.State(state_vector: StateVector, timestamp: datetime.datetime = None)[source]
State type.
Most simple state type, which only has time and a state vector.
- Parameters
state_vector (
StateVector
) – State vector.timestamp (
datetime.datetime
, optional) – Timestamp of the state. Default None.
- timestamp: datetime.datetime
Timestamp of the state. Default None.
- state_vector: stonesoup.types.array.StateVector
State vector.
- property ndim
The number of dimensions represented by the state.
- class stonesoup.types.track.Track(states: MutableSequence[State] = None, id: str = None, init_metadata: MutableMapping = {})[source]
Track type
A
StateMutableSequence
representing a track.- Notes:
Any manual modifications to
metadata
ormetadatas
will be overwritten if a state is inserted at a point prior to where the modifications are made. For example, inserting a state at the start ofstates
will result in ametadatas
update that will update all subsequent metadata values, resulting in manual metadata modifications being lost.
- Parameters
states (
MutableSequence[State]
, optional) – The initial states of the track. Default None which initialises with empty list.id (
str
, optional) – The unique track IDinit_metadata (
MutableMapping
, optional) – Initial dictionary of metadata items for track. Default None which initialises track metadata as an empty dictionary.
- states: MutableSequence[stonesoup.types.state.State]
The initial states of the track. Default None which initialises with empty list.
- init_metadata: MutableMapping
Initial dictionary of metadata items for track. Default None which initialises track metadata as an empty dictionary.
- id: str
The unique track ID
- property metadata
Current metadata dictionary of track. If track contains no states, this is the initial metadata dictionary
init_metadata
.
- class stonesoup.types.update.Update(hypothesis: Hypothesis)[source]
Update type
The base update class. Updates are returned by :class:’~.Updater’ objects and contain the information that was used to perform the updating
- Parameters
hypothesis (
Hypothesis
) – Hypothesis used for updating
- hypothesis: stonesoup.types.hypothesis.Hypothesis
Hypothesis used for updating
- classmethod from_state(state: State, *args: Any, update_type: Optional[Update] = None, **kwargs: Any) → stonesoup.types.update.Update
Return new Update instance of suitable type using existing properties
- Parameters
state (State) –
State
to use existing properties from, and identify update type from*args (Sequence) – Arguments to pass to newly created update, replacing those with same name on
state
parameter.update_type (
Update
, optional) – Type to use for update, overriding one fromclass_mapping
.**kwargs (Mapping) – New property names and associate value for use in newly created update, replacing those on the
state
parameter.