def w_acoustic_vel(T,S,Z,lat):
    """ Calculate acoustic velocity of water dependent on water depth,
    temperature, salinity and latitude. After Leroy et al. (2008)
    J. Acoust. Soc. Am. 124(5). """
    w_ac_vel = 1402.5 + 5 * T - 5.44e-2 * T**2 + 2.1e-4 * T**3 + 1.33 * S - 1.23e-2 * S * T + 8.7e-5 * S * T**2 + 1.56e-2 * Z + 2.55e-7 * Z**2 - 7.3e-12 * Z**3 + 1.2e-6 * Z * (lat - 45) - 9.5e-13 * T * Z**3 + 3e-7 * T**2 * Z + 1.43e-5 * S * Z
    return w_ac_vel