def calculate(tmax_c, tmin_c, on_error=float('nan'), **kwargs):
    """Calculate the growing degree-days.

    The growing degree-days are calculated using the maximum and 
    minimum daily air temperatures in degrees Celsius.  See:
    https://en.wikipedia.org/wiki/Growing_degree-day

    Parameters
    ----------
    tmax_c : float
        The maximum daily air temperature in degrees C.
    tmin_c : float
        The minimum daily air temperature in degrees C.
    on_error : optional, float('nan')
        The return value when an error occcurs during calculation.  May 
        be any type, but preferably a float.
    tbase : optional, 10.0
        The base temperature, in degrees C.
    tmaxcutoff : optional, 999.0
        Sets the maximum value for the 'tmax_c' parameter.
    tmincutoff : optional, -999.0
        Sets the minimum value for the 'tmin_c" parameter.

    Returns
    -------
    float
        The growing degree-days calculated using Celsius values.  To 
        convert, multiple the return value by (9.0 / 5.0).

    """
    tbase = kwargs.get('tbase', 10.0)
    tmaxcutoff = kwargs.get('tmaxcutoff', 999.0)
    tmincutoff = kwargs.get('tmincutoff', -999.0)
    try:
        _tmax = float(tmax_c)
        _tmin = float(tmin_c)
        _tbase = float(tbase)
        _tmaxcutoff = float(tmaxcutoff)
        _tmincutoff = float(tmincutoff)
        if _tmax > _tmaxcutoff:
            _tmax = _tmaxcutoff
        if _tmin < _tmincutoff:
            _tmin = _tmincutoff
        gdd = (_tmax + _tmin) / 2.0 - _tbase
        if gdd < 0.0:
            gdd = 0.0
    except:
        gdd = on_error
    return gdd
