-
Notifications
You must be signed in to change notification settings - Fork 1
/
thetaep.py
84 lines (64 loc) · 1.69 KB
/
thetaep.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
"""This is the docstring for the thetaep.py module."""
import numpy as np
from constants import constants
from LCLfind import LCLfind
from wsat import wsat
from theta import theta
def thetaep(Td, T, p):
"""
thetaep(Td, T, p)
Calculates the pseudo equivalent potential temperature of a
parcel.
Parameters
- - - - - -
Td : float
Dewpoint temperature (K).
T : float
Temperature (K).
p : float
Pressure (Pa).
Returns
- - - -
thetaepOut : float
Pseudo equivalent potential temperature (K).
Notes
- - -
Note that the pseudo equivalent potential temperature of an air
parcel is not a conserved variable.
References
- - - - - -
Emanuel 4.7.9 p. 132
Examples
- - - - -
>>> thetaep(280., 300., 8.e4) # Parcel is unsaturated.
344.99830738253371
>>> thetaep(300., 280., 8.e4) # Parcel is saturated.
321.5302927767795
"""
c = constants();
if Td < T:
#parcel is unsaturated
[Tlcl, plcl] = LCLfind(Td, T, p);
wv = wsat(Td, p);
else:
#parcel is saturated -- prohibit supersaturation with Td > T
Tlcl = T;
wv = wsat(T, p);
# $$$ disp('inside theate')
# $$$ [Td,T,wv]
thetaval = theta(T, p, wv);
power = 0.2854 * (1 - 0.28 * wv);
thetaep = thetaval * np.exp(wv * (1 + 0.81 * wv) \
* (3376. / Tlcl - 2.54));
#
# peg this at 450 so rootfinder won't blow up
#
#thetaepOut = thetaep
#if(thetaepOut > 450.):
# thetaepOut = 450;
return thetaep
def _test():
import doctest
doctest.testmod()
if __name__ == "__main__":
_test()