Source code for taurex.data.profiles.temperature.tprofile
"""Base temperature class."""importtypingastimportnumpyasnpimportnumpy.typingasnptfromtaurex.data.citationimportCitablefromtaurex.data.fittableimportFittable,derivedparamfromtaurex.logimportLoggerfromtaurex.outputimportOutputGroupfromtaurex.output.writeableimportWriteablefromtaurex.planetimportPlanet
[docs]classTemperatureProfile(Fittable,Logger,Writeable,Citable):"""Defines temperature profile for an atmosphere. *Abstract Class* Must define: - :func:`profile` """def__init__(self,name:str):"""Initialize temperature class. Parameters ---------- name : str Name used in logging """Logger.__init__(self,name)Fittable.__init__(self)
[docs]definitialize_profile(self,planet:t.Optional[Planet]=None,nlayers:t.Optional[int]=100,pressure_profile:t.Optional[npt.NDArray]=None,):"""Initializes the profile. Parameters ---------- planet: :class:`~taurex.data.planet.Planet` nlayers: int Number of layers in atmosphere pressure_profile: :obj:`array` Pressure at each layer of the atmosphere """self.nlayers=nlayersself.nlevels=nlayers+1self.pressure_profile=pressure_profileself.planet=planet
@propertydefprofile(self)->npt.NDArray[np.float64]:"""Temperature profile at each layer. Must return a temperature profile at each layer of the atmosphere Returns ------- temperature: :obj:`array` Temperature in Kelvin """raiseNotImplementedError
[docs]defwrite(self,output:OutputGroup)->OutputGroup:"""Write temperature profile to output."""temperature=output.create_group("Temperature")temperature.write_string("temperature_type",self.__class__.__name__)returntemperature
@derivedparam(param_name="avg_T",param_latex="$\\bar{T}$",compute=False)defaverageTemperature(self)->float:# noqa: N802"""Average temperature across all layers."""returnnp.mean(self.profile)
[docs]@classmethoddefinput_keywords(cls)->t.Tuple[str,...]:"""Return all input keywords."""raiseNotImplementedError