From 88214c010cb5d43acd5295b144a7c1af55d7716e Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Tue, 13 Jun 2023 15:58:39 +0200 Subject: [PATCH 1/6] Change wind_dir to wind_direction --- pvlib/iotools/srml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/iotools/srml.py b/pvlib/iotools/srml.py index 397a7bd612..d6f40707af 100644 --- a/pvlib/iotools/srml.py +++ b/pvlib/iotools/srml.py @@ -15,7 +15,7 @@ '100': 'ghi', '201': 'dni', '300': 'dhi', - '920': 'wind_dir', + '920': 'wind_direction', '921': 'wind_speed', '930': 'temp_air', '931': 'temp_dew', From 1d7b372c1827ef5c6e821ef98ab0c3775d4447fa Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Tue, 13 Jun 2023 16:13:56 +0200 Subject: [PATCH 2/6] Add variable mapping --- pvlib/iotools/srml.py | 20 +++++++++++++------- pvlib/tests/iotools/test_srml.py | 10 ++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/pvlib/iotools/srml.py b/pvlib/iotools/srml.py index d6f40707af..6e7675482c 100644 --- a/pvlib/iotools/srml.py +++ b/pvlib/iotools/srml.py @@ -24,7 +24,7 @@ } -def read_srml(filename): +def read_srml(filename, map_variables=True): """ Read University of Oregon SRML 1min .tsv file into pandas dataframe. The SRML is described in [1]_. @@ -33,13 +33,14 @@ def read_srml(filename): ---------- filename: str filepath or url to read for the tsv file. + map_variables: bool, default: True + When true, renames columns of the DataFrame to pvlib variable names + where applicable. See variable :const:`VARIABLE_MAP`. Returns ------- data: Dataframe - A dataframe with datetime index and all of the variables listed - in the `VARIABLE_MAP` dict inside of the map_columns function, - along with their associated quality control flags. + A dataframe with datetime index Notes ----- @@ -64,7 +65,8 @@ def read_srml(filename): # Drop day of year and time columns data = data[data.columns[2:]] - data = data.rename(columns=map_columns) + if map_variables: + data = data.rename(columns=map_columns) # Quality flag columns are all labeled 0 in the original data. They # appear immediately after their associated variable and are suffixed @@ -166,7 +168,8 @@ def format_index(df): return df -def read_srml_month_from_solardat(station, year, month, filetype='PO'): +def read_srml_month_from_solardat(station, year, month, filetype='PO', + map_variables=True): """Request a month of SRML data from solardat and read it into a Dataframe. The SRML is described in [1]_. @@ -180,6 +183,9 @@ def read_srml_month_from_solardat(station, year, month, filetype='PO'): Month to request data for. filetype: string SRML file type to gather. See notes for explanation. + map_variables: bool, default: True + When true, renames columns of the DataFrame to pvlib variable names + where applicable. See variable :const:`VARIABLE_MAP`. Returns ------- @@ -214,5 +220,5 @@ def read_srml_month_from_solardat(station, year, month, filetype='PO'): year=year % 100, month=month) url = "http://solardat.uoregon.edu/download/Archive/" - data = read_srml(url + file_name) + data = read_srml(url + file_name, map_variables=map_variables) return data diff --git a/pvlib/tests/iotools/test_srml.py b/pvlib/tests/iotools/test_srml.py index 556bd7111d..9939374ebf 100644 --- a/pvlib/tests/iotools/test_srml.py +++ b/pvlib/tests/iotools/test_srml.py @@ -28,6 +28,16 @@ def test_read_srml_columns_exist(): assert '7008_flag' in data.columns +def test_read_srml_map_variables_false(): + data = srml.read_srml(srml_testfile, map_variables=False) + assert '1000' in data.columns + assert '1000_flag' in data.columns + assert '2010' in data.columns + assert '2010_flag' in data.columns + assert '7008' in data.columns + assert '7008_flag' in data.columns + + def test_read_srml_nans_exist(): data = srml.read_srml(srml_testfile) assert isnan(data['dni_0'][1119]) From 29c7e8bb286a7d55c738f6405bc9b128d69f31c1 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Tue, 13 Jun 2023 16:40:36 +0200 Subject: [PATCH 3/6] Update v0.10.0.rst --- docs/sphinx/source/whatsnew/v0.10.0.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/sphinx/source/whatsnew/v0.10.0.rst b/docs/sphinx/source/whatsnew/v0.10.0.rst index a4406072f8..10babdad8f 100644 --- a/docs/sphinx/source/whatsnew/v0.10.0.rst +++ b/docs/sphinx/source/whatsnew/v0.10.0.rst @@ -13,7 +13,9 @@ Breaking changes :py:func:`pvlib.singlediode._lambertw_v_from_i` to match :py:func:`pvlib.pvsystem.singlediode`. (:issue:`1718`, :pull:`1719`) - +* Map wind direction to `wind_direction` instead of `wind_dir` in + :py:func:`pvlib.iotools.read_srml` and :py:func:`pvlib.iotools.get_srml` + (:pul:`1773`) Deprecations ~~~~~~~~~~~~ From 7dfd9e0d436736fd459482f325e119de5b133a8a Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Tue, 13 Jun 2023 16:42:18 +0200 Subject: [PATCH 4/6] Update v0.10.0.rst --- docs/sphinx/source/whatsnew/v0.10.0.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.10.0.rst b/docs/sphinx/source/whatsnew/v0.10.0.rst index 10babdad8f..8d0db097e7 100644 --- a/docs/sphinx/source/whatsnew/v0.10.0.rst +++ b/docs/sphinx/source/whatsnew/v0.10.0.rst @@ -15,7 +15,7 @@ Breaking changes (:issue:`1718`, :pull:`1719`) * Map wind direction to `wind_direction` instead of `wind_dir` in :py:func:`pvlib.iotools.read_srml` and :py:func:`pvlib.iotools.get_srml` - (:pul:`1773`) + (:pull:`1773`) Deprecations ~~~~~~~~~~~~ @@ -23,7 +23,8 @@ Deprecations Enhancements ~~~~~~~~~~~~ - +* Added `map_variables` parameter to :py:func:`pvlib.iotools.read_srml` + and :py:func:`pvlib.iotools.get_srml` (:pull:`1773`) Bug fixes ~~~~~~~~~ From ad8ef8e93649429fd86d52e0339c11d4c82f2c9d Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Tue, 13 Jun 2023 16:43:45 +0200 Subject: [PATCH 5/6] Update v0.10.0.rst --- docs/sphinx/source/whatsnew/v0.10.0.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/sphinx/source/whatsnew/v0.10.0.rst b/docs/sphinx/source/whatsnew/v0.10.0.rst index ec960223de..599457c655 100644 --- a/docs/sphinx/source/whatsnew/v0.10.0.rst +++ b/docs/sphinx/source/whatsnew/v0.10.0.rst @@ -20,6 +20,8 @@ Breaking changes * :func:`~pvlib.iotools.get_pvgis_tmy` and :func:`~pvlib.iotools.read_pvgis_tmy` now rename columns to standard pvlib names by default (``map_variables=True``) (:pull:`1772`) + :py:func:`pvlib.iotools.read_srml` and + :py:func:`pvlib.iotools.read_srml_month_from_solardat` (:pull:`1773`) Deprecations ~~~~~~~~~~~~ @@ -28,7 +30,7 @@ Deprecations Enhancements ~~~~~~~~~~~~ * Added `map_variables` parameter to :py:func:`pvlib.iotools.read_srml` - and :py:func:`pvlib.iotools.get_srml` (:pull:`1773`) + and :py:func:`pvlib.iotools.read_srml_month_from_solardat` (:pull:`1773`) Bug fixes ~~~~~~~~~ From 6479a05aa916e173a481099263deb1e0426d3764 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Tue, 13 Jun 2023 16:46:17 +0200 Subject: [PATCH 6/6] Update v0.10.0.rst --- docs/sphinx/source/whatsnew/v0.10.0.rst | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.10.0.rst b/docs/sphinx/source/whatsnew/v0.10.0.rst index 599457c655..f7ad2b7d7c 100644 --- a/docs/sphinx/source/whatsnew/v0.10.0.rst +++ b/docs/sphinx/source/whatsnew/v0.10.0.rst @@ -14,14 +14,11 @@ Breaking changes :py:func:`pvlib.pvsystem.singlediode`. (:issue:`1718`, :pull:`1719`) * Map wind direction to `wind_direction` instead of `wind_dir` in - :py:func:`pvlib.iotools.read_srml` and :py:func:`pvlib.iotools.get_srml` - (:pull:`1773`) - (:pul:`1773`) + :py:func:`pvlib.iotools.read_srml` and + :py:func:`pvlib.iotools.read_srml_month_from_solardat` (:pull:`1773`) * :func:`~pvlib.iotools.get_pvgis_tmy` and :func:`~pvlib.iotools.read_pvgis_tmy` now rename columns to standard pvlib names by default (``map_variables=True``) (:pull:`1772`) - :py:func:`pvlib.iotools.read_srml` and - :py:func:`pvlib.iotools.read_srml_month_from_solardat` (:pull:`1773`) Deprecations ~~~~~~~~~~~~