import math


def apptempC(t_C, rh, ws_mps):
    """Calculate the apparent temperature in degree Celsius

    t_C - temperature in degree Celsius

    rh - relative humidity [0-100]

    ws_mps - wind speed in meters per second

    http://www.bom.gov.au/info/thermal_stress/#atapproximation
      AT = Ta + 0.33*e - 0.70*ws - 4.00
    where
      AT and Ta (air temperature) are deg-C
      e is water vapor pressure
      ws is wind speed (m/s) at elevation of 10 meters
      e = rh / 100 * 6.105 * exp(17.27 * Ta / (237.7 + Ta))
      rh is relative humidity

    http://www.ncdc.noaa.gov/societal-impacts/apparent-temp/
      AT = -2.7 + 1.04*T + 2.0*e -0.65*v
    where
      AT and T (air temperature) are deg-C
      e is vapor pressure in kPa
      v is 10m wind speed in m/sec
    """
    if t_C is None:
        return None
    if rh is None or rh < 0 or rh > 100:
        return None
    if ws_mps is None or ws_mps < 0:
        return None
    try:
        e = (rh / 100.0) * 6.105 * math.exp(17.27 * t_C / (237.7 + t_C))
        at_C = t_C + 0.33 * e - 0.7 * ws_mps - 4.0
    except (ValueError, OverflowError):
        at_C = None
    return at_C