petitRADTRANS.temperature_profiles
==================================

.. py:module:: petitRADTRANS.temperature_profiles


Submodules
----------

.. toctree::
   :maxdepth: 1

   /autoapi/petitRADTRANS/temperature_profiles/gradient/index
   /autoapi/petitRADTRANS/temperature_profiles/guillot/index
   /autoapi/petitRADTRANS/temperature_profiles/isothermal/index
   /autoapi/petitRADTRANS/temperature_profiles/madhusudhan/index
   /autoapi/petitRADTRANS/temperature_profiles/molliere/index
   /autoapi/petitRADTRANS/temperature_profiles/power_law/index
   /autoapi/petitRADTRANS/temperature_profiles/spline/index


Functions
---------

.. autoapisummary::

   petitRADTRANS.temperature_profiles.zhang_2023_temperature_profile
   petitRADTRANS.temperature_profiles.guillot_temperature_profile
   petitRADTRANS.temperature_profiles.guillot_dayside_temperature_profile
   petitRADTRANS.temperature_profiles.guillot_global_temperature_profile
   petitRADTRANS.temperature_profiles.guillot_global_ret_temperature_profile
   petitRADTRANS.temperature_profiles.guillot_metallic_temperature_profile
   petitRADTRANS.temperature_profiles.guillot_modif_temperature_profile
   petitRADTRANS.temperature_profiles.isothermal_temperature_profile
   petitRADTRANS.temperature_profiles.madhusudhan_seager_temperature_profile
   petitRADTRANS.temperature_profiles.molliere_2020_temperature_profile
   petitRADTRANS.temperature_profiles.power_law_temperature_profile
   petitRADTRANS.temperature_profiles.linear_spline_temperature_profile
   petitRADTRANS.temperature_profiles.cubic_spline_temperature_profile


Package Contents
----------------

.. py:function:: zhang_2023_temperature_profile(pressures: jax.typing.ArrayLike, num_layer: int, layer_pt_slopes: jax.typing.ArrayLike, t_bottom: float, top_of_atmosphere_pressure: float = -3, bottom_of_atmosphere_pressure: float = 3) -> jax.Array

   This function takes the temperature gradient at a set number of spline points and interpolates a temperature
   profile as a function of pressure. Based on the method described in Zhang et al. (2023).

   Args:
       pressures: The pressure array in bar.
       num_layer: The number of layers. Default for covering 10^3 to 10^-3 bar as in Zhang 2023 is 6.
           To cover 10^3 to 10^-6 bar 10 is recommended.
       layer_pt_slopes: The temperature gradient (d(ln T) / d(ln P)) at the spline points.
       t_bottom: The temperature at the bottom of the atmosphere.
       top_of_atmosphere_pressure: Minimum atmospheric pressure in log bar. If the pressure array extends
           beyond this value, the temperature structure at lower pressures will be isothermal.
       bottom_of_atmosphere_pressure: Maximum atmospheric pressure in log bar.

   Returns:
       The temperature profile in K.


.. py:function:: guillot_temperature_profile(pressures: jax.typing.ArrayLike, infrared_mean_opacity: float, gamma: float, gravities: jax.typing.ArrayLike, intrinsic_temperature: float, equilibrium_temperature: float, redistribution_coefficient: float = 0.25) -> jax.Array

   Returns a temperature array, in units of K, of the same dimensions as the pressure P (in bar).

   For this the temperature model of Guillot (2010) is used (his Equation 29).
   Source: https://doi.org/10.1051/0004-6361/200913396

   Args:
       pressures: Array of pressures in bar.
       infrared_mean_opacity: The infrared mean opacity in units of cm^2/g.
       gamma: The ratio between the visual and infrared mean opacities.
       gravities: The planetary gravity at the given pressures in units of cm/s^2.
       intrinsic_temperature: The planetary intrinsic temperature in K.
       equilibrium_temperature: The planetary equilibrium temperature in K.
       redistribution_coefficient: The redistribution coefficient of the irradiance. A value of 1 corresponds to the
           substellar point, 1/2 for the day-side average and 1/4 for the global average.
   Returns:
       The temperature profile in K.


.. py:function:: guillot_dayside_temperature_profile(pressures: jax.typing.ArrayLike, infrared_mean_opacity: float, gamma: float, gravities: jax.typing.ArrayLike, intrinsic_temperature: float, equilibrium_temperature: float) -> jax.Array

   Returns a dayside temperature array, in units of K, using the Guillot (2010) model.

   This is a wrapper for `guillot_temperature_profile` with `redistribution_coefficient` set to 0.5,
   which corresponds to an average over the day side of the planet.

   Args:
       pressures: Array of pressures in bar.
       infrared_mean_opacity: The infrared mean opacity in units of cm^2/g.
       gamma: The ratio between the visual and infrared mean opacities.
       gravities: The planetary gravity at the given pressures in units of cm/s^2.
       intrinsic_temperature: The planetary intrinsic temperature in K.
       equilibrium_temperature: The planetary equilibrium temperature in K.
   Returns:
       The temperature profile in K.


