diff --git a/docs/sphinx/source/whatsnew/v0.10.0.rst b/docs/sphinx/source/whatsnew/v0.10.0.rst index f4368de6f2..f7ad2b7d7c 100644 --- a/docs/sphinx/source/whatsnew/v0.10.0.rst +++ b/docs/sphinx/source/whatsnew/v0.10.0.rst @@ -13,6 +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.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`) @@ -23,7 +26,8 @@ Deprecations Enhancements ~~~~~~~~~~~~ - +* Added `map_variables` parameter to :py:func:`pvlib.iotools.read_srml` + and :py:func:`pvlib.iotools.read_srml_month_from_solardat` (:pull:`1773`) Bug fixes ~~~~~~~~~ diff --git a/pvlib/iotools/srml.py b/pvlib/iotools/srml.py index 397a7bd612..6e7675482c 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', @@ -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])