solarenergy.radiation module

Functions for solar energy dealing with (solar) radiation.

References

solarenergy.radiation.airmass(sun_alt, return_value_below_horizon=False)[source]

Compute airmass as a function of Sun altitude.

Parameters:
  • sun_alt (float) – True altitude of the Sun (uncorrected for atmospheric refraction; rad), can be an array.
  • return_value_below_horizon (bool) – Return a very large value when the Sun is below the horizon, larger when the Sun is lower. This can be useful for solvers. Default: False.
Returns:

Airmass at sea level (AM~1 if the Sun is in the zenith, AM~38 near the horizon).

Return type:

float

References

A.T. Young, “AIR-MASS AND REFRACTION,” Applied Optics, vol. 33, pp. 1108-1110, Feb 1994.

solarenergy.radiation.clearsky_bird(sun_alt, i_ext=1353, sun_dist=1, press=1013, uo=0.34, uw=1.42, ta5=0.2661, ta3=0.3538, ba=0.84, k1=0.1, rg=0.2)[source]

A simplified clear-sky model for direct and diffuse insolation on horizontal surfaces.

A.k.a. as “the Bird model”.

This function is adapted from the libTheSky Fortran implementation (libthesky.sf.net).

See Bird & Hulstrom, A simplified clear-sky model for direct and diffuse insolation on horizontal surfaces, SERI/TR-642-761 (1981).

Note that the value of Taa does not agree with tabulated values from the paper, and hence neither do dependent values (except for AM~1). When I substitute their values for Taa, everything matches perfectly. Error in their formula, or (hopefully!) in their table?

Parameters:
  • sun_alt (float) – Sun altitude above the horizon (rad)
  • i_ext (float) – Extraterrestrial radiation (at the top of the atmosphere; AM0; W/m^2 - optional, default: 1353 (1361.5))
  • sun_dist (float) – Sun distance (AU - optional, default: 1)
  • press (float) – Air pressure at the observer’s site, corrected for altitude (hPa - optional, default: 1013)
  • uo (float) – Ozone abundance in a vertical column (cm - optional, default: 0.34)
  • uw (float) – Percipitable water-vapor abundance in a vertical column (cm - optional, default: 1.42)
  • ta5 (float) – Aerosol optical depth from surface in vertical path at 500 nm (optional, default: 0.2661)
  • ta3 (float) – Aerosol optical depth from surface in vertical path at 380 nm (optional, default: 0.3538)
  • ba (float) – Aerosol forward-scattering ratio (optional, 0.82-0.86, default: 0.84)
  • k1 (float) – Aerosol-absorptance constant (optional, rural: 0.0933, urban: 0.385, default: 0.1)
  • rg (float) – Ground albedo (optional, fraction - default: 0.2)
Returns:

Tuple containing (i_tot, i_dir, i_dif, i_gr):

  • i_tot (float): Total (global) insolation on a horizontal surface (GHI; W/m^2)
  • i_dir (float): Direct (beam) insolation on a horizontal surface (BHI; W/m^2)
  • i_dif (float): Diffuse insolation on a horizontal surface (DHI; W/m^2)
  • i_gr (float): Ground-reflection insolation from a horizontal surface (W/m^2)

Return type:

tuple (float,float,float,float)

solarenergy.radiation.computeSunPos(geo_lon, geo_lat, year, month, day, hour, minute=0, second=0, timezone='UTC', debug=False)[source]

Obsolete version of sun_position_from_date_and_time(). Use that function instead!

solarenergy.radiation.cosAngleSunPanels(sp_az, sp_incl, sun_az, sun_alt)[source]

Obsolete version of cos_angle_sun_panels(). Use that function instead!

solarenergy.radiation.cos_angle_sun_panels(sp_az, sp_incl, sun_az, sun_alt)[source]
Compute the cosine of the angle between the orientation vector of the solar panels and the position vector
of the Sun.

