def clearness_index(ghi, altitude, extra_radiation, min_sin_altitude=<NUM_LIT>,<EOL>max_clearness_index=<NUM_LIT>):
sin_altitude = math.sin(math.radians(altitude))<EOL>I0h = extra_radiation * max(sin_altitude, min_sin_altitude)<EOL>kt = ghi / I0h<EOL>kt = max(kt, <NUM_LIT:0>)<EOL>kt = min(kt, max_clearness_index)<EOL>return kt<EOL>
Calculate the clearness index.

The clearness index is the ratio of global to extraterrestrial
irradiance on a horizontal plane.

Note:
    [1] Maxwell, E. L., "A Quasi-Physical Model for Converting Hourly
    Global Horizontal to Direct Normal Insolation", Technical
    Report No. SERI/TR-215-3087, Golden, CO: Solar Energy Research
    Institute, 1987.

Args:
    ghi: numeric
        Global horizontal irradiance in W/m^2.
    altitude: numeric
        True (not refraction-corrected) solar altitude angle in decimal
        degrees.
    extra_radiation: numeric
        Irradiance incident at the top of the atmosphere
    min_sin_altitude: numeric, default 0.065
        Minimum value of sin(altitude) to allow when calculating global
        clearness index `kt`. Equivalent to altitude = 3.727 degrees.
    max_clearness_index: numeric, default 2.0
        Maximum value of the clearness index. The default, 2.0, allows
        for over-irradiance events typically seen in sub-hourly data.
        NREL's SRRL Fortran code used 0.82 for hourly data.

Returns:
    kt : numeric
        Clearness index