pytmosph3r.model.diagfimodel

Module Contents

class DiagfiModel(t: int = -1, var_dict: Dict | None = None, gas_units: str | None = None, aerosols_units: str | None = None, extra_longitude: bool = True, *args, **kwargs)[source]

Bases: pytmosph3r.model.model.FileModel

Model reading from a diagfi.nc file, from a LMDZ GCM for example. Same parameters as FileModel, plus the ones listed here. See DiagfiData for the structure of the diagfi file.

To read from a diagfi, you may need the following parameters:

Parameters:
  • t (int) – Time slice to read from diagfi input file. If you do not have time-dependent data,set it to False. By default, takes the last time slice.

  • var_dict (dict) – Dictionary listing the names of the variables in the input file. Includes pressure ‘p’ and temperature ‘temp’ for now, as well as their surface values, and the surface area. ‘u’,’v’ and ‘w’ are the zonal, meridional and vertical winds, respectively. Defaults to {‘p’:’p’, ‘temp’:’temp’, ‘ps’:’ps’, ‘tsurf’:’tsurf’, ‘surface’:’aire’, ‘u’:’u’, ‘v’:’v’, ‘w’:’w’}.

  • gas_units (str) – Used to indicate what units are in the input file. For example “log_vmr” indicates it is a log of a VMR. Possible units are “vmr”, “mmr”, “log_vmr”, “log_mmr”,”ln_vmr”, “ln_mmr”.

  • aerosols_units (str) – Used to indicate what units are in the input file. For example “log_mmr” indicates it is a log of a MMR. Possible units are “mmr”, “log_mmr”, “ln_mmr”.

  • input_mu (float) – Molar mass (if you need to convert MMR to VMR).

gas_units

Units of gases in input file.

aerosols_units

Units of aerosols in input file.

var_dict

Dictionary listing the names of the variables in the input file. This includes pressure ‘p’ and temperature ‘temp’, as well as surface pressure and temperature ‘ps’ and ‘tsurf’, or the surface ‘surface’. ‘u’,’v’ and ‘w’ are the zonal, meridional and vertical winds, respectively.

extra_longitude

If the last longitude is a duplicate of the first one.

inputs()[source]
read_data()[source]

Read data from a diagfi.nc file generated by the LMDZ GCM. The netCDF file should have at least a temperature temp and a pressure either defined by p on all grid points or by ps the surface pressure and coefficients ap, bp and aps, bps. For the gas and aerosols descriptions, see library_input. The controle variable should (preferrably) list:

  1. \(n_{longitudes}\) (optional, last longitude is a duplicate from the first one)

  2. \(n_{latitudes}\) (optional)

  3. \(n_{vertical}\) (optional)

  4. \(R_{p}\) (planet radius) in m

  5. #NOT USED#

  6. \(g_{0}\) (surface gravity)

  7. \(\mu\) (molar mass) in g/mol (if abundances given in mass mixing ratios)

grid_to_radians(f, grid)[source]

Convert latitudes and longitudes to radians.

read_gases(f, controle)[source]

Read gases from f file descriptor using gas_dict.

read_aerosols(f)[source]

Read aerosols from diagfi using aerosols_dict. Each key should be composed of the name of the aerosol + the entry it corresponds to. The entries we will try to find are: ["mmr", "reff", "condensate_density", "p_min", "optical_properties"]. Example of a valid dictionary: {‘H2O’: ‘h2o_ice’, ‘H2O_reff’: ‘H2Oice_reff’}.

read_winds(f, grid)[source]

Read winds from diagfi using winds_dict. Each key should be composed of the name of the aerosol + the entry it corresponds to. The entries we will try to find are: ["mmr", "reff", "condensate_density", "p_min", "optical_properties"]. Example of a valid dictionary: {‘H2O’: ‘h2o_ice’, ‘H2O_reff’: ‘H2Oice_reff’}.

get_var(var, t=None, ndim=3)[source]

Try to fit the dimensions of one variable read from the input file. If the attribute extra_longitude of the class is set, we remove one longitude. If t: is not None nor False, we take the corresponding timestep in the simulation.

Parameters:
  • var (ndarray) – Raw array read from the input file.

  • t (int, optional) – Timestep to read in input file. If None, uses the attribute :attr:`t: of the class. If False, does not read any timestep. Defaults to None.

  • ndim (int, optional) – Check if the output variable has the required number of dimensions ndim. Defaults to 3.

Returns:

Array at timestep t and that should have ndim dimensions.

Return type:

ndarray

extend_bt(array, surf=None)[source]
extend_b(array, surf=None)[source]