exo_k.atm_profile

@author: jeremy leconte

This module contain classes to handle atmospheric profiles. Radiative properties are handled in atm.py which contains a daughter class.

The nomenclature for layers, levels, etc., can be found in atm.py.

Module Contents

class exo_k.atm_profile.Atm_profile(composition=None, psurf=None, ptop=None, logplay=None, tlay=None, Tsurf=None, Tstrat=None, grav=None, Rp=None, Mgas=None, Rstar=None, rcp=None, Nlay=20, logplev=None, aerosols=None, Nlev=None, tlev=None, **kwargs)[source]

Bases: object

A class defining an atmospheric PT profile with some global data (gravity, etc.)

The derived class Atm handles radiative transfer calculations.

Initializes atmospheric profiles

Parameters:
  • composition (dict) – Keys are molecule names and values the vmr. Vmr can be arrays of size Nlev-1 (i.e. the number of layers).

  • grav (float) – Planet surface gravity (gravity constant with altitude for now).

  • Rp (float or Astropy.unit quantity) – Planet radius. If float, meters are assumed.

  • rcp (float) – Adiabatic lapse rate for the gas (R/cp)

  • Mgas (float, optional) – Molar mass of the gas (kg/mol). If given, overrides the molar mass computed from composition.

There are two ways to define the profile. You can define:

  • Nlay: int Number of layers

  • psurf, Tsurf: float Surface pressure (Pa) and temperature

  • ptop: float Pressure at the top of the model (Pa)

  • Tstrat: float Stratospheric temperature

This way you will have an adiabatic atmosphere with Tsurf at the ground that becomes isothermal wherever T=<Tstrat. You can also specify:

  • logplay or play: array, np.ndarray

  • tlay: array, np.ndarray (same size) These will become the pressures (Pa; the log10 if you give logplay) and temperatures of the layers. This will be used to define the surface and top pressures. Nlay becomes the size of the arrays.

Warning

Layers are counted from the top down (increasing pressure order). All methods follow the same convention.

set_logPT_profile(logplay, tlay, logplev=None)[source]

Set the logP-T profile of the atmosphere with a new one

Parameters:
  • logplay (array, np.ndarray) – Log pressure (in Pa) of the layer

  • tlay (array, np.ndarray (same size)) – temperature of the layers.

  • logplev (array, np.ndarray (size Nlay+1)) – If provided, allows the user to choose the location of the level surfaces separating the layers.

set_T_profile(tlay)[source]

Reset the temperature profile without changing the pressure levels

compute_pressure_levels()[source]

Computes various pressure related quantities

update_pressure_profile(play=None, plev=None)[source]

Updates pressure levels without changing temperatures.

To be used Atm_evolution class.

set_adiab_profile(Tsurf=None, Tstrat=None)[source]

Initializes the logP-T atmospheric profile with an adiabat with index R/cp=rcp

Parameters:
  • Tsurf (float) – Surface temperature.

  • Tstrat (float, optional) – Temperature of the stratosphere. If None is given, an isothermal atmosphere with T=Tsurf is returned.

set_grav(grav=None)[source]

Sets the surface gravity of the planet

Parameters:

grav (float) – surface gravity (m/s^2)

compute_layer_masses()[source]

compute_layer_masses

set_gas(composition_dict, Mgas=None, compute_Mgas=True)[source]

Sets the composition of the atmosphere.

The composition_dict gives the composition in the layers, but we will need the composition in the radiative layers, so the interpolation is done here. For the moment we do a geometrical average.

Important

For the first initialization, compute_Mgas must be False because we need Gas_mix to be initialized before we know the number of layers in the atmosphere, but the number of layers is needed by set_Mgas! So set_Mgas needs to be called at the end of the initialization.

Parameters:
  • composition_dict (dictionary) – Keys are molecule names, and values are volume mixing ratios. A ‘background’ value means that the gas will be used to fill up to vmr=1 If they do not add up to 1 and there is no background gas_mix, the rest of the gas_mix is considered transparent.

  • compute_Mgas (bool) – If False, the molar mass of the gas is not updated.

set_Mgas(Mgas=None)[source]

Sets the mean molar mass of the atmosphere.

Parameters:

Mgas (float or array of size Nlay-1) – Mean molar mass in the radiative layers (kg/mol). If None is given, the mmm is computed from the composition.

set_rcp(rcp=None)[source]

Sets the adiabatic index of the atmosphere

Parameters:

rcp (float) – R/c_p

set_aerosols(aerosols)[source]

Sets the aerosols dictionary

performs the interlayer averaging so that we only have properties at the middle of radiative layers

set_Rp(Rp)[source]

Sets the radius of the planet

Parameters:

Rp (float) – radius of the planet (m)

set_Rstar(Rstar)[source]

Sets the radius of the star

Parameters:

Rstar (float) – radius of the star (m)

compute_number_density()[source]

Computes the number density (m^-3) profile of the atmosphere in the radiative layers

compute_mass_density()[source]

Computes the mass density (kg/m^-3) profile of the atmosphere in the radiative layers

compute_layer_col_density()[source]

Computes the column number density (molecules/m^2) per radiative layer of the atmosphere.

There are Nlay-1 radiative layers as they go from the middle of a layer to the next.

compute_altitudes()[source]

Compute altitudes of the level surfaces (zlev) and mid layers (zlay).

compute_area()[source]

Computes the area of the annulus covered by each radiative layer (from a mid layer to the next) in a transit setup.

compute_tangent_path()[source]

Computes a triangular array of the tangent path length (in m) spent in each radiative layer.

self.tangent_path[ilay][jlay] is the length that the ray that is tangent to the ilay radiative layer spends in the jlay>=ilay layer (accounting for a factor of 2 due to symmetry)

plot_T_profile(ax, invert_p=True, use_altitudes=False, xscale=None, yscale=None, **kwarg)[source]

Plot the T P profile

Parameters:
  • ax (pyplot.Axes) – A pyplot axes instance where to put the plot.

  • x/yscale (str, optional) – If ‘log’ log axes are used.

write_soundings(dirname='.', fmt='%.10e', cp=None, qvap=None, p0=None, p_dry=None)[source]

Writes sounding files that can be used to initiate the mesoscale model