.. py:function:: guillot_global_temperature_profile(pressures: jax.typing.ArrayLike, infrared_mean_opacity: float, gamma: float, gravities: jax.typing.ArrayLike, intrinsic_temperature: float, equilibrium_temperature: float) -> jax.Array

   Returns a global average temperature array, in units of K, using the Guillot (2010) model.

   This is a wrapper for `guillot_temperature_profile` with `redistribution_coefficient` set to 0.25,
   which corresponds to an average over the whole planetary surface.

   Args:
       pressures: Array of pressures in bar.
       infrared_mean_opacity: The infrared mean opacity in units of cm^2/g.
       gamma: The ratio between the visual and infrared mean opacities.
       gravities: The planetary gravity at the given pressures in units of cm/s^2.
       intrinsic_temperature: The planetary intrinsic temperature in K.
       equilibrium_temperature: The planetary equilibrium temperature in K.
   Returns:
       The temperature profile in K.


.. py:function:: guillot_global_ret_temperature_profile(pressures: jax.typing.ArrayLike, delta: float, gamma: float, intrinsic_temperature: float, equilibrium_temperature: float) -> jax.Array

   Global Guillot P-T formula for retrievals, with kappa/gravity replaced by delta.

   This function is a variation of the Guillot (2010) temperature profile, where the ratio of the
   mean infrared opacity to gravity (kappa/g) is replaced by a single parameter, delta.
   This is useful for retrieval applications where gravity is fixed and opacity is a parameter.

   Args:
       pressures: Array of pressures in bar.
       delta: Proportionality factor for optical depth, equal to kappa_ir / g, where kappa_ir is the
              infrared mean opacity (cm^2/g) and g is the gravity (cm/s^2).
       gamma: The ratio between the visual and infrared mean opacities.
       intrinsic_temperature: The planetary intrinsic temperature in K.
       equilibrium_temperature: The planetary equilibrium temperature in K.
   Returns:
       The temperature profile in K.


.. py:function:: guillot_metallic_temperature_profile(pressures: jax.typing.ArrayLike, gamma: float, reference_gravity: jax.typing.ArrayLike, intrinsic_temperature: float, equilibrium_temperature: float, infrared_mean_opacity_solar_metallicity: float, metallicity: Optional[float] = None) -> jax.Array

   Get a Guillot temperature profile depending on metallicity.

   This function calculates a global average Guillot temperature profile, where the infrared mean
   opacity is scaled with metallicity.

   Args:
       pressures: Array of pressures in bar.
       gamma: Ratio between visual and infrared opacity.
       reference_gravity: Surface gravity in cm/s^2.
       intrinsic_temperature: Intrinsic temperature in K.
       equilibrium_temperature: Equilibrium temperature in K.
       infrared_mean_opacity_solar_metallicity: Infrared mean opacity for a solar metallicity (Z=1)
           atmosphere, in cm^2/g.
       metallicity: Ratio of heavy elements abundance over H abundance with respect to the solar ratio.
           If None, solar metallicity is assumed.
   Returns:
       The temperature profile in K.


.. py:function:: guillot_modif_temperature_profile(pressures: jax.typing.ArrayLike, delta: float, gamma: float, intrinsic_temperature: float, equilibrium_temperature: float, ptrans: float, alpha: float) -> jax.Array

   Modified Guillot P-T formula for retrievals.

   This function uses the `guillot_global_ret_temperature_profile` and applies a
   modifying factor to the temperature profile. The modification is controlled by `alpha`
   and `ptrans`, which can shape the profile around a transition pressure.

   Args:
       pressures: Array of pressures in bar.
       delta: Proportionality factor for optical depth, equal to kappa_ir / g.
       gamma: The ratio between the visual and infrared mean opacities.
       intrinsic_temperature: The planetary intrinsic temperature in K.
       equilibrium_temperature: The planetary equilibrium temperature in K.
       ptrans: Transition pressure in bar, where the modification is centered.
       alpha: A parameter controlling the strength and shape of the temperature modification.
   Returns:
       The modified temperature profile in K.


.. py:function:: isothermal_temperature_profile(pressures: jax.typing.ArrayLike, temperature: float) -> jax.Array

   Returns an isothermal temperature profile.

   Args:
       pressures: An array of pressures. The shape is preserved for the output temperatures.
       temperature: The constant temperature value for the profile.

   Returns:
       An array of temperatures with the same shape as `pressures`, all set to the input `temperature`.


