petitRADTRANS.retrieval.models
==============================

.. py:module:: petitRADTRANS.retrieval.models

.. autoapi-nested-parse::

   Models Module

   This module contains a set of functions that generate the spectra used
   in the petitRADTRANS retrieval. This includes setting up the
   pressure-temperature structure, the chemistry, and the radiative
   transfer to compute the emission or transmission spectrum.

   All models must take the same set of inputs:

       prt_object : petitRADTRANS.RadTrans
           This is the pRT object that is used to compute the spectrum
           It must be fully initialized prior to be used in the model function
       parameters : dict
           A dictionary of Parameter objects. The naming of the parameters
           must be consistent between the Priors and the model function you
           are using.
       PT_plot_mode : bool
           If this argument is True, the model function should return the pressure
           and temperature arrays before computing the flux.
       amr : bool
           If this parameter is True, your model should allow for reshaping of the
           pressure and temperature arrays based on the position of the clouds or
           the location of the photosphere, increasing the resolution where required.
           For example, using the fixed_length_amr function defined below.



Attributes
----------

.. autoapisummary::

   petitRADTRANS.retrieval.models.PGLOBAL


Functions
---------

.. autoapisummary::

   petitRADTRANS.retrieval.models._compute_gravity
   petitRADTRANS.retrieval.models.emission_model_diseq
   petitRADTRANS.retrieval.models.emission_model_diseq_simple_patchy_clouds
   petitRADTRANS.retrieval.models.emission_model_diseq_patchy_clouds
   petitRADTRANS.retrieval.models.guillot_emission
   petitRADTRANS.retrieval.models.guillot_emission_add_gaussian_temperature
   petitRADTRANS.retrieval.models.guillot_patchy_emission
   petitRADTRANS.retrieval.models.interpolated_profile_emission
   petitRADTRANS.retrieval.models.gradient_profile_emission
   petitRADTRANS.retrieval.models.power_law_profile_emission
   petitRADTRANS.retrieval.models.guillot_transmission
   petitRADTRANS.retrieval.models.guillot_patchy_transmission
   petitRADTRANS.retrieval.models.madhushudhan_seager_emission
   petitRADTRANS.retrieval.models.madhushudhan_seager_transmission
   petitRADTRANS.retrieval.models.madhu_seager_patchy_transmission
   petitRADTRANS.retrieval.models.isothermal_transmission
   petitRADTRANS.retrieval.models.power_law_profile_transmission
   petitRADTRANS.retrieval.models.add_blackbody_cpd_model
   petitRADTRANS.retrieval.models.initialize_pressure
   petitRADTRANS.retrieval.models.set_pglobal
   petitRADTRANS.retrieval.models.calculate_emission_spectrum
   petitRADTRANS.retrieval.models.calculate_transmission_spectrum
   petitRADTRANS.retrieval.models.pglobal_check


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

.. py:data:: PGLOBAL

.. py:function:: _compute_gravity(parameters)

.. py:function:: emission_model_diseq(prt_object, parameters, pt_plot_mode=False, amr=True)

   Disequilibrium Chemistry Emission Model

   This model computes an emission spectrum based on the temperature profile of (Molliere 2020).
   (Dis)equilibrium or free chemistry, can be used. The use of easychem for on-the-fly (dis)equilibrium
   chemistry calculations is supported, but is currently under development.
   Many of the parameters are optional, but must be used in the correct combination
   with other parameters.

   Args:
       prt_object : object
           An instance of the pRT class, with optical properties as defined in the RunDefinition.
       parameters : dict
           Dictionary of required parameters:
               *  D_pl : Distance to the planet in [cm]
               Two of
                 *  log_g : Log of surface gravity
                 *  planet_radius : planet radius [cm]
                 *  mass : planet mass [g]
               *  T_int : Interior temperature of the planet [K]
               *  T3 : Innermost temperature spline [K]
               *  T2 : Middle temperature spline [K]
               *  T1 : Outer temperature spline [K]
               *  alpha : power law index in tau = delta * press_cgs**alpha
               *  log_delta : proportionality factor in tau = delta * press_cgs**alpha
               *  log_pquench : Pressure at which CO, CH4 and H2O abundances become vertically constant
               *  Fe/H : Metallicity
               *  C/O : Carbon to oxygen ratio
               *  fsed : sedimentation parameter - can be unique to each cloud type by adding _CloudName
               One of:
                 *  sigma_lnorm : Width of cloud particle size distribution (log normal)
                 *  b_hans : Width of cloud particle size distribution (hansen)
               One of:
                 *  log_cloud_radius_* : Central particle radius (typically computed with fsed and Kzz)
                 *  log_kzz : Vertical mixing parameter
               One of
                 *  eq_scaling_* : Scaling factor for equilibrium cloud abundances.
                 *  log_X_cb_: cloud mass fraction abundance
               Optional
                 *  contribution : return the emission contribution function
                 *  patchiness : Cloud coverage fraction, mixes two columns with different cloud properties.
                 *  remove_cloud_species : Specifies which cloud species to remove for clear atmosphere column.
                 *  T_disk_blackbody : Temperature of a blackbody circumplanetary disk component.
                 *  disk_radius : Radius [cm] of a blackbody circumplanetary disk component.
       pt_plot_mode : bool
           Return only the pressure-temperature profile for plotting. Evaluate mode only.
       amr : bool
           Adaptive mesh refinement. Use the high resolution pressure grid around the cloud base.

   Returns:
       wlen_model : np.ndarray
           Wavlength array of computed model, not binned to data [um]
       spectrum_model : np.ndarray
           Computed emission spectrum [W/m2/micron]
       contr_em : Optional, np.ndarray
           Emission contribution function, relative contributions for each wavelength and pressure level.



