value = 1383.636203


@pytest.mark.parametrize('input, expected', [
    (doy, value),
    (np.float64(doy), value),
    (dt_date, value),
    (dt_datetime, value),
    (dt_np64, value),
    (np.array([doy]), np.array([value])),
    (pd.Series([doy]), np.array([value])),
    (dt_index, pd.Series([value], index=dt_index)),
    (timestamp, value)
])
@pytest.mark.parametrize('method', [
    'asce', 'spencer', 'nrel', requires_ephem('pyephem')])
def test_get_extra_radiation(input, expected, method):
    out = irradiance.get_extra_radiation(input)
    assert_allclose(out, expected, atol=1)


@requires_numba
def test_get_extra_radiation_nrel_numba(times):
    result = irradiance.get_extra_radiation(times, method='nrel', how='numba',
                                            numthreads=8)
    assert_allclose(result, [1322.332316, 1322.296282, 1322.261205, 1322.227091])


def test_get_extra_radiation_epoch_year():
    out = irradiance.get_extra_radiation(doy, method='nrel', epoch_year=2012)
    assert_allclose(out, 1382.4926804890767, atol=0.1)
Example #2
0
dt_datetime = datetime.datetime.combine(dt_date, datetime.time(0))
dt_np64 = np.datetime64(dt_datetime)
value = 1383.636203


@pytest.mark.parametrize('input, expected',
                         [(doy, value), (np.float64(doy), value),
                          (dt_date, value), (dt_datetime, value),
                          (dt_np64, value),
                          (np.array([doy]), np.array([value])),
                          (pd.Series([doy]), np.array([value])),
                          (dt_index, pd.Series([value], index=dt_index)),
                          (timestamp, value)])
@pytest.mark.parametrize(
    'method', ['asce', 'spencer', 'nrel',
               requires_ephem('pyephem')])
def test_extraradiation(input, expected, method):
    out = irradiance.extraradiation(input)
    assert_allclose(out, expected, atol=1)


@requires_numba
def test_extraradiation_nrel_numba():
    result = irradiance.extraradiation(times,
                                       method='nrel',
                                       how='numba',
                                       numthreads=8)
    assert_allclose(result,
                    [1322.332316, 1322.296282, 1322.261205, 1322.227091])

Example #3
0
dt_np64 = np.datetime64(dt_datetime)
value = 1383.636203

@pytest.mark.parametrize('input, expected', [
    (doy, value),
    (np.float64(doy), value),
    (dt_date, value),
    (dt_datetime, value),
    (dt_np64, value),
    (np.array([doy]), np.array([value])),
    (pd.Series([doy]), np.array([value])),
    (dt_index, pd.Series([value], index=dt_index)),
    (timestamp, value)
])
@pytest.mark.parametrize('method', [
    'asce', 'spencer', 'nrel', requires_ephem('pyephem')])
def test_extraradiation(input, expected, method):
    out = irradiance.extraradiation(input)
    assert_allclose(out, expected, atol=1)


@requires_numba
def test_extraradiation_nrel_numba():
    irradiance.extraradiation(times, method='nrel', how='numba', numthreads=8)


def test_extraradiation_epoch_year():
    out = irradiance.extraradiation(doy, method='nrel', epoch_year=2012)
    assert_allclose(out, 1382.4926804890767, atol=0.1)