8000 Create `pvlib.iotools.get_solrad` by kandersolar · Pull Request #1967 · pvlib/pvlib-python · GitHub
[go: up one dir, main page]

Skip to content

Create pvlib.iotools.get_solrad #1967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Mar 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix problem with read_solrad for 404 URLs
  • Loading branch information
kandersolar committed Mar 5, 2024
commit eb32362c1b2fef5cf71b8089ecc79065ae277467
4 changes: 2 additions & 2 deletions pvlib/iotools/solrad.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Functions to read data from the NOAA SOLRAD network."""

import pandas as pd
import urllib
import warnings
import requests
import io
Expand Down Expand Up @@ -110,6 +109,7 @@ def read_solrad(filename):

if str(filename).startswith('ftp') or str(filename).startswith('http'):
response = requests.get(filename)
response.raise_for_status()
file_buffer = io.StringIO(response.content.decode())
else:
with open(str(filename), 'r') as file_buffer:
Expand Down Expand Up @@ -207,7 +207,7 @@ def get_solrad(station, start, end,
try:
dfi, file_metadata = read_solrad(url + f)
dfs.append(dfi)
except urllib.error.HTTPError:
except requests.exceptions.HTTPError:
warnings.warn(f"The following file was not found: {f}")

data = pd.concat(dfs, axis='rows')
Expand Down
0