spotter.utils
=============

.. py:module:: spotter.utils

.. autoapi-nested-parse::

   Utility functions for spherical harmonics, HEALPix, and conversions.

   This module provides helper functions for working with spherical harmonics,
   converting between representations, and mapping to HEALPix.



Functions
---------

.. autoapisummary::

   spotter.utils.sigmoid
   spotter.utils.y1d_to_2d
   spotter.utils.y2d_to_1d
   spotter.utils.C
   spotter.utils.ylm_to_hp


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

.. py:function:: sigmoid(x, scale=1000)

   Numerically stable sigmoid function.

   :param x: Input value(s).
   :type x: float or array_like
   :param scale: Scaling factor (default 1000).
   :type scale: float, optional

   :returns: **y** -- Output value(s) in [0, 1].
   :rtype: float or array_like


.. py:function:: y1d_to_2d(ydeg: int, flm_1d: numpy.ndarray) -> numpy.ndarray

   Convert 1D starry Ylm to 2D s2fft format.

   :param ydeg: Maximum degree.
   :type ydeg: int
   :param flm_1d: 1D array of coefficients.
   :type flm_1d: ndarray

   :returns: **flm_2d** -- 2D array of coefficients.
   :rtype: ndarray


.. py:function:: y2d_to_1d(ydeg: int, flm_2d: numpy.ndarray) -> numpy.ndarray

   Convert 2D s2fft Ylm to 1D starry format.

   :param ydeg: Maximum degree.
   :type ydeg: int
   :param flm_2d: 2D array of coefficients.
   :type flm_2d: ndarray

   :returns: **flm_1d** -- 1D array of coefficients.
   :rtype: ndarray


.. py:function:: C(l)

   Complex to real spherical harmonics conversion matrix.

   :param l: Degree.
   :type l: int

   :returns: **C** -- Conversion matrix.
   :rtype: ndarray


.. py:function:: ylm_to_hp(y, N)

   Convert a ylm array (starry-like) to healpy coefficients and map.

   :param y: Spherical harmonic coefficients.
   :type y: ndarray
   :param N: HEALPix nside.
   :type N: int

   :returns: **mh** -- HEALPix map.
   :rtype: ndarray


