Source code for pycif.plugins.transforms.complex.diagmet.utils.low_cloud_top
import numpy as np
[docs]
def low_cloud_top(transf, inout_datastore, ddi, mapper):
"""Compute the top pressure of the low cloud layer from relative humidity and temperature.
Relative humidity is derived at every level from the Tetens saturation
vapour pressure formula. Outputs the surface relative humidity (``sreh``)
and stores a below-1000 m maximum relative humidity (``rhmaxx``, clipped to
:math:`[0.90, 1]`) in ``transf.diag_misc`` for use by
:func:`~pycif.plugins.transforms.complex.diagmet.utils.vertical_turbulent_diffusivity.vertical_turbulent_diffusivity`.
See :doc:`/documentation/doc-models/chimere/diagmet` (section 9) for the
full derivation.
Args:
transf (Plugin): diagmet transform instance.
inout_datastore (dict): mutable datastore.
ddi (datetime): current sub-simulation date.
mapper (dict): transform mapper.
"""
# Parameters
crhx = 0.90 # Min RH for cloud BLH enhancement
topcldmax = 1000.
# Inputs
temp = transf.diag_misc["temp"]
sphu = transf.diag_misc["sphu"]
pres = transf.diag_misc["pres"]
alti = transf.diag_misc["alti"]
# Compute rh
vapp = 611. * np.exp(17.27 * (temp - 273.15) / (temp - 35.86))
qsbt = 0.622 * vapp / (pres - vapp)
rh = sphu / qsbt
ntime, nlev, nlat, nlon = alti.shape
ind_cloud = np.maximum(0, np.argmin(alti <= topcldmax, axis=1) - 1)
t, i, j = np.meshgrid(np.arange(ntime), np.arange(nlat), np.arange(nlon),
indexing="ij")
rhmaxx = np.minimum(1., np.maximum(crhx, rh[t, ind_cloud, i, j]))
# Save for later
transf.diag_misc["rhmaxx"] = rhmaxx
transf.diag_misc["rh"] = rh
ref_dataarray = 0 * inout_datastore["outputs"][("meteo", "hght")][ddi]["spec"]
inout_datastore["outputs"][("meteo", "sreh")][ddi]["spec"] = \
ref_dataarray + np.minimum(1, np.maximum(rh[:, [0]], 0))