Source code for taurex.data.profiles.chemistry.gas.constantgas
"""Constant gas profile."""importtypingastimportnumpyasnpimportnumpy.typingasnptfromtaurex.outputimportOutputGroupfromtaurex.utilimportmolecule_texlabelfrom.gasimportGas
[docs]classConstantGas(Gas):"""Constant gas profile. Molecular abundace is constant at each layer of the atmosphere """def__init__(self,molecule_name:t.Optional[str]="H2O",mix_ratio:t.Optional[float]=1e-5,)->None:"""Initialize constant gas profile. Parameters ----------- molecule_name : str Name of molecule mix_ratio : float Mixing ratio of the molecule """super().__init__("ConstantGas",molecule_name)self._mix_ratio=mix_ratioself.add_active_gas_param()@propertydefmixProfile(self)->npt.NDArray[np.float64]:# noqa: N802""" Mixing profile Returns ------- mix: :obj:`array` Mix ratio for molecule at each layer """returnself._mix_array
[docs]definitialize_profile(self,nlayers:t.Optional[int]=None,temperature_profile:t.Optional[npt.NDArray[np.float64]]=None,pressure_profile:t.Optional[npt.NDArray[np.float64]]=None,altitude_profile:t.Optional[npt.NDArray[np.float64]]=None,)->None:"""Initialize the mixing profile. Parameters ----------- nlayers: int Number of layers in atmosphere temperature_profile: :obj:`array` Temperature profile of atmosphere pressure_profile: :obj:`array` Pressure profile of atmosphere altitude_profile: :obj:`array` Altitude profile of atmosphere, deprecated """self._mix_array=np.full(nlayers,self._mix_ratio)
[docs]defadd_active_gas_param(self)->None:"""Add the mixing ratio as a fitting parameter. Fitting parameter identifier is the molecule name. Generates a fitting parameter on the fly by building getter and setter functions and passing them to :func:`taurex.fitting.fittable.Fittable.add_fittable_param` """mol_name=self.moleculeparam_name=self.moleculeparam_tex=molecule_texlabel(mol_name)defread_mol(self):returnself._mix_ratiodefwrite_mol(self,value):self._mix_ratio=valueread_mol.__doc__=f"{mol_name} constant mix ratio (VMR)"fget=read_molfset=write_molbounds=[1.0e-12,0.1]default_fit=Falseself.add_fittable_param(param_name,param_tex,fget,fset,"log",default_fit,bounds)
[docs]defwrite(self,output:OutputGroup):"""Write constant gas profile to output."""gas_entry=super().write(output)gas_entry.write_scalar("mix_ratio",self._mix_ratio)returngas_entry