def gasMassForFloat(currentAltitude, floatingAltitude,
    gasMassAtInflation, gasMassAtFloatingAltitude, ventStart=500):
    """
    Returns the gas mass profile to simulate the valves venting air to reach
    floating conditions.

    This method should only be used for floating flights.

    Parameters
    ----------
    currentAltitude : scalar
        the altitude for which the gas mass is required [m]
    floatingAltitude : scalar
        the target altitude for float [m]
    gasMassAtInflation : scalar
        the initial gas mass, before venting [kg]
    gasMassAtFloatingAltitude : scalar
        the final gas mass required to reach floating conditions [kg]
    ventStart : scalar
        how many meters below the target floating altitude should the venting
        start. Default is 500m

    Returns
    -------
    gasMassAtFloatingAltitude : float
    """
    if currentAltitude < (floatingAltitude - ventStart):
        # Below the threshold to start venting. The gas mass is unchanged
        return gasMassAtInflation
    elif currentAltitude < floatingAltitude:
        # The balloon is approaching the target altitude, start venting

        # The following is the equation for linear interpolation between the
        # start and the end of the venting.
        return (gasMassAtInflation - gasMassAtFloatingAltitude) / float(ventStart) * (
            floatingAltitude - currentAltitude) + gasMassAtFloatingAltitude
    else:
        # The balloon has reached the floating altitude
        return gasMassAtFloatingAltitude