bw_temporalis.temporal_distribution
Attributes
Classes
An absolute TemporalDistribution that ignores other temporal information. |
|
Instead of creating a relative shift in time, regardless of the starting datetime or the properties of the system being modeled, create an absolute period in the first available year. |
|
Base class for functions which can be multiplied by temporal distributions |
|
A container for a series of amount spread over time. |
|
Base class for temporal distributions |
Module Contents
- class bw_temporalis.temporal_distribution.FixedTD(date: numpy.typing.NDArray[numpy.datetime64 | numpy.timedelta64], amount: numpy.typing.NDArray)[source]
Bases:
TemporalDistributionAn absolute TemporalDistribution that ignores other temporal information.
- class bw_temporalis.temporal_distribution.FixedTimeOfYearTD(date: numpy.typing.NDArray[numpy.timedelta64], amount: numpy.typing.NDArray, allow_overlap: bool | None = False)[source]
Bases:
TemporalDistributionInstead of creating a relative shift in time, regardless of the starting datetime or the properties of the system being modeled, create an absolute period in the first available year.
The fixed time of year is a relative temporal distribution, and must already be constructed as such.
When multiplied by another temporal distribution, the entire period of the FixedTimeOfYear must lie before the other distribution, or else the FixedTimeOfYear is shifted back a year. In other words, a FixedTimeOfYear of March to May could be multiplied by August 2020 and result in March to May 2020, but if multiplied by April 2020 it would result in March to May 2019. To allow partial overlaps and stay in the same year, set allow_overlap to True. In any case, the start of the FixedTimeOfYear must be before the start of the temporal distribution being multiplied or it is shifted back a year.
- class bw_temporalis.temporal_distribution.TDAware[source]
Base class for functions which can be multiplied by temporal distributions
- class bw_temporalis.temporal_distribution.TemporalDistribution(date: numpy.typing.NDArray[numpy.datetime64 | numpy.timedelta64], amount: numpy.typing.NDArray)[source]
Bases:
TemporalDistributionBaseA container for a series of amount spread over time. :param * date: 1D array containg temporal info of amount with type timedelta64 or datetime64 . :type * date: ndarray :param * amount: 1D array containg amount with type float :type * amount: ndarray :param Times and amount must have same length and element of amount must correspond to the element of date: :param with the same index.:
- classmethod from_json(json_obj: str | collections.abc.Mapping) TemporalDistributionBase[source]
- simplify(threshhold: int | None = 1000, num_clusters: int | None = None, iterations: int | None = 30) TemporalDistribution[source]
Use clustering to simplify a TemporalDistribution with more than threshhold number of points.
Uses the kmeans2 implementation of KNN from [scipy.cluster.vq](https://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.vq.kmeans2.html). Subclass and override this method to get a custom clustering algorithm.
This isn’t perfect, kmeans2 produces “lumpy” distributions - to see this graph the simplification of a uniform distribution with many points.
- Parameters:
threshhold (int, optional) – The number of date points above which simplification is triggered
iterations (int, optional) – iter parameters to feed to kmeans2
- Return type:
Either self (if no simplification) or a new instance of TemporalDistribution.
- class bw_temporalis.temporal_distribution.TemporalDistributionBase[source]
Base class for temporal distributions