Source code for pycif.plugins.transforms.complex.diagmet.utils.convection

import numpy as np


[docs] def convection(transf, inout_datastore, ddi, mapper): """Compute convective mass fluxes (up-draught and down-draught) for CHIMERE. Passes through the ECMWF updraught/downdraught detrainment profiles (``dpdu``, ``dpdd``, clipped to non-negative values) and recovers the corresponding entrainment profiles (``dpeu``, ``dped``) as the level-to-level convergence of the mass flux plus the detrainment term. All four outputs are zero when ``deep_convection`` is disabled. See :doc:`/documentation/doc-models/chimere/diagmet` (section 12) 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. """ # Compute convection if transf.deep_convection: upfl = inout_datastore["inputs"][("meteo", "mumf")][ddi]["spec"] dpdu = inout_datastore["inputs"][("meteo", "mudr")][ddi]["spec"] dwfl = inout_datastore["inputs"][("meteo", "mdmf")][ddi]["spec"] dpdd = inout_datastore["inputs"][("meteo", "mddr")][ddi]["spec"] else: upfl = 0. * inout_datastore["inputs"][("meteo", "temp")][ddi]["spec"] dpdu = 0. * inout_datastore["inputs"][("meteo", "temp")][ddi]["spec"] dwfl = 0. * inout_datastore["inputs"][("meteo", "temp")][ddi]["spec"] dpdd = 0. * inout_datastore["inputs"][("meteo", "temp")][ddi]["spec"] dpeu = np.concatenate([ upfl[:, [0]] + dpdu[:, [0]], upfl[:, 1:] - upfl[:, :-1] + dpdu[:, 1:], ], axis=1) dped = np.concatenate([ dwfl[:, 1:] - dwfl[:, :-1] + dpdd[:, :-1], -dwfl[:, [-1]] + dpdd[:, [-1]] ], axis=1) # Put back to datastore inout_datastore["outputs"][("meteo", "dpdu")][ddi]["spec"] = \ 0. * upfl + np.maximum(0, dpdu) inout_datastore["outputs"][("meteo", "dpdd")][ddi]["spec"] = \ 0. * upfl + np.maximum(0, dpdd) inout_datastore["outputs"][("meteo", "dpeu")][ddi]["spec"] = \ 0. * upfl + np.maximum(0, dpeu) inout_datastore["outputs"][("meteo", "dped")][ddi]["spec"] = \ 0. * upfl + np.maximum(0, dped)