roms_tools.setup.utils.compute_mld#
- roms_tools.setup.utils.compute_mld(sigma0: DataArray, depth: DataArray, depth_dim: str, reference_depth: float = 10.0, threshold: float = 0.03) DataArray#
Compute the mixed layer depth (MLD) from a potential-density field.
Density-threshold criterion (de Boyer Montégut et al. 2004): the MLD is the (positive) depth at which sigma-0 first exceeds its value at
reference_depthbythresholdkg/m³, found by linear interpolation to the crossing. Fully mixed columns (no crossing) return the full water-column depth; all-NaN (land) columns return NaN. Works per horizontal column, so both 1D and spatially varying (3D)depthcoordinates and either vertical orientation (surface-first or surface-last) are supported.The crossing is found with
xgcm.transform— the same engine as xroms’mld/isoslice(so results are consistent with xroms; passreference_depth=0for the surface-referenced xroms convention). Like allxgcmlinear transforms it assumes a monotonic profile and does an endpoint flip rather than a full sort, so for a non-monotonic upper-ocean profile (a density inversion / barrier layer) it returns the linear-search crossing rather than guaranteeing the shallowest one.- Parameters:
sigma0 (xr.DataArray) – Potential density anomaly (e.g. from
compute_potential_density()) with vertical dimensiondepth_dim.depth (xr.DataArray) – Positive-down depth (m) aligned with
sigma0alongdepth_dim. May be 1D (broadcast over the horizontal) or sharesigma0’s horizontal dims.depth_dim (str) – Name of the vertical dimension.
reference_depth (float, optional) – Depth (m) at which the reference density is taken. Default 10 m (de Boyer Montégut). Columns shallower than
reference_depthfall back to the shallowest level. Pass 0 for the surface-referenced xroms convention.threshold (float, optional) – Density excess (kg/m³) defining the base of the mixed layer. Default 0.03.
- Returns:
xr.DataArray – MLD as positive depth (m), with
depth_dimremoved.
References
de Boyer Montégut, C., Madec, G., Fischer, A. S., Lazar, A., & Iudicone, D. (2004). Mixed layer depth over the global ocean. J. Geophys. Res. Oceans, 109(C12). See also xroms
roms_seawater.mldand the NCLmixed_layer_depthroutine.