def sky_irradiances(dates=None, daydate=_daydate, ghi=None, dhi=None, attenuation=None, pressure=101325, temp_dew=None, longitude=_longitude, latitude=_latitude, altitude=_altitude, timezone=_timezone): """ Estimate variables related to sky irradiance. Args: dates: A pandas datetime index (as generated by pandas.date_range). If None, daydate is used. daydate: (str) yyyy-mm-dd (not used if dates is not None). ghi: (array_like) : global horizontal irradiance (W. m-2).If None (default) clear_sky irradiance are used dhi: (array-like): diffuse horizontal irradiance attenuation: (float) a attenuation factor for ghi (actual_ghi = attenuation * ghi). If None (default), no attenuation is applied. If dhi is not None, this parameter is not taken into account. pressure: the site pressure (Pa) (for dirint model) temp_dew: the dew point temperature (dirint model) longitude: (float) in degrees latitude: (float) in degrees altitude: (float) in meter timezone:(str) the time zone (not used if dates are already localised) Returns: a pandas dataframe with azimuth, zenital and elevation angle of the sun, clearness and brightness indices, global horizontal irradiance, direct normal irradiance and diffuse horizontal irradiance of the sky. """ df = sun_position(dates=dates, daydate=daydate, latitude=latitude, longitude=longitude, altitude=altitude, timezone=timezone) if ghi is None: irr = clear_sky_irradiances(dates=df.index, latitude=latitude, longitude=longitude, altitude=altitude, timezone=timezone) df = pandas.concat([df, irr], axis=1) elif dhi is None: irr = actual_sky_irradiances(dates=df.index, ghi=ghi, attenuation=attenuation, pressure=pressure, temp_dew=temp_dew, latitude=latitude, longitude=longitude, altitude=altitude, timezone=timezone) df = pandas.concat([df, irr], axis=1) else: df['ghi'] = ghi df['dhi'] = dhi df['dni'] = normal_irradiance(numpy.array(ghi) - numpy.array(dhi), df.elevation) am = air_mass(df['zenith'], altitude) dni_extra = sun_extraradiation(df.index) df['brightness'] = brightness(am, df['dhi'], dni_extra) df['clearness'] = clearness(df['dni'], df['dhi'], df['zenith']) return df.loc[:, ['azimuth', 'zenith', 'elevation', 'clearness', 'brightness', 'ghi', 'dni', 'dhi']]
def daily_diffuse_fraction(ghi, times, latitude): """ estimate the diffuse fraction using daily averages of global horizontal irradiance""" Io = sun_extraradiation(times) dayofyear = times.tz_convert('UTC').dayofyear year = times.tz_convert('UTC').year So = Io * sinel_integral(dayofyear, year, latitude) RsRso = ghi / So return numpy.where( RsRso <= 0.07, 1, numpy.where(RsRso <= 0.35, 1 - 2.3 * (RsRso - 0.07)**2, numpy.where(RsRso <= 0.75, 1.33 - 1.46 * RsRso, 0.23)))
def clear_sky_irradiances(dates=None, daydate=_daydate, longitude=_longitude, latitude=_latitude, altitude=_altitude, timezone=_timezone): """ Estimate components of sky irradiance for clear sy conditions Args: dates: A pandas datetime index (as generated by pandas.date_range). If None, daydate is used. daydate: (str) yyyy-mm-dd (not used if dates is not None). longitude: (float) in degrees latitude: (float) in degrees altitude: (float) in meter timezone:(str) the time zone (not used if dates are already localised) Returns: a pandas dataframe with global horizontal irradiance, direct normal irradiance and diffuse horizontal irradiance. Details: GHI is computed after Haurwitz (1945) and DNI after Meinel (1976) B. Haurwitz, "Insolation in Relation to Cloudiness and Cloud Density," Journal of Meteorology, vol. 2, pp. 154-166, 1945. A. B. Meinel and M. P. Meinel, Applied solar energy. Reading, MA: Addison-Wesley Publishing Co., 1976 """ df = sun_position(dates=dates, daydate=daydate, latitude=latitude, longitude=longitude, altitude=altitude, timezone=timezone) df['am'] = air_mass(df['zenith'], altitude) df['dni_extra'] = sun_extraradiation(df.index) clearsky = df z = numpy.radians(df['zenith']) clearsky['ghi'] = 1098 * numpy.cos(z) * numpy.exp(-0.057 / numpy.cos(z)) clearsky['dni'] = df['dni_extra'] * numpy.power( 0.7, numpy.power(df['am'], 0.678)) clearsky['dhi'] = clearsky['ghi'] - horizontal_irradiance( clearsky['dni'], df['elevation']) return clearsky.loc[:, ['ghi', 'dni', 'dhi']]
def actual_sky_irradiances(dates=None, daydate=_daydate, ghi=None, attenuation=None, pressure=101325, temp_dew=None, longitude=_longitude, latitude=_latitude, altitude=_altitude, timezone=_timezone): """ Estimate component of sky irradiances from measured actual global horizontal irradiance or attenuated clearsky conditions. Args: dates: A pandas datetime index (as generated by pandas.date_range). If None, daydate is used. daydate: (str) yyyy-mm-dd (not used if dates is not None). ghi: (array_like) : global horizontal irradiance (W. m-2).If None (default) clear_sky irradiance are used attenuation: (float) a attenuation factor for ghi (actual_ghi = attenuation * ghi). If None (default), no attenuation is applied pressure: the site pressure (Pa) (for dirint model) temp_dew: the dew point temperature (dirint model) longitude: (float) in degrees latitude: (float) in degrees altitude: (float) in meter timezone:(str) the time zone (not used if dates are already localised) Returns: a pandas dataframe with global horizontal irradiance, direct normal irradiance and diffuse horizontal irradiance. Details: Spitters CJT, Toussaint HAJM, Goudriaan J (1986) Separating the diffuse and direct component of global radiation and its implications for modeling canopy photosynthesis.Part I. Components of incoming radiation. Agricultural and Forest Meteorology 38: 217-229. """ df = sun_position(dates=dates, daydate=daydate, latitude=latitude, longitude=longitude, altitude=altitude, timezone=timezone) if ghi is None: cs = clear_sky_irradiances(dates=df.index, latitude=latitude, longitude=longitude, altitude=altitude, timezone=timezone) ghi = cs['ghi'] df['ghi'] = ghi if attenuation is not None: df.ghi *= attenuation Io = sun_extraradiation(df.index) costheta = numpy.sin(numpy.radians(df.elevation)) So = Io * costheta RsRso = df.ghi / So R = 0.847 - 1.61 * costheta + 1.04 * costheta * costheta K = (1.47 - R) / 1.66 RdRs = numpy.where( RsRso <= 0.22, 1, numpy.where(RsRso <= 0.35, 1 - 6.4 * (RsRso - 0.22)**2, numpy.where(RsRso <= K, 1.47 - 1.66 * RsRso, R))) df['dhi'] = df.ghi * RdRs df['dni'] = normal_irradiance(df['ghi'] - df['dhi'], df['elevation']) return df.loc[:, ('ghi', 'dhi', 'dni')]