Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _ghi_to_dni_dhi(latitude, longitude, elevation, ghi):
"""
Calculate DNI, DHI from GHI and calculated solar position.
"""
solar_position = pvmodel.calculate_solar_position(
latitude, longitude, elevation, ghi.index)
dni, dhi = pvmodel.complete_irradiance_components(
ghi, solar_position['zenith'])
def solar_pos_calculator(): return solar_position
return dni, dhi, solar_pos_calculator
Returns
-------
timestamp_flag, night_flag, poa_clearsky_flag : pandas.Series
Integer bitmask series from
:py:func:`.validator.check_timestamp_spacing`,
:py:func:`.validator.check_irradiance_day_night`,
:py:func:`.validator.check_poa_clearsky` respectively
"""
solar_position, dni_extra, timestamp_flag, night_flag = _solpos_dni_extra(
observation, values)
clearsky = pvmodel.calculate_clearsky(
observation.site.latitude, observation.site.longitude,
observation.site.elevation, solar_position['apparent_zenith'])
aoi_func = pvmodel.aoi_func_factory(observation.site.modeling_parameters)
poa_clearsky = pvmodel.calculate_poa_effective(
aoi_func=aoi_func, apparent_zenith=solar_position['apparent_zenith'],
azimuth=solar_position['azimuth'], ghi=clearsky['ghi'],
dni=clearsky['dni'], dhi=clearsky['dhi'])
poa_clearsky_flag = validator.check_poa_clearsky(values, poa_clearsky,
_return_mask=True)
return timestamp_flag, night_flag, poa_clearsky_flag
same as the observation interval label.
"""
# ensure that we're using times rounded to multiple of interval_length
_check_intervals_times(observation.interval_label, data_start, data_end,
forecast_start, forecast_end,
observation.interval_length)
# get observation data for specified range
obs = load_data(observation, data_start, data_end)
# partial-up the metadata for solar position and
# clearsky calculation clarity and consistency
site = observation.site
calc_solpos = partial(pvmodel.calculate_solar_position,
site.latitude, site.longitude, site.elevation)
calc_cs = partial(pvmodel.calculate_clearsky,
site.latitude, site.longitude, site.elevation)
# Calculate solar position and clearsky for obs time range.
# if data is instantaneous, calculate at the obs time.
# else (if data is interval average), calculate at 1 minute resolution to
# reduce errors from changing solar position during persistence data range.
# Later, modeled clear sky or ac power will be averaged over the data range
closed = datamodel.CLOSED_MAPPING[observation.interval_label]
if closed is None:
freq = observation.interval_length
else:
freq = pd.Timedelta('1min')
obs_range = pd.date_range(start=data_start, end=data_end, freq=freq,
closed=closed)
solar_position_obs = calc_solpos(obs_range)
clearsky_obs = calc_cs(solar_position_obs['apparent_zenith'])
2. Estimate cloudy sky DNI and DHI using the Erbs model.
Parameters
----------
site : datamodel.Site
cloud_cover : Series
Cloud cover in %.
zenith : Series
Solar zenith
Returns
-------
ghi : pd.Series, dni : pd.Series, dhi : pd.Series
"""
ghi = cloud_cover_to_ghi_linear(cloud_cover, ghi_clear)
dni, dhi = pvmodel.complete_irradiance_components(ghi, zenith)
return ghi, dni, dhi