Skip to content

Commit

Permalink
Update get functions
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamRJensen committed Jul 1, 2023
1 parent 6bf9e07 commit d735e98
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
4 changes: 4 additions & 0 deletions pvlib/iotools/bsrn.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ def get_bsrn(station, start, end, username, password,
# The FTP server uses lowercase station abbreviations
station = station.lower()

# Use pd.to_datetime so that strings (e.g. '2021-01-01') are accepted
start = pd.to_datetime(start)
end = pd.to_datetime(end)

# Generate list files to download based on start/end (SSSMMYY.dat.gz)
filenames = pd.date_range(
start, end.replace(day=1) + pd.DateOffset(months=1), freq='1M')\
Expand Down
8 changes: 4 additions & 4 deletions pvlib/iotools/midc.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ def read_midc_raw_data_from_nrel(site, start, end, variable_map={},
----------
site: string
The MIDC station id.
start: datetime
start: datetime-like
Start date for requested data.
end: datetime
end: datetime-like
End date for requested data.
variable_map: dict
A dictionary mapping MIDC field names to pvlib names. Used to
Expand Down Expand Up @@ -247,8 +247,8 @@ def read_midc_raw_data_from_nrel(site, start, end, variable_map={},
for more details and considerations.
"""
args = {'site': site,
'begin': start.strftime('%Y%m%d'),
'end': end.strftime('%Y%m%d')}
'begin': pd.to_datetime(start).strftime('%Y%m%d'),
'end': pd.to_datetime(end).strftime('%Y%m%d')}
url = 'https://midcdmz.nrel.gov/apps/data_api.pl'
# NOTE: just use requests.get(url, params=args) to build querystring
# number of header columns and data columns do not always match,
Expand Down
4 changes: 2 additions & 2 deletions pvlib/iotools/pvgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ def get_pvgis_hourly(latitude, longitude, start=None, end=None,
if raddatabase is not None:
params['raddatabase'] = raddatabase
if start is not None:
params['startyear'] = start if isinstance(start, int) else start.year
params['startyear'] = start if isinstance(start, int) else pd.to_datetime(start).year # noqa: E501
if end is not None:
params['endyear'] = end if isinstance(end, int) else end.year
params['endyear'] = end if isinstance(end, int) else pd.to_datetime(start).year # noqa: E501
if peakpower is not None:
params['peakpower'] = peakpower

Expand Down
9 changes: 5 additions & 4 deletions pvlib/iotools/sodapro.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ def get_cams(latitude, longitude, start, end, email, identifier='mcclear',
altitude=None, time_step='1h', time_ref='UT', verbose=False,
integrated=False, label=None, map_variables=True,
server=URL, timeout=30):
"""
Retrieve time-series of radiation and/or clear-sky global, beam, and
"""Retrieve irradiance and clear-sky time series from CAMS.
Time-series of radiation and/or clear-sky global, beam, and
diffuse radiation from CAMS (see [1]_). Data is retrieved from SoDa [2]_.
Time coverage: 2004-01-01 to two days ago
Expand All @@ -65,9 +66,9 @@ def get_cams(latitude, longitude, start, end, email, identifier='mcclear',
in decimal degrees, between -90 and 90, north is positive (ISO 19115)
longitude : float
in decimal degrees, between -180 and 180, east is positive (ISO 19115)
start: datetime like
start: datetime-like
First day of the requested period
end: datetime like
end: datetime-like
Last day of the requested period
email: str
Email address linked to a SoDa account
Expand Down
4 changes: 2 additions & 2 deletions pvlib/iotools/srml.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ def get_srml(station, start, end, filetype='PO', map_variables=True,
----------
station : str
Two letter station abbreviation.
start : datetime like
start : datetime-like
First day of the requested period
end : datetime like
end : datetime-like
Last day of the requested period
filetype : string, default: 'PO'
SRML file type to gather. See notes for explanation.
Expand Down

0 comments on commit d735e98

Please sign in to comment.