.. py:function:: emission_model_diseq_simple_patchy_clouds(prt_object, parameters, pt_plot_mode=False, amr=True)

   Deprecated, to be removed in future version


.. py:function:: emission_model_diseq_patchy_clouds(prt_object, parameters, pt_plot_mode=False, amr=True)

   Disequilibrium Chemistry Emission Model

   This model computes an emission spectrum based on the temperature profile of (Molliere 2020).
   (Dis)equilibrium or free chemistry, can be used. The use of easychem for on-the-fly (dis)equilibrium
   chemistry calculations is supported, but is currently under development.
   This model includes patchy clouds, and requires a unique temperature profile for the
   clear atmosphere regions - ie this is a full two column model!

   Args:
       prt_object : object
           An instance of the pRT class, with optical properties as defined in the RunDefinition.
       parameters : dict
           Dictionary of required parameters:
               *  D_pl : Distance to the planet in [cm]
               Two of
                 *  log_g : Log of surface gravity
                 *  planet_radius : planet radius [cm]
                 *  mass : planet mass [g]
               *  T_int : Interior temperature of the planet [K]
               *  T3 : Innermost temperature spline
               *  T2 : Middle temperature spline
               *  T1 : Outer temperature spline
               *  T3_clear : Innermost temperature spline for clear atmosphere
               *  T2_clear : Middle temperature spline for clear atmosphere
               *  T1_clear : Outer temperature spline for clear atmosphere
               *  alpha : power law index in tau = delta * press_cgs**alpha
               *  alpha_clear : power law index in tau = delta * press_cgs**alpha for clear atmosphere
               *  log_delta : proportionality factor in tau = delta * press_cgs**alpha
               *  log_delta_clear : proportionality factor in tau = delta * press_cgs**alpha for clear atmosphere
               *  log_pquench : Pressure at which CO, CH4 and H2O abundances become vertically constant
               *  Fe/H : Metallicity
               *  C/O : Carbon to oxygen ratio
               *  fsed : sedimentation parameter - can be unique to each cloud type
               One of:
                 *  sigma_lnorm : Width of cloud particle size distribution (log normal)
                 *  b_hans : Width of cloud particle size distribution (hansen)
               One of:
                 *  log_cloud_radius_* : Central particle radius (typically computed with fsed and Kzz)
                 *  log_kzz : Vertical mixing parameter
               One of
                 *  eq_scaling_* : Scaling factor for equilibrium cloud abundances.
                 *  log_X_cb_: cloud mass fraction abundance
               Optional
                 *  contribution : return the emission contribution function
                 *  patchiness : Cloud coverage fraction, mixes two  columns with different cloud properties.
                 *  remove_cloud_species : Specifies which cloud species to remove for the clear atmosphere column.
                 *  T_disk_blackbody : Temperature of a blackbody circumplanetary disk component.
                 *  disk_radius : Radius [cm] of a blackbody circumplanetary disk component.
       pt_plot_mode : bool
           Return only the pressure-temperature profile for plotting. Evaluate mode only.
       amr : bool
           Adaptive mesh refinement. Use the high resolution pressure grid around the cloud base.

   Returns:
       wlen_model : np.array
           Wavlength array of computed model, not binned to data [um]
       spectrum_model : np.array
           Computed emission spectrum [W/m2/micron]
       contr_em : Optional, np.ndarray
           Emission contribution function, relative contributions for each wavelength and pressure level.
           Only returns the contribution of the clear atmosphere component.



.. py:function:: guillot_emission(prt_object, parameters, pt_plot_mode=False, amr=False)

   Emission spectrum calculation for the Guillot 2010 temperature profile.
   (Dis)equilibrium or free chemistry, can be used. The use of easychem for on-the-fly (dis)equilibrium
   chemistry calculations is supported, but is currently under development.

   Args:
       prt_object : object
           An instance of the pRT class, with optical properties as defined in the RunDefinition.
       parameters : dict
           Dictionary of required parameters:
               *  D_pl : Distance to the planet in [cm]
               Two of
                 *  log_g : Log of surface gravity
                 *  planet_radius : planet radius [cm]
                 *  mass : planet mass [g]
               *  T_int : Interior temperature of the planet [K]
               *  T_equ : Equilibrium temperature of the planet
               *  gamma : Guillot gamma parameter
               *  log_kappa_IR : The log of the ratio between the infrared and optical opacities

               Either:
                 *  log_pquench : Pressure at which CO, CH4 and H2O abundances become vertically constant
                 *  Fe/H : Metallicity
                 *  C/O : Carbon to oxygen ratio
               Or:
                 * $SPECIESNAME[_$DATABASE][_R_$RESOLUTION] : The log mass fraction abundance of the species

               *  fsed : sedimentation parameter - can be unique to each cloud type
               One of:
                 *  sigma_lnorm : Width of cloud particle size distribution (log normal)
                 *  b_hans : Width of cloud particle size distribution (hansen)
               One of:
                 *  log_cloud_radius_* : Central particle radius (typically computed with fsed and Kzz)
                 *  log_kzz : Vertical mixing parameter
               One of
                 *  eq_scaling_* : Scaling factor for equilibrium cloud abundances.
                 *  log_X_cb_: cloud mass fraction abundance
               Optional
                 *  contribution : return the emission contribution function
                 *  patchiness : Cloud coverage fraction, mixes two columns with different cloud properties.
                 *  remove_cloud_species : Specifies which cloud species to remove for the clear atmosphere column.
                 *  T_disk_blackbody : Temperature of a blackbody circumplanetary disk component.
                 *  disk_radius : Radius [cm] of a blackbody circumplanetary disk component.
       pt_plot_mode : bool
           Return only the pressure-temperature profile for plotting. Evaluate mode only.
       amr :
           Adaptive mesh refinement. Use the high resolution pressure grid around the cloud base.

   Returns:
       wlen_model : np.array
           Wavlength array of computed model, not binned to data [um]
       spectrum_model : np.array
           Computed transmission spectrum planet_radius**2/Rstar**2
       contr-em : np.ndarray
           Optional, Emission contribution function, relative contributions for each wavelength and pressure level.