.. py:function:: madhusudhan_seager_temperature_profile(pressures: jax.typing.ArrayLike, log_pressure_points: tuple[float], temperature_reference: float, alpha_points: tuple[float], beta_points: tuple[float]) -> jax.Array

   Calculate temperatures based on the Madhusudhan and Seager (2009) parameterization.

   This function computes temperatures using the Madhu and Seager (2009) parameterization
   for a given set of pressure values, pressure breakpoints, temperature breakpoints,
   alpha values, and beta values.

   Based off of the POSEIDON implementation:
   https://github.com/MartianColonist/POSEIDON/blob/main/POSEIDON/atmosphere.py

   Parameters:
       pressures : (numpy.ndarray)
           An array of pressure values (in bar) at which to calculate temperatures.
       log_pressure_points : (list)
           A list of log10 pressure breakpoints defining different temperature regimes.
           The zeroth element is the minimum pressure, should be log10(press[0]).
           The first element is the 1-2 boundary
           The second element is the level of the inversion
           The third element is the 2-3 boundary.
           The fourth element is the pressure at which the temperature is set (P_set).
       temperature_reference : (float)
           A temperature at log_pressure_points[4] used to constrain the temperature profile.
       alpha_points : (list)
           A list of alpha values used in the parameterization for different regimes.
           Must have length 2.
       beta_points : (list)
           A list of beta values used in the parameterization for different regimes.
           By default, b[0] == b[1] == 0.5, unclear how well this will work if these aren't used!
           Must have length 2.

   Returns:
       temperatures : (numpy.ndarray)
           An array of calculated temperatures (in K) corresponding to the input pressure values.

   Reference:
   - Madhusudhan, N., & Seager, S. (2009). A Temperature and Abundance Retrieval Method for Exoplanet Atmospheres.
     The Astrophysical Journal, 707(1), 24-39. https://doi.org/10.1088/0004-637X/707/1/24


.. py:function:: molliere_2020_temperature_profile(temperature_nodes, delta, alpha, t_internal, pressures, metallicity, co_ratio, conv)

   Self-luminous retrieval P-T model.
   Args:
       temperature_nodes : jnp.array([t1, t2, t3])
           temperature points to be added on top
           radiative Eddington structure (above tau = 0.1).
           Use spline interpolation, t1 < t2 < t3 < tconnect as prior.
       delta : float
           proportionality factor in tau = delta * pressures_cgs**alpha
       alpha : float
           power law index in tau = delta * pressures_cgs**alpha
           For the tau model: use proximity to kappa_rosseland photosphere
           as prior.
       t_internal : float
           internal temperature of the Eddington model
       pressures : jnp.ndarray
           input pressure profile in bar
       conv : bool
           enforce convective adiabat yes/no
       co_ratio : float
           C/O for the nabla_ad interpolation
       metallicity : float
           metallicity for the nabla_ad interpolation
   Returns:
       Tret : jnp.ndarray
           The temperature as a function of atmospheric pressure.


.. py:function:: power_law_temperature_profile(pressures: jax.typing.ArrayLike, alpha: float, T0: float) -> jax.Array

   Compute a power law profile for temperature; log(T) = a*log(P) + b.

   This function computes a cubic spline profile for temperature using
   pressure and temperature data points, along with a curvature prior.

   Args:
       pressures (array-like): An array or list of pressure data points.
       alpha (float): power law exponent (how steep is the profile)
       T0 (float): multiplicative factor (offsets the profile)

   Returns:
       temperatures (array): temperature values for each pressure value


.. py:function:: linear_spline_temperature_profile(pressures: jax.typing.ArrayLike, temperature_points: jax.typing.ArrayLike, gamma: float, nnodes: int = 0) -> tuple[jax.typing.ArrayLike, float]

   Compute a linear spline profile for temperature based on pressure points.

   This function computes a linear spline profile for temperature using
   pressure and temperature data points, along with a curvature prior.

   Args:
       pressures: An array of pressure data points.
       temperature_points: An array of temperature data points.
       gamma: A parameter controlling the curvature of the spline.
       nnodes: Number of nodes to use in the spline interpolation.
           Defaults to 0, which means automatic determination of nodes.

   Returns:
       A tuple containing:
           - interpolated_temperatures: Interpolated temperature values based on the linear spline.
           - prior: Curvature prior value calculated for the spline.


.. py:function:: cubic_spline_temperature_profile(pressures: jax.typing.ArrayLike, temperature_points: jax.typing.ArrayLike, gamma: float, nnodes: int = 0) -> tuple[jax.Array, float]

   Compute a cubic spline profile for temperature based on pressure points.

   This function computes a cubic spline profile for temperature using
   pressure and temperature data points, along with a curvature prior.

   Args:
       pressures: An array of pressure data points.
       temperature_points: An array of temperature data points.
       gamma: A parameter controlling the curvature of the spline.
       nnodes: Number of nodes to use in the spline interpolation.
           Defaults to 0, which means automatic determination of nodes.

   Returns:
       A tuple containing:
           - interpolated_temperatures: Interpolated temperature values based on the cubic spline.
           - prior: Curvature prior value calculated for the spline.


