def king(surface_tilt, dhi, ghi, solar_zenith):
sky_diffuse = (dhi * ((<NUM_LIT:1> + tools.cosd(surface_tilt))) / <NUM_LIT:2> + ghi *<EOL>((<NUM_LIT> * solar_zenith - <NUM_LIT>)) *<EOL>((<NUM_LIT:1> - tools.cosd(surface_tilt))) / <NUM_LIT:2>)<EOL>sky_diffuse = np.maximum(sky_diffuse, <NUM_LIT:0>)<EOL>return sky_diffuse<EOL>
Determine diffuse irradiance from the sky on a tilted surface using
the King model.

King's model determines the diffuse irradiance from the sky (ground
reflected irradiance is not included in this algorithm) on a tilted
surface using the surface tilt angle, diffuse horizontal irradiance,
global horizontal irradiance, and sun zenith angle. Note that this
model is not well documented and has not been published in any
fashion (as of January 2012).

Parameters
----------
surface_tilt : numeric
    Surface tilt angles in decimal degrees. The tilt angle is
    defined as degrees from horizontal (e.g. surface facing up = 0,
    surface facing horizon = 90)

dhi : numeric
    Diffuse horizontal irradiance in W/m^2.

ghi : numeric
    Global horizontal irradiance in W/m^2.

solar_zenith : numeric
    Apparent (refraction-corrected) zenith angles in decimal degrees.

Returns
--------
poa_sky_diffuse : numeric
    The diffuse component of the solar radiation.