Exemplo n.º 1
0
def test_clearness_index_zenith_independent(airmass_kt):
    clearness_index = np.array([-1, 0, .1, 1])
    clearness_index, airmass_kt = np.meshgrid(clearness_index, airmass_kt)
    out = irradiance.clearness_index_zenith_independent(clearness_index,
                                                        airmass_kt)
    expected = np.array(
        [[0.   , 0.   , 0.1  , 1.   ],
         [0.   , 0.   , 0.138, 1.383],
         [0.   , 0.   , 0.182, 1.822],
         [0.   , 0.   , 0.212, 2.   ]])
    assert_allclose(out, expected, atol=0.001)
    # test max_clearness_index
    out = irradiance.clearness_index_zenith_independent(
        clearness_index, airmass_kt, max_clearness_index=0.82)
    expected = np.array(
        [[ 0.   ,  0.   ,  0.1  ,  0.82 ],
         [ 0.   ,  0.   ,  0.138,  0.82 ],
         [ 0.   ,  0.   ,  0.182,  0.82 ],
         [ 0.   ,  0.   ,  0.212,  0.82 ]])
    assert_allclose(out, expected, atol=0.001)
    # scalars
    out = irradiance.clearness_index_zenith_independent(.4, 2)
    expected = 0.443
    assert_allclose(out, expected, atol=0.001)
    # series
    times = pd.DatetimeIndex(start='20180601', periods=2, freq='12H')
    clearness_index = pd.Series([0, .5], index=times)
    airmass = pd.Series([np.nan, 2], index=times)
    out = irradiance.clearness_index_zenith_independent(clearness_index,
                                                        airmass)
    expected = pd.Series([np.nan, 0.553744437562], index=times)
    assert_series_equal(out, expected)
Exemplo n.º 2
0
def test_clearness_index_zenith_independent(airmass_kt):
    clearness_index = np.array([-1, 0, .1, 1])
    clearness_index, airmass_kt = np.meshgrid(clearness_index, airmass_kt)
    out = irradiance.clearness_index_zenith_independent(
        clearness_index, airmass_kt)
    expected = np.array([[0., 0., 0.1, 1.], [0., 0., 0.138, 1.383],
                         [0., 0., 0.182, 1.822], [0., 0., 0.212, 2.]])
    assert_allclose(out, expected, atol=0.001)
    # test max_clearness_index
    out = irradiance.clearness_index_zenith_independent(
        clearness_index, airmass_kt, max_clearness_index=0.82)
    expected = np.array([[0., 0., 0.1, 0.82], [0., 0., 0.138, 0.82],
                         [0., 0., 0.182, 0.82], [0., 0., 0.212, 0.82]])
    assert_allclose(out, expected, atol=0.001)
    # scalars
    out = irradiance.clearness_index_zenith_independent(.4, 2)
    expected = 0.443
    assert_allclose(out, expected, atol=0.001)
    # series
    times = pd.date_range(start='20180601', periods=2, freq='12H')
    clearness_index = pd.Series([0, .5], index=times)
    airmass = pd.Series([np.nan, 2], index=times)
    out = irradiance.clearness_index_zenith_independent(
        clearness_index, airmass)
    expected = pd.Series([np.nan, 0.553744437562], index=times)
    assert_series_equal(out, expected)