def test_marion_diffuse_model(mocker): # 1: return values are correct # 2: the underlying models are called appropriately ashrae_expected = { 'sky': 0.9596085829811408, 'horizon': 0.8329070417832541, 'ground': 0.719823559106309 } physical_expected = { 'sky': 0.9539178294437575, 'horizon': 0.7652650139134007, 'ground': 0.6387140117795903 } ashrae_spy = mocker.spy(_iam, 'ashrae') physical_spy = mocker.spy(_iam, 'physical') ashrae_actual = _iam.marion_diffuse('ashrae', 20) assert ashrae_spy.call_count == 3 # one call for each of the 3 regions assert physical_spy.call_count == 0 physical_actual = _iam.marion_diffuse('physical', 20) assert ashrae_spy.call_count == 3 assert physical_spy.call_count == 3 for k, v in ashrae_expected.items(): np.testing.assert_allclose(ashrae_actual[k], v) for k, v in physical_expected.items(): np.testing.assert_allclose(physical_actual[k], v)
def test_marion_diffuse_kwargs(): # kwargs get passed to underlying model expected = { 'sky': 0.967489994422575, 'horizon': 0.8647842827418412, 'ground': 0.7700443455928433 } actual = _iam.marion_diffuse('ashrae', 20, b=0.04) for k, v in expected.items(): np.testing.assert_allclose(actual[k], v)
def test_marion_diffuse_invalid(): with pytest.raises(ValueError): _iam.marion_diffuse('not_a_model', 20)
plt.grid() # %% # Diffuse sky, ground, and horizon IAM # ------------------------------------ # # Now that we have an AOI model, we use :py:func:`pvlib.iam.marion_diffuse` # to integrate it across solid angle and determine diffuse irradiance IAM. # Marion defines three types of diffuse irradiance: # sky, horizon, and ground-reflected. The diffuse IAM value is evaluated # independently for each type. tilts = np.arange(0, 91, 2.5) # marion_diffuse calculates all three IAM values (sky, horizon, ground) iam_no_coating = marion_diffuse('physical', tilts, n=1.526, K=0) iam_ar_coating = marion_diffuse('physical', tilts, n=1.3, K=0) # %% # First we recreate Figure 4 in [1]_, showing the dependence of the sky diffuse # incidence angle modifier on module tilt. plt.plot(tilts, iam_ar_coating['sky'], c='b', marker='^', label='$F_{sky}$, AR coated, n=1.3') plt.plot(tilts, iam_no_coating['sky'], c='r', marker='x',