You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks @cwhanse for that. Subsequent to my post, I had even tried running the code in a new virtual environment, hoping it was a problem with another library but I received the same error. I think this supports your analysis that something is amiss further upstream with THREDDS.
I managed to 'solve' this problem by bypassing pvlib and using siphon directly to access GFS data. For instance, to download the wind data for the next 24 hours for Greenwich, London:
# adapted from
#https://unidata.github.io/python-training/workshop/Bonus/downloading-gfs-with-siphon/
from siphon.catalog import TDSCatalog
import datetime
import pytz
# list of relevant wind variables
var_list = ['u-component_of_wind_isobaric','v-component_of_wind_isobaric',\
'Wind_speed_gust_surface']
# query 0.5 degree model, same as pvlib
best_gfs = TDSCatalog('http://thredds.ucar.edu/thredds/catalog/grib/NCEP/GFS/'
'Global_0p5deg/catalog.xml?dataset=grib/NCEP/GFS/Global_0p5deg/Best')
best_ds = list(best_gfs.datasets.values())[0]
ncss = best_ds.subset()
query = ncss.query()
# single geographic location
query.lonlat_point(lat = 0, lon = 0)
# read in data for next 24 hours
timezone = pytz.timezone("Europe/London")
T0 = datetime.datetime.now().astimezone(timezone)
query.time_range(T0, T0 + datetime.timedelta(days = 1))
query.accept('netcdf4')
# loop over wind variables
for var in var_list:
query.variables(var)
query.vertical_level(100000)
dataset = ncss.get_data(query)
surface_wind_gust = dataset.variables['Wind_speed_gust_surface'][0].data
u_isobaric = dataset.variables['u-component_of_wind_isobaric'][0].data
v_isobaric = dataset.variables['v-component_of_wind_isobaric'][0].data
I have done a few non-exhaustive checks and the data obtained this way seems identical to data I had previously downloaded using pvlib. Given the pvlib forecast function always came with a 'highly experimental' warning anyway, I think I am going to stick with the siphon approach, even it requires a little more coding on my part to replicate the ease of pvlib.
Activity
cwhanse commentedon Mar 10, 2022
@DavidLloydNGP I've seen that error when an empty file is returned by the THREDDS server. In this case, the error occurs on this line. (I ran your code in the Spyder debugger). A few lines earlier, the
model_urlis constructed: "https://thredds.ucar.edu/thredds/catalog/grib/NCEP/GFS/Global_0p5deg/catalog.xml" Pasting that URL in a browser returns an empty page.This appears to be a THREDDS issue. Perhaps pvlib could return a more informative error somehow.
DavidLloydNGP commentedon Mar 11, 2022
Thanks @cwhanse for that. Subsequent to my post, I had even tried running the code in a new virtual environment, hoping it was a problem with another library but I received the same error. I think this supports your analysis that something is amiss further upstream with THREDDS.
I managed to 'solve' this problem by bypassing pvlib and using siphon directly to access GFS data. For instance, to download the wind data for the next 24 hours for Greenwich, London:
I have done a few non-exhaustive checks and the data obtained this way seems identical to data I had previously downloaded using pvlib. Given the pvlib forecast function always came with a 'highly experimental' warning anyway, I think I am going to stick with the siphon approach, even it requires a little more coding on my part to replicate the ease of pvlib.
kandersolar commentedon Mar 11, 2022
FWIW the example code at the top of this thread seems to work again. Still worth considering a nicer error message though.
cwhanse commentedon Mar 16, 2022
THREDDS appears to be working (at least today it is). Closing in anticipation on #1426