.. py:function:: guillot_emission_add_gaussian_temperature(prt_object, parameters, pt_plot_mode=False, amr=False)

   Emission spectrum calculation for the Guillot 2010 temperature profile.
   (Dis)equilibrium or free chemistry, can be used. The use of easychem for on-the-fly (dis)equilibrium
   chemistry calculations is supported, but is currently under development.

   Args:
       prt_object : object
           An instance of the pRT class, with optical properties as defined in the RunDefinition.
       parameters : dict
           Dictionary of required parameters:
               *  D_pl : Distance to the planet in [cm]
               Two of
                 *  log_g : Log of surface gravity
                 *  planet_radius : planet radius [cm]
                 *  mass : planet mass [g]
               *  T_int : Interior temperature of the planet [K]
               *  T_equ : Equilibrium temperature of the planet
               *  gamma : Guillot gamma parameter
               *  log_kappa_IR : The log of the ratio between the infrared and optical opacities

               Either:
                 *  log_pquench : Pressure at which CO, CH4 and H2O abundances become vertically constant
                 *  Fe/H : Metallicity
                 *  C/O : Carbon to oxygen ratio
               Or:
                 * $SPECIESNAME[_$DATABASE][_R_$RESOLUTION] : The log mass fraction abundance of the species

               *  fsed : sedimentation parameter - can be unique to each cloud type
               One of:
                 *  sigma_lnorm : Width of cloud particle size distribution (log normal)
                 *  b_hans : Width of cloud particle size distribution (hansen)
               One of:
                 *  log_cloud_radius_* : Central particle radius (typically computed with fsed and Kzz)
                 *  log_kzz : Vertical mixing parameter
               One of
                 *  eq_scaling_* : Scaling factor for equilibrium cloud abundances.
                 *  log_X_cb_: cloud mass fraction abundance
               Optional
                 *  contribution : return the emission contribution function
                 *  patchiness : Cloud coverage fraction, mixes two columns with different cloud properties.
                 *  remove_cloud_species : Specifies which cloud species to remove for the clear atmosphere column.
                 *  T_disk_blackbody : Temperature of a blackbody circumplanetary disk component.
                 *  disk_radius : Radius [cm] of a blackbody circumplanetary disk component.
       pt_plot_mode : bool
           Return only the pressure-temperature profile for plotting. Evaluate mode only.
       amr :
           Adaptive mesh refinement. Use the high resolution pressure grid around the cloud base.

   Returns:
       wlen_model : np.array
           Wavlength array of computed model, not binned to data [um]
       spectrum_model : np.array
           Computed transmission spectrum planet_radius**2/Rstar**2
       contr-em : np.ndarray
           Optional, Emission contribution function, relative contributions for each wavelength and pressure level.



.. py:function:: guillot_patchy_emission(prt_object, parameters, pt_plot_mode=False, amr=False)

   Deprecated, to be removed in future version


.. py:function:: interpolated_profile_emission(prt_object, parameters, pt_plot_mode=False, amr=False)

   This model computes a emission spectrum based a spline temperature-pressure profile.
   Either free or equilibrium chemistry can be used, together with a range of cloud parameterizations.
   It is possible to use free abundances for some species and equilibrium chemistry for the remainder.

   Args:
       prt_object : object
           An instance of the pRT class, with optical properties as defined in the RunDefinition.
       parameters : dict
           Dictionary of required parameters:
               *  D_pl : Distance to the planet in [cm]
               Two of
                 *  log_g : Log of surface gravity
                 *  planet_radius : planet radius [cm]
                 *  mass : planet mass [g]
               *  nnodes : number of nodes to interplate, excluding the first and last points.
                           so the total number of nodes is nnodes + 2
               *  T{i}  : One parameter for each temperature node
               *  gamma : weight for penalizing the profile curvature

               Either:
                 *  log_pquench : Pressure at which CO, CH4 and H2O abundances become vertically constant
                 *  Fe/H : Metallicity
                 *  C/O : Carbon to oxygen ratio
               Or:
                 * $SPECIESNAME[_$DATABASE][_R_$RESOLUTION] : The log mass fraction abundance of the species
               Optional:
               *  fsed : sedimentation parameter - can be unique to each cloud type
               One of:
                 *  sigma_lnorm : Width of cloud particle size distribution (log normal)
                 *  b_hans : Width of cloud particle size distribution (hansen)
               One of:
                 *  log_cloud_radius_* : Central particle radius (typically computed with fsed and Kzz)
                 *  log_kzz : Vertical mixing parameter
               One of
                 *  eq_scaling_* : Scaling factor for equilibrium cloud abundances.
                 *  log_X_cb_: cloud mass fraction abundance
               Optional
                 *  contribution : return the emission contribution function
                 *  patchiness : Cloud coverage fraction, mixes two columns with different cloud properties.
                 *  remove_cloud_species : Specifies which cloud species to remove for the clear atmosphere column.
                 *  T_disk_blackbody : Temperature of a blackbody circumplanetary disk component.
                 *  disk_radius : Radius [cm] of a blackbody circumplanetary disk component.
       pt_plot_mode : bool
           Return only the pressure-temperature profile for plotting. Evaluate mode only.
       amr :
           Adaptive mesh refinement. Use the high resolution pressure grid around the cloud base.

   Returns:
       wlen_model : np.array
           Wavlength array of computed model, not binned to data [um]
       spectrum_model : np.array
           Computed transmission spectrum planet_radius**2/Rstar**2
       contr-em : np.ndarray
           Optional, the emission contribution function, relative contributions for each wavelength and pressure level.


