datasim.Quantity¶
- class datasim.Quantity(world, id: str, quantity_type: str, start_value: int | float | None = None, min: int | float | None = None, max: int | float | None = None, gather: bool = True, data_id: str = '', sample_frequency: int = 1, plot_options: ~datasim.types.PlotOptions = <datasim.types.PlotOptions object>)¶
Representation of a custom quantity that can be automatically saved and plotted.
- __init__(world, id: str, quantity_type: str, start_value: int | float | None = None, min: int | float | None = None, max: int | float | None = None, gather: bool = True, data_id: str = '', sample_frequency: int = 1, plot_options: ~datasim.types.PlotOptions = <datasim.types.PlotOptions object>)¶
Create a quantity.
- Parameters:
world (World) – the World to add this quantity to.
id (str) – Descriptive name of the quantity.
start_value (int | float | None, optional) – Starting value of the quantity. If set to None, won’t add data points until __set__ is called, even if gather is set and sample_frequency is greater than zero. Defaults to None.
min (int | float | None, optional) – Optional minimum value of the quantity. If set, any attempts to set an amount below this value will be clamped off. Defaults to None.
max (int | float | None, optional) – Optional maximum value of the quantity. If set, any attempts to set an amount above this value will be clamped off. Defaults to None.
gather (PlotType or False, optional) – Whether to automatically gather data for the output for this quantity, and which type of plot if so. Defaults to PlotType.none to only save.
data_id (str, optional) – id for the data source if gather is True. Defaults to empty string which sets data_id to the value of this Quantity’s id.
sample_frequency (int, optional) – Whether to add a data point every frequency ticks. If set to 0, adds a data point only when the quantity changes. Defaults to 0.
plot_options (Optional[PlotOptions], optional) – Options for a plot. Defaults to default PlotOptions.
Methods
__init__
(world, id, quantity_type[, ...])Create a quantity.
add_output
([data_id, frequency, plot_options])Create an output source for this Quantity.
Attributes
value
Current value of the quantity.
world
Unique identifier of the quantity.
id
Descriptive type of things or unit of the quantity (also used as plot axis legend).
quantity_type
Optional minimum value of the quantity.
min
Optional maximum value of the quantity.
max