From d735e987be6baca5c5fd95a379c598f3d9908f35 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Sat, 1 Jul 2023 22:37:20 +0200 Subject: [PATCH 1/5] Update get functions --- pvlib/iotools/bsrn.py | 4 ++++ pvlib/iotools/midc.py | 8 ++++---- pvlib/iotools/pvgis.py | 4 ++-- pvlib/iotools/sodapro.py | 9 +++++---- pvlib/iotools/srml.py | 4 ++-- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/pvlib/iotools/bsrn.py b/pvlib/iotools/bsrn.py index b9292b41ae..c9ed8394cd 100644 --- a/pvlib/iotools/bsrn.py +++ b/pvlib/iotools/bsrn.py @@ -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')\ diff --git a/pvlib/iotools/midc.py b/pvlib/iotools/midc.py index 75cc5609a7..c554dd1d1f 100644 --- a/pvlib/iotools/midc.py +++ b/pvlib/iotools/midc.py @@ -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 @@ -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, diff --git a/pvlib/iotools/pvgis.py b/pvlib/iotools/pvgis.py index da238898a8..6ba9112336 100644 --- a/pvlib/iotools/pvgis.py +++ b/pvlib/iotools/pvgis.py @@ -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 diff --git a/pvlib/iotools/sodapro.py b/pvlib/iotools/sodapro.py index 9fb4602e09..cf599b74ea 100644 --- a/pvlib/iotools/sodapro.py +++ b/pvlib/iotools/sodapro.py @@ -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 @@ -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 diff --git a/pvlib/iotools/srml.py b/pvlib/iotools/srml.py index 81b61556a0..01b835da6d 100644 --- a/pvlib/iotools/srml.py +++ b/pvlib/iotools/srml.py @@ -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. From 6034bbfeefc8a041c4e3a234a4096dfc67ca714c Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Sat, 1 Jul 2023 22:57:17 +0200 Subject: [PATCH 2/5] Update pvgis.py --- pvlib/iotools/pvgis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/iotools/pvgis.py b/pvlib/iotools/pvgis.py index 6ba9112336..ca1371d4a1 100644 --- a/pvlib/iotools/pvgis.py +++ b/pvlib/iotools/pvgis.py @@ -219,7 +219,7 @@ def get_pvgis_hourly(latitude, longitude, start=None, end=None, if start is not None: 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 pd.to_datetime(start).year # noqa: E501 + params['endyear'] = end if isinstance(end, int) else pd.to_datetime(end).year # noqa: E501 if peakpower is not None: params['peakpower'] = peakpower From d9ca3bef99c05912b282dfbc240e829576ad6847 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Sat, 1 Jul 2023 23:03:19 +0200 Subject: [PATCH 3/5] Update whatsnew and add get_cams --- docs/sphinx/source/whatsnew/v0.10.1.rst | 4 ++++ pvlib/iotools/sodapro.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.10.1.rst b/docs/sphinx/source/whatsnew/v0.10.1.rst index fda67c7465..f07ba1430e 100644 --- a/docs/sphinx/source/whatsnew/v0.10.1.rst +++ b/docs/sphinx/source/whatsnew/v0.10.1.rst @@ -11,6 +11,10 @@ Deprecations Enhancements ~~~~~~~~~~~~ +* Added support for dates to specified as strings in the iotools get functions: + :py:func:`pvlib.iotools.get_pvgis_hourly`, :py:func:`pvlib.iotools.get_cams`, + and :py:func:`pvlib.iotools.read_midc_raw_data_from_nrel`. + (:pull:`1800`) Bug fixes diff --git a/pvlib/iotools/sodapro.py b/pvlib/iotools/sodapro.py index cf599b74ea..95d6ffd866 100644 --- a/pvlib/iotools/sodapro.py +++ b/pvlib/iotools/sodapro.py @@ -178,8 +178,8 @@ def get_cams(latitude, longitude, start, end, email, identifier='mcclear', altitude = -999 # Start and end date should be in the format: yyyy-mm-dd - start = start.strftime('%Y-%m-%d') - end = end.strftime('%Y-%m-%d') + start = pd.to_datetime(start).strftime('%Y-%m-%d') + end = pd.to_datetime(end).strftime('%Y-%m-%d') email = email.replace('@', '%2540') # Format email address identifier = 'get_{}'.format(identifier.lower()) # Format identifier str From dc93f24c0674008b0e5cbf8975c40c593d05b85e Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Thu, 6 Jul 2023 15:58:18 +0200 Subject: [PATCH 4/5] Update whatsnews --- docs/sphinx/source/whatsnew/v0.10.1.rst | 31 ------------------------- docs/sphinx/source/whatsnew/v0.10.2.rst | 6 ++++- 2 files changed, 5 insertions(+), 32 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.10.1.rst b/docs/sphinx/source/whatsnew/v0.10.1.rst index 7116f1f1ec..42d709c808 100644 --- a/docs/sphinx/source/whatsnew/v0.10.1.rst +++ b/docs/sphinx/source/whatsnew/v0.10.1.rst @@ -4,37 +4,6 @@ v0.10.1 (July 3, 2023) ---------------------- - -Deprecations -~~~~~~~~~~~~ - - -Enhancements -~~~~~~~~~~~~ -* Added support for dates to specified as strings in the iotools get functions: - :py:func:`pvlib.iotools.get_pvgis_hourly`, :py:func:`pvlib.iotools.get_cams`, - and :py:func:`pvlib.iotools.read_midc_raw_data_from_nrel`. - (:pull:`1800`) - - -Bug fixes -~~~~~~~~~ - - -Testing -~~~~~~~ - - -Documentation -~~~~~~~~~~~~~ - - -Requirements -~~~~~~~~~~~~ - - -Contributors -~~~~~~~~~~~~ To resolve an installation issue with ``pvfactors`` and ``shapely``, this release drops the optional ``pvfactors`` dependency and replaces it with ``solarfactors``, a fork of ``pvfactors`` maintained by the diff --git a/docs/sphinx/source/whatsnew/v0.10.2.rst b/docs/sphinx/source/whatsnew/v0.10.2.rst index 4b18a7fe9b..fc40b2b7e3 100644 --- a/docs/sphinx/source/whatsnew/v0.10.2.rst +++ b/docs/sphinx/source/whatsnew/v0.10.2.rst @@ -11,6 +11,10 @@ Deprecations Enhancements ~~~~~~~~~~~~ +* Added support for dates to specified as strings in the iotools get functions: + :py:func:`pvlib.iotools.get_pvgis_hourly`, :py:func:`pvlib.iotools.get_cams`, + and :py:func:`pvlib.iotools.read_midc_raw_data_from_nrel`. + (:pull:`1800`) Bug fixes @@ -31,4 +35,4 @@ Requirements Contributors ~~~~~~~~~~~~ - +* Adam R. Jensen (:ghuser:`AdamRJensen`) From eea00f0cab836386650d3d09174d15aafa984d0a Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Thu, 6 Jul 2023 17:27:54 +0200 Subject: [PATCH 5/5] Update v0.10.2.rst --- docs/sphinx/source/whatsnew/v0.10.2.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.10.2.rst b/docs/sphinx/source/whatsnew/v0.10.2.rst index fc40b2b7e3..f95f0bd93d 100644 --- a/docs/sphinx/source/whatsnew/v0.10.2.rst +++ b/docs/sphinx/source/whatsnew/v0.10.2.rst @@ -11,9 +11,9 @@ Deprecations Enhancements ~~~~~~~~~~~~ -* Added support for dates to specified as strings in the iotools get functions: +* Added support for dates to be specified as strings in the iotools get functions: :py:func:`pvlib.iotools.get_pvgis_hourly`, :py:func:`pvlib.iotools.get_cams`, - and :py:func:`pvlib.iotools.read_midc_raw_data_from_nrel`. + :py:func:`pvlib.iotools.get_bsrn`, and :py:func:`pvlib.iotools.read_midc_raw_data_from_nrel`. (:pull:`1800`)