.. _time_series_access: ==================== Time-series access ==================== Since one dimension of time-series data is associated with time, there is a natural way to index into time-series data using time objects as indices. For the data classes (:ref:`time_series_classes`) an indexing operation performed with a single time-point (a single-element :class:`TimeArray` or a :class:`TimeArray` with more than one element) should result in returning the data at that time-point - that is, removal of the time-dimension from the data. The base-classes representing time (:ref:`time_classes`) serve as natural intermediaries in this process, by providing the integer index of a particular time-point (or returning an array of integers, as the case may be, see below). Therefore, these classes should include a method which performs this conversion, :func:`index_at`. This function should accept as parameter a :class:`TimeArray` and return integers corresponding to the location of that time-point in the different types of time classes. Access into Time classes ------------------------ :class:`EventArray` ~~~~~~~~~~~~~~~~~~~ :func:`ev.index_at` returns the indices of the values in the array that are *closest* to t. That is, it returns i, such that $|(t-t_i)|$ is the minimal. Potentially, an optional 'tolerance' argument can be implemented, specifying a maximal time difference between the index time and the returned time. :class:`NonUniformTime` ~~~~~~~~~~~~~~~~~~~~~~~ As above, :func:`nut.index_at` also returns the indices in the array that are closest to t. Since :class:`NonUniformTime` is ordered, this should give you either the index below or the index above the time-point you provide as input, depending on what interval ($|t-t_i|$ or $|t-t_{i+1}|$) is smaller. :class:`UniformTime` ~~~~~~~~~~~~~~~~~~~~ :func:`ut.index_at` returns the indices of the values in the array that are the largest time values, smaller than the input values t. That is, it returns i for which $t_i$ is the maximal one, which still fulfills: $t_i