.. py:function:: gradient_profile_emission(prt_object, parameters, pt_plot_mode=False, amr=False)

   This model computes a emission spectrum based a gradient temperature-pressure profile (Zhang 2023).
   Either free or equilibrium chemistry can be used, together with a range of cloud parameterizations.
   It is possible to use free abundances for some species and equilibrium chemistry for the remainder.

   Args:
       prt_object : object
           An instance of the pRT class, with optical properties as defined in the RunDefinition.
       parameters : dict
           Dictionary of required parameters:
               *  D_pl : Distance to the planet in [cm]
               Two of
                 *  log_g : Log of surface gravity
                 *  planet_radius : planet radius [cm]
                 *  mass : planet mass [g]
               *  N_layers : number of nodes to interplate, excluding the first and last points.
                           so the total number of nodes is nnodes + 2
               *  T_bottom : temperature at the base of the atmosphere
               *  PTslope_* : temperature gradient for each of the n_layers between which the profile is interpolated.

               Either:
                 *  log_pquench : Pressure at which CO, CH4 and H2O abundances become vertically constant
                 *  Fe/H : Metallicity
                 *  C/O : Carbon to oxygen ratio
               Or:
                 * $SPECIESNAME[_$DATABASE][_R_$RESOLUTION] : The log mass fraction abundance of the species
               Optional:
               *  fsed : sedimentation parameter - can be unique to each cloud type
               One of:
                 *  sigma_lnorm : Width of cloud particle size distribution (log normal)
                 *  b_hans : Width of cloud particle size distribution (hansen)
               One of:
                 *  log_cloud_radius_* : Central particle radius (typically computed with fsed and Kzz)
                 *  log_kzz : Vertical mixing parameter
               One of
                 *  eq_scaling_* : Scaling factor for equilibrium cloud abundances.
                 *  log_X_cb_: cloud mass fraction abundance
               Optional
                 *  contribution : return the emission contribution function
                 *  patchiness : Cloud coverage fraction, mixes two columns with different cloud properties.
                 *  remove_cloud_species : Specifies which cloud species to remove for the clear atmosphere column.
                 *  T_disk_blackbody : Temperature of a blackbody circumplanetary disk component.
                 *  disk_radius : Radius [cm] of a blackbody circumplanetary disk component.
       pt_plot_mode : bool
           Return only the pressure-temperature profile for plotting. Evaluate mode only.
       amr :
           Adaptive mesh refinement. Use the high resolution pressure grid around the cloud base.

   Returns:
       wlen_model : np.array
           Wavlength array of computed model, not binned to data [um]
       spectrum_model : np.array
           Computed transmission spectrum planet_radius**2/Rstar**2
       contr-em : np.ndarray
           Optional, the emission contribution function, relative contributions for each wavelength and pressure level.


.. py:function:: power_law_profile_emission(prt_object, parameters, pt_plot_mode=False, amr=False)

   This model computes a emission spectrum based a gradient temperature-pressure profile (Zhang 2023).
   Either free or equilibrium chemistry can be used, together with a range of cloud parameterizations.
   It is possible to use free abundances for some species and equilibrium chemistry for the remainder.

   Args:
       prt_object : object
           An instance of the pRT class, with optical properties as defined in the RunDefinition.
       parameters : dict
           Dictionary of required parameters:
               *  D_pl : Distance to the planet in [cm]
               Two of
                 *  log_g : Log of surface gravity
                 *  planet_radius : planet radius [cm]
                 *  mass : planet mass [g]
               *  alpha : power law slope for the temperture profile
               *  T_0 : multiplicative factor for the power law slope

               Either:
                 *  log_pquench : Pressure at which CO, CH4 and H2O abundances become vertically constant
                 *  Fe/H : Metallicity
                 *  C/O : Carbon to oxygen ratio
               Or:
                 * $SPECIESNAME[_$DATABASE][_R_$RESOLUTION] : The log mass fraction abundance of the species
               Optional:
               *  fsed : sedimentation parameter - can be unique to each cloud type
               One of:
                 *  sigma_lnorm : Width of cloud particle size distribution (log normal)
                 *  b_hans : Width of cloud particle size distribution (hansen)
               One of:
                 *  log_cloud_radius_* : Central particle radius (typically computed with fsed and Kzz)
                 *  log_kzz : Vertical mixing parameter
               One of
                 *  eq_scaling_* : Scaling factor for equilibrium cloud abundances.
                 *  log_X_cb_: cloud mass fraction abundance
               Optional
                 *  contribution : return the emission contribution function
                 *  patchiness : Cloud coverage fraction, mixes two columns with different cloud properties.
                 *  remove_cloud_species : Specifies which cloud species to remove for the clear atmosphere column.
                 *  T_disk_blackbody : Temperature of a blackbody circumplanetary disk component.
                 *  disk_radius : Radius [cm] of a blackbody circumplanetary disk component.
       pt_plot_mode : bool
           Return only the pressure-temperature profile for plotting. Evaluate mode only.
       amr :
           Adaptive mesh refinement. Use the high resolution pressure grid around the cloud base.

   Returns:
       wlen_model : np.array
           Wavlength array of computed model, not binned to data [um]
       spectrum_model : np.array
           Computed transmission spectrum planet_radius**2/Rstar**2
       contr-em : np.ndarray
           Optional, the emission contribution function, relative contributions for each wavelength and pressure level.


