def rho_CT_exact(SA, CT, p):
    r"""Calculates in-situ density from Absolute Salinity and Conservative
    Temperature.

    Parameters
    ----------
    SA : array_like
         Absolute Salinity  [g/kg]
    CT : array_like
         Conservative Temperature [:math:`^\circ` C (ITS-90)]
    p : array_like
        sea pressure [dbar]

    Returns
    -------
    rho_CT_exact : array_like
                   in-situ density [kg/m**3]

    See Also
    --------
    TODO

    Notes
    -----
    The potential density with respect to reference pressure, p_ref, is
    obtained by calling this function with the pressure argument being p_ref
    (i.e. "rho_CT_exact(SA, CT, p_ref)").  This function uses the full Gibbs
    function.  There is an alternative to calling this function, namely
    rho_CT(SA, CT, p), which uses the computationally efficient 48-term
    expression for density in terms of SA, CT and p (McDougall et al., 2011).

    Examples
    --------
    TODO

    References
    ----------
    .. [1] IOC, SCOR and IAPSO, 2010: The international thermodynamic equation
    of seawater - 2010: Calculation and use of thermodynamic properties.
    Intergovernmental Oceanographic Commission, Manuals and Guides No. 56,
    UNESCO (English), 196 pp. See Eqn. (2.8.2).

    .. [2] McDougall T.J., P.M. Barker, R. Feistel and D.R. Jackett, 2011:  A
    computationally efficient 48-term expression for the density of
    seawater in terms of Conservative Temperature, and related properties
    of seawater.

    Modifications:
    2011-04-03. Trevor McDougall and Paul Barker.
    """

    t = t_from_CT(SA, CT, p)
    return rho_t_exact(SA, t, p)
def rho_alpha_beta_CT_exact(SA, CT, p):
    r"""Calculates in-situ density, the appropriate thermal expansion
    coefficient and the appropriate saline contraction coefficient of seawater
    from Absolute Salinity and Conservative Temperature.

    See the individual functions rho_CT_exact, alpha_CT_exact, and
    beta_CT_exact.  Retained for compatibility with the Matlab GSW toolbox.
    """

    t = t_from_CT(SA, CT, p)
    rho_CT_exact = rho_t_exact(SA, t, p)
    alpha_CT_exact = alpha_wrt_CT_t_exact(SA, t, p)
    beta_CT_exact = beta_const_CT_t_exact(SA, t, p)

    return rho_CT_exact, alpha_CT_exact, beta_CT_exact
def sigma4_CT_exact(SA, CT):
    r"""Calculates potential density anomaly with reference pressure of
    4000 dbar."""
    t = t_from_CT(SA, CT, 4000.)
    return rho_t_exact(SA, t, 4000.) - 1000