|
1
|
|
|
# Copyright (c) 2008-2015 MetPy Developers. |
|
2
|
|
|
# Distributed under the terms of the BSD 3-Clause License. |
|
3
|
|
|
# SPDX-License-Identifier: BSD-3-Clause |
|
4
|
|
|
"""Contains calculation of various derived indicies.""" |
|
5
|
|
|
import numpy as np |
|
6
|
|
|
|
|
7
|
|
|
from .thermo import mixing_ratio, saturation_vapor_pressure |
|
8
|
|
|
from .tools import get_layer |
|
9
|
|
|
from ..constants import g, rho_l |
|
10
|
|
|
from ..package_tools import Exporter |
|
11
|
|
|
from ..units import check_units, units |
|
12
|
|
|
|
|
13
|
|
|
exporter = Exporter(globals()) |
|
14
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
@exporter.export |
|
17
|
|
|
@check_units('[temperature]', '[pressure]', '[pressure]') |
|
18
|
|
|
def precipitable_water(dewpt, p, top=400 * units('hPa')): |
|
19
|
|
|
r"""Calculate precipitable water through the depth of a sounding. |
|
20
|
|
|
|
|
21
|
|
|
Default layer depth is sfc-400 hPa. Formula used is: |
|
22
|
|
|
|
|
23
|
|
|
\begin{align} |
|
24
|
|
|
\frac{1}{pg} \int\limits_0^d x \,dp |
|
25
|
|
|
\end{align} |
|
26
|
|
|
|
|
27
|
|
|
from [Tsonis2008]_, p. 170. |
|
28
|
|
|
|
|
29
|
|
|
Parameters |
|
30
|
|
|
---------- |
|
31
|
|
|
dewpt : array-like |
|
32
|
|
|
Atmospheric dewpoint profile |
|
33
|
|
|
p : array-like |
|
34
|
|
|
Atmospheric pressure profile |
|
35
|
|
|
top: `pint.Quantity` |
|
36
|
|
|
The top of the layer, specified in pressure. |
|
37
|
|
|
|
|
38
|
|
|
Returns |
|
39
|
|
|
------- |
|
40
|
|
|
`pint.Quantity' |
|
41
|
|
|
The precipitable water in the layer, in inches |
|
42
|
|
|
|
|
43
|
|
|
""" |
|
44
|
|
|
pres_layer, dewpt_layer = get_layer(p, dewpt, depth=p[0] - top) |
|
45
|
|
|
|
|
46
|
|
|
w = mixing_ratio(saturation_vapor_pressure(dewpt_layer), pres_layer) |
|
47
|
|
|
|
|
48
|
|
|
sort_inds = np.argsort(pres_layer) |
|
49
|
|
|
pres_layer = pres_layer[sort_inds] |
|
50
|
|
|
w = w[sort_inds] |
|
51
|
|
|
|
|
52
|
|
|
pw = ((np.trapz(w, pres_layer) / (g * rho_l)) * 100 * |
|
53
|
|
|
(units('kilogram') / units('m*s^2'))).to('inches') |
|
54
|
|
|
|
|
55
|
|
|
return pw |
|
56
|
|
|
|