.. py:function:: guillot_transmission(prt_object, parameters, pt_plot_mode=False, amr=False)

   Transmission Model, Guillot Profile

   This model computes a transmission spectrum based on the Guillot profile
   Either free or (dis)equilibrium chemistry can be used, together with a range of cloud parameterizations.
   It is possible to use free abundances for some species and equilibrium chemistry for the remainder.
   Chemical clouds can be used, or a simple gray opacity source.

   Args:
       prt_object : object
           An instance of the pRT class, with optical properties as defined in the RunDefinition.
       parameters : dict
           Dictionary of required parameters:
               *  D_pl : Distance to the planet in [cm]
               Two of
                 *  log_g : Log of surface gravity
                 *  planet_radius : planet radius [cm]
                 *  mass : planet mass [g]
               *  T_int : Interior temperature of the planet [K]
               *  T_equ : Equilibrium temperature of the planet
               *  gamma : Guillot gamma parameter
               *  log_kappa_IR : The log of the ratio between the infrared and optical opacities

               Either:
                 *  log_pquench : Pressure at which CO, CH4 and H2O abundances become vertically constant
                 *  Fe/H : Metallicity
                 *  C/O : Carbon to oxygen ratio
               Or:
                 * $SPECIESNAME[_$DATABASE][.R$RESOLUTION] : The log mass fraction abundance of the species

               Either:
                 * [log_]Pcloud : The (log) pressure at which to place the gray cloud opacity.
               Or:
                 *  fsed : sedimentation parameter - can be unique to each cloud type
                 One of:
                   *  sigma_lnorm : Width of cloud particle size distribution (log normal)
                   *  b_hans : Width of cloud particle size distribution (hansen)
                 One of:
                   *  log_cloud_radius_* : Central particle radius (typically computed with fsed and Kzz)
                   *  log_kzz : Vertical mixing parameter
                 One of
                   *  eq_scaling_* : Scaling factor for equilibrium cloud abundances.
                   *  log_X_cb_: cloud mass fraction abundance
               Optional
                 *  contribution : return the transmission contribution function
                 *  power_law_opacity_coefficient : gamma, power law slope for a rayleigh-like haze
                 *  haze_factor : multiplicative scaling factor for the strength of the rayleigh haze
                 *  power_law_opacity_350nm : strength of the rayleigh haze at 350 nm.
       pt_plot_mode : bool
           Return only the pressure-temperature profile for plotting. Evaluate mode only.
       amr :
           Adaptive mesh refinement. Use the high resolution pressure grid around the cloud base.

   Returns:
       wlen_model : np.array
           Wavlength array of computed model, not binned to data [um]
       spectrum_model : np.array
           Computed transmission spectrum planet_radius**2/Rstar**2
       contr-em : np.ndarray
           Optional, the transmission contribution function, relative contributions for each wavelength and pressure
           level.


.. py:function:: guillot_patchy_transmission(prt_object, parameters, pt_plot_mode=False, amr=False)

   Deprecated


