photod.bayes
============

.. py:module:: photod.bayes


Attributes
----------

.. autoapisummary::

   photod.bayes.cc


Functions
---------

.. autoapisummary::

   photod.bayes.set_column_mapping
   photod.bayes.makeBayesEstimates3d
   photod.bayes.makeBayesPosteriors3d
   photod.bayes.getColorsAndPriorIndices
   photod.bayes.loopOverEachStar
   photod.bayes.calculateChi2
   photod.bayes.likeAndPrior
   photod.bayes.getMargPosteriors
   photod.bayes.postProcess
   photod.bayes.getEstimatesMeta


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

.. py:data:: cc
   :value: None


.. py:function:: set_column_mapping(variable_mapping: pathlib.Path)

   Set the column mapping used for this module.  Updates the module-global 'cc'
   ColumnMap object.


.. py:function:: makeBayesEstimates3d(starsData: nested_pandas.NestedFrame, priorGrid: numpy.ndarray, globalParams: photod.parameters.GlobalParams, batchSize: int = 100, returnPosteriors: bool = False)

   Compute the bayes statistics for all the stars in a catalog partition.

   Used for fast, large-scale processing. It leverages parallelization with JAX.


.. py:function:: makeBayesPosteriors3d(starsData: nested_pandas.NestedFrame, mapCatalog: lsdb.catalog.map_catalog.MapCatalog, globalParams: photod.parameters.GlobalParams)

   Compute the bayes posteriors for all the stars in a DataFrame.

   The posterior arrays are extremely large in memory and, therefore, this method should
   only be used with a handful set of stars.

   It does not use JAX for parallelization.


.. py:function:: getColorsAndPriorIndices(catalog, params)

.. py:function:: loopOverEachStar(starData, priorGrid, globalParams, returnPosteriors)

   Internal method with the logic to be run for each star.


.. py:function:: calculateChi2(colors, colorsErr, locusColors)

   Compute chi-squared map using provided 3D model locus.


.. py:function:: likeAndPrior(Ar1d, FeH1d, Mr1d, chi2map, priorGrid, priorIndices)

   Compute the likelihood map, the 3D (Mr, FeH, Ar) prior from 2D (Mr, FeH) prior
   using uniform prior for Ar, and the chi_sq_min.


.. py:function:: getMargPosteriors(priorCube, likeCube, postCube, dMr, dFeH, dAr)

   Get posterior information


.. py:function:: postProcess(Ar1d, FeH1d, Mr1d, postCube, QrGrid, QrIndices, margpostMr, margpostFeH, margpostAr)

   Get expectation values and uncertainties marginalize and get statistics.


.. py:function:: getEstimatesMeta()

   Creates an empty pd.DataFrame with the meta for the results


