import math


def calc_VPD(t_celsius, rel_humidity):
    """
    calculates the Vapour Pressure Deficit (VPD) from temperature (degrees
    celsius) and relative humidity values. We'll use the algorithm given
    in the Licor LI-6400 manual for calculating VPD.

    Parameters
    ----------
    t_celsius : float
        temperature in degrees celsius
    rel_humidity : float
        relative humidity (represented as a fraction between 0.0 and 1.0)

    Returns
    -------
    vpd : float
        Vapour Pressure Deficit

    Other algorithms to calculate VPD include:

        A, B, C, D, E, F = -1.88e4, -13.1, -1.5e-2, 8e-7, -1.69e-11, 6.456
        vp_sat = math.exp(A / T + B + C * T + D * T ** 2 + E * T ** 3 + F * math.log(T))
        Source: http://en.wikipedia.org/wiki/Vapour_Pressure_Deficit

        A, B, C, D, E, F = -1.044e4, -1.129e1, -2.702e-2, 1.289e-5, -2.478e-9, 6.456
        vp_sat = math.exp(A / T + B + C * T + D * T ** 2 + E * T ** 3 + F * math.log(T)) * PSI_IN_KPA
        Source: http://ohioline.osu.edu/aex-fact/0804.html

        vp_sat = 6.11 * math.exp((2.5e6 / 461) * (1 / 273 - 1 / (273 + T)))
        Source: http://physics.stackexchange.com/questions/4343
    """
    # according to Licor LI-6400 manual pg 14-10
    # and Buck AL (1981). New equations for computing vapor pressure and
    # enhancement factor. J Appl Meteor 20:1527-1532
    vp_sat = 0.61365 * math.exp((17.502 * t_celsius) / (240.97 + t_celsius))

    vp_air = vp_sat * rel_humidity
    return vp_sat - vp_air