.. py:function:: madhushudhan_seager_emission(prt_object, parameters, pt_plot_mode=False, amr=False)

   Transmission Model, Madhusudhan Seager 2009 Profile

   This model computes a transmission spectrum based on a Guillot temperature-pressure profile.
   Either free or equilibrium chemistry can be used, together with a range of cloud parameterizations.
   It is possible to use free abundances for some species and equilibrium chemistry for the remainder.
   Chemical clouds can be used, or a simple gray opacity source. This model requires patchy clouds.

   Args:
       prt_object : object
           An instance of the pRT class, with optical properties as defined in the RunDefinition.
       parameters : dict
           Dictionary of required parameters:
               *  D_pl : Distance to the planet in [cm]
               Two of
                 *  log_g : Log of surface gravity
                 *  planet_radius : planet radius [cm]
                 *  mass : planet mass [g]
               *  log_P_set : Pressure value to contrain the PT profile, defaults to 10 bar.
               *  T_set : temperature at P_set to constrain the PT profile. [K]
               *  log_P3 : (log) Pressure value for the top of the deep atmospheric layer, [bar]
               *  P2 : in range (0,1), sets the pressure level of the middle atmospheric layer
               *  P1 : in range (0,1), sets the pressure level of the top atmospheric layer
               *  alpha_0 : slope of the upper atmospheric layer
               *  alpha_1 : slope of the middle atmospheric layer
               Optional :
                   *  beta : power law for the slopes, default value is 0.5. Not recommended to change!

               Either:
                 *  log_pquench : Pressure at which CO, CH4 and H2O abundances become vertically constant
                 *  Fe/H : Metallicity
                 *  C/O : Carbon to oxygen ratio
               Or:
                 * $SPECIESNAME[_$DATABASE][.R$RESOLUTION] : The log mass fraction abundance of the species

               Optional:
               *  fsed : sedimentation parameter - can be unique to each cloud type
               One of:
                 *  sigma_lnorm : Width of cloud particle size distribution (log normal)
                 *  b_hans : Width of cloud particle size distribution (hansen)
               One of:
                 *  log_cloud_radius_* : Central particle radius (typically computed with fsed and Kzz)
                 *  log_kzz : Vertical mixing parameter
               One of
                 *  eq_scaling_* : Scaling factor for equilibrium cloud abundances.
                 *  log_X_cb_: cloud mass fraction abundance
               Optional
                 *  contribution : return the emission contribution function
                 *  patchiness : Cloud coverage fraction, mixes two columns with different cloud properties.
                 *  remove_cloud_species : Specifies which cloud species to remove for the clear atmosphere column.
                 *  T_disk_blackbody : Temperature of a blackbody circumplanetary disk component.
                 *  disk_radius : Radius [cm] of a blackbody circumplanetary disk component.
       pt_plot_mode : bool
           Return only the pressure-temperature profile for plotting. Evaluate mode only.
       amr :
           Adaptive mesh refinement. Use the high resolution pressure grid around the cloud base.

   Returns:
       wlen_model : np.array
           Wavlength array of computed model, not binned to data [um]
       spectrum_model : np.array
           Computed transmission spectrum planet_radius**2/Rstar**2
       contr-em : np.ndarray
           Optional, the transmission contribution function, relative contributions for each wavelength and pressure
           level.
           Only the clear atmosphere contribution is returned.


.. py:function:: madhushudhan_seager_transmission(prt_object, parameters, pt_plot_mode=False, amr=False)

   Transmission Model, Madhusudhan Seager 2009 Profile

   This model computes a transmission spectrum based on a Guillot temperature-pressure profile.
   Either free or equilibrium chemistry can be used, together with a range of cloud parameterizations.
   It is possible to use free abundances for some species and equilibrium chemistry for the remainder.
   Chemical clouds can be used, or a simple gray opacity source. This model requires patchy clouds.

   Args:
       prt_object : object
           An instance of the pRT class, with optical properties as defined in the RunDefinition.
       parameters : dict
           Dictionary of required parameters:
               *  D_pl : Distance to the planet in [cm]
               Two of
                 *  log_g : Log of surface gravity
                 *  planet_radius : planet radius [cm]
                 *  mass : planet mass [g]
               *  log_P_set : Pressure value to contrain the PT profile, defaults to 10 bar.
               *  T_set : temperature at P_set to constrain the PT profile. [K]
               *  log_P3 : (log) Pressure value for the top of the deep atmospheric layer, [bar]
               *  P2 : in range (0,1), sets the pressure level of the middle atmospheric layer
               *  P1 : in range (0,1), sets the pressure level of the top atmospheric layer
               *  alpha_0 : slope of the upper atmospheric layer
               *  alpha_1 : slope of the middle atmospheric layer
               Optional :
                   *  beta : power law for the slopes, default value is 0.5. Not recommended to change!

               Either:
                 *  log_pquench : Pressure at which CO, CH4 and H2O abundances become vertically constant
                 *  Fe/H : Metallicity
                 *  C/O : Carbon to oxygen ratio
               Or:
                 * $SPECIESNAME[_$DATABASE][.R$RESOLUTION] : The log mass fraction abundance of the species

               Either:
                 * [log_]Pcloud : The (log) pressure at which to place the gray cloud opacity.
               Or:
                 *  fsed : sedimentation parameter - can be unique to each cloud type
                 One of:
                   *  sigma_lnorm : Width of cloud particle size distribution (log normal)
                   *  b_hans : Width of cloud particle size distribution (hansen)
                 One of:
                   *  log_cloud_radius_* : Central particle radius (typically computed with fsed and Kzz)
                   *  log_kzz : Vertical mixing parameter
                 One of
                   *  eq_scaling_* : Scaling factor for equilibrium cloud abundances.
                   *  log_X_cb_: cloud mass fraction abundance
               Optional
                 *  contribution : return the transmission contribution function
                 *  power_law_opacity_coefficient : gamma, power law slope for a rayleigh-like haze
                 *  haze_factor : multiplicative scaling factor for the strength of the rayleigh haze
                 *  power_law_opacity_350nm : strength of the rayleigh haze at 350 nm.
       pt_plot_mode : bool
           Return only the pressure-temperature profile for plotting. Evaluate mode only.
       amr :
           Adaptive mesh refinement. Use the high resolution pressure grid around the cloud base.

   Returns:
       wlen_model : np.array
           Wavlength array of computed model, not binned to data [um]
       spectrum_model : np.array
           Computed transmission spectrum planet_radius**2/Rstar**2
       contr-em : np.ndarray
           Optional, the transmission contribution function, relative contributions for each wavelength and pressure
           level.
           Only the clear atmosphere contribution is returned.


.. py:function:: madhu_seager_patchy_transmission(prt_object, parameters, pt_plot_mode=False, amr=False)

   Deprecated


