eztaox.ts_utils
===============

.. py:module:: eztaox.ts_utils

.. autoapi-nested-parse::

   Utility functions for time series processing.



Functions
---------

.. autoapisummary::

   eztaox.ts_utils.down_sample_by_time
   eztaox.ts_utils.formatlc
   eztaox.ts_utils.add_noise
   eztaox.ts_utils.merge_two_sorted_argsort
   eztaox.ts_utils.merge_many_sorted_argsort
   eztaox.ts_utils.merge_sort


Module Contents
---------------

.. py:function:: down_sample_by_time(t_in, t_out) -> tinygp.helpers.JAXArray

   Downsample `t_in` to match the time points in `t_out`.

   :param t_in: Array of time values to be downsampled.
   :type t_in: JAXArray
   :param t_out: Array of target time values.
   :type t_out: JAXArray

   :returns: Downsampled array of time values.
   :rtype: JAXArray


.. py:function:: formatlc(ts: dict[str, numpy.typing.NDArray | tinygp.helpers.JAXArray], ys: dict[str, numpy.typing.NDArray | tinygp.helpers.JAXArray], yerrs: dict[str, numpy.typing.NDArray | tinygp.helpers.JAXArray], band_order: dict[str, int]) -> tuple[tuple[tinygp.helpers.JAXArray, tinygp.helpers.JAXArray], tinygp.helpers.JAXArray, tinygp.helpers.JAXArray]

   Transform light curves in dictionary to EzTaoX friendly format.

   :param ts: Time stamps for observation in each band.
   :type ts: dict[str, NDArray  |  JAXArray]
   :param ys: Observed values in each band.
   :type ys: dict[str, NDArray  |  JAXArray]
   :param yerrs: Uncertainties in observed values for
                 each band.
   :type yerrs: dict[str, NDArray  |  JAXArray]
   :param band_order: Mapping of band names to band indices.
   :type band_order: dict[str, int]

   :returns:

             Light curves formatted as
                 ((time stamps, band indices), observed values, uncertainties).
   :rtype: tuple[tuple[JAXArray, JAXArray], JAXArray, JAXArray]


.. py:function:: add_noise(y: tinygp.helpers.JAXArray, yerr: tinygp.helpers.JAXArray, key: jax.random.PRNGKey) -> tinygp.helpers.JAXArray

   Add Gaussian noise to a time series given measurement uncertainties.

   JAX-compatible (works with jit/vmap).

   :param y: Input values to which noise will be added.
   :type y: JAXArray
   :param yerr: Associated errors for the input values.
   :type yerr: JAXArray
   :param key: Pseudorandom number generator key used to
               draw the noise samples.
   :type key: jax.random.PRNGKey

   :returns: Array of the same shape as ``y`` with additive Gaussian noise applied.
   :rtype: JAXArray


.. py:function:: merge_two_sorted_argsort(a, b)

   Merge two sorted arrays and return the argsort permutation.

   :param a: First sorted array.
   :type a: JAXArray
   :param b: Second sorted array.
   :type b: JAXArray

   :returns: Indices that would sort the concatenation of ``a`` and ``b``.
   :rtype: JAXArray


.. py:function:: merge_many_sorted_argsort(arrays)

   Merge multiple sorted arrays and return the argsort permutation.

   :param arrays: List of sorted arrays to merge.
   :type arrays: list[JAXArray]

   :returns: Indices that would sort the concatenation of all input arrays.
   :rtype: JAXArray


.. py:function:: merge_sort(*arrays) -> tinygp.helpers.JAXArray

   Merge multiple sorted arrays and return the argsort permutation.

   :param \*arrays: Variable number of sorted arrays to merge.

   :returns: Indices that would sort the concatenation of all input arrays.
   :rtype: JAXArray


