continuous_timeseries.time_axis#
Definition of TimeAxis
This is a container that stores our representation of a time axis.
It is designed to be compatible with the
Timeseries,
TimeseriesContinuous,
and TimeseriesDiscrete
classes.
The idea is that the time axis' intent is made clear
and clearly differentiated from a plain array.
The bounds provided to the TimeAxis
instance define the bounds of each time step in the time series.
These bounds are provided as one-dimensional arrays.
The first time step runs from bounds[0] to bounds[1],
the second from bounds[1] to bounds[2],
the third from bounds[2] to bounds[3] etc.
(the nth time step runs from bounds[n-1] to bounds[n]).
The design means that the bounds are always contiguous.
In other words, we can have a time axis concept and API
without the headaches of having to handle arbitrary time steps,
particularly those that have gaps.
This is clearly a design trade-off.
One other consequence of this container's structure is
that you can't have bounds which start before the first value.
In other words, the start of the first timestep
is always equal to the first value held by the TimeAxis instance.
However, we can't think of a situation in which that is a problem
(and setting it up this way makes life much simpler).
As background, we considered supporting arbitrary bounds following something like the CF-Conventions and cf-python. However, this introduces many more complexities. For our use case, these were not deemed desirable or relevant so we went for this simplified approach. If there were a clear use case, it would probably not be difficult to create a translation between this package and e.g. cf-python.
Classes:
| Name | Description |
|---|---|
TimeAxis |
Time axis representation |
TimeAxis #
Time axis representation
Methods:
| Name | Description |
|---|---|
__str__ |
Get string representation of self |
bounds_validator |
Validate the received bounds |
Attributes:
| Name | Type | Description |
|---|---|---|
bounds |
PINT_NUMPY_ARRAY
|
Bounds of each time step in the time axis. |
bounds_2d |
PINT_NUMPY_ARRAY
|
Get the bounds of the time steps in two-dimensions |
Source code in src/continuous_timeseries/time_axis.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
bounds
class-attribute
instance-attribute
#
bounds: PINT_NUMPY_ARRAY = field()
Bounds of each time step in the time axis.
Must be one-dimensional and monotonically increasing.
The first time step runs from bounds[0] to bounds[1],
the second from bounds[1] to bounds[2],
the third from bounds[2] to bounds[3] etc.
(the nth step runs from bounds[n-1] to bounds[n]).
As a result, if bounds has length n, then it defines n - 1 time steps.
bounds_2d
property
#
bounds_2d: PINT_NUMPY_ARRAY
Get the bounds of the time steps in two-dimensions
This representation can be useful for some operations.
Returns:
| Type | Description |
|---|---|
PINT_NUMPY_ARRAY
|
Bounds of the time steps in two-dimensions (bounds is the second dimension i.e. has size 2). |
bounds_validator #
bounds_validator(
attribute: Attribute[Any], value: PINT_NUMPY_ARRAY
) -> None
Validate the received bounds