Get percent composition of animal from body density

    The equation calculating animal density is from Biuw et al. (2003), and
    default values for component densities are from human studies collected in
    the book by Moore et al. (1963).

    Args
    ----
    dens_gcm3: float or ndarray
        An array of seal densities (g/cm^3). The calculations only yield valid
        percents with densities between 0.888-1.123 with other parameters left
        as defaults.
    dens_lipid: float
        Density of lipid content in the animal (g/cm^3)
    dens_prot: float
        Density of protein content in the animal (g/cm^3)
    dens_water: float
        Density of water content in the animal (g/cm^3)
    dens_ash: float
        Density of ash content in the animal (g/cm^3)

    Returns
    -------
    perc_all: pandas.DataFrame
        Dataframe of components of body composition

    References
    ----------
    Biuw, M., 2003. Blubber and buoyancy: monitoring the body condition of
    free-ranging seals using simple dive characteristics. Journal of
    Experimental Biology 206, 3405–3423. doi:10.1242/jeb.00583

    Moore FD, Oleson KH, McMurrery JD, Parker HV, Ball MR, Boyden CM. The Body
    Cell Mass and Its Supporting Environment - The Composition in Health and
    Disease. Philadelphia: W.B. Saunders Company; 1963. 535 p.
    ISBN:0-7216-6480-6

def dens2lip(dens_gcm3, dens_lipid=0.9007, dens_prot=1.34, dens_water=0.994,
        dens_ash=2.3):
    '''Get percent composition of animal from body density

    The equation calculating animal density is from Biuw et al. (2003), and
    default values for component densities are from human studies collected in
    the book by Moore et al. (1963).

    Args
    ----
    dens_gcm3: float or ndarray
        An array of seal densities (g/cm^3). The calculations only yield valid
        percents with densities between 0.888-1.123 with other parameters left
        as defaults.
    dens_lipid: float
        Density of lipid content in the animal (g/cm^3)
    dens_prot: float
        Density of protein content in the animal (g/cm^3)
    dens_water: float
        Density of water content in the animal (g/cm^3)
    dens_ash: float
        Density of ash content in the animal (g/cm^3)

    Returns
    -------
    perc_all: pandas.DataFrame
        Dataframe of components of body composition

    References
    ----------
    Biuw, M., 2003. Blubber and buoyancy: monitoring the body condition of
    free-ranging seals using simple dive characteristics. Journal of
    Experimental Biology 206, 3405–3423. doi:10.1242/jeb.00583

    Moore FD, Oleson KH, McMurrery JD, Parker HV, Ball MR, Boyden CM. The Body
    Cell Mass and Its Supporting Environment - The Composition in Health and
    Disease. Philadelphia: W.B. Saunders Company; 1963. 535 p.
    ISBN:0-7216-6480-6
    '''
    import numpy

    # Cast iterables to numpy array
    if numpy.iterable(dens_gcm3):
        dens_gcm3 = numpy.asarray(dens_gcm3)

    # Numerators
    ad_num =  -3.2248 * dens_ash
    pd_num = -25.2786 * dens_prot
    wd_num = -71.4966 * dens_water

    # Denominators
    ad_den = -0.034  * dens_ash
    pd_den = -0.2857 * dens_prot
    wd_den = -0.6803 * dens_water

    perc_lipid = ((100 * dens_gcm3) + ad_num + pd_num + wd_num) / \
                        (dens_lipid + ad_den + pd_den + wd_den)

    return perc_lipid