This is the cosine of the angle under which the direct sunlight hits the solar panels. Multiply it with the DNI to obtain the direct insolation on the panels. See Celestial mechanics in a nutshell, Sect. 4.3: Insolation on an inclined surface (http://CMiaNS.sf.net).

Parameters:
  • sp_az (float) – Azimuth in which the solar panels are facing (rad; e.g. north or south = 0, same as sun_az).
  • sp_incl (float) – Inclination (‘zenith angle’) of the solar panels w.r.t. the horizontal (rad).
  • sun_az (float) – Azimuth of the Sun (rad; e.g. north or south = 0, same as sp_az).
  • sun_alt (float) – Altitude of the Sun (rad).
Returns:

The cosine between the normal vector of the solar panels and the position vector of the Sun (rad).

Note that this value is zero (indicating radiation from behind the panels) or positive.

Return type:

float

solarenergy.radiation.diffuseRad_from_globalRad_sunshine(glob_horiz, sun_frac, sun_alt, i_ext=1361.5)[source]

Obsolete version of diffuse_radiation_from_global_radiation_and_sunshine(). Use that function instead!

solarenergy.radiation.diffuse_radiation_from_global_radiation_and_sunshine(glob_horiz, sun_frac, sun_alt, i_ext=1361.5)[source]

Compute the diffuse horizontal radiation from the global horizontal radiation, the fraction of sunshine and the Sun altitude.

Parameters:
  • glob_horiz (float) – Global horizontal radiation (W/m2).
  • sun_frac (float) – Fraction of sunshine (e.g. fraction of cloud cover) (-; 0-1).
  • sun_alt (float) – Sun altitude above the horizon (rad).
  • i_ext (float) – Extraterrestrial radiation (W/m2). Defaults to the solar constant.
Returns:

Tuple containing (dif_horiz, beam_horiz, beam_norm):

  • dif_horiz (float): Diffuse horizontal radiation = DHI (W/m2).
  • beam_horiz (float): Beam (direct) horizontal radiation = BHI (W/m2).
  • beam_norm (float): Beam (direct) normal radiation = BNI = DNI (W/m2).

Return type:

tuple (float,float,float)

solarenergy.radiation.diffuse_radiation_projection_Perez87(doy, alt, surf_incl, theta, beam_norm, dif_horiz)[source]

Obsolete version of diffuse_radiation_projection_perez87(). Use that function instead!

solarenergy.radiation.diffuse_radiation_projection_perez87(doy, sun_alt, surf_incl, theta, beam_norm, dif_horiz, return_components=False)[source]

Compute diffuse radiation on an inclined surface using the 1987 Perez model

This function is adapted from the libTheSky Fortran implementation (libthesky.sf.net).

See Perez et al. Solar Energy Vol. 39, Nr. 3, p. 221 (1987) - references to equations and tables are to this paper. Most equations can be found in the Nomenclature section at the end of the paper (p.230). I use a and c here, not b and d.

Parameters:
  • doy (int) – Day of year (Nday)
  • sun_alt (float) – Altitude of the Sun (radians, may be an array)
  • surf_incl (float) – Surface inclination wrt horizontal (radians) - 0 = horizontal, pi/2 = vertical
  • theta (float) – Angle between surface normal vector and Sun position vector (radians, may be an array)
  • beam_norm (float) – Beam (direct) normal radiation = DNI (W/m2; in the direction of the Sun, may be an array)
  • dif_horiz (float) – Diffuse radiation on a horizontal surface = DHI (W/m2, may be an array)
  • return_components (bool) – Return isotropic, circumsolar and horizon parts separately (i.e., four return values).
Returns:

Diffuse irradiation on the inclined surface (W/m2) (may be an array) - if return_components=False

tuple: Diffuse irradiation + components as (float1, float2, float3, float4), may be arrays - if return_components=True:

  • float1: Total diffuse irradiation on the inclined surface (W/m2)
  • float2: Isotropic diffuse irradiation on the inclined surface (W/m2)
  • float3: Circumsolar diffuse irradiation on the inclined surface (W/m2)
  • float4: Horizon-band diffuse irradiation on the inclined surface (W/m2)

Return type:

float

solarenergy.radiation.extinctionFactor(airmass, return_value_below_horizon=False)[source]

Obsolete version of extinction_factor(). Use that function instead!

solarenergy.radiation.extinction_factor(airmass, return_value_below_horizon=False)[source]

Compute the atmospheric extinction factor for sunlight from the air mass.

Parameters:
  • airmass (float) – Airmass at sea level (AM~1 if the Sun is in the zenith, AM~38 near the horizon), can be an array.
  • return_value_below_horizon (bool) – Return a very large value when the Sun is below the horizon, larger when the Sun is lower. This can be useful for solvers. Default: False.
Returns:

The extinciton factor for sunlight in the atmosphere. Divide the extraterrestrial (AM0)

radiation (or, if unknown, the solar constant) by this number to obtain the DNI.

Return type:

float

solarenergy.radiation.reflectance_transmittance(ang_i, n_ref1, n_ref2, comp_transmittance=False, comp_polarised=False)[source]

Compute the reflectance and transmittance as function of incidence angle and refactive indices.

Compute the reflectance for the transition from a medium with refractive index n_ref1 to one with n_ref2, under an incidence angle ang_i. Optionally, compute the transmittance, and the polarised components. The media are assumed to be non-magnetic.

Parameters:
  • ang_i (float) – Angle of incidence (rad).
  • n_ref1 (float) – Refractive index of initial medium (-).
  • n_ref2 (float) – Refractive index of second medium (-).
  • comp_transmittance (bool) – Compute and return the transmittance and its angle.
  • comp_polarised (bool) – Compute and return the polarised reflectances and transmittances.
Returns:

Tuple consisting of one or more values, depending on the input parameters:

  • comp_transmittance=False, comp_polarised=False: (r_unp);
  • comp_transmittance=False, comp_polarised=True: (r_unp, r_prp,r_par);
  • comp_transmittance=True, comp_polarised=False: (r_unp, t_unp, ang_t);
  • comp_transmittance=True, comp_polarised=True: (r_unp, t_unp, ang_t, r_prp,r_par,
    t_prp,t_par);
With the following variables:

r_unp (float): Unpolarised reflectance (-);

t_unp (float): Unpolarised transmittance (-); ang_t (float): Angle of transmittance (rad);

r_prp (float): Perpendicular polarised reflectance (-); r_par (float): Parallel polarised reflectance (-); t_prp (float): Perpendicular polarised transmittance (-); t_par (float): Parallel polarised transmittance (-).

Return type:

(tuple)

See:
solarenergy.radiation.solar_power_from_clear_sky(sp, dat, warn=True)[source]

Model to compute the electrical power for a given solar-panel system and Sun position(s) for a clear sky.

Parameters:
  • sp (se.SolarPanels) – struct containing solar-panel data, including the elements: - sp.az (float): azimuth (rad; same as df[‘sun_az’] (default S=0, W=pi/2)); - sp.incl (float): inclunation (rad; horizontal=0, vertical=pi/2); - sp.eff0 (float): original PV+inverter efficiency at determined T (e.g. 20°C) (fraction; 0-1); - sp.year (int): year of installation (defaults to 2015); - sp.deff_dt (float): change in PV efficiency (dη/dt; year^-1, <0; defaults to 0); - sp.t_coef (float): PV temperature coefficient (K^-1; defaults to 0); - sp.n_refr (float): panel refractive index (>1; defaults to 1.43); - sp.area (float): PV area (m^2); - sp.p_max (float): maximum power of solar-panel system (W).

  • dat (pd.DataFrame) –

    Pandas DataFrame containing solar-panel and weather data, including the columns:
    • df[‘dtm’] (datetime): Date and time;
    • df[‘sun_az’] (float): Sun azimuth (rad; same as sp.az (default S=0, W=pi/2));
    • df[‘sun_alt’] (float): Sun altitude (rad);
    • df[‘sun_dist’] (float): Sun distance (AU; defaults to 1);
    • df[‘press’] (float): air pressure (mbar; defaults to 1010);
    • df[‘temp’] (float): ambient air temperature (°C; defaults to 15);
    • df[‘ws’] (float): wind speed (m/s; defaults to 3).

    More columns with intermediate results will be added during the calculation. The final result will be added as a column named ‘Pclrsky’, as well as returned as an array.

  • warn (bool) – Warn if a parameter or variable is missing and the default value is used (defaults to True).

Returns:

Array containing predicted electrical power of solar panels for a clear sky (kW). Note that

this result is ALSO added to the input DataFrame, as a column named ‘Pclrsky’.

Return type:

float

solarenergy.radiation.sun_position_from_date_and_time(geo_lon, geo_lat, year, month, day, hour, minute=0, second=0, timezone='UTC', debug=False)[source]

Compute the Sun local position (azimuth, altitude and distance) for the given geographical location and date and time (ymd, hms) using SolTrack.

Parameters:
  • geo_lon (float) – Geographic longitude to compute the Sun position for (rad).
  • geo_lat (float) – Geographic latitude to compute the Sun position for (rad).
  • year (int) – Year (CE) to compute the Sun position for.
  • month (int) – Month to compute the Sun position for.
  • day (int) – Day of month to compute the Sun position for.
  • hour (int) – Hour of day to compute the Sun position for (local time!).
  • minute (int) – Minute to compute the Sun position for (optional; default = 0).
  • second (int) – Second to compute the Sun position for (optional; default = 0).
  • timezone (str) – Timezone for which date and time are provided (optional; default = ‘UTC’).
  • debug (bool) – Switch to write detailed output to stdout (optional; default = False).
Returns:

Tuple containing (azimuth, altitude, distance):

  • azimuth (float): Azimuth of the Sun (rad; south = 0 on the northern hemisphere).
  • altitude (float): Altitude of the Sun (rad).
  • distance (float): Distance Sun-Earth (AU).

Return type:

tuple (float,float,float)

solarenergy.radiation.sun_position_from_datetime(geo_lon, geo_lat, date_time, utc=False, debug=False)[source]

Compute the Sun local position (azimuth, altitude and distance) for the given geographical location and a Python datetime using SolTrack.

Parameters:
  • geo_lon (float) – Geographic longitude to compute the Sun position for (rad).
  • geo_lat (float) – Geographic latitude to compute the Sun position for (rad).
  • date_time (datetime) – Date and time to compute the Sun position for (timezone aware and/or UTC, i.e. must be UTC if timezone naive. CHECK: must be UTC if a list or (numpy) array?).
  • utc (bool) – Specify that the input is in UTC. This can speed up calls with a single datetime (as opposed to arrays). Defaults to False.
  • debug (bool) – Switch to write detailed output to stdout (optional; default = False).
Returns:

Tuple containing (arrays of) (azimuth, altitude, distance):

  • azimuth (float): Azimuth of the Sun (rad; south = 0 on the northern hemisphere).
  • altitude (float): Altitude of the Sun (rad).
  • distance (float): Distance Sun-Earth (AU).

Return type:

tuple (float,float,float)