Skip to content

Commit e24d1c9

Browse files
committed
Merge pull request #7 from wholmgren/tmyurl
TMY loading improvements
2 parents e0abcd7 + 8d6c6b2 commit e24d1c9

File tree

2 files changed

+156
-134
lines changed

2 files changed

+156
-134
lines changed

pvlib/test/test_tmy.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,41 @@
44
import inspect
55
import os
66

7+
from pandas.util.testing import network
8+
79
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')
812

913
from pvlib import tmy
1014

1115

1216
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
1441

1542
def test_readtmy2():
16-
tmy.readtmy2(os.path.join(test_dir, '../data/12839.tm2'))
43+
tmy.readtmy2(tmy2_testfile)
1744

0 commit comments

Comments
 (0)