|
4 | 4 | import inspect
|
5 | 5 | import os
|
6 | 6 |
|
| 7 | +from pandas.util.testing import network |
| 8 | + |
7 | 9 | test_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
| 10 | +tmy3_testfile = os.path.join(test_dir, '../data/703165TY.csv') |
| 11 | +tmy2_testfile = os.path.join(test_dir, '../data/12839.tm2') |
8 | 12 |
|
9 | 13 | from pvlib import tmy
|
10 | 14 |
|
11 | 15 |
|
12 | 16 | def test_readtmy3():
|
13 |
| - tmy.readtmy3(os.path.join(test_dir, '../data/703165TY.csv')) |
| 17 | + tmy.readtmy3(tmy3_testfile) |
| 18 | + |
| 19 | +@network |
| 20 | +def test_readtmy3_remote(): |
| 21 | + url = 'http://rredc.nrel.gov/solar/old_data/nsrdb/1991-2005/data/tmy3/703165TYA.CSV' |
| 22 | + tmy.readtmy3(url) |
| 23 | + |
| 24 | +def test_readtmy3_recolumn(): |
| 25 | + data, meta = tmy.readtmy3(tmy3_testfile) |
| 26 | + assert 'GHISource' in data.columns |
| 27 | + |
| 28 | +def test_readtmy3_norecolumn(): |
| 29 | + data, meta = tmy.readtmy3(tmy3_testfile, recolumn=False) |
| 30 | + assert 'GHI source' in data.columns |
| 31 | + |
| 32 | +def test_readtmy3_coerce_year(): |
| 33 | + coerce_year = 1987 |
| 34 | + data, meta = tmy.readtmy3(tmy3_testfile, coerce_year=coerce_year) |
| 35 | + assert (data.index.year == 1987).all() |
| 36 | + |
| 37 | +def test_readtmy3_no_coerce_year(): |
| 38 | + coerce_year = None |
| 39 | + data, meta = tmy.readtmy3(tmy3_testfile, coerce_year=coerce_year) |
| 40 | + assert 1997 and 1999 in data.index.year |
14 | 41 |
|
15 | 42 | def test_readtmy2():
|
16 |
| - tmy.readtmy2(os.path.join(test_dir, '../data/12839.tm2')) |
| 43 | + tmy.readtmy2(tmy2_testfile) |
17 | 44 |
|
0 commit comments