pytmosph3r.model.model

Module Contents

class Model(output_file: str = None, n_vertical: int | None = None, noise=None, interp=None, gas_dict=None, aerosols_dict=None, input_atmosphere: pytmosph3r.atmosphere.InputAtmosphere | None = None, opacity: pytmosph3r.opacity.Opacity | None = None, planet: pytmosph3r.planetary_system.Planet | None = None, star: pytmosph3r.planetary_system.Star | None = None, observer: pytmosph3r.planetary_system.Observer | None = None, orbit: pytmosph3r.planetary_system.Orbit | None = None, radiative_transfer=None, transmission: pytmosph3r.observations.Transmission | None = None, emission: pytmosph3r.observations.Emission | None = None, lightcurve: pytmosph3r.observations.Lightcurve | None = None, phasecurve: pytmosph3r.observations.Phasecurve | None = None, parallel=None, **kwargs)[source]

Bases: pytmosph3r.log.Logger

Main model structure which plays the role of the puppeteer. The main function are build(), which initializes some of the classes once you are sure of your input data (computes altitude for example), and \(run\), which basically computes everything (transit depth/emission, ..).

All ‘property’ attributes are derived from AltitudeAtmosphere.

Main class to control all submodules. Here you control everything.

Parameters:
  • output_file (str) – HDF5 output filename.

  • n_vertical (int) – Number of vertical layers for the altitude-based atmosphere (100 by default).

  • noise (float, array) – If a float, it gives the width of the errorbar (the output spectrum will be noised with a normal distribution scaled with this value). if an array, the noise is simply added to the spectrum. 0 by default.

  • interp – Interpolation of the pressure in the transformation of the input atmosphere into the altitude-based atmosphere. It may be either one the parameters to pass to scipy.interpolate.interp1d function (see ‘kind’ parameters) or False (default option). If it is set to false, the pressure will be recomputed using compute_pressure.

  • gas_dict – Dictionary containing the names of the gas and the keys to find them in the input file (diagfi, hdf5). Defaults to {‘H2O’: ‘h2o_vap’}.

  • aerosols_dict – Similar to gas_dict, it’s a dictionary containing the names of the aerosols (and their characteristics) and the keys to find them in the input file (diagfi, hdf5). If only the name of the molecule is given, the key is assumed to represent the MMR (mass molecular ratio in kg/kg). Example : {‘H2O’: ‘h2o_ice’, ‘H2O_reff’: ‘H2Oice_reff’}.

  • planet (Planet) – Planet object.

  • star (Star) – Star object (not optional).

  • input_atmosphere (InputAtmosphere) – Input atmospheric grid based on levels (and inter-layers).

  • observer (Observer) – Position of the observer (latitude, longitude).

  • opacity (Opacity) – Opacity parameters.

  • transmission (Transmission) – Transmission parameters.

  • emission (Emission) – Emission parameters.

  • lightcurve (Lightcurve) – Lightcurve parameters.

  • phasecurve (Phasecurve) – Phasecurve parameters.

  • kwargs (dict) – You can use set/override other parameters using this.

property default_values
property stats_file

File with profiling statistics. Profiling is activated by start_profiling() and saved in dump_profiling(). Defaults to the same name as output_file, with ‘.prof’ as a file extension.

property atmosphere
property doppler
property grid
property shape
property n_latitudes: int
property n_longitudes: int
property n_layers: int
property n_levels: int
property altitude
property pressure
property temperature
property molar_mass
property gas_mix_ratio
property aerosols
property Rs
property surface

Surface area at each latitude x longitude.

property spectrum
property wns
property wnedges
property wls
property wledges
property spectrum_value
property spectrum_noised
noised_spectrum: exo_k.Spectrum | None

Noiseless spectrum.

modes = ['transmission', 'lightcurve', 'emission', 'phasecurve']

Names of modes, and their order of computation.

outputs()[source]
start_profiling(file=None)[source]

Start profiling code. Can specify in which file (optional).

dump_profiling(file=None)[source]

Save profiling stats in file (optional, defaults to stats_file).

Rp()[source]
gas(gas)[source]

Return the key corresponding to gas using user dictionary gas_dict.

aerosol(aerosol)[source]

Return the key corresponding to aerosol using user dictionary aerosols_dict.

read_data()[source]
override_data_file(params)[source]

This method allows subclasses to override the data read from data file (HDF5, diagfi, …)

override_file_param(data_name, config)[source]

Override an element from the datafile

Parameters:
  • data_name (string) – name of attribute to override

  • config (object) – object read from config file

default_value(data_name, value)[source]
build()[source]

Initialize the model once all the parameters have been set. Set default values if needed.

run(profiling=False)[source]

Run Pytmosph3R, i.e., compute the spectrum of a built model (the function build (or an equivalent) should have been called).

class FileModel(filename: str, *args, **kwargs)[source]

Bases: Model

Model reading from a file. Same parameters as Model, with the addition of a filename.

Main class to control all submodules. Here you control everything.

Parameters:
  • output_file (str) – HDF5 output filename.

  • n_vertical (int) – Number of vertical layers for the altitude-based atmosphere (100 by default).

  • noise (float, array) – If a float, it gives the width of the errorbar (the output spectrum will be noised with a normal distribution scaled with this value). if an array, the noise is simply added to the spectrum. 0 by default.

  • interp – Interpolation of the pressure in the transformation of the input atmosphere into the altitude-based atmosphere. It may be either one the parameters to pass to scipy.interpolate.interp1d function (see ‘kind’ parameters) or False (default option). If it is set to false, the pressure will be recomputed using compute_pressure.

  • gas_dict – Dictionary containing the names of the gas and the keys to find them in the input file (diagfi, hdf5). Defaults to {‘H2O’: ‘h2o_vap’}.

  • aerosols_dict – Similar to gas_dict, it’s a dictionary containing the names of the aerosols (and their characteristics) and the keys to find them in the input file (diagfi, hdf5). If only the name of the molecule is given, the key is assumed to represent the MMR (mass molecular ratio in kg/kg). Example : {‘H2O’: ‘h2o_ice’, ‘H2O_reff’: ‘H2Oice_reff’}.

  • planet (Planet) – Planet object.

  • star (Star) – Star object (not optional).

  • input_atmosphere (InputAtmosphere) – Input atmospheric grid based on levels (and inter-layers).

  • observer (Observer) – Position of the observer (latitude, longitude).

  • opacity (Opacity) – Opacity parameters.

  • transmission (Transmission) – Transmission parameters.

  • emission (Emission) – Emission parameters.

  • lightcurve (Lightcurve) – Lightcurve parameters.

  • phasecurve (Phasecurve) – Phasecurve parameters.

  • kwargs (dict) – You can use set/override other parameters using this.

abstract read_data(*args, **kwargs)[source]

Adapt this function according to your format. See read_data() for an example.

inputs()[source]