Example #1
0
def system_power(request, system_location, naive_times):
    tilt = request.param[0]
    azimuth = request.param[1]
    local_time = naive_times.tz_localize(system_location.tz)
    clearsky = system_location.get_clearsky(local_time,
                                            model='simplified_solis')
    solar_position = system_location.get_solarposition(local_time)
    poa = irradiance.get_total_irradiance(tilt, azimuth,
                                          solar_position['zenith'],
                                          solar_position['azimuth'],
                                          **clearsky)
    temp_cell = pvlib.temperature.sapm_cell(
        poa['poa_global'], 25, 0,
        **pvlib.temperature.TEMPERATURE_MODEL_PARAMETERS['sapm']
        ['open_rack_glass_glass'])
    pdc = pvsystem.pvwatts_dc(poa['poa_global'], temp_cell, 100, -0.002)
    pac = pvsystem.inverter.pvwatts(pdc, 120)
    return {
        'location': system_location,
        'tilt': tilt,
        'azimuth': azimuth,
        'clearsky': clearsky,
        'solar_position': solar_position,
        'ac': pac
    }
Example #2
0
def test_pvwatts_dc_arrays():
    irrad_trans = np.array([np.nan, 900, 900])
    temp_cell = np.array([30, np.nan, 30])
    irrad_trans, temp_cell = np.meshgrid(irrad_trans, temp_cell)
    expected = np.array([[nan, 88.65, 88.65], [nan, nan, nan],
                         [nan, 88.65, 88.65]])
    out = pvsystem.pvwatts_dc(irrad_trans, temp_cell, 100, -0.003)
    assert_allclose(out, expected, equal_nan=True)
def test_pvwatts_dc_arrays():
    irrad_trans = np.array([np.nan, 900, 900])
    temp_cell = np.array([30, np.nan, 30])
    irrad_trans, temp_cell = np.meshgrid(irrad_trans, temp_cell)
    expected = np.array([[   nan,  88.65,  88.65],
                         [   nan,    nan,    nan],
                         [   nan,  88.65,  88.65]])
    out = pvsystem.pvwatts_dc(irrad_trans, temp_cell, 100, -0.003)
    assert_allclose(expected, out, equal_nan=True)
Example #4
0
def test_orientation_fit_pvwatts_missing_data(naive_times):
    tilt = 30
    azimuth = 100
    system_location = location.Location(35, -106)
    local_time = naive_times.tz_localize('MST')
    clearsky = system_location.get_clearsky(local_time,
                                            model='simplified_solis')
    clearsky.loc['3/1/2020':'3/15/2020'] = np.nan
    solar_position = system_location.get_solarposition(clearsky.index)
    solar_position.loc['3/1/2020':'3/15/2020'] = np.nan
    poa = irradiance.get_total_irradiance(tilt, azimuth,
                                          solar_position['zenith'],
                                          solar_position['azimuth'],
                                          **clearsky)
    temp_cell = pvlib.temperature.sapm_cell(
        poa['poa_global'], 25, 0,
        **pvlib.temperature.TEMPERATURE_MODEL_PARAMETERS['sapm']
        ['open_rack_glass_glass'])
    pdc = pvsystem.pvwatts_dc(poa['poa_global'], temp_cell, 100, -0.002)
    pac = pvsystem.inverter.pvwatts(pdc, 120)
    solar_position.dropna(inplace=True)
    with pytest.raises(ValueError,
                       match=".* must not contain undefined values"):
        system.infer_orientation_fit_pvwatts(
            pac,
            solar_zenith=solar_position['zenith'],
            solar_azimuth=solar_position['azimuth'],
            **clearsky)
    pac.dropna(inplace=True)
    with pytest.raises(ValueError,
                       match=".* must not contain undefined values"):
        system.infer_orientation_fit_pvwatts(
            pac,
            solar_zenith=solar_position['zenith'],
            solar_azimuth=solar_position['azimuth'],
            **clearsky)
    clearsky.dropna(inplace=True)
    tilt_out, azimuth_out, rsquared = system.infer_orientation_fit_pvwatts(
        pac,
        solar_zenith=solar_position['zenith'],
        solar_azimuth=solar_position['azimuth'],
        **clearsky)
    assert rsquared > 0.9
    assert tilt_out == pytest.approx(tilt, abs=10)
    assert azimuth_out == pytest.approx(azimuth, abs=10)
