Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Dataframe with the following columns:
['solar_zenith', 'solar_azimuth', 'surface_tilt', 'surface_azimuth',
'dhi', 'dni', 'vf_horizon', 'vf_circumsolar', 'vf_isotropic',
'luminance_horizon', 'luminance_circumsolar', 'luminance_isotropic',
'poa_isotropic', 'poa_circumsolar', 'poa_horizon', 'poa_total_diffuse']
"""
# Create a dataframe to help filtering on all arrays
df_inputs = pd.DataFrame(
{'surface_tilt': surface_tilt, 'surface_azimuth': surface_azimuth,
'solar_zenith': solar_zenith, 'solar_azimuth': solar_azimuth,
'dni': dni, 'dhi': dhi},
index=pd.DatetimeIndex(timestamps))
dni_et = irradiance.extraradiation(df_inputs.index.dayofyear)
am = atmosphere.relativeairmass(df_inputs.solar_zenith)
# Need to treat the case when the sun is hitting the back surface of pvrow
aoi_proj = aoi_projection(
df_inputs.surface_tilt, df_inputs.surface_azimuth,
df_inputs.solar_zenith, df_inputs.solar_azimuth)
sun_hitting_back_surface = ((aoi_proj < 0) &
(df_inputs.solar_zenith <= 90))
df_inputs_back_surface = df_inputs.loc[sun_hitting_back_surface].copy()
# Reverse the surface normal to switch to back-surface circumsolar calc
df_inputs_back_surface.loc[:, 'surface_azimuth'] = (
df_inputs_back_surface.loc[:, 'surface_azimuth'] - 180.)
df_inputs_back_surface.loc[:, 'surface_azimuth'] = np.mod(
df_inputs_back_surface.loc[:, 'surface_azimuth'], 360.
)
df_inputs_back_surface.loc[:, 'surface_tilt'] = (
180. - df_inputs_back_surface.surface_tilt)
----------
.. [5] `pvlib globalinplane `_.
.. [6] `pvlib atmosphere `_.
See Also
--------
solarposition_hourly_mean, solarposition, angle_of_incidenc
"""
# Determine the extraterrestrial radiation
data['dni_extra'] = pvlib.irradiance.extraradiation(
datetime_or_doy=data.index.dayofyear)
# Determine the relative air mass
data['airmass'] = pvlib.atmosphere.relativeairmass(data['zenith'])
# Determine direct normal irradiation
data['dni'] = (data['dirhi']) / np.sin(np.radians(90 - data['zenith']))
# what for??
data['dni'][data['zenith'] > 88] = data['dirhi']
# Determine the sky diffuse irradiation in plane
# with model of Perez (modell switch would be good)
data['poa_sky_diffuse'] = pvlib.irradiance.perez(
surface_tilt=self.powerplant.tilt,
surface_azimuth=self.powerplant.azimuth,
dhi=data['dhi'],
dni=data['dni'],
dni_extra=data['dni_extra'],
solar_zenith=data['zenith'],
Function used to calculate the luminance and the view factor terms from the
Perez diffuse light transposition model, as implemented in the
``pvlib-python`` library.
:param df_inputs: class:`pandas.DataFrame` with following columns:
['solar_zenith', 'solar_azimuth', 'array_tilt', 'array_azimuth', 'dhi',
'dni']. Units are: ['deg', 'deg', 'deg', 'deg', 'W/m2', 'W/m2']
:return: class:`pandas.DataFrame` with the following columns:
['solar_zenith', 'solar_azimuth', 'array_tilt', 'array_azimuth', 'dhi',
'dni', 'vf_horizon', 'vf_circumsolar', 'vf_isotropic',
'luminance_horizon', 'luminance_circumsolar', 'luminance_isotropic',
'poa_isotropic', 'poa_circumsolar', 'poa_horizon', 'poa_total_diffuse']
"""
dni_et = irradiance.extraradiation(df_inputs.index.dayofyear)
am = atmosphere.relativeairmass(df_inputs.solar_zenith)
# Need to treat the case when the sun is hitting the back surface of pvrow
aoi_proj = aoi_projection(df_inputs.array_tilt, df_inputs.array_azimuth,
df_inputs.solar_zenith, df_inputs.solar_azimuth)
sun_hitting_back_surface = ((aoi_proj < 0) &
(df_inputs.solar_zenith <= 90))
df_inputs_back_surface = df_inputs.loc[sun_hitting_back_surface]
# Reverse the surface normal to switch to back-surface circumsolar calc
df_inputs_back_surface.loc[:, 'array_azimuth'] -= 180.
df_inputs_back_surface.loc[:, 'array_azimuth'] = np.mod(
df_inputs_back_surface.loc[:, 'array_azimuth'], 360.
)
df_inputs_back_surface.loc[:, 'array_tilt'] = (
180. - df_inputs_back_surface.array_tilt)
if df_inputs_back_surface.shape[0] > 0: