def SWdensityFromCTD(SA, t, p, potential=False):
    """Calculate seawater density at CTD depth

    Args
    ----
    SA: ndarray
        Absolute salinity, g/kg
    t: ndarray
        In-situ temperature (ITS-90), degrees C
    p: ndarray
        Sea pressure (absolute pressure minus 10.1325 dbar), dbar

    Returns
    -------
    rho: ndarray
        Seawater density, in-situ or potential, kg/m^3
    """
    import numpy
    import gsw
    CT = gsw.CT_from_t(SA, t, p)
    if potential:
        p = numpy.zeros(len(SA))
    return gsw.rho(SA, CT, p)
