import xarray as xr
from .utils.uv_rotation import uv_rotation
from .utils.altipres import altipres
from .utils.checkcfl import checkcfl
from .utils.vertical_turbulent_diffusivity import vertical_turbulent_diffusivity
from .utils.convection import convection
from .utils.boundary_layer_height import boundary_layer_height
from .utils.mean_z0_shf_extra_urban_temp import mean_z0_shf_extra_urban_temp
from .utils.friction_velocity import friction_velocity
from .utils.sv_heat_flux import sv_heat_flux
from .utils.obukov_length import obukov_length
from .utils.low_cloud_top import low_cloud_top
from .utils.defcolumn import defcolumn
from .utils.precipitations import precipitations
from .utils.cloud_optical_thickness import cloud_optical_thickness
[docs]
def forward(
transf,
inout_datastore,
controlvect,
obsvect,
mapper,
di,
df,
mode,
runsubdir,
workdir,
onlyinit=False,
**kwargs
):
ddi = min(di, df)
# Initialize diag_misc to allow propagation of temporary variables
# from one function to the other
transf.diag_misc = {}
# Directly transfer variables if output in input
for trid in mapper["outputs"]:
if trid in inout_datastore["inputs"]:
inout_datastore["outputs"][trid][ddi] = \
inout_datastore["inputs"][trid][ddi]
# Compute pressure, altitudes
altipres(transf, inout_datastore, ddi, mapper)
# Interpolate variables to surface
defcolumn(transf, inout_datastore, ddi, mapper)
# Do u/v rotation
uv_rotation(transf, inout_datastore, ddi, mapper)
# Correction by urban heat
mean_z0_shf_extra_urban_temp(transf, inout_datastore, ddi, mapper)
# SV heat flux
sv_heat_flux(transf, inout_datastore, ddi, mapper)
# Compute ustar
friction_velocity(transf, inout_datastore, ddi, mapper)
# Boundary layer height
boundary_layer_height(transf, inout_datastore, ddi, mapper)
# Check CFL conditions
checkcfl(transf, inout_datastore, ddi, mapper)
# Low cloud top
low_cloud_top(transf, inout_datastore, ddi, mapper)
# Obukov length
obukov_length(transf, inout_datastore, ddi, mapper)
# Vertical turbulent diffusivity at top CHIMERE layers
vertical_turbulent_diffusivity(transf, inout_datastore, ddi, mapper)
# Convection
convection(transf, inout_datastore, ddi, mapper)
# Precipatation
precipitations(transf, inout_datastore, ddi, mapper)
# Cloud optical thickness
cloud_optical_thickness(transf, inout_datastore, ddi, mapper)
# Remove diag_misc from memory
del transf.diag_misc