def conv_precip_frac(precip_largescale, precip_convective):
    """Fraction of total precip that is from convection parameterization.

    Parameters
    ----------
    precip_largescale, precip_convective : xarray.DataArrays
        Precipitation from grid-scale condensation and from convective
        parameterization, respectively.

    Returns
    -------
    xarray.DataArray
    """
    total = total_precip(precip_largescale, precip_convective)
    # Mask using xarray's `where` method to prevent divide-by-zero.
    return precip_convective / total.where(total)
Fraction of total precip that is from convection parameterization.

    Parameters
    ----------
    precip_largescale, precip_convective : xarray.DataArrays
        Precipitation from grid-scale condensation and from convective
        parameterization, respectively.

    Returns
    -------
    xarray.DataArray