Example #5
0
def power_pvwatts(request, clearsky_july, solarposition_july):
    pdc0 = 100
    pdc0_inverter = 110
    tilt = 30
    azimuth = 180
    pdc0_marker = request.node.get_closest_marker("pdc0_inverter")
    if pdc0_marker is not None:
        pdc0_inverter = pdc0_marker.args[0]
    poa = irradiance.get_total_irradiance(
        tilt, azimuth,
        solarposition_july['zenith'], solarposition_july['azimuth'],
        **clearsky_july
    )
    cell_temp = temperature.sapm_cell(
        poa['poa_global'], 25, 0,
        **TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_glass']
    )
    dc = pvsystem.pvwatts_dc(poa['poa_global'], cell_temp, pdc0, -0.004)
    return inverter.pvwatts(dc, pdc0_inverter)
Example #6
0
def test_pvwatts_dc_series():
    irrad_trans = pd.Series([np.nan, 900, 900])
    temp_cell = pd.Series([30, np.nan, 30])
    expected = pd.Series(np.array([   nan,    nan,  88.65]))
    out = pvsystem.pvwatts_dc(irrad_trans, temp_cell, 100, -0.003)
    assert_series_equal(expected, out)
Example #7
0
def test_pvwatts_dc_scalars():
    expected = 88.65
    out = pvsystem.pvwatts_dc(900, 30, 100, -0.003)
    assert_allclose(out, expected)
def test_pvwatts_dc_series():
    irrad_trans = pd.Series([np.nan, 900, 900])
    temp_cell = pd.Series([30, np.nan, 30])
    expected = pd.Series(np.array([   nan,    nan,  88.65]))
    out = pvsystem.pvwatts_dc(irrad_trans, temp_cell, 100, -0.003)
    assert_series_equal(expected, out)
def test_pvwatts_dc_scalars():
    expected = 88.65
    out = pvsystem.pvwatts_dc(900, 30, 100, -0.003)
    assert_allclose(expected, out)
Example #10
0
irrad = pd.concat(irrad, axis=1)

# using bifaciality factor and pvfactors results, create effective irradiance
bifaciality = 0.75
effective_irrad_bifi = irrad['total_abs_front'] + (irrad['total_abs_back'] *
                                                   bifaciality)

# get cell temperature using the Faiman model
temp_cell = temperature.faiman(effective_irrad_bifi, temp_air=25, wind_speed=1)

# using the pvwatts_dc model and parameters detailed above,
# set pdc0 and return DC power for both bifacial and monofacial
pdc0 = 1
gamma_pdc = -0.0043
pdc_bifi = pvsystem.pvwatts_dc(effective_irrad_bifi,
                               temp_cell,
                               pdc0,
                               gamma_pdc=gamma_pdc).fillna(0)
pdc_bifi.plot(title='Bifacial Simulation on June Solstice', ylabel='DC Power')

# %%
# For illustration, perform monofacial simulation using pvfactors front-side
# irradiance (AOI-corrected), and plot along with bifacial results.

effective_irrad_mono = irrad['total_abs_front']
pdc_mono = pvsystem.pvwatts_dc(effective_irrad_mono,
                               temp_cell,
                               pdc0,
                               gamma_pdc=gamma_pdc).fillna(0)

