Skip to content

Commit 9d76b49

Browse files
committed
Merge pull request #1 from MoonRaker/master
Fixed test_temp_convert
2 parents 16a216f + a218e95 commit 9d76b49

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

pvlib/forecast.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
retreiving forecasted data from UNIDATA Thredd servers.
44
'''
55
import datetime
6-
from xml.etree.ElementTree import ParseError
76
from netCDF4 import num2date
8-
import pandas as pd
97
import numpy as np
8+
import pandas as pd
9+
from requests.exceptions import HTTPError
10+
from xml.etree.ElementTree import ParseError
1011

1112
from pvlib.location import Location
1213
from pvlib.tools import localize_to_utc
@@ -129,7 +130,11 @@ def __init__(self, model_type, model_name, set_type):
129130
except ParseError:
130131
raise ParseError(self.model_name + ' model may be unavailable.')
131132

132-
self.model = TDSCatalog(model_url)
133+
try:
134+
self.model = TDSCatalog(model_url)
135+
except HTTPError:
136+
raise HTTPError(self.model_name + ' model may be unavailable.')
137+
133138
self.datasets_list = list(self.model.datasets.keys())
134139
self.set_dataset()
135140

pvlib/test/test_forecast.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from nose.tools import raises,assert_almost_equals
1111
from nose.plugins.skip import SkipTest
1212
from numpy.testing import assert_almost_equal
13+
from requests.exceptions import HTTPError
1314
from xml.etree.ElementTree import ParseError
1415

1516
from pvlib.forecast import GFS,HRRR_ESRL,HRRR,NAM,NDFD,RAP
@@ -21,7 +22,7 @@
2122
_longitude = -110.9
2223
_tz = 'US/Arizona'
2324
_time = pd.DatetimeIndex([datetime.now()], tz=_tz)
24-
_models = [GFS, HRRR_ESRL, NAM, HRRR, NDFD, RAP]
25+
_models = [GFS, NAM, HRRR, RAP, NDFD, HRRR_ESRL]
2526
_working_models = []
2627
_variables = np.array(['temperature',
2728
'wind_speed',
@@ -48,7 +49,7 @@ def test_fmcreation():
4849
else:
4950
try:
5051
amodel = model()
51-
except ParseError:
52+
except (ParseError, HTTPError):
5253
pass
5354

5455

@@ -103,7 +104,7 @@ def test_gfs():
103104

104105
def test_temp_convert():
105106
amodel = _working_models[0]
106-
amodel.queryvariables = ['Temperature']
107+
amodel.queryvariables = ['Temperature_surface']
107108
amodel.data = pd.DataFrame({'temperature':[273.15]})
108109
amodel.convert_temperature()
109110

0 commit comments

Comments
 (0)