.. py:function:: isothermal_transmission(prt_object, parameters, pt_plot_mode=False, amr=False)

   Equilibrium Chemistry Transmission Model, Isothermal Profile

   This model computes a transmission spectrum based on an isothermal temperature-pressure profile.

   Args:
       prt_object : object
           An instance of the pRT class, with optical properties as defined in the RunDefinition.
       parameters : dict
           Dictionary of required parameters:
               *  D_pl : Distance to the planet in [cm]
               Two of
                 *  log_g : Log of surface gravity
                 *  planet_radius : planet radius [cm]
                 *  mass : planet mass [g]
               *  temperature : Interior temperature of the planet [K]

               Either:
                 *  log_pquench : Pressure at which CO, CH4 and H2O abundances become vertically constant
                 *  Fe/H : Metallicity
                 *  C/O : Carbon to oxygen ratio
               Or:
                 * $SPECIESNAME[_$DATABASE][.R$RESOLUTION] : The log mass fraction abundance of the species

               Either:
                 * [log_]Pcloud : The (log) pressure at which to place the gray cloud opacity.
               Or:
                 *  fsed : sedimentation parameter - can be unique to each cloud type
                 One of:
                   *  sigma_lnorm : Width of cloud particle size distribution (log normal)
                   *  b_hans : Width of cloud particle size distribution (hansen)
                 One of:
                   *  log_cloud_radius_* : Central particle radius (typically computed with fsed and Kzz)
                   *  log_kzz : Vertical mixing parameter
                 One of
                   *  eq_scaling_* : Scaling factor for equilibrium cloud abundances.
                   *  log_X_cb_: cloud mass fraction abundance
               Optional
                 *  contribution : return the transmission contribution function
                 *  power_law_opacity_coefficient : gamma, power law slope for a rayleigh-like haze
                 *  haze_factor : multiplicative scaling factor for the strength of the rayleigh haze
                 *  power_law_opacity_350nm : strength of the rayleigh haze at 350 nm.
       pt_plot_mode : bool
           Return only the pressure-temperature profile for plotting. Evaluate mode only.
       amr :
           Adaptive mesh refinement. Use the high resolution pressure grid around the cloud base.

   Returns:
       wlen_model : np.array
           Wavlength array of computed model, not binned to data [um]
       spectrum_model : np.array
           Computed transmission spectrum planet_radius**2/Rstar**2
       contr-em : np.ndarray
           Optional, the transmission contribution function, relative contributions for each wavelength and pressure
           level.
           Only the clear atmosphere contribution is returned if patchy clouds are considered.


.. py:function:: power_law_profile_transmission(prt_object, parameters, pt_plot_mode=False, amr=False)

   This model computes a emission spectrum based a gradient temperature-pressure profile (Zhang 2023).
   Either free or equilibrium chemistry can be used, together with a range of cloud parameterizations.
   It is possible to use free abundances for some species and equilibrium chemistry for the remainder.

   Args:
       prt_object : object
           An instance of the pRT class, with optical properties as defined in the RunDefinition.
       parameters : dict
           Dictionary of required parameters:
               *  D_pl : Distance to the planet in [cm]
               Two of
                 *  log_g : Log of surface gravity
                 *  planet_radius : planet radius [cm]
                 *  mass : planet mass [g]
               *  alpha : power law slope for the temperture profile
               *  T_0 : multiplicative factor for the power law slope

               Either:
                 *  log_pquench : Pressure at which CO, CH4 and H2O abundances become vertically constant
                 *  Fe/H : Metallicity
                 *  C/O : Carbon to oxygen ratio
               Or:
                 * $SPECIESNAME[_$DATABASE][_R_$RESOLUTION] : The log mass fraction abundance of the species
               Optional:
               *  fsed : sedimentation parameter - can be unique to each cloud type
               One of:
                 *  sigma_lnorm : Width of cloud particle size distribution (log normal)
                 *  b_hans : Width of cloud particle size distribution (hansen)
               One of:
                 *  log_cloud_radius_* : Central particle radius (typically computed with fsed and Kzz)
                 *  log_kzz : Vertical mixing parameter
               One of
                 *  eq_scaling_* : Scaling factor for equilibrium cloud abundances.
                 *  log_X_cb_: cloud mass fraction abundance
               Optional
                 *  contribution : return the emission contribution function
                 *  patchiness : Cloud coverage fraction, mixes two columns with different cloud properties.
                 *  remove_cloud_species : Specifies which cloud species to remove for the clear atmosphere column.
                 *  T_disk_blackbody : Temperature of a blackbody circumplanetary disk component.
                 *  disk_radius : Radius [cm] of a blackbody circumplanetary disk component.
       pt_plot_mode : bool
           Return only the pressure-temperature profile for plotting. Evaluate mode only.
       amr :
           Adaptive mesh refinement. Use the high resolution pressure grid around the cloud base.

   Returns:
       wlen_model : np.array
           Wavlength array of computed model, not binned to data [um]
       spectrum_model : np.array
           Computed transmission spectrum planet_radius**2/Rstar**2
       contr-em : np.ndarray
           Optional, the emission contribution function, relative contributions for each wavelength and pressure level.