# plot monofacial results
plt.figure()
Example #11
0
def test_orientation_fit_pvwatts_temp_wind_as_series(naive_times):
    tilt = 30
    azimuth = 100
    system_location = location.Location(35, -106)
    local_time = naive_times.tz_localize('MST')
    clearsky = system_location.get_clearsky(local_time,
                                            model='simplified_solis')
    solar_position = system_location.get_solarposition(clearsky.index)
    poa = irradiance.get_total_irradiance(tilt, azimuth,
                                          solar_position['zenith'],
                                          solar_position['azimuth'],
                                          **clearsky)
    temp_cell = pvlib.temperature.sapm_cell(
        poa['poa_global'], 25, 1,
        **pvlib.temperature.TEMPERATURE_MODEL_PARAMETERS['sapm']
        ['open_rack_glass_glass'])
    temperature = pd.Series(25, index=clearsky.index)
    wind_speed = pd.Series(1, index=clearsky.index)
    temperature_missing = temperature.copy()
    temperature_missing.loc['4/5/2020':'4/10/2020'] = np.nan
    wind_speed_missing = wind_speed.copy()
    wind_speed_missing.loc['5/5/2020':'5/15/2020'] = np.nan
    pdc = pvsystem.pvwatts_dc(poa['poa_global'], temp_cell, 100, -0.002)
    pac = pvsystem.inverter.pvwatts(pdc, 120)
    with pytest.raises(ValueError,
                       match=".* must not contain undefined values"):
        system.infer_orientation_fit_pvwatts(
            pac,
            solar_zenith=solar_position['zenith'],
            solar_azimuth=solar_position['azimuth'],
            temperature=temperature_missing,
            wind_speed=wind_speed_missing,
            **clearsky)
    with pytest.raises(ValueError,
                       match="temperature must not contain undefined values"):
        system.infer_orientation_fit_pvwatts(
            pac,
            solar_zenith=solar_position['zenith'],
            solar_azimuth=solar_position['azimuth'],
            temperature=temperature_missing,
            wind_speed=wind_speed,
            **clearsky)
    with pytest.raises(ValueError,
                       match="wind_speed must not contain undefined values"):
        system.infer_orientation_fit_pvwatts(
            pac,
            solar_zenith=solar_position['zenith'],
            solar_azimuth=solar_position['azimuth'],
            temperature=temperature,
            wind_speed=wind_speed_missing,
            **clearsky)
    # ValueError if indices don't match
    with pytest.raises(ValueError):
        system.infer_orientation_fit_pvwatts(
            pac,
            solar_zenith=solar_position['zenith'],
            solar_azimuth=solar_position['azimuth'],
            temperature=temperature_missing.dropna(),
            wind_speed=wind_speed_missing.dropna(),
            **clearsky)
    tilt_out, azimuth_out, rsquared = system.infer_orientation_fit_pvwatts(
        pac,
        solar_zenith=solar_position['zenith'],
        solar_azimuth=solar_position['azimuth'],
        **clearsky)
    assert rsquared > 0.9
    assert tilt_out == pytest.approx(tilt, abs=10)
    assert azimuth_out == pytest.approx(azimuth, abs=10)
Example #12
0
def performance_ratio_nrel(poa_global,
                           temp_air,
                           wind_speed,
                           pac,
                           pdc0,
                           a=-3.56,
                           b=-0.075,
                           deltaT=3,
                           gamma_pdc=-0.00433):
    r"""
    Calculate NREL Performance Ratio.

    See equation [5] in Weather-Corrected Performance Ratio [1]_ for details
    on the weighted method for Tref.

    Parameters
    ----------
    poa_global : numeric
        Total incident irradiance [W/m^2].

    temp_air : numeric
        Ambient dry bulb temperature [C].

    wind_speed : numeric
        Wind speed at a height of 10 meters [m/s].

    pac : float
        AC power [kW].

    pdc0 : float
        Power of the modules at 1000 W/m2 and cell reference temperature [kW].

    a : float
        Parameter :math:`a` in SAPM model [unitless].

    b : float
        Parameter :math:`b` in in SAPM model [s/m].

    deltaT : float
        Parameter :math:`\Delta T` in SAPM model [C].

    gamma_pdc : float
        The temperature coefficient in units of 1/C. Typically -0.002 to
        -0.005 per degree C [1/C].

    Returns
    -------
    performance_ratio: float
        Performance Ratio of data.

    References
    ----------
    .. [1] Dierauf et al. "Weather-Corrected Performance Ratio". NREL, 2013.
       https://www.nrel.gov/docs/fy13osti/57991.pdf
    """

    cell_temperature = sapm_cell(poa_global, temp_air, wind_speed, a, b,
                                 deltaT)

    tcell_poa_global = poa_global * cell_temperature
    tref = tcell_poa_global.sum() / poa_global.sum()

    pdc = pvwatts_dc(poa_global,
                     cell_temperature,
                     pdc0,
                     gamma_pdc,
                     temp_ref=tref)

    performance_ratio = pac.sum() / pdc.sum()

    return performance_ratio