Skip to content
Snippets Groups Projects
Commit e734a9b7 authored by Lukas Kluft's avatar Lukas Kluft
Browse files

Fix syntax of most doctests

parent 05a6abde
No related branches found
No related tags found
1 merge request!1Fix doctests
...@@ -21,8 +21,8 @@ def es_liq(T): ...@@ -21,8 +21,8 @@ def es_liq(T):
""" Returns the saturation vapor pressure of water over liquid following Wagner and Pruss (2002) """ Returns the saturation vapor pressure of water over liquid following Wagner and Pruss (2002)
fits for saturation over planar liquid. These formulations were found to be the most accurate as fits for saturation over planar liquid. These formulations were found to be the most accurate as
compared to the IAPWS standard for warm temperatures compared to the IAPWS standard for warm temperatures
>>> mt.es_liq(np.asarray([273.16,305.])) >>> es_liq(np.asarray([273.16,305.]))
[611.65706974, 4719.32683147] array([ 611.65706974, 4719.32683147])
""" """
TvC = constants.temperature_water_vapor_critical_point TvC = constants.temperature_water_vapor_critical_point
PvC = constants.pressure_water_vapor_critical_point PvC = constants.pressure_water_vapor_critical_point
...@@ -65,8 +65,8 @@ def es_liq_analytic(T, delta_cl=constants.delta_cl): ...@@ -65,8 +65,8 @@ def es_liq_analytic(T, delta_cl=constants.delta_cl):
that require consisntency with assumption of cp's being constant. The analytic that require consisntency with assumption of cp's being constant. The analytic
expressions become identical to Romps (2017) in the case when the differential specific expressions become identical to Romps (2017) in the case when the differential specific
heats are adjusted to his suggested values. heats are adjusted to his suggested values.
>>> es(np.asarray([273.16,305.])) >>> es_liq_analytic(np.asarray([273.16,305.]))
[611.655, 4711.13161169] array([ 611.655 , 4711.13161169])
""" """
TvT = constants.temperature_water_vapor_triple_point TvT = constants.temperature_water_vapor_triple_point
PvT = constants.pressure_water_vapor_triple_point PvT = constants.pressure_water_vapor_triple_point
...@@ -85,7 +85,7 @@ def es_ice_analytic(T, delta_ci=constants.delta_ci): ...@@ -85,7 +85,7 @@ def es_ice_analytic(T, delta_ci=constants.delta_ci):
expressions become identical to Romps (2017) in the case when the differential specific expressions become identical to Romps (2017) in the case when the differential specific
heats are adjusted to his suggested values. heats are adjusted to his suggested values.
>>> es_ice_analytic(np.asarray([273.16,260.])) >>> es_ice_analytic(np.asarray([273.16,260.]))
[611.655, 195.99959431] array([611.655 , 195.99959431])
""" """
TvT = constants.temperature_water_vapor_triple_point TvT = constants.temperature_water_vapor_triple_point
PvT = constants.pressure_water_vapor_triple_point PvT = constants.pressure_water_vapor_triple_point
...@@ -101,16 +101,15 @@ def es_mxd_analytic(T, delta_cl=constants.delta_cl, delta_ci=constants.delta_ci) ...@@ -101,16 +101,15 @@ def es_mxd_analytic(T, delta_cl=constants.delta_cl, delta_ci=constants.delta_ci)
""" Saturation vapor pressure of water over liquid (T>Tmelt) or ice (T>Tmel) following the """ Saturation vapor pressure of water over liquid (T>Tmelt) or ice (T>Tmel) following the
analytic formulations (constant cp) for each of these. analytic formulations (constant cp) for each of these.
>>> es_ice_analytic(np.asarray([273.16,260.])) >>> es_ice_analytic(np.asarray([273.16,260.]))
[4711.13161169, 195.99959431] array([611.655 , 195.99959431])
""" """
return np.maximum(es_liq_analytic(T,delta_cl),es_ice_analytic(T,delta_ci)) return np.maximum(es_liq_analytic(T,delta_cl),es_ice_analytic(T,delta_ci))
def vaporization_enthalpy(TK,delta_cl=constants.delta_cl): def vaporization_enthalpy(TK,delta_cl=constants.delta_cl):
""" Returns the enthlapy [J/g] of vaporization (default) of water vapor or """ Returns the enthlapy [J/g] of vaporization (default) of water vapor or
(if fusion=True) the fusion anthalpy. Input temperature can be in degC or Kelvin (if fusion=True) the fusion anthalpy. Input temperature can be in degC or Kelvin
>>> vaporization_enthalpy(np.asarray([305.,273.15]) >>> vaporization_enthalpy(np.asarray([305.,273.15]))
[2500930., 2427211.264] array([2427211.264, 2500930. ])
""" """
T0 = constants.standard_temperature T0 = constants.standard_temperature
lv0 = constants.vaporization_enthalpy_stp lv0 = constants.vaporization_enthalpy_stp
...@@ -120,7 +119,7 @@ def sublimation_enthalpy(TK,delta_ci=constants.delta_ci): ...@@ -120,7 +119,7 @@ def sublimation_enthalpy(TK,delta_ci=constants.delta_ci):
""" Returns the enthlapy [J/g] of vaporization (default) of water vapor or """ Returns the enthlapy [J/g] of vaporization (default) of water vapor or
(if fusion=True) the fusion anthalpy. Input temperature can be in degC or Kelvin (if fusion=True) the fusion anthalpy. Input temperature can be in degC or Kelvin
>>> sublimation_enthalpy(273.15) >>> sublimation_enthalpy(273.15)
[2834350., 2834881.523] 2834350.0
""" """
T0 = constants.standard_temperature T0 = constants.standard_temperature
ls0 = constants.sublimation_enthalpy_stp ls0 = constants.sublimation_enthalpy_stp
...@@ -129,7 +128,7 @@ def sublimation_enthalpy(TK,delta_ci=constants.delta_ci): ...@@ -129,7 +128,7 @@ def sublimation_enthalpy(TK,delta_ci=constants.delta_ci):
def partial_pressure_to_mixing_ratio(pp,p): def partial_pressure_to_mixing_ratio(pp,p):
""" Calculates mixing ratio from the partial and total pressure assuming """ Calculates mixing ratio from the partial and total pressure assuming
no condensate is present. Returns value in units of kg/kg. no condensate is present. Returns value in units of kg/kg.
>>> partial_pressure_to_mixing_ratio(es(300.),60000.) >>> partial_pressure_to_mixing_ratio(es_liq(300.),60000.)
0.0389569254590098 0.0389569254590098
""" """
eps1 = constants.rd_over_rv eps1 = constants.rd_over_rv
...@@ -148,7 +147,7 @@ def partial_pressure_to_specific_humidity(pp,p): ...@@ -148,7 +147,7 @@ def partial_pressure_to_specific_humidity(pp,p):
""" Calculates specific mass from the partial and total pressure """ Calculates specific mass from the partial and total pressure
assuming both have same units and no condensate is present. Returns value assuming both have same units and no condensate is present. Returns value
in units of kg/kg. in units of kg/kg.
>>> partial_pressure_to_specific_humidity(es(300.),60000.) >>> partial_pressure_to_specific_humidity(es_liq(300.),60000.)
0.037496189210922945 0.037496189210922945
""" """
r = partial_pressure_to_mixing_ratio(pp,p) r = partial_pressure_to_mixing_ratio(pp,p)
...@@ -307,8 +306,8 @@ def T_from_Te(Te,P,qt,es=es_liq): ...@@ -307,8 +306,8 @@ def T_from_Te(Te,P,qt,es=es_liq):
def T_from_Tl(Tl,P,qt,es=es_liq): def T_from_Tl(Tl,P,qt,es=es_liq):
""" Given theta_e solves implicitly for the temperature at some other pressure, """ Given theta_e solves implicitly for the temperature at some other pressure,
so that theta_e(T,P,qt) = Te so that theta_e(T,P,qt) = Te
>>> T_from_Tl(282.75436951,90000,20.e-3) >>> T_from_Tl(282., 90000, 20.e-3)
290.00 array([289.73684039])
""" """
def zero(T,Tl,P,qt,es=es): def zero(T,Tl,P,qt,es=es):
return np.abs(Tl-theta_l(T,P,qt,es=es)) return np.abs(Tl-theta_l(T,P,qt,es=es))
...@@ -318,7 +317,7 @@ def T_from_Ts(Ts,P,qt,es=es_liq): ...@@ -318,7 +317,7 @@ def T_from_Ts(Ts,P,qt,es=es_liq):
""" Given theta_e solves implicitly for the temperature at some other pressure, """ Given theta_e solves implicitly for the temperature at some other pressure,
so that theta_e(T,P,qt) = Te so that theta_e(T,P,qt) = Te
>>> T_from_Tl(282.75436951,90000,20.e-3) >>> T_from_Tl(282.75436951,90000,20.e-3)
290.00 array([289.98864293])
""" """
def zero(T,Ts,P,qt,es=es): def zero(T,Ts,P,qt,es=es):
return np.abs(Ts-theta_s(T,P,qt,es=es)) return np.abs(Ts-theta_s(T,P,qt,es=es))
...@@ -337,8 +336,8 @@ def P_from_Te(Te,T,qt,es=es_liq): ...@@ -337,8 +336,8 @@ def P_from_Te(Te,T,qt,es=es_liq):
def P_from_Tl(Tl,T,qt,es=es_liq): def P_from_Tl(Tl,T,qt,es=es_liq):
""" Given Tl solves implicitly for the pressure at some temperature and qt """ Given Tl solves implicitly for the pressure at some temperature and qt
so that theta_l(T,P,qt) = Tl so that theta_l(T,P,qt) = Tl
>>> T_from_Tl(282.75436951,290,20.e-3) >>> P_from_Tl(282.75436951,290,20.e-3)
90000 array([90027.65146427])
""" """
def zero(P,Tl,T,qt,es=es): def zero(P,Tl,T,qt,es=es):
return np.abs(Tl-theta_l(T,P,qt,es=es)) return np.abs(Tl-theta_l(T,P,qt,es=es))
...@@ -347,7 +346,7 @@ def P_from_Tl(Tl,T,qt,es=es_liq): ...@@ -347,7 +346,7 @@ def P_from_Tl(Tl,T,qt,es=es_liq):
def plcl(TK,PPa,qt,es=es_liq): def plcl(TK,PPa,qt,es=es_liq):
""" Iteratively solve for the pressure [Pa] of the LCL, allows for saturate air. """ Iteratively solve for the pressure [Pa] of the LCL, allows for saturate air.
>>> plcl(300.,102000.,17e-3) >>> plcl(300.,102000.,17e-3)
95971.6975098 array([95971.6975098])
""" """
p2r = partial_pressure_to_mixing_ratio p2r = partial_pressure_to_mixing_ratio
...@@ -363,7 +362,7 @@ def plcl_bolton(TK,PPa,qt): ...@@ -363,7 +362,7 @@ def plcl_bolton(TK,PPa,qt):
""" Returns the pressure [Pa] of the LCL using the Bolton formula. Usually accurate to """ Returns the pressure [Pa] of the LCL using the Bolton formula. Usually accurate to
within about 10 Pa, or about 1 m within about 10 Pa, or about 1 m
>>> plcl_bolton(300.,102000.,17e-3) >>> plcl_bolton(300.,102000.,17e-3)
95980.41895404423.495 95980.41895404423
""" """
Rd = constants.dry_air_gas_constant Rd = constants.dry_air_gas_constant
Rv = constants.water_vapor_gas_constant Rv = constants.water_vapor_gas_constant
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment