qsrlib_io.world_qsr_trace module¶
-
class
qsrlib_io.world_qsr_trace.
QSR
(timestamp, between, qsr, qsr_type='')[source]¶ Bases:
object
Data class structure that is holding the QSR and other related information.
-
between
= None¶ str: For which object(s) is the QSR for. Multiple objects are comma separated, e.g. “o1,o2”.
-
qsr
= None¶ dict: QSR value(s). It is a dictionary where the keys are the unique names of each QSR and the values are the QSR values as strings.
-
timestamp
= None¶ float: Timestamp of the QSR, which usually matches the corresponding key t in World_QSR_Trace.trace[t].
-
type
= None¶ str: Name of the QSR. For multiple QSRs it is usually a sorted comma separated string.
-
-
class
qsrlib_io.world_qsr_trace.
World_QSR_State
(timestamp, qsrs=None)[source]¶ Bases:
object
Data class structure that is holding various information about the QSR world at a particular time.
-
add_qsr
(qsr)[source]¶ Add/Overwrite a QSR object to the state.
Parameters: qsr (QSR) – QSR to be added in the world QSR state.
-
qsrs
= None¶ dict: Holds the QSRs that exist in this world QSR state, i.e. a dict of objects of type QSR with the keys being the object(s) names that these QSR are for.
-
timestamp
= None¶ float: Timestamp of the state, which matches the corresponding key t in World_QSR_Trace.trace[t].
-
-
class
qsrlib_io.world_qsr_trace.
World_QSR_Trace
(qsr_type, trace=None)[source]¶ Bases:
object
Data class structure that is holding a time series of the world QSR states.
-
add_qsr
(qsr, timestamp)[source]¶ Add/Overwrite a QSR at timestamp.
Parameters: - qsr (QSR) – QSR object to be added.
- timestamp (float) – Timestamp of the QSR.
-
add_world_qsr_state
(world_qsr_state)[source]¶ Add/Overwrite a world QSR state.
Parameters: world_qsr_state (World_QSR_State) – World QSR state to be added.
-
get_at_timestamp_range
(start=None, stop=None, istep=1, copy_by_reference=False, include_finish=True)[source]¶ Return a subsample between start and stop timestamps.
Parameters: - start (int or float) – Sstart timestamp.
- stop (int or float) – Finish timestamp. If empty then stop is set to the last timestamp.
- istep (int) – subsample based on istep measured in timestamps list index
- copy_by_reference (bool) – Return a copy or by reference.
- include_finish (bool) – Whether to include or not the world state at the stop timestamp.
Returns: Subsample between start and stop.
Return type:
-
get_for_objects
(objects_names, copy_by_reference=False)[source]¶ Return a subsample for requested objects.
Parameters: - objects_names (list or tuple of str) – Requested objects names.
- copy_by_reference (bool) – Return a copy or by reference.
Returns: Subsample for the requested objects.
Return type:
-
get_for_qsrs
(qsrs_list)[source]¶ Return a subsample for requested QSRs only.
Parameters: qsrs_list (list of str) – List of requested QSRs. Returns: Subsample for the requested QSRs. Return type: World_QSR_Trace
-
get_last_state
(copy_by_reference=False)[source]¶ Get the last world QSR state.
Parameters: copy_by_reference (bool) – Return a copy or by reference. Returns: Last world QSR state in self.trace. Return type: World_QSR_State
-
get_sorted_timestamps
()[source]¶ Return a sorted list of the timestamps.
Returns: Sorted list of the timestamps. Return type: list of floats
-
put_empty_world_qsr_state
(timestamp)[source]¶ Put an empty
World_QSR_State
object at timestamp.Parameters: timestamp (float) – Timestamp of where to add an empty World_QSR_State Returns:
-
qsr_type
= None¶ str: Name of the QSR. For multiple QSRs it is usually a sorted comma separated string.
-
trace
= None¶ dict: Time series of world QSR states, i.e. a dict of objects of type
World_QSR_State
with the keys being the timestamps.
-