def physicaliam(aoi, n=<NUM_LIT>, K=<NUM_LIT>, L=<NUM_LIT>):
zeroang = <NUM_LIT><EOL>aoi_input = aoi<EOL>aoi = np.where(aoi == <NUM_LIT:0>, zeroang, aoi)<EOL>thetar_deg = tools.asind(<NUM_LIT:1.0> / n*(tools.sind(aoi)))<EOL>rho_zero = ((<NUM_LIT:1>-n) / (<NUM_LIT:1>+n)) ** <NUM_LIT:2><EOL>tau_zero = np.exp(-K*L)<EOL>rho_para = (tools.tand(thetar_deg - aoi) /<EOL>tools.tand(thetar_deg + aoi)) ** <NUM_LIT:2><EOL>rho_perp = (tools.sind(thetar_deg - aoi) /<EOL>tools.sind(thetar_deg + aoi)) ** <NUM_LIT:2><EOL>tau = np.exp(-K*L / tools.cosd(thetar_deg))<EOL>iam = ((<NUM_LIT:1> - (rho_para + rho_perp) / <NUM_LIT:2>) / (<NUM_LIT:1> - rho_zero) * tau / tau_zero)<EOL>with np.errstate(invalid='<STR_LIT:ignore>'):<EOL><INDENT>small_angle = <NUM_LIT><EOL>iam = np.where(np.abs(aoi) < small_angle, <NUM_LIT:1.0>, iam)<EOL>iam = np.where(iam < <NUM_LIT:0>, <NUM_LIT:0>, iam)<EOL>iam = np.where(aoi > <NUM_LIT>, <NUM_LIT:0>, iam)<EOL><DEDENT>if isinstance(aoi_input, pd.Series):<EOL><INDENT>iam = pd.Series(iam, index=aoi_input.index)<EOL><DEDENT>return iam<EOL>
Determine the incidence angle modifier using refractive index,
extinction coefficient, and glazing thickness.

physicaliam calculates the incidence angle modifier as described in
De Soto et al. "Improvement and validation of a model for
photovoltaic array performance", section 3. The calculation is based
on a physical model of absorbtion and transmission through a
cover.

Note: The authors of this function believe that eqn. 14 in [1] is
incorrect. This function uses the following equation in its place:
theta_r = arcsin(1/n * sin(aoi))

Parameters
----------
aoi : numeric
    The angle of incidence between the module normal vector and the
    sun-beam vector in degrees. Angles of 0 are replaced with 1e-06
    to ensure non-nan results. Angles of nan will result in nan.

n : numeric, default 1.526
    The effective index of refraction (unitless). Reference [1]
    indicates that a value of 1.526 is acceptable for glass. n must
    be a numeric scalar or vector with all values >=0. If n is a
    vector, it must be the same size as all other input vectors.

K : numeric, default 4.0
    The glazing extinction coefficient in units of 1/meters.
    Reference [1] indicates that a value of  4 is reasonable for
    "water white" glass. K must be a numeric scalar or vector with
    all values >=0. If K is a vector, it must be the same size as
    all other input vectors.

L : numeric, default 0.002
    The glazing thickness in units of meters. Reference [1]
    indicates that 0.002 meters (2 mm) is reasonable for most
    glass-covered PV panels. L must be a numeric scalar or vector
    with all values >=0. If L is a vector, it must be the same size
    as all other input vectors.

Returns
-------
iam : numeric
    The incident angle modifier

References
----------
[1] W. De Soto et al., "Improvement and validation of a model for
photovoltaic array performance", Solar Energy, vol 80, pp. 78-88,
2006.

[2] Duffie, John A. & Beckman, William A.. (2006). Solar Engineering
of Thermal Processes, third edition. [Books24x7 version] Available
from http://common.books24x7.com/toc.aspx?bookid=17160.

See Also
--------
getaoi
ephemeris
spa
ashraeiam