.. py:function:: add_blackbody_cpd_model(parameters, wavelengths)

   Calculates the flux of a blackbody with area 4*pi*disk_radius^2 and temperature T_disk_blackbody.
   This is in units of W/m2/micron, and can be added to a planetary spectrum to model the contribution
   of a circumplanetary disk

   Args:
       parameters (dict): dictionary of atmospheric and disk parameters
       wavelengths (np.ndarray): Wavelength grid of atmospheric model in micron

   Returns:
       blackbody_spectrum (np.ndarray): 1D Planck emission spectrum for a circular CPD.


.. py:function:: initialize_pressure(press, parameters, amr)

   Provide the pressure array correctly sized to the prt_object in use, accounting for
   the use of Adaptive Mesh Refinement around the location of clouds.

   Args:
       press : numpy.ndarray
           Pressure array from a prt_object. Used to set the min and max values of PGLOBAL
       parameters :
           # TODO complete docstring
       amr :
           # TODO complete docstring


.. py:function:: set_pglobal(press, parameters)

   Check to ensure that the global pressure array has the correct length.
   Updates PGLOBAL.

   Args:
       press : numpy.ndarray
           Pressure array from a prt_object. Used to set the min and max values of PGLOBAL
       parameters : dict
           Must include the 'pressure_simple' and 'pressure_scaling' parameters,
           used to determine the size of the high resolution grid.


.. py:function:: calculate_emission_spectrum(prt_object, parameters, temperatures, abundances, gravity, mean_molar_masses, planet_radius, sigma_lnorm, cloud_particles_mean_radii, cloud_f_sed, eddy_diffusion_coefficients, cloud_hansen_b, cloud_fraction, complete_coverage_clouds, distribution)

   Calls Radtrans.calculate_flux to compute the emission spectrum of an atmosphere.
   This function automatically checks if patchiness is included in the retrieval, and
   mixes the clear and cloudy columns. Patchiness can be applied to all of the cloud species,
   or individual clouds can be chosen using the remove_cloud_species parameter.
   A circumplanetary disk model is optionally included, modelled as a blackbody with some temperature
   T_disk_blackbody and a radius disk_radius.

   Args:
       prt_object (Radtrans): The Radtrans object used to calculate the spectrum
       parameters (dict): Dictionary of atmospheric parameters.
       temperatures (np.ndarray): Array of temperatures for each pressure level in the atmosphere
       abundances (dict): Dictionary of molecular mass fraction abundances for each level in the atmosphere
       gravity (np.ndarray): Gravitational acceleration at each pressure level
       mean_molar_masses (np.ndarray): Mean molecular mass at each pressure level
       planet_radius (float): Planet radius in cm
       sigma_lnorm (float): Width of the cloud particle size distribution (log-normal)
       cloud_particles_mean_radii (np.ndarray): Mean particle radius
       cloud_f_sed (np.ndarray): Sedimentation fraction
       eddy_diffusion_coefficients (np.ndarray): Vertical mixing strength (Kzz)
       cloud_hansen_b (np.ndarray): Cloud particle distribution width, hansen distsribution
       cloud_fraction (float) : fraction of planet covered by clouds
       complete_coverage_clouds (list(str)) : Which clouds are NOT patchy
       distribution (string): Which cloud particle size distribution to use


.. py:function:: calculate_transmission_spectrum(prt_object, parameters, temperatures, abundances, gravity, mean_molar_masses, planet_radius, reference_pressure, opaque_cloud_top_pressure, sigma_lnorm, cloud_particles_mean_radii, cloud_f_sed, eddy_diffusion_coefficients, haze_factor, power_law_opacity_coefficient, power_law_opacity_350nm, cloud_hansen_b, cloud_fraction, complete_coverage_clouds, distribution)

   _summary_

   Args:
       prt_object (Radtrans): The Radtrans object used to calculate the spectrum
       parameters (dict): Dictionary of atmospheric parameters.
       temperatures (np.ndarray): Array of temperatures for each pressure level in the atmosphere
       abundances (dict): Dictionary of molecular mass fraction abundances for each level in the atmosphere
       gravity (np.ndarray): Gravitational acceleration at each pressure level
       mean_molar_masses (np.ndarray): Mean molecular mass at each pressure level
       planet_radius (float):Planet radius in cm
       reference_pressure (float): Pressure at which the planet radius is defined
       opaque_cloud_top_pressure (float): Pressure where an opaque grey cloud deck is placed
       sigma_lnorm (float): Width of the cloud particle size distribution (log-normal)
       cloud_particles_mean_radii (np.ndarray): Mean particle radius
       cloud_f_sed (np.ndarray): Sedimentation fraction
       eddy_diffusion_coefficients (np.ndarray): Vertical mixing strength (Kzz)
       haze_factor (float): Multiplicative factor on the strength of a power law haze slope
       power_law_opacity_coefficient (float): Exponent for the slope of a power law haze
       power_law_opacity_350nm (float): Strength of the power law scattering at 350nm
       cloud_hansen_b (np.ndarray): Cloud particle distribution width, hansen distsribution
       cloud_fraction (float) : fraction of planet covered by clouds
       complete_coverage_clouds (list(str)) : Which clouds are NOT patchy
       distribution (string): Log normal or hansen particle size distribution
   Returns:
       _type_: _description_


.. py:function:: pglobal_check(press, shape, scaling)

   Check to ensure that the global pressure array has the correct length.
   Updates PGLOBAL.

   Args:
       press : numpy.ndarray
           Pressure array from a prt_object. Used to set the min and max values of PGLOBAL
       shape : int
           the shape of the pressure array if no amr is used
       scaling :
           The factor by which the pressure array resolution should be scaled.


