From 0e602774e468945b4fcce353800de1fb1b039b49 Mon Sep 17 00:00:00 2001 From: Pratham Chauhan Date: Wed, 21 Dec 2022 22:12:35 +0530 Subject: [PATCH 01/43] Added map_variables param in read_tmy3 func --- pvlib/iotools/tmy.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index 032680a14b..0c479d64e1 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -3,9 +3,10 @@ import datetime import re import pandas as pd +import warnings -def read_tmy3(filename, coerce_year=None, recolumn=True): +def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True): """Read a TMY3 file into a pandas dataframe. Note that values contained in the metadata dictionary are unchanged @@ -24,6 +25,10 @@ def read_tmy3(filename, coerce_year=None, recolumn=True): If supplied, the year of the index will be set to `coerce_year`, except for the last index value which will be set to the *next* year so that the index increases monotonically. + map_variables : bool, default None + If ``True``, apply standard names to TMY3 columns. Typically this + results in stripping the units from the column name and issues deprecationWarning + for recolumn recolumn : bool, default True If ``True``, apply standard names to TMY3 columns. Typically this results in stripping the units from the column name. @@ -198,9 +203,17 @@ def read_tmy3(filename, coerce_year=None, recolumn=True): # NOTE: as of pvlib-0.6.3, min req is pandas-0.18.1, so pd.to_timedelta # unit must be in (D,h,m,s,ms,us,ns), but pandas>=0.24 allows unit='hour' data.index = data_ymd + pd.to_timedelta(shifted_hour, unit='h') - - if recolumn: + + if map_variables: data = _recolumn(data) # rename to standard column names + elif recolumn: + if not map_variables: # silence warning if map_variables is false + data = _recolumn(data) + elif map_variables is None: + data = _recolumn(data) + warnings.warn("recolumn parameter will be retired starting version 0.9.5, please" + "use map_variables parameter instead.",DeprecationWarning) + data = data.tz_localize(int(meta['TZ'] * 3600)) From a8977faa8226a391e17ebcb0da858fae331788ae Mon Sep 17 00:00:00 2001 From: Pratham Chauhan Date: Wed, 21 Dec 2022 22:21:13 +0530 Subject: [PATCH 02/43] solved failing tests --- pvlib/iotools/tmy.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index 0c479d64e1..fea1c10421 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -27,8 +27,8 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True): the index increases monotonically. map_variables : bool, default None If ``True``, apply standard names to TMY3 columns. Typically this - results in stripping the units from the column name and issues deprecationWarning - for recolumn + results in stripping the units from the column name and issues + deprecationWarning for recolumn recolumn : bool, default True If ``True``, apply standard names to TMY3 columns. Typically this results in stripping the units from the column name. @@ -203,16 +203,17 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True): # NOTE: as of pvlib-0.6.3, min req is pandas-0.18.1, so pd.to_timedelta # unit must be in (D,h,m,s,ms,us,ns), but pandas>=0.24 allows unit='hour' data.index = data_ymd + pd.to_timedelta(shifted_hour, unit='h') - + if map_variables: data = _recolumn(data) # rename to standard column names elif recolumn: if not map_variables: # silence warning if map_variables is false - data = _recolumn(data) - elif map_variables is None: - data = _recolumn(data) + data = _recolumn(data) + elif map_variables is None: + data = _recolumn(data) warnings.warn("recolumn parameter will be retired starting version 0.9.5, please" - "use map_variables parameter instead.",DeprecationWarning) + "use map_variables parameter instead.", + DeprecationWarning) data = data.tz_localize(int(meta['TZ'] * 3600)) From 054dd35a94f912700ffdfa2aaa1043f8d1593aa7 Mon Sep 17 00:00:00 2001 From: Pratham Chauhan Date: Thu, 22 Dec 2022 19:54:48 +0530 Subject: [PATCH 03/43] solved failing tests --- pvlib/iotools/tmy.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index fea1c10421..f07003a385 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -25,7 +25,7 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True): If supplied, the year of the index will be set to `coerce_year`, except for the last index value which will be set to the *next* year so that the index increases monotonically. - map_variables : bool, default None + map_variables : bool, default None If ``True``, apply standard names to TMY3 columns. Typically this results in stripping the units from the column name and issues deprecationWarning for recolumn @@ -211,10 +211,9 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True): data = _recolumn(data) elif map_variables is None: data = _recolumn(data) - warnings.warn("recolumn parameter will be retired starting version 0.9.5, please" - "use map_variables parameter instead.", - DeprecationWarning) - + warnings.warn( + "recolumn parameter will be retired starting version 0.9.5, please" + "use map_variables parameter instead.",DeprecationWarning) data = data.tz_localize(int(meta['TZ'] * 3600)) From 3c7f7f6a0115ccfbd080fe2d96c304b088753d93 Mon Sep 17 00:00:00 2001 From: Pratham Chauhan Date: Thu, 22 Dec 2022 19:57:24 +0530 Subject: [PATCH 04/43] solving stickerly test fail --- pvlib/iotools/tmy.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index f07003a385..8aa1256625 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -213,7 +213,8 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True): data = _recolumn(data) warnings.warn( "recolumn parameter will be retired starting version 0.9.5, please" - "use map_variables parameter instead.",DeprecationWarning) + "use map_variables parameter instead." + ,DeprecationWarning) data = data.tz_localize(int(meta['TZ'] * 3600)) From dc6399dd8fa3fc9de8f9be39991b4b84c72b22e9 Mon Sep 17 00:00:00 2001 From: Pratham Chauhan Date: Fri, 23 Dec 2022 13:12:36 +0530 Subject: [PATCH 05/43] solving stickerly test fail --- pvlib/iotools/tmy.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index 8aa1256625..11355828e7 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -212,9 +212,9 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True): elif map_variables is None: data = _recolumn(data) warnings.warn( - "recolumn parameter will be retired starting version 0.9.5, please" - "use map_variables parameter instead." - ,DeprecationWarning) + "recolumn parameter will be retired starting version 0.9.5" + ", please use map_variables parameter instead.", + DeprecationWarning) data = data.tz_localize(int(meta['TZ'] * 3600)) From 773b94e5ca14f5c27ab7b68e8238d1bf639f3df2 Mon Sep 17 00:00:00 2001 From: Pratham Chauhan Date: Fri, 23 Dec 2022 13:19:43 +0530 Subject: [PATCH 06/43] solving stickerly test fail --- pvlib/iotools/tmy.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index 11355828e7..be3d8b4b9d 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -211,10 +211,8 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True): data = _recolumn(data) elif map_variables is None: data = _recolumn(data) - warnings.warn( - "recolumn parameter will be retired starting version 0.9.5" - ", please use map_variables parameter instead.", - DeprecationWarning) + warnings.warn("recolumn parameter will be retired starting version 0.9.5," + "please use map_variables parameter instead.",DeprecationWarning) data = data.tz_localize(int(meta['TZ'] * 3600)) From df97faf7c881e5b3ff2c145fd66faed59248531a Mon Sep 17 00:00:00 2001 From: Pratham Chauhan Date: Sat, 21 Jan 2023 13:22:01 +0530 Subject: [PATCH 07/43] added variable_map --- pvlib/iotools/tmy.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index be3d8b4b9d..fa7da3b54a 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -4,6 +4,17 @@ import re import pandas as pd import warnings +from pvlib._deprecation import pvlibDeprecationWarning + +# Dictionary mapping TMY3 names to pvlib names +VARIABLE_MAP = { + 'GHI': 'ghi', + 'DNI': 'dni', + 'DHI': 'dhi', + 'Pressure': 'pressure', + 'Wdir': 'wind_direction', + 'Wspd': 'wind_speed', +} def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True): @@ -203,16 +214,16 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True): # NOTE: as of pvlib-0.6.3, min req is pandas-0.18.1, so pd.to_timedelta # unit must be in (D,h,m,s,ms,us,ns), but pandas>=0.24 allows unit='hour' data.index = data_ymd + pd.to_timedelta(shifted_hour, unit='h') - - if map_variables: + if map_variables is None: data = _recolumn(data) # rename to standard column names - elif recolumn: - if not map_variables: # silence warning if map_variables is false - data = _recolumn(data) - elif map_variables is None: - data = _recolumn(data) - warnings.warn("recolumn parameter will be retired starting version 0.9.5," - "please use map_variables parameter instead.",DeprecationWarning) + warnings.warn( + 'TMY3 variable names will be renamed to pvlib conventions by ' + 'default starting in pvlib 0.9.5. Specify map_variables=True ' + 'to enable that behavior now, or specify map_variables=False ' + 'to hide this warning.', pvlibDeprecationWarning) + map_variables = False + if map_variables: + data = _recolumn(data).rename(columns=VARIABLE_MAP) data = data.tz_localize(int(meta['TZ'] * 3600)) From 2eee8cee96222d384bc569c076ba12b930dc9089 Mon Sep 17 00:00:00 2001 From: Pratham Chauhan Date: Sat, 21 Jan 2023 13:24:39 +0530 Subject: [PATCH 08/43] resolving formatting issues --- pvlib/iotools/tmy.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index fa7da3b54a..a8f8d659cd 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -8,13 +8,13 @@ # Dictionary mapping TMY3 names to pvlib names VARIABLE_MAP = { - 'GHI': 'ghi', - 'DNI': 'dni', - 'DHI': 'dhi', - 'Pressure': 'pressure', - 'Wdir': 'wind_direction', - 'Wspd': 'wind_speed', -} + 'GHI': 'ghi', + 'DNI': 'dni', + 'DHI': 'dhi', + 'Pressure': 'pressure', + 'Wdir': 'wind_direction', + 'Wspd': 'wind_speed', +} def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True): From 7a86c55528db7e93faf4c57c7ad8fe10bd299429 Mon Sep 17 00:00:00 2001 From: ooprathamm <89736193+ooprathamm@users.noreply.github.com> Date: Sun, 22 Jan 2023 18:12:36 +0530 Subject: [PATCH 09/43] Update pvlib/iotools/tmy.py Co-authored-by: Adam R. Jensen <39184289+AdamRJensen@users.noreply.github.com> --- pvlib/iotools/tmy.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index a8f8d659cd..4f01e29aaf 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -37,9 +37,8 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True): for the last index value which will be set to the *next* year so that the index increases monotonically. map_variables : bool, default None - If ``True``, apply standard names to TMY3 columns. Typically this - results in stripping the units from the column name and issues - deprecationWarning for recolumn + When True, renames columns of the DataFrame to pvlib variable names + where applicable. See variable :const:`VARIABLE_MAP`. recolumn : bool, default True If ``True``, apply standard names to TMY3 columns. Typically this results in stripping the units from the column name. From 7013739dec3e73e3663f0da1759f97f07a4a5603 Mon Sep 17 00:00:00 2001 From: ooprathamm <89736193+ooprathamm@users.noreply.github.com> Date: Sun, 22 Jan 2023 18:12:46 +0530 Subject: [PATCH 10/43] Update pvlib/iotools/tmy.py Co-authored-by: Adam R. Jensen <39184289+AdamRJensen@users.noreply.github.com> --- pvlib/iotools/tmy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index 4f01e29aaf..da61b9ac19 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -222,7 +222,7 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True): 'to hide this warning.', pvlibDeprecationWarning) map_variables = False if map_variables: - data = _recolumn(data).rename(columns=VARIABLE_MAP) + data = data.rename(columns=VARIABLE_MAP) data = data.tz_localize(int(meta['TZ'] * 3600)) From 16b3986d9071b6d8f09a49ad28bdc8f6c2f42095 Mon Sep 17 00:00:00 2001 From: ooprathamm <89736193+ooprathamm@users.noreply.github.com> Date: Sun, 22 Jan 2023 18:13:01 +0530 Subject: [PATCH 11/43] Update pvlib/iotools/tmy.py Co-authored-by: Adam R. Jensen <39184289+AdamRJensen@users.noreply.github.com> --- pvlib/iotools/tmy.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index da61b9ac19..88898eeee1 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -214,7 +214,8 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True): # unit must be in (D,h,m,s,ms,us,ns), but pandas>=0.24 allows unit='hour' data.index = data_ymd + pd.to_timedelta(shifted_hour, unit='h') if map_variables is None: - data = _recolumn(data) # rename to standard column names + if recolumn: + data = _recolumn(data) # rename to standard column names warnings.warn( 'TMY3 variable names will be renamed to pvlib conventions by ' 'default starting in pvlib 0.9.5. Specify map_variables=True ' From 5210407f721d5436ba360b075e442a2705b467c9 Mon Sep 17 00:00:00 2001 From: ooprathamm <89736193+ooprathamm@users.noreply.github.com> Date: Sun, 22 Jan 2023 18:13:12 +0530 Subject: [PATCH 12/43] Update pvlib/iotools/tmy.py Co-authored-by: Adam R. Jensen <39184289+AdamRJensen@users.noreply.github.com> --- pvlib/iotools/tmy.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index 88898eeee1..517149293d 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -8,12 +8,16 @@ # Dictionary mapping TMY3 names to pvlib names VARIABLE_MAP = { - 'GHI': 'ghi', - 'DNI': 'dni', - 'DHI': 'dhi', - 'Pressure': 'pressure', - 'Wdir': 'wind_direction', - 'Wspd': 'wind_speed', + 'GHI (W/m^2)': 'ghi', + 'DNI (W/m^2)': 'dni', + 'DHI (W/m^2)': 'dhi', + 'Pressure (mbar)': 'pressure', + 'Wdir (degrees)': 'wind_direction', + 'Wspd (m/s)': 'wind_speed', + 'Dry-bulb (C)': 'temp_air', + 'Dew-point (C)': 'temp_dew', + 'RHum (%)': 'relative_humidity', + 'Alb (unitless)': 'albedo', } From 68b54fe4c22e36cff1a448cc515fd8313a56dace Mon Sep 17 00:00:00 2001 From: Pratham Chauhan Date: Sun, 22 Jan 2023 21:24:44 +0530 Subject: [PATCH 13/43] Added tests to map_variables and check depreciation warning --- pvlib/tests/iotools/test_tmy.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pvlib/tests/iotools/test_tmy.py b/pvlib/tests/iotools/test_tmy.py index cc939588ac..d278b3c32e 100644 --- a/pvlib/tests/iotools/test_tmy.py +++ b/pvlib/tests/iotools/test_tmy.py @@ -1,6 +1,7 @@ import numpy as np import pandas as pd from pvlib.iotools import tmy +from pvlib._deprecation import pvlibDeprecationWarning from ..conftest import DATA_DIR import pytest @@ -23,11 +24,17 @@ def test_read_tmy3_recolumn(): data, meta = tmy.read_tmy3(TMY3_TESTFILE) assert 'GHISource' in data.columns - def test_read_tmy3_norecolumn(): data, _ = tmy.read_tmy3(TMY3_TESTFILE, recolumn=False) assert 'GHI source' in data.columns +def test_read_tmy3_map_variables(): + data, meta = tmy.read_tmy3(TMY3_TESTFILE,map_variables=True) + assert 'ghi' in data.columns + +def test_read_tmy3_map_variables_deprecating_warning(): + with pytest.warns(pvlibDeprecationWarning, match='TMY3 variable names will be renamed to pvlib conventions'): + data, meta = tmy.read_tmy3(TMY3_TESTFILE) def test_read_tmy3_coerce_year(): coerce_year = 1987 From 2ccae9eda36296fa53ea34569c15a8d2090cc526 Mon Sep 17 00:00:00 2001 From: Pratham Chauhan Date: Sun, 22 Jan 2023 21:30:13 +0530 Subject: [PATCH 14/43] resolving formatting issues --- pvlib/tests/iotools/test_tmy.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pvlib/tests/iotools/test_tmy.py b/pvlib/tests/iotools/test_tmy.py index d278b3c32e..83be103570 100644 --- a/pvlib/tests/iotools/test_tmy.py +++ b/pvlib/tests/iotools/test_tmy.py @@ -24,18 +24,22 @@ def test_read_tmy3_recolumn(): data, meta = tmy.read_tmy3(TMY3_TESTFILE) assert 'GHISource' in data.columns + def test_read_tmy3_norecolumn(): data, _ = tmy.read_tmy3(TMY3_TESTFILE, recolumn=False) assert 'GHI source' in data.columns + def test_read_tmy3_map_variables(): - data, meta = tmy.read_tmy3(TMY3_TESTFILE,map_variables=True) + data, meta = tmy.read_tmy3(TMY3_TESTFILE, map_variables=True) assert 'ghi' in data.columns + def test_read_tmy3_map_variables_deprecating_warning(): - with pytest.warns(pvlibDeprecationWarning, match='TMY3 variable names will be renamed to pvlib conventions'): + with pytest.warns(pvlibDeprecationWarning, match='names will be renamed to pvlib'): data, meta = tmy.read_tmy3(TMY3_TESTFILE) + def test_read_tmy3_coerce_year(): coerce_year = 1987 data, _ = tmy.read_tmy3(TMY3_TESTFILE, coerce_year=coerce_year) From 1ee7ff074459ad701bbafe6361171fb48643c218 Mon Sep 17 00:00:00 2001 From: Pratham Chauhan Date: Sun, 22 Jan 2023 21:32:12 +0530 Subject: [PATCH 15/43] resolving formatting issues --- pvlib/tests/iotools/test_tmy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/tests/iotools/test_tmy.py b/pvlib/tests/iotools/test_tmy.py index 83be103570..b32397f6fb 100644 --- a/pvlib/tests/iotools/test_tmy.py +++ b/pvlib/tests/iotools/test_tmy.py @@ -36,7 +36,7 @@ def test_read_tmy3_map_variables(): def test_read_tmy3_map_variables_deprecating_warning(): - with pytest.warns(pvlibDeprecationWarning, match='names will be renamed to pvlib'): + with pytest.warns(pvlibDeprecationWarning, match='names will be renamed'): data, meta = tmy.read_tmy3(TMY3_TESTFILE) From 98e53b37029b527cc6412e98b59debadc3a110b0 Mon Sep 17 00:00:00 2001 From: Pratham Chauhan Date: Tue, 24 Jan 2023 06:13:19 +0530 Subject: [PATCH 16/43] Adding more test cases --- pvlib/tests/iotools/test_tmy.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pvlib/tests/iotools/test_tmy.py b/pvlib/tests/iotools/test_tmy.py index b32397f6fb..a1130fcaf0 100644 --- a/pvlib/tests/iotools/test_tmy.py +++ b/pvlib/tests/iotools/test_tmy.py @@ -33,6 +33,15 @@ def test_read_tmy3_norecolumn(): def test_read_tmy3_map_variables(): data, meta = tmy.read_tmy3(TMY3_TESTFILE, map_variables=True) assert 'ghi' in data.columns + assert 'dni' in data.columns + assert 'dhi' in data.columns + assert 'pressure' in data.columns + assert 'wind_direction' in data.columns + assert 'wind_speed' in data.columns + assert 'temp_air' in data.columns + assert 'temp_dew' in data.columns + assert 'relative_humidity' in data.columns + assert 'albedo' in data.columns def test_read_tmy3_map_variables_deprecating_warning(): From 96a30a6049cdede662fba3c1298c9602b7ad347f Mon Sep 17 00:00:00 2001 From: Pratham Chauhan Date: Thu, 26 Jan 2023 18:42:58 +0530 Subject: [PATCH 17/43] updated VARIABLE_MAP --- pvlib/iotools/tmy.py | 5 ++++- pvlib/tests/iotools/test_tmy.py | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index 517149293d..94539c9ed8 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -9,7 +9,9 @@ # Dictionary mapping TMY3 names to pvlib names VARIABLE_MAP = { 'GHI (W/m^2)': 'ghi', + 'ETR (W/m^2)': 'ghi_extra', 'DNI (W/m^2)': 'dni', + 'ETRN (W/m^2)': 'dni_extra', 'DHI (W/m^2)': 'dhi', 'Pressure (mbar)': 'pressure', 'Wdir (degrees)': 'wind_direction', @@ -18,6 +20,7 @@ 'Dew-point (C)': 'temp_dew', 'RHum (%)': 'relative_humidity', 'Alb (unitless)': 'albedo', + 'Pwat (cm)': 'precipitable_water' } @@ -222,7 +225,7 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True): data = _recolumn(data) # rename to standard column names warnings.warn( 'TMY3 variable names will be renamed to pvlib conventions by ' - 'default starting in pvlib 0.9.5. Specify map_variables=True ' + 'default starting in pvlib 0.11.0. Specify map_variables=True ' 'to enable that behavior now, or specify map_variables=False ' 'to hide this warning.', pvlibDeprecationWarning) map_variables = False diff --git a/pvlib/tests/iotools/test_tmy.py b/pvlib/tests/iotools/test_tmy.py index a1130fcaf0..339bf3c4ae 100644 --- a/pvlib/tests/iotools/test_tmy.py +++ b/pvlib/tests/iotools/test_tmy.py @@ -42,6 +42,9 @@ def test_read_tmy3_map_variables(): assert 'temp_dew' in data.columns assert 'relative_humidity' in data.columns assert 'albedo' in data.columns + assert 'ghi_extra' in data.columns + assert 'dni_extra' in data.columns + assert 'precipitable_water' in data.columns def test_read_tmy3_map_variables_deprecating_warning(): From 9a69f127c55bd5e0c4a1f5e1dee4631810f6c939 Mon Sep 17 00:00:00 2001 From: Pratham Chauhan Date: Thu, 26 Jan 2023 18:52:30 +0530 Subject: [PATCH 18/43] updates DOIs in tmy.py --- pvlib/iotools/tmy.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index 94539c9ed8..947de5ec41 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -174,8 +174,10 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True): ---------- .. [1] Wilcox, S and Marion, W. "Users Manual for TMY3 Data Sets". NREL/TP-581-43156, Revised May 2008. + :doi:`10.2172/928611` .. [2] Wilcox, S. (2007). National Solar Radiation Database 1991 2005 Update: Users Manual. 472 pp.; NREL Report No. TP-581-41364. + :doi:`10.2172/901864` .. [3] `SolarAnywhere file formats `_ """ # noqa: E501 From 1e86046642d5357896a63ef5302b08910b703b09 Mon Sep 17 00:00:00 2001 From: Pratham Chauhan Date: Thu, 2 Feb 2023 22:13:31 +0530 Subject: [PATCH 19/43] Final changes as requested --- docs/sphinx/source/whatsnew/v0.9.5.rst | 4 +++- pvlib/data/variables_style_rules.csv | 3 +++ pvlib/tests/iotools/test_tmy.py | 12 ++++++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.9.5.rst b/docs/sphinx/source/whatsnew/v0.9.5.rst index 3261cb3b92..ffd05669cd 100644 --- a/docs/sphinx/source/whatsnew/v0.9.5.rst +++ b/docs/sphinx/source/whatsnew/v0.9.5.rst @@ -16,7 +16,9 @@ Deprecations Enhancements ~~~~~~~~~~~~ - +* Added variable mapping of columns when reading TMY3 dataframe using the + ``read_tmy3`` function. + (:issue:`1517`, :pull:`1623`) Bug fixes ~~~~~~~~~ diff --git a/pvlib/data/variables_style_rules.csv b/pvlib/data/variables_style_rules.csv index a56dddd161..bcba10ec6a 100644 --- a/pvlib/data/variables_style_rules.csv +++ b/pvlib/data/variables_style_rules.csv @@ -7,6 +7,7 @@ dni_extra;direct normal irradiance at top of atmosphere (extraterrestrial) dhi;diffuse horizontal irradiance bhi;beam/direct horizontal irradiance ghi;global horizontal irradiance +ghi_extra;Extraterrestrial horizontal radiation recv’d during 60 minutes prior to timestamp gri;ground-reflected irradiance aoi;angle of incidence between :math:`90\deg` and :math:`90\deg` aoi_projection;cos(aoi) @@ -49,3 +50,5 @@ pac, ac; ac powe. eta_inv; inverter efficiency eta_inv_ref; reference inverter efficiency eta_inv_nom; nominal inverter efficiency +albedo;The ratio of reflected solar irradiance to global horizontal irradiance, unitless +precipitable_water;Total precipitable water contained in a column of unit cross section from earth to top of atmosphere \ No newline at end of file diff --git a/pvlib/tests/iotools/test_tmy.py b/pvlib/tests/iotools/test_tmy.py index 339bf3c4ae..20dc12e3c8 100644 --- a/pvlib/tests/iotools/test_tmy.py +++ b/pvlib/tests/iotools/test_tmy.py @@ -17,7 +17,7 @@ def test_read_tmy3(): - tmy.read_tmy3(TMY3_TESTFILE) + tmy.read_tmy3(TMY3_TESTFILE, map_variables=False) def test_read_tmy3_recolumn(): @@ -26,7 +26,7 @@ def test_read_tmy3_recolumn(): def test_read_tmy3_norecolumn(): - data, _ = tmy.read_tmy3(TMY3_TESTFILE, recolumn=False) + data, _ = tmy.read_tmy3(TMY3_TESTFILE, recolumn=False, map_variables=False) assert 'GHI source' in data.columns @@ -54,14 +54,14 @@ def test_read_tmy3_map_variables_deprecating_warning(): def test_read_tmy3_coerce_year(): coerce_year = 1987 - data, _ = tmy.read_tmy3(TMY3_TESTFILE, coerce_year=coerce_year) + data, _ = tmy.read_tmy3(TMY3_TESTFILE, coerce_year=coerce_year, map_variables=False) assert (data.index[:-1].year == 1987).all() assert data.index[-1].year == 1988 def test_read_tmy3_no_coerce_year(): coerce_year = None - data, _ = tmy.read_tmy3(TMY3_TESTFILE, coerce_year=coerce_year) + data, _ = tmy.read_tmy3(TMY3_TESTFILE, coerce_year=coerce_year, map_variables=False) assert 1997 and 1999 in data.index.year assert data.index[-2] == pd.Timestamp('1998-12-31 23:00:00-09:00') assert data.index[-1] == pd.Timestamp('1999-01-01 00:00:00-09:00') @@ -73,7 +73,7 @@ def test_read_tmy2(): def test_gh865_read_tmy3_feb_leapyear_hr24(): """correctly parse the 24th hour if the tmy3 file has a leap year in feb""" - data, meta = read_tmy3(TMY3_FEB_LEAPYEAR) + data, meta = read_tmy3(TMY3_FEB_LEAPYEAR, map_variables=False) # just to be safe, make sure this _IS_ the Greensboro file greensboro = { 'USAF': 723170, @@ -110,7 +110,7 @@ def test_solaranywhere_tmy3(solaranywhere_index): # The SolarAnywhere TMY3 format specifies midnight as 00:00 whereas the # NREL TMY3 format utilizes 24:00. The SolarAnywhere file is therefore # included to test files with 00:00 timestamps are parsed correctly - data, meta = tmy.read_tmy3(TMY3_SOLARANYWHERE) + data, meta = tmy.read_tmy3(TMY3_SOLARANYWHERE,map_variables=False) pd.testing.assert_index_equal(data.index, solaranywhere_index) assert meta['USAF'] == 0 assert meta['Name'] == 'Burlington United States' From 02447327e21041ecc98cfb69950645051b1ffc12 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Thu, 2 Feb 2023 17:57:28 +0100 Subject: [PATCH 20/43] Fix stickler --- pvlib/tests/iotools/test_tmy.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pvlib/tests/iotools/test_tmy.py b/pvlib/tests/iotools/test_tmy.py index 20dc12e3c8..39b0b3d053 100644 --- a/pvlib/tests/iotools/test_tmy.py +++ b/pvlib/tests/iotools/test_tmy.py @@ -54,14 +54,16 @@ def test_read_tmy3_map_variables_deprecating_warning(): def test_read_tmy3_coerce_year(): coerce_year = 1987 - data, _ = tmy.read_tmy3(TMY3_TESTFILE, coerce_year=coerce_year, map_variables=False) + data, _ = tmy.read_tmy3(TMY3_TESTFILE, coerce_year=coerce_year, + map_variables=False) assert (data.index[:-1].year == 1987).all() assert data.index[-1].year == 1988 def test_read_tmy3_no_coerce_year(): coerce_year = None - data, _ = tmy.read_tmy3(TMY3_TESTFILE, coerce_year=coerce_year, map_variables=False) + data, _ = tmy.read_tmy3(TMY3_TESTFILE, coerce_year=coerce_year, + map_variables=False) assert 1997 and 1999 in data.index.year assert data.index[-2] == pd.Timestamp('1998-12-31 23:00:00-09:00') assert data.index[-1] == pd.Timestamp('1999-01-01 00:00:00-09:00') @@ -110,7 +112,7 @@ def test_solaranywhere_tmy3(solaranywhere_index): # The SolarAnywhere TMY3 format specifies midnight as 00:00 whereas the # NREL TMY3 format utilizes 24:00. The SolarAnywhere file is therefore # included to test files with 00:00 timestamps are parsed correctly - data, meta = tmy.read_tmy3(TMY3_SOLARANYWHERE,map_variables=False) + data, meta = tmy.read_tmy3(TMY3_SOLARANYWHERE, map_variables=False) pd.testing.assert_index_equal(data.index, solaranywhere_index) assert meta['USAF'] == 0 assert meta['Name'] == 'Burlington United States' From bccaf021213a0a224211b4d3be0c0d696e00db2d Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Thu, 2 Feb 2023 17:59:44 +0100 Subject: [PATCH 21/43] Update variables_style_rules.csv --- pvlib/data/variables_style_rules.csv | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pvlib/data/variables_style_rules.csv b/pvlib/data/variables_style_rules.csv index bcba10ec6a..9e3f351839 100644 --- a/pvlib/data/variables_style_rules.csv +++ b/pvlib/data/variables_style_rules.csv @@ -7,7 +7,7 @@ dni_extra;direct normal irradiance at top of atmosphere (extraterrestrial) dhi;diffuse horizontal irradiance bhi;beam/direct horizontal irradiance ghi;global horizontal irradiance -ghi_extra;Extraterrestrial horizontal radiation recv’d during 60 minutes prior to timestamp +ghi_extra;horizontal irradiance at top of atmosphere (extraterrestrial) gri;ground-reflected irradiance aoi;angle of incidence between :math:`90\deg` and :math:`90\deg` aoi_projection;cos(aoi) @@ -33,6 +33,8 @@ relative_humidity;relative humidity wind_speed;wind speed wind_direction;wind direction pressure;atmospheric pressure +albedo;ratio of reflected solar irradiance to global horizontal irradiance, unitless +precipitable_water;total precipitable water contained in a column of unit cross section from earth to top of atmosphere v_mp, i_mp, p_mp;module voltage, current, power at the maximum power point v_oc;open circuit module voltage i_sc;short circuit module current @@ -50,5 +52,3 @@ pac, ac; ac powe. eta_inv; inverter efficiency eta_inv_ref; reference inverter efficiency eta_inv_nom; nominal inverter efficiency -albedo;The ratio of reflected solar irradiance to global horizontal irradiance, unitless -precipitable_water;Total precipitable water contained in a column of unit cross section from earth to top of atmosphere \ No newline at end of file From c4e4417cdf0c582b522bc0acc5f3c060acc79941 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Thu, 2 Feb 2023 18:07:37 +0100 Subject: [PATCH 22/43] Add missing map_variables=False --- pvlib/tests/iotools/test_tmy.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pvlib/tests/iotools/test_tmy.py b/pvlib/tests/iotools/test_tmy.py index 39b0b3d053..2085958f42 100644 --- a/pvlib/tests/iotools/test_tmy.py +++ b/pvlib/tests/iotools/test_tmy.py @@ -21,7 +21,7 @@ def test_read_tmy3(): def test_read_tmy3_recolumn(): - data, meta = tmy.read_tmy3(TMY3_TESTFILE) + data, meta = tmy.read_tmy3(TMY3_TESTFILE, map_variables=False) assert 'GHISource' in data.columns @@ -49,7 +49,7 @@ def test_read_tmy3_map_variables(): def test_read_tmy3_map_variables_deprecating_warning(): with pytest.warns(pvlibDeprecationWarning, match='names will be renamed'): - data, meta = tmy.read_tmy3(TMY3_TESTFILE) + data, meta = tmy.read_tmy3(TMY3_TESTFILE, map_variables=False) def test_read_tmy3_coerce_year(): @@ -91,7 +91,8 @@ def test_gh865_read_tmy3_feb_leapyear_hr24(): assert data.index[1414] == pd.Timestamp('1996-02-28 23:00:00-0500') assert data.index[1415] == pd.Timestamp('1996-03-01 00:00:00-0500') # now check if it parses correctly when we try to coerce the year - data, _ = read_tmy3(TMY3_FEB_LEAPYEAR, coerce_year=1990) + data, _ = read_tmy3(TMY3_FEB_LEAPYEAR, coerce_year=1990, + map_variables=False) # if get's here w/o an error, then gh865 is fixed, but let's check anyway assert all(data.index[:-1].year == 1990) assert data.index[-1].year == 1991 From b91408a3d762b722ebafd7db6551d2e26684b91b Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Thu, 2 Feb 2023 19:23:34 +0100 Subject: [PATCH 23/43] Add whatsnew deprecation entry --- docs/sphinx/source/whatsnew/v0.9.5.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.9.5.rst b/docs/sphinx/source/whatsnew/v0.9.5.rst index ffd05669cd..67665a86f7 100644 --- a/docs/sphinx/source/whatsnew/v0.9.5.rst +++ b/docs/sphinx/source/whatsnew/v0.9.5.rst @@ -12,12 +12,13 @@ the ``pvlib`` `conda channel `_. We recommend Deprecations ~~~~~~~~~~~~ - - +* Deprecated the ``recolumn`` argument in :py:func:`pvlib.iotools.read_tmy3` which + stripped the units from the original column names. (:issue:`1517`, :pull:`1623`) + Enhancements ~~~~~~~~~~~~ -* Added variable mapping of columns when reading TMY3 dataframe using the - ``read_tmy3`` function. +* Added ``map_variables`` argument to the :py:func:`pvlib.iotools.read_tmy3` in + order to offer the option of mapping column names to standard pvlib names. (:issue:`1517`, :pull:`1623`) Bug fixes From 94383e93955583ce22f5f4e4cb03c9c8771213d4 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Tue, 7 Feb 2023 23:15:52 +0100 Subject: [PATCH 24/43] Apply suggestions from code review --- pvlib/iotools/tmy.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index 947de5ec41..51c5649a40 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -48,7 +48,9 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True): where applicable. See variable :const:`VARIABLE_MAP`. recolumn : bool, default True If ``True``, apply standard names to TMY3 columns. Typically this - results in stripping the units from the column name. + results in stripping the units from the column name. If + ``map_variables`` is ``True`` then the ``recolumn`` parameter has no + effect. Returns ------- @@ -222,7 +224,7 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True): # NOTE: as of pvlib-0.6.3, min req is pandas-0.18.1, so pd.to_timedelta # unit must be in (D,h,m,s,ms,us,ns), but pandas>=0.24 allows unit='hour' data.index = data_ymd + pd.to_timedelta(shifted_hour, unit='h') - if map_variables is None: + if map_variables is not True: if recolumn: data = _recolumn(data) # rename to standard column names warnings.warn( From c6ebd9ee858691aae27ec6c768c81209117ef246 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Tue, 7 Feb 2023 23:34:32 +0100 Subject: [PATCH 25/43] Add separate if statement for warning --- pvlib/iotools/tmy.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index 51c5649a40..4a45530ecf 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -227,6 +227,7 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True): if map_variables is not True: if recolumn: data = _recolumn(data) # rename to standard column names + if map_variables is None: warnings.warn( 'TMY3 variable names will be renamed to pvlib conventions by ' 'default starting in pvlib 0.11.0. Specify map_variables=True ' From 616cc7651f1c89d5b782b77bb89e347cc7182183 Mon Sep 17 00:00:00 2001 From: Pratham Chauhan Date: Thu, 9 Feb 2023 20:15:32 +0530 Subject: [PATCH 26/43] removed wrong whatsnew entry --- docs/sphinx/source/whatsnew/v0.9.5.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.9.5.rst b/docs/sphinx/source/whatsnew/v0.9.5.rst index 83c2abce4e..73dd8ab2c8 100644 --- a/docs/sphinx/source/whatsnew/v0.9.5.rst +++ b/docs/sphinx/source/whatsnew/v0.9.5.rst @@ -12,8 +12,7 @@ the ``pvlib`` `conda channel `_. We recommend Deprecations ~~~~~~~~~~~~ -* Deprecated the ``recolumn`` argument in :py:func:`pvlib.iotools.read_tmy3` which - stripped the units from the original column names. (:issue:`1517`, :pull:`1623`) + Enhancements ~~~~~~~~~~~~ From cd9cc8682ad93399ed36add5bddbc64edb086de4 Mon Sep 17 00:00:00 2001 From: ooprathamm <89736193+ooprathamm@users.noreply.github.com> Date: Sun, 12 Feb 2023 20:19:09 +0530 Subject: [PATCH 27/43] Update pvlib/tests/iotools/test_tmy.py Co-authored-by: Kevin Anderson --- pvlib/tests/iotools/test_tmy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/tests/iotools/test_tmy.py b/pvlib/tests/iotools/test_tmy.py index 2085958f42..37d288e003 100644 --- a/pvlib/tests/iotools/test_tmy.py +++ b/pvlib/tests/iotools/test_tmy.py @@ -49,7 +49,7 @@ def test_read_tmy3_map_variables(): def test_read_tmy3_map_variables_deprecating_warning(): with pytest.warns(pvlibDeprecationWarning, match='names will be renamed'): - data, meta = tmy.read_tmy3(TMY3_TESTFILE, map_variables=False) + data, meta = tmy.read_tmy3(TMY3_TESTFILE) def test_read_tmy3_coerce_year(): From da591f5ffb9aa8314b8d3c374254d57c559b914c Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Wed, 17 May 2023 07:28:22 +0200 Subject: [PATCH 28/43] Update warning messages according to table --- pvlib/iotools/tmy.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index 4a45530ecf..d824a860e1 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -224,9 +224,19 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True): # NOTE: as of pvlib-0.6.3, min req is pandas-0.18.1, so pd.to_timedelta # unit must be in (D,h,m,s,ms,us,ns), but pandas>=0.24 allows unit='hour' data.index = data_ymd + pd.to_timedelta(shifted_hour, unit='h') - if map_variables is not True: - if recolumn: - data = _recolumn(data) # rename to standard column names + # shouldnt' specify both recolumn and map_variables + if (type(recolumn) is bool) & (type(map_variables) is bool): + raise ValueError( + 'Specify only map_variables and do not pass a value for ' + 'the recolumn parameter. Starting in pvlib 0.11.0, the ' + 'recolumn parameter will be deprecated and replaced by ' + 'the map_variable parameter. By default, the map_variable ' + 'will be set to True and TMY3 variable names will be renamed ' + 'to pvlib conventions.') + elif map_variables is False: + pass + elif (map_variables is None) & ((recolumn is True) | (recolumn is None)): + data = _recolumn(data) # rename to standard column names if map_variables is None: warnings.warn( 'TMY3 variable names will be renamed to pvlib conventions by ' From 8f9c788b00b586f783f339d5cec3a882dacca483 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Wed, 17 May 2023 07:33:50 +0200 Subject: [PATCH 29/43] Update whatsnew --- docs/sphinx/source/whatsnew/v0.9.5.rst | 15 --------------- docs/sphinx/source/whatsnew/v0.9.6.rst | 4 ++++ 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.9.5.rst b/docs/sphinx/source/whatsnew/v0.9.5.rst index ec71d115b6..23766d566e 100644 --- a/docs/sphinx/source/whatsnew/v0.9.5.rst +++ b/docs/sphinx/source/whatsnew/v0.9.5.rst @@ -10,19 +10,6 @@ the ``pvlib`` `conda channel `_. We recommend :ref:`installation`). -Deprecations -~~~~~~~~~~~~ - - -Enhancements -~~~~~~~~~~~~ -* Added ``map_variables`` argument to the :py:func:`pvlib.iotools.read_tmy3` in - order to offer the option of mapping column names to standard pvlib names. - (:issue:`1517`, :pull:`1623`) -* Added the optional `string_factor` parameter to - :py:func:`pvlib.snow.loss_townsend` (:issue:`1636`, :pull:`1653`) -* Added optional ``n_ar`` parameter to :py:func:`pvlib.iam.physical` to - support an anti-reflective coating. (:issue:`1501`, :pull:`1616`) Enhancements ~~~~~~~~~~~~ * Added the optional ``string_factor`` parameter to @@ -56,8 +43,6 @@ Bug fixes * Added a limit to :py:func:`pvlib.snow.loss_townsend` to guard against incorrect loss results for systems that are near the ground. (:issue:`1636`, :pull:`1653`) -* Fixed incorrect mapping of requested parameters names when using the ``get_psm3`` - function. Also fixed the random reordering of the dataframe columns. * Fixed incorrect mapping of requested parameters names when using :py:func:`pvlib.iotools.get_psm3`. Also fixed the random reordering of the dataframe columns. diff --git a/docs/sphinx/source/whatsnew/v0.9.6.rst b/docs/sphinx/source/whatsnew/v0.9.6.rst index 7d1271086f..0ef89ed112 100644 --- a/docs/sphinx/source/whatsnew/v0.9.6.rst +++ b/docs/sphinx/source/whatsnew/v0.9.6.rst @@ -11,6 +11,9 @@ Deprecations Enhancements ~~~~~~~~~~~~ +* Added ``map_variables`` argument to the :py:func:`pvlib.iotools.read_tmy3` in + order to offer the option of mapping column names to standard pvlib names. + (:issue:`1517`, :pull:`1623`) Bug fixes @@ -43,4 +46,5 @@ Contributors * Siddharth Kaul (:ghuser:`k10blogger`) * Kshitiz Gupta (:ghuser:`kshitiz305`) * Stefan de Lange (:ghuser:`langestefan`) +* :ghuser:`ooprathamm` From 5661f716d3df18041b9f481cf050f74498688238 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Wed, 17 May 2023 08:14:48 +0200 Subject: [PATCH 30/43] Set recolumn=None --- pvlib/iotools/tmy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index d824a860e1..d84997d6b8 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -24,7 +24,7 @@ } -def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=True): +def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=None): """Read a TMY3 file into a pandas dataframe. Note that values contained in the metadata dictionary are unchanged From a3e2016f117bf417b8e67eab2e4f94b67c9ffffa Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Wed, 17 May 2023 08:14:54 +0200 Subject: [PATCH 31/43] Update tests --- pvlib/tests/iotools/test_tmy.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pvlib/tests/iotools/test_tmy.py b/pvlib/tests/iotools/test_tmy.py index 37d288e003..3be4d3ebd5 100644 --- a/pvlib/tests/iotools/test_tmy.py +++ b/pvlib/tests/iotools/test_tmy.py @@ -21,15 +21,20 @@ def test_read_tmy3(): def test_read_tmy3_recolumn(): - data, meta = tmy.read_tmy3(TMY3_TESTFILE, map_variables=False) + data, meta = tmy.read_tmy3(TMY3_TESTFILE) assert 'GHISource' in data.columns def test_read_tmy3_norecolumn(): - data, _ = tmy.read_tmy3(TMY3_TESTFILE, recolumn=False, map_variables=False) + data, _ = tmy.read_tmy3(TMY3_TESTFILE, map_variables=False) assert 'GHI source' in data.columns +def test_read_tmy3_raise_valueerror(): + with pytest.raises(ValueError, match='Specify only map_variables'): + _ = tmy.read_tmy3(TMY3_TESTFILE, recolumn=True, map_variables=True) + + def test_read_tmy3_map_variables(): data, meta = tmy.read_tmy3(TMY3_TESTFILE, map_variables=True) assert 'ghi' in data.columns From d0d1644cb53e937ea8ad8e6fe4b22fa5a83fe90b Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Mon, 22 May 2023 17:49:24 +0200 Subject: [PATCH 32/43] Update pvlib/iotools/tmy.py Co-authored-by: Kevin Anderson --- pvlib/iotools/tmy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index d84997d6b8..75cb59ca97 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -46,7 +46,7 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=None): map_variables : bool, default None When True, renames columns of the DataFrame to pvlib variable names where applicable. See variable :const:`VARIABLE_MAP`. - recolumn : bool, default True + recolumn : bool (deprecated, use map_variables instead) If ``True``, apply standard names to TMY3 columns. Typically this results in stripping the units from the column name. If ``map_variables`` is ``True`` then the ``recolumn`` parameter has no From b080c767f3cba86e63067ae53e8530be4e02d5c5 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Mon, 22 May 2023 17:49:34 +0200 Subject: [PATCH 33/43] Update pvlib/iotools/tmy.py Co-authored-by: Kevin Anderson --- pvlib/iotools/tmy.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index 75cb59ca97..0fc11410b0 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -48,9 +48,8 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=None): where applicable. See variable :const:`VARIABLE_MAP`. recolumn : bool (deprecated, use map_variables instead) If ``True``, apply standard names to TMY3 columns. Typically this - results in stripping the units from the column name. If - ``map_variables`` is ``True`` then the ``recolumn`` parameter has no - effect. + results in stripping the units from the column name. + Cannot be used in combination with ``map_variables``. Returns ------- From da131ada6dfc349ca2a5cae09cfad7df91104965 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Mon, 22 May 2023 17:49:50 +0200 Subject: [PATCH 34/43] Update docs/sphinx/source/whatsnew/v0.9.6.rst Co-authored-by: Kevin Anderson --- docs/sphinx/source/whatsnew/v0.9.6.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/sphinx/source/whatsnew/v0.9.6.rst b/docs/sphinx/source/whatsnew/v0.9.6.rst index 0ef89ed112..0f2b350427 100644 --- a/docs/sphinx/source/whatsnew/v0.9.6.rst +++ b/docs/sphinx/source/whatsnew/v0.9.6.rst @@ -8,6 +8,10 @@ v0.9.6 (Anticipated June 2023) Deprecations ~~~~~~~~~~~~ +* The ``recolumn`` parameter in :py:func:`pvlib.iotools.read_tmy3`, which maps + TMY3 column names to nonstandard alternatives, is now deprecated. + We encourage using ``map_variables`` (which produces standard pvlib names) instead. + (:issue:`1517`, :pull:`1623`) Enhancements ~~~~~~~~~~~~ From 828b994f16c352620a74efddd851d273998cbf46 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Mon, 22 May 2023 17:54:14 +0200 Subject: [PATCH 35/43] Implement updated error message logic from kansersolar --- pvlib/iotools/tmy.py | 26 ++++++++++++-------------- pvlib/tests/iotools/test_tmy.py | 2 +- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index d84997d6b8..44f8b3e8be 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -225,27 +225,25 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=None): # unit must be in (D,h,m,s,ms,us,ns), but pandas>=0.24 allows unit='hour' data.index = data_ymd + pd.to_timedelta(shifted_hour, unit='h') # shouldnt' specify both recolumn and map_variables - if (type(recolumn) is bool) & (type(map_variables) is bool): - raise ValueError( - 'Specify only map_variables and do not pass a value for ' - 'the recolumn parameter. Starting in pvlib 0.11.0, the ' - 'recolumn parameter will be deprecated and replaced by ' - 'the map_variable parameter. By default, the map_variable ' - 'will be set to True and TMY3 variable names will be renamed ' - 'to pvlib conventions.') - elif map_variables is False: - pass - elif (map_variables is None) & ((recolumn is True) | (recolumn is None)): - data = _recolumn(data) # rename to standard column names - if map_variables is None: + if recolumn is not None and map_variables is not None: + msg = "`map_variables` and `recolumn` cannot both be specified" + raise ValueError(msg) + elif map_variables is None and recolumn is not None: + warnings.warn( + 'The recolumn parameter is deprecated and will be removed in ' + 'pvlib 0.11.0. Use `map_variables` instead, although note that ' + 'its behavior is different from `recolumn`.', + pvlibDeprecationWarning) + elif map_variables is None and recolumn is None: warnings.warn( 'TMY3 variable names will be renamed to pvlib conventions by ' 'default starting in pvlib 0.11.0. Specify map_variables=True ' 'to enable that behavior now, or specify map_variables=False ' 'to hide this warning.', pvlibDeprecationWarning) - map_variables = False if map_variables: data = data.rename(columns=VARIABLE_MAP) + elif recolumn or (recolumn is None and map_variables is None): + data = _recolumn(data) data = data.tz_localize(int(meta['TZ'] * 3600)) diff --git a/pvlib/tests/iotools/test_tmy.py b/pvlib/tests/iotools/test_tmy.py index 3be4d3ebd5..e60cd7f213 100644 --- a/pvlib/tests/iotools/test_tmy.py +++ b/pvlib/tests/iotools/test_tmy.py @@ -31,7 +31,7 @@ def test_read_tmy3_norecolumn(): def test_read_tmy3_raise_valueerror(): - with pytest.raises(ValueError, match='Specify only map_variables'): + with pytest.raises(ValueError, match='map_variables` and `recolumn` cannot both be specified'): _ = tmy.read_tmy3(TMY3_TESTFILE, recolumn=True, map_variables=True) From 1f313904107eb39f9725e7ab179965d6227b1462 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Mon, 22 May 2023 21:06:16 +0200 Subject: [PATCH 36/43] Clean up deprecation warnings --- .../adr-pvarray/plot_simulate_system.py | 6 ++-- .../plot_diffuse_fraction.py | 30 +++++++++---------- .../plot_seasonal_tilt.py | 6 ++-- .../plot_transposition_gain.py | 10 +++---- .../soiling/plot_greensboro_kimber_soiling.py | 4 +-- docs/sphinx/source/user_guide/clearsky.rst | 2 +- .../source/user_guide/timetimezones.rst | 4 +-- pvlib/tests/iotools/test_tmy.py | 5 +++- pvlib/tests/test_location.py | 2 +- pvlib/tests/test_soiling.py | 4 +-- 10 files changed, 38 insertions(+), 35 deletions(-) diff --git a/docs/examples/adr-pvarray/plot_simulate_system.py b/docs/examples/adr-pvarray/plot_simulate_system.py index de6f1ecd7c..9847e68cba 100644 --- a/docs/examples/adr-pvarray/plot_simulate_system.py +++ b/docs/examples/adr-pvarray/plot_simulate_system.py @@ -29,10 +29,10 @@ PVLIB_DIR = pvlib.__path__[0] DATA_FILE = os.path.join(PVLIB_DIR, 'data', '723170TYA.CSV') -tmy, metadata = iotools.read_tmy3(DATA_FILE, coerce_year=1990) +tmy, metadata = iotools.read_tmy3(DATA_FILE, coerce_year=1990, map_variables=True) -df = pd.DataFrame({'ghi': tmy['GHI'], 'dhi': tmy['DHI'], 'dni': tmy['DNI'], - 'temp_air': tmy['DryBulb'], 'wind_speed': tmy['Wspd'], +df = pd.DataFrame({'ghi': tmy['ghi'], 'dhi': tmy['dhi'], 'dni': tmy['dni'], + 'temp_air': tmy['temp_air'], 'wind_speed': tmy['wind_speed'], }) # %% diff --git a/docs/examples/irradiance-decomposition/plot_diffuse_fraction.py b/docs/examples/irradiance-decomposition/plot_diffuse_fraction.py index dbd0406cf6..c1b6fb113b 100644 --- a/docs/examples/irradiance-decomposition/plot_diffuse_fraction.py +++ b/docs/examples/irradiance-decomposition/plot_diffuse_fraction.py @@ -27,7 +27,7 @@ # of data measured from 1990 to 2010. Therefore we change the timestamps to a # common year, 1990. DATA_DIR = pathlib.Path(pvlib.__file__).parent / 'data' -greensboro, metadata = read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990) +greensboro, metadata = read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990, map_variables=True) # Many of the diffuse fraction estimation methods require the "true" zenith, so # we calculate the solar positions for the 1990 at Greensboro, NC. @@ -36,8 +36,8 @@ solpos = get_solarposition( greensboro.index.shift(freq="-30T"), latitude=metadata['latitude'], longitude=metadata['longitude'], altitude=metadata['altitude'], - pressure=greensboro.Pressure*100, # convert from millibar to Pa - temperature=greensboro.DryBulb) + pressure=greensboro.pressure*100, # convert from millibar to Pa + temperature=greensboro.temp_air) solpos.index = greensboro.index # reset index to end of the hour # %% @@ -56,10 +56,10 @@ # an exponential relation with airmass. out_disc = irradiance.disc( - greensboro.GHI, solpos.zenith, greensboro.index, greensboro.Pressure*100) + greensboro.ghi, solpos.zenith, greensboro.index, greensboro.pressure*100) # use "complete sum" AKA "closure" equations: DHI = GHI - DNI * cos(zenith) df_disc = irradiance.complete_irradiance( - solar_zenith=solpos.apparent_zenith, ghi=greensboro.GHI, dni=out_disc.dni, + solar_zenith=solpos.apparent_zenith, ghi=greensboro.ghi, dni=out_disc.dni, dhi=None) out_disc = out_disc.rename(columns={'dni': 'dni_disc'}) out_disc['dhi_disc'] = df_disc.dhi @@ -72,11 +72,11 @@ # developed by Richard Perez and Pierre Ineichen in 1992. dni_dirint = irradiance.dirint( - greensboro.GHI, solpos.zenith, greensboro.index, greensboro.Pressure*100, - temp_dew=greensboro.DewPoint) + greensboro.ghi, solpos.zenith, greensboro.index, greensboro.pressure*100, + temp_dew=greensboro.temp_dew) # use "complete sum" AKA "closure" equation: DHI = GHI - DNI * cos(zenith) df_dirint = irradiance.complete_irradiance( - solar_zenith=solpos.apparent_zenith, ghi=greensboro.GHI, dni=dni_dirint, + solar_zenith=solpos.apparent_zenith, ghi=greensboro.ghi, dni=dni_dirint, dhi=None) out_dirint = pd.DataFrame( {'dni_dirint': dni_dirint, 'dhi_dirint': df_dirint.dhi}, @@ -91,7 +91,7 @@ # splits kt into 3 regions: linear for kt <= 0.22, a 4th order polynomial # between 0.22 < kt <= 0.8, and a horizontal line for kt > 0.8. -out_erbs = irradiance.erbs(greensboro.GHI, solpos.zenith, greensboro.index) +out_erbs = irradiance.erbs(greensboro.ghi, solpos.zenith, greensboro.index) out_erbs = out_erbs.rename(columns={'dni': 'dni_erbs', 'dhi': 'dhi_erbs'}) # %% @@ -102,7 +102,7 @@ # exponential correlation that is continuously differentiable and bounded # between zero and one. -out_boland = irradiance.boland(greensboro.GHI, solpos.zenith, greensboro.index) +out_boland = irradiance.boland(greensboro.ghi, solpos.zenith, greensboro.index) out_boland = out_boland.rename( columns={'dni': 'dni_boland', 'dhi': 'dhi_boland'}) @@ -118,20 +118,20 @@ # file together to make plotting easier. dni_renames = { - 'DNI': 'TMY3', 'dni_disc': 'DISC', 'dni_dirint': 'DIRINT', + 'dni': 'TMY3', 'dni_disc': 'DISC', 'dni_dirint': 'DIRINT', 'dni_erbs': 'Erbs', 'dni_boland': 'Boland'} dni = [ - greensboro.DNI, out_disc.dni_disc, out_dirint.dni_dirint, + greensboro.dni, out_disc.dni_disc, out_dirint.dni_dirint, out_erbs.dni_erbs, out_boland.dni_boland] dni = pd.concat(dni, axis=1).rename(columns=dni_renames) dhi_renames = { - 'DHI': 'TMY3', 'dhi_disc': 'DISC', 'dhi_dirint': 'DIRINT', + 'dhi': 'TMY3', 'dhi_disc': 'DISC', 'dhi_dirint': 'DIRINT', 'dhi_erbs': 'Erbs', 'dhi_boland': 'Boland'} dhi = [ - greensboro.DHI, out_disc.dhi_disc, out_dirint.dhi_dirint, + greensboro.dhi, out_disc.dhi_disc, out_dirint.dhi_dirint, out_erbs.dhi_erbs, out_boland.dhi_boland] dhi = pd.concat(dhi, axis=1).rename(columns=dhi_renames) -ghi_kt = pd.concat([greensboro.GHI/1000.0, out_erbs.kt], axis=1) +ghi_kt = pd.concat([greensboro.ghi/1000.0, out_erbs.kt], axis=1) # %% # Winter diff --git a/docs/examples/irradiance-transposition/plot_seasonal_tilt.py b/docs/examples/irradiance-transposition/plot_seasonal_tilt.py index 999aaca96a..bf01594554 100644 --- a/docs/examples/irradiance-transposition/plot_seasonal_tilt.py +++ b/docs/examples/irradiance-transposition/plot_seasonal_tilt.py @@ -44,12 +44,12 @@ def get_orientation(self, solar_zenith, solar_azimuth): # like we expect: DATA_DIR = pathlib.Path(pvlib.__file__).parent / 'data' -tmy, metadata = iotools.read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990) +tmy, metadata = iotools.read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990, map_variables=True) # shift from TMY3 right-labeled index to left-labeled index: tmy.index = tmy.index - pd.Timedelta(hours=1) weather = pd.DataFrame({ - 'ghi': tmy['GHI'], 'dhi': tmy['DHI'], 'dni': tmy['DNI'], - 'temp_air': tmy['DryBulb'], 'wind_speed': tmy['Wspd'], + 'ghi': tmy['ghi'], 'dhi': tmy['dhi'], 'dni': tmy['dni'], + 'temp_air': tmy['temp_air'], 'wind_speed': tmy['wind_speed'], }) loc = location.Location.from_tmy(metadata) solpos = loc.get_solarposition(weather.index) diff --git a/docs/examples/irradiance-transposition/plot_transposition_gain.py b/docs/examples/irradiance-transposition/plot_transposition_gain.py index 13ac8f61e5..2edae7077e 100644 --- a/docs/examples/irradiance-transposition/plot_transposition_gain.py +++ b/docs/examples/irradiance-transposition/plot_transposition_gain.py @@ -32,7 +32,7 @@ DATA_DIR = pathlib.Path(pvlib.__file__).parent / 'data' # get TMY3 dataset -tmy, metadata = read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990) +tmy, metadata = read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990, map_variables=True) # TMY3 datasets are right-labeled (AKA "end of interval") which means the last # interval of Dec 31, 23:00 to Jan 1 00:00 is labeled Jan 1 00:00. When rolling # up hourly irradiance to monthly insolation, a spurious January value is @@ -60,9 +60,9 @@ def calculate_poa(tmy, solar_position, surface_tilt, surface_azimuth): poa = irradiance.get_total_irradiance( surface_tilt=surface_tilt, surface_azimuth=surface_azimuth, - dni=tmy['DNI'], - ghi=tmy['GHI'], - dhi=tmy['DHI'], + dni=tmy['dni'], + ghi=tmy['ghi'], + dhi=tmy['dhi'], solar_zenith=solar_position['apparent_zenith'], solar_azimuth=solar_position['azimuth'], model='isotropic') @@ -97,7 +97,7 @@ def calculate_poa(tmy, solar_position, surface_tilt, surface_azimuth): df_monthly['SAT-0.4'] = poa_irradiance.resample('m').sum() # calculate the percent difference from GHI -ghi_monthly = tmy['GHI'].resample('m').sum() +ghi_monthly = tmy['ghi'].resample('m').sum() df_monthly = 100 * (df_monthly.divide(ghi_monthly, axis=0) - 1) df_monthly.plot() diff --git a/docs/examples/soiling/plot_greensboro_kimber_soiling.py b/docs/examples/soiling/plot_greensboro_kimber_soiling.py index db9a97dd43..2ebd62ebf7 100644 --- a/docs/examples/soiling/plot_greensboro_kimber_soiling.py +++ b/docs/examples/soiling/plot_greensboro_kimber_soiling.py @@ -40,9 +40,9 @@ DATA_DIR = pathlib.Path(pvlib.__file__).parent / 'data' # get TMY3 data with rain -greensboro, _ = read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990) +greensboro, _ = read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990, map_variables=True) # get the rain data -greensboro_rain = greensboro.Lprecipdepth +greensboro_rain = greensboro['Lprecip depth (mm)'] # calculate soiling with no wash dates and cleaning threshold of 25-mm of rain THRESHOLD = 25.0 soiling_no_wash = kimber(greensboro_rain, cleaning_threshold=THRESHOLD) diff --git a/docs/sphinx/source/user_guide/clearsky.rst b/docs/sphinx/source/user_guide/clearsky.rst index 6e51981e95..19b19ead9d 100644 --- a/docs/sphinx/source/user_guide/clearsky.rst +++ b/docs/sphinx/source/user_guide/clearsky.rst @@ -216,7 +216,7 @@ wavelengths [Bir80]_, and is implemented in In [1]: tmy_file = os.path.join(pvlib_data, '703165TY.csv') # TMY file - In [1]: tmy_data, tmy_header = read_tmy3(tmy_file, coerce_year=1999) # read TMY data + In [1]: tmy_data, tmy_header = read_tmy3(tmy_file, coerce_year=1999, map_variables=True) In [1]: tl_historic = clearsky.lookup_linke_turbidity(time=tmy_data.index, ...: latitude=tmy_header['latitude'], longitude=tmy_header['longitude']) diff --git a/docs/sphinx/source/user_guide/timetimezones.rst b/docs/sphinx/source/user_guide/timetimezones.rst index 235bd4776c..142faeaf76 100644 --- a/docs/sphinx/source/user_guide/timetimezones.rst +++ b/docs/sphinx/source/user_guide/timetimezones.rst @@ -272,7 +272,7 @@ Let's first examine how pvlib handles time when it imports a TMY3 file. # some gymnastics to find the example file pvlib_abspath = os.path.dirname(os.path.abspath(inspect.getfile(pvlib))) file_abspath = os.path.join(pvlib_abspath, 'data', '703165TY.csv') - tmy3_data, tmy3_metadata = pvlib.iotools.read_tmy3(file_abspath) + tmy3_data, tmy3_metadata = pvlib.iotools.read_tmy3(file_abspath, map_variables=True) tmy3_metadata @@ -287,7 +287,7 @@ print just a few of the rows and columns of the large dataframe. tmy3_data.index.tz - tmy3_data.loc[tmy3_data.index[0:3], ['GHI', 'DNI', 'AOD']] + tmy3_data.loc[tmy3_data.index[0:3], ['ghi', 'dni', 'AOD']] The :py:func:`~pvlib.iotools.read_tmy2` function also returns a DataFrame with a localized DatetimeIndex. diff --git a/pvlib/tests/iotools/test_tmy.py b/pvlib/tests/iotools/test_tmy.py index e60cd7f213..e2d3fce67d 100644 --- a/pvlib/tests/iotools/test_tmy.py +++ b/pvlib/tests/iotools/test_tmy.py @@ -4,6 +4,7 @@ from pvlib._deprecation import pvlibDeprecationWarning from ..conftest import DATA_DIR import pytest +import warnings # test the API works from pvlib.iotools import read_tmy3 @@ -21,7 +22,9 @@ def test_read_tmy3(): def test_read_tmy3_recolumn(): - data, meta = tmy.read_tmy3(TMY3_TESTFILE) + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + data, meta = tmy.read_tmy3(TMY3_TESTFILE, recolumn=True) assert 'GHISource' in data.columns diff --git a/pvlib/tests/test_location.py b/pvlib/tests/test_location.py index b3c1576bdf..b818b2fd94 100644 --- a/pvlib/tests/test_location.py +++ b/pvlib/tests/test_location.py @@ -212,7 +212,7 @@ def test_get_clearsky_valueerror(times): def test_from_tmy_3(): from pvlib.tests.iotools.test_tmy import TMY3_TESTFILE from pvlib.iotools import read_tmy3 - data, meta = read_tmy3(TMY3_TESTFILE) + data, meta = read_tmy3(TMY3_TESTFILE, map_variables=True) loc = Location.from_tmy(meta, data) assert loc.name is not None assert loc.altitude != 0 diff --git a/pvlib/tests/test_soiling.py b/pvlib/tests/test_soiling.py index efa44b0e1c..67c0e26c7a 100644 --- a/pvlib/tests/test_soiling.py +++ b/pvlib/tests/test_soiling.py @@ -147,8 +147,8 @@ def test_hsu_variable_time_intervals(rainfall_input, expected_output_3): @pytest.fixture def greensboro_rain(): # get TMY3 data with rain - greensboro, _ = read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990) - return greensboro.Lprecipdepth + greensboro, _ = read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990, map_variables=True) + return greensboro['Lprecip depth (mm)'] @pytest.fixture From 98e78910a0a424e6e822c92cc5f510a8851c2f96 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Mon, 22 May 2023 21:26:52 +0200 Subject: [PATCH 37/43] Fix clearsky.rst --- docs/sphinx/source/user_guide/clearsky.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/sphinx/source/user_guide/clearsky.rst b/docs/sphinx/source/user_guide/clearsky.rst index 19b19ead9d..c76024a5e8 100644 --- a/docs/sphinx/source/user_guide/clearsky.rst +++ b/docs/sphinx/source/user_guide/clearsky.rst @@ -223,18 +223,18 @@ wavelengths [Bir80]_, and is implemented in In [1]: solpos = solarposition.get_solarposition(time=tmy_data.index, ...: latitude=tmy_header['latitude'], longitude=tmy_header['longitude'], - ...: altitude=tmy_header['altitude'], pressure=tmy_data['Pressure']*mbars, - ...: temperature=tmy_data['DryBulb']) + ...: altitude=tmy_header['altitude'], pressure=tmy_data['pressure']*mbars, + ...: temperature=tmy_data['temp_air']) In [1]: am_rel = atmosphere.get_relative_airmass(solpos.apparent_zenith) - In [1]: am_abs = atmosphere.get_absolute_airmass(am_rel, tmy_data['Pressure']*mbars) + In [1]: am_abs = atmosphere.get_absolute_airmass(am_rel, tmy_data['pressure']*mbars) In [1]: airmass = pd.concat([am_rel, am_abs], axis=1).rename( ...: columns={0: 'airmass_relative', 1: 'airmass_absolute'}) In [1]: tl_calculated = atmosphere.kasten96_lt( - ...: airmass.airmass_absolute, tmy_data['Pwat'], tmy_data['AOD']) + ...: airmass.airmass_absolute, tmy_data['precipitable_water'], tmy_data['AOD']) In [1]: tl = pd.concat([tl_historic, tl_calculated], axis=1).rename( ...: columns={0:'Historic', 1:'Calculated'}) From 24e90d767971021929e380eec58d601339e1de87 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Mon, 22 May 2023 22:05:06 +0200 Subject: [PATCH 38/43] Update aod variable mapping --- docs/sphinx/source/user_guide/clearsky.rst | 3 ++- docs/sphinx/source/user_guide/timetimezones.rst | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/sphinx/source/user_guide/clearsky.rst b/docs/sphinx/source/user_guide/clearsky.rst index c76024a5e8..7d45a38159 100644 --- a/docs/sphinx/source/user_guide/clearsky.rst +++ b/docs/sphinx/source/user_guide/clearsky.rst @@ -234,7 +234,8 @@ wavelengths [Bir80]_, and is implemented in ...: columns={0: 'airmass_relative', 1: 'airmass_absolute'}) In [1]: tl_calculated = atmosphere.kasten96_lt( - ...: airmass.airmass_absolute, tmy_data['precipitable_water'], tmy_data['AOD']) + ...: airmass.airmass_absolute, tmy_data['precipitable_water'], + ...: tmy_data['AOD (unitless)']) In [1]: tl = pd.concat([tl_historic, tl_calculated], axis=1).rename( ...: columns={0:'Historic', 1:'Calculated'}) diff --git a/docs/sphinx/source/user_guide/timetimezones.rst b/docs/sphinx/source/user_guide/timetimezones.rst index 142faeaf76..f5b71d1759 100644 --- a/docs/sphinx/source/user_guide/timetimezones.rst +++ b/docs/sphinx/source/user_guide/timetimezones.rst @@ -287,7 +287,7 @@ print just a few of the rows and columns of the large dataframe. tmy3_data.index.tz - tmy3_data.loc[tmy3_data.index[0:3], ['ghi', 'dni', 'AOD']] + tmy3_data.loc[tmy3_data.index[0:3], ['ghi', 'dni', 'AOD (unitless)']] The :py:func:`~pvlib.iotools.read_tmy2` function also returns a DataFrame with a localized DatetimeIndex. From b4bf0043a597e26dd7cd93b0914e2c71f4db9ee2 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Tue, 23 May 2023 16:24:44 +0200 Subject: [PATCH 39/43] Fix stickler --- docs/examples/adr-pvarray/plot_simulate_system.py | 6 ++++-- .../irradiance-decomposition/plot_diffuse_fraction.py | 3 ++- .../examples/irradiance-transposition/plot_seasonal_tilt.py | 3 ++- .../irradiance-transposition/plot_transposition_gain.py | 3 ++- docs/examples/soiling/plot_greensboro_kimber_soiling.py | 3 ++- pvlib/tests/iotools/test_tmy.py | 2 +- pvlib/tests/test_soiling.py | 3 ++- 7 files changed, 15 insertions(+), 8 deletions(-) diff --git a/docs/examples/adr-pvarray/plot_simulate_system.py b/docs/examples/adr-pvarray/plot_simulate_system.py index 9847e68cba..b0abede934 100644 --- a/docs/examples/adr-pvarray/plot_simulate_system.py +++ b/docs/examples/adr-pvarray/plot_simulate_system.py @@ -29,10 +29,12 @@ PVLIB_DIR = pvlib.__path__[0] DATA_FILE = os.path.join(PVLIB_DIR, 'data', '723170TYA.CSV') -tmy, metadata = iotools.read_tmy3(DATA_FILE, coerce_year=1990, map_variables=True) +tmy, metadata = iotools.read_tmy3(DATA_FILE, coerce_year=1990, + map_variables=True) df = pd.DataFrame({'ghi': tmy['ghi'], 'dhi': tmy['dhi'], 'dni': tmy['dni'], - 'temp_air': tmy['temp_air'], 'wind_speed': tmy['wind_speed'], + 'temp_air': tmy['temp_air'], + 'wind_speed': tmy['wind_speed'], }) # %% diff --git a/docs/examples/irradiance-decomposition/plot_diffuse_fraction.py b/docs/examples/irradiance-decomposition/plot_diffuse_fraction.py index c1b6fb113b..30d1385f87 100644 --- a/docs/examples/irradiance-decomposition/plot_diffuse_fraction.py +++ b/docs/examples/irradiance-decomposition/plot_diffuse_fraction.py @@ -27,7 +27,8 @@ # of data measured from 1990 to 2010. Therefore we change the timestamps to a # common year, 1990. DATA_DIR = pathlib.Path(pvlib.__file__).parent / 'data' -greensboro, metadata = read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990, map_variables=True) +greensboro, metadata = read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990, + map_variables=True) # Many of the diffuse fraction estimation methods require the "true" zenith, so # we calculate the solar positions for the 1990 at Greensboro, NC. diff --git a/docs/examples/irradiance-transposition/plot_seasonal_tilt.py b/docs/examples/irradiance-transposition/plot_seasonal_tilt.py index bf01594554..afe610f6d2 100644 --- a/docs/examples/irradiance-transposition/plot_seasonal_tilt.py +++ b/docs/examples/irradiance-transposition/plot_seasonal_tilt.py @@ -44,7 +44,8 @@ def get_orientation(self, solar_zenith, solar_azimuth): # like we expect: DATA_DIR = pathlib.Path(pvlib.__file__).parent / 'data' -tmy, metadata = iotools.read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990, map_variables=True) +tmy, metadata = iotools.read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990, + map_variables=True) # shift from TMY3 right-labeled index to left-labeled index: tmy.index = tmy.index - pd.Timedelta(hours=1) weather = pd.DataFrame({ diff --git a/docs/examples/irradiance-transposition/plot_transposition_gain.py b/docs/examples/irradiance-transposition/plot_transposition_gain.py index 2edae7077e..4ce558b47c 100644 --- a/docs/examples/irradiance-transposition/plot_transposition_gain.py +++ b/docs/examples/irradiance-transposition/plot_transposition_gain.py @@ -32,7 +32,8 @@ DATA_DIR = pathlib.Path(pvlib.__file__).parent / 'data' # get TMY3 dataset -tmy, metadata = read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990, map_variables=True) +tmy, metadata = read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990, + map_variables=True) # TMY3 datasets are right-labeled (AKA "end of interval") which means the last # interval of Dec 31, 23:00 to Jan 1 00:00 is labeled Jan 1 00:00. When rolling # up hourly irradiance to monthly insolation, a spurious January value is diff --git a/docs/examples/soiling/plot_greensboro_kimber_soiling.py b/docs/examples/soiling/plot_greensboro_kimber_soiling.py index 2ebd62ebf7..6565679f6d 100644 --- a/docs/examples/soiling/plot_greensboro_kimber_soiling.py +++ b/docs/examples/soiling/plot_greensboro_kimber_soiling.py @@ -40,7 +40,8 @@ DATA_DIR = pathlib.Path(pvlib.__file__).parent / 'data' # get TMY3 data with rain -greensboro, _ = read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990, map_variables=True) +greensboro, _ = read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990, + map_variables=True) # get the rain data greensboro_rain = greensboro['Lprecip depth (mm)'] # calculate soiling with no wash dates and cleaning threshold of 25-mm of rain diff --git a/pvlib/tests/iotools/test_tmy.py b/pvlib/tests/iotools/test_tmy.py index e2d3fce67d..7c64af81ad 100644 --- a/pvlib/tests/iotools/test_tmy.py +++ b/pvlib/tests/iotools/test_tmy.py @@ -34,7 +34,7 @@ def test_read_tmy3_norecolumn(): def test_read_tmy3_raise_valueerror(): - with pytest.raises(ValueError, match='map_variables` and `recolumn` cannot both be specified'): + with pytest.raises(ValueError, match='`map_variables` and `recolumn`'): _ = tmy.read_tmy3(TMY3_TESTFILE, recolumn=True, map_variables=True) diff --git a/pvlib/tests/test_soiling.py b/pvlib/tests/test_soiling.py index 67c0e26c7a..0385728c43 100644 --- a/pvlib/tests/test_soiling.py +++ b/pvlib/tests/test_soiling.py @@ -147,7 +147,8 @@ def test_hsu_variable_time_intervals(rainfall_input, expected_output_3): @pytest.fixture def greensboro_rain(): # get TMY3 data with rain - greensboro, _ = read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990, map_variables=True) + greensboro, _ = read_tmy3(DATA_DIR / '723170TYA.CSV', coerce_year=1990, + map_variables=True) return greensboro['Lprecip depth (mm)'] From 143f9ac6087ac2f700e56a92028d74bf66b155f0 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Tue, 23 May 2023 16:25:08 +0200 Subject: [PATCH 40/43] Update tmy3 variables names in field,description table --- pvlib/iotools/tmy.py | 145 +++++++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 69 deletions(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index 5586bf1781..0230b83bae 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -48,7 +48,7 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=None): where applicable. See variable :const:`VARIABLE_MAP`. recolumn : bool (deprecated, use map_variables instead) If ``True``, apply standard names to TMY3 columns. Typically this - results in stripping the units from the column name. + results in stripping the units from the column name. Cannot be used in combination with ``map_variables``. Returns @@ -80,79 +80,86 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=None): USAF Int USAF identifier =============== ====== =================== + + ======================== ====== ========================================= + **Mapped field names are returned when the map_variables argument is True** + --------------------------------------------------------------------------- + ===================== ====================================================================================================================================================== field description ===================== ====================================================================================================================================================== + **† denotes variables that are mapped when `map_variables` is True** + ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Index A pandas datetime index. NOTE, the index is timezone aware, and times are set to local standard time (daylight savings is not included) - ETR Extraterrestrial horizontal radiation recv'd during 60 minutes prior to timestamp, Wh/m^2 - ETRN Extraterrestrial normal radiation recv'd during 60 minutes prior to timestamp, Wh/m^2 - GHI Direct and diffuse horizontal radiation recv'd during 60 minutes prior to timestamp, Wh/m^2 - GHISource See [1]_, Table 1-4 - GHIUncertainty Uncertainty based on random and bias error estimates see [2]_ - DNI Amount of direct normal radiation (modeled) recv'd during 60 mintues prior to timestamp, Wh/m^2 - DNISource See [1]_, Table 1-4 - DNIUncertainty Uncertainty based on random and bias error estimates see [2]_ - DHI Amount of diffuse horizontal radiation recv'd during 60 minutes prior to timestamp, Wh/m^2 - DHISource See [1]_, Table 1-4 - DHIUncertainty Uncertainty based on random and bias error estimates see [2]_ - GHillum Avg. total horizontal illuminance recv'd during the 60 minutes prior to timestamp, lx - GHillumSource See [1]_, Table 1-4 - GHillumUncertainty Uncertainty based on random and bias error estimates see [2]_ - DNillum Avg. direct normal illuminance recv'd during the 60 minutes prior to timestamp, lx - DNillumSource See [1]_, Table 1-4 - DNillumUncertainty Uncertainty based on random and bias error estimates see [2]_ - DHillum Avg. horizontal diffuse illuminance recv'd during the 60 minutes prior to timestamp, lx - DHillumSource See [1]_, Table 1-4 - DHillumUncertainty Uncertainty based on random and bias error estimates see [2]_ - Zenithlum Avg. luminance at the sky's zenith during the 60 minutes prior to timestamp, cd/m^2 - ZenithlumSource See [1]_, Table 1-4 - ZenithlumUncertainty Uncertainty based on random and bias error estimates see [1]_ section 2.10 - TotCld Amount of sky dome covered by clouds or obscuring phenonema at time stamp, tenths of sky - TotCldSource See [1]_, Table 1-5 - TotCldUncertainty See [1]_, Table 1-6 - OpqCld Amount of sky dome covered by clouds or obscuring phenonema that prevent observing the sky at time stamp, tenths of sky - OpqCldSource See [1]_, Table 1-5 - OpqCldUncertainty See [1]_, Table 1-6 - DryBulb Dry bulb temperature at the time indicated, deg C - DryBulbSource See [1]_, Table 1-5 - DryBulbUncertainty See [1]_, Table 1-6 - DewPoint Dew-point temperature at the time indicated, deg C - DewPointSource See [1]_, Table 1-5 - DewPointUncertainty See [1]_, Table 1-6 - RHum Relatitudeive humidity at the time indicated, percent - RHumSource See [1]_, Table 1-5 - RHumUncertainty See [1]_, Table 1-6 - Pressure Station pressure at the time indicated, 1 mbar - PressureSource See [1]_, Table 1-5 - PressureUncertainty See [1]_, Table 1-6 - Wdir Wind direction at time indicated, degrees from north (360 = north; 0 = undefined,calm) - WdirSource See [1]_, Table 1-5 - WdirUncertainty See [1]_, Table 1-6 - Wspd Wind speed at the time indicated, meter/second - WspdSource See [1]_, Table 1-5 - WspdUncertainty See [1]_, Table 1-6 - Hvis Distance to discernable remote objects at time indicated (7777=unlimited), meter - HvisSource See [1]_, Table 1-5 - HvisUncertainty See [1]_, Table 1-6 - CeilHgt Height of cloud base above local terrain (7777=unlimited), meter - CeilHgtSource See [1]_, Table 1-5 - CeilHgtUncertainty See [1]_, Table 1-6 - Pwat Total precipitable water contained in a column of unit cross section from earth to top of atmosphere, cm - PwatSource See [1]_, Table 1-5 - PwatUncertainty See [1]_, Table 1-6 + ghi_extra† Extraterrestrial horizontal radiation recv'd during 60 minutes prior to timestamp, Wh/m^2 + dni_extra† Extraterrestrial normal radiation recv'd during 60 minutes prior to timestamp, Wh/m^2 + ghi† Direct and diffuse horizontal radiation recv'd during 60 minutes prior to timestamp, Wh/m^2 + GHI source See [1]_, Table 1-4 + GHI uncert (%) Uncertainty based on random and bias error estimates see [2]_ + dni† Amount of direct normal radiation (modeled) recv'd during 60 mintues prior to timestamp, Wh/m^2 + DNI source See [1]_, Table 1-4 + DNI uncert (%) Uncertainty based on random and bias error estimates see [2]_ + dhi† Amount of diffuse horizontal radiation recv'd during 60 minutes prior to timestamp, Wh/m^2 + DHI source See [1]_, Table 1-4 + DHI uncert (%) Uncertainty based on random and bias error estimates see [2]_ + GH illum (lx) Avg. total horizontal illuminance recv'd during the 60 minutes prior to timestamp, lx + GH illum source See [1]_, Table 1-4 + GH illum uncert (%) Uncertainty based on random and bias error estimates see [2]_ + DN illum (lx) Avg. direct normal illuminance recv'd during the 60 minutes prior to timestamp, lx + DN illum source See [1]_, Table 1-4 + DN illum uncert (%) Uncertainty based on random and bias error estimates see [2]_ + DH illum (lx) Avg. horizontal diffuse illuminance recv'd during the 60 minutes prior to timestamp, lx + DH illum source See [1]_, Table 1-4 + DH illum uncert (%) Uncertainty based on random and bias error estimates see [2]_ + Zenith lum (cd/m^2) Avg. luminance at the sky's zenith during the 60 minutes prior to timestamp, cd/m^2 + Zenith lum source See [1]_, Table 1-4 + Zenith lum uncert (%) Uncertainty based on random and bias error estimates see [1]_ section 2.10 + TotCld (tenths) Amount of sky dome covered by clouds or obscuring phenonema at time stamp, tenths of sky + TotCld source See [1]_, Table 1-5 + TotCld uncert (code) See [1]_, Table 1-6 + OpqCld (tenths) Amount of sky dome covered by clouds or obscuring phenonema that prevent observing the sky at time stamp, tenths of sky + OpqCld source See [1]_, Table 1-5 + OpqCld uncert (code) See [1]_, Table 1-6 + temp_air† Dry bulb temperature at the time indicated, deg C + Dry-bulb source See [1]_, Table 1-5 + Dry-bulb uncert (code) See [1]_, Table 1-6 + temp_dew† Dew-point temperature at the time indicated, deg C + Dew-point source See [1]_, Table 1-5 + Dew-point uncert (code) See [1]_, Table 1-6 + relative_humidity† Relatitudeive humidity at the time indicated, percent + RHum source See [1]_, Table 1-5 + RHum uncert (code) See [1]_, Table 1-6 + pressure† Station pressure at the time indicated, 1 mbar + Pressure source See [1]_, Table 1-5 + Pressure uncert (code) See [1]_, Table 1-6 + wind_direction† Wind direction at time indicated, degrees from north (360 = north; 0 = undefined,calm) + Wdir source See [1]_, Table 1-5 + Wdir uncert (code) See [1]_, Table 1-6 + wind_speed† Wind speed at the time indicated, meter/second + Wspd source See [1]_, Table 1-5 + Wspd uncert (code) See [1]_, Table 1-6 + Hvis (m) Distance to discernable remote objects at time indicated (7777=unlimited), meter + Hvis source See [1]_, Table 1-5 + Hvis uncert (coe) See [1]_, Table 1-6 + CeilHgt (m) Height of cloud base above local terrain (7777=unlimited), meter + CeilHgt source See [1]_, Table 1-5 + CeilHgt uncert (code) See [1]_, Table 1-6 + precipitable_water† Total precipitable water contained in a column of unit cross section from earth to top of atmosphere, cm + Pwat source See [1]_, Table 1-5 + Pwat uncert (code) See [1]_, Table 1-6 AOD The broadband aerosol optical depth per unit of air mass due to extinction by aerosol component of atmosphere, unitless - AODSource See [1]_, Table 1-5 - AODUncertainty See [1]_, Table 1-6 - Alb The ratio of reflected solar irradiance to global horizontal irradiance, unitless - AlbSource See [1]_, Table 1-5 - AlbUncertainty See [1]_, Table 1-6 - Lprecipdepth The amount of liquid precipitation observed at indicated time for the period indicated in the liquid precipitation quantity field, millimeter - Lprecipquantity The period of accumulatitudeion for the liquid precipitation depth field, hour - LprecipSource See [1]_, Table 1-5 - LprecipUncertainty See [1]_, Table 1-6 - PresWth Present weather code, see [2]_. - PresWthSource Present weather code source, see [2]_. - PresWthUncertainty Present weather code uncertainty, see [2]_. + AOD source See [1]_, Table 1-5 + AOD uncert (code) See [1]_, Table 1-6 + albedo† The ratio of reflected solar irradiance to global horizontal irradiance, unitless + Alb source See [1]_, Table 1-5 + Alb uncert (code) See [1]_, Table 1-6 + Lprecip depth (mm) The amount of liquid precipitation observed at indicated time for the period indicated in the liquid precipitation quantity field, millimeter + Lprecip quantity (hr) The period of accumulatitudeion for the liquid precipitation depth field, hour + Lprecip source See [1]_, Table 1-5 + Lprecip uncert (code) See [1]_, Table 1-6 + PresWth (METAR code) Present weather code, see [2]_. + PresWth source Present weather code source, see [2]_. + PresWth uncert (code) Present weather code uncertainty, see [2]_. ===================== ====================================================================================================================================================== .. admonition:: Midnight representation From 5d2ef3a3fa32ea62173d0bb96f5bdb0bd8e2e7a9 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Wed, 24 May 2023 14:37:45 +0200 Subject: [PATCH 41/43] Update table --- pvlib/iotools/tmy.py | 152 +++++++++++++++++++++---------------------- 1 file changed, 74 insertions(+), 78 deletions(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index 0230b83bae..5f08973e37 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -81,86 +81,82 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=None): =============== ====== =================== - ======================== ====== ========================================= - **Mapped field names are returned when the map_variables argument is True** - --------------------------------------------------------------------------- - - ===================== ====================================================================================================================================================== + ======================== ====================================================================================================================================================== field description - ===================== ====================================================================================================================================================== + ======================== ====================================================================================================================================================== **† denotes variables that are mapped when `map_variables` is True** - ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - Index A pandas datetime index. NOTE, the index is timezone aware, and times are set to local standard time (daylight savings is not included) - ghi_extra† Extraterrestrial horizontal radiation recv'd during 60 minutes prior to timestamp, Wh/m^2 - dni_extra† Extraterrestrial normal radiation recv'd during 60 minutes prior to timestamp, Wh/m^2 - ghi† Direct and diffuse horizontal radiation recv'd during 60 minutes prior to timestamp, Wh/m^2 - GHI source See [1]_, Table 1-4 - GHI uncert (%) Uncertainty based on random and bias error estimates see [2]_ - dni† Amount of direct normal radiation (modeled) recv'd during 60 mintues prior to timestamp, Wh/m^2 - DNI source See [1]_, Table 1-4 - DNI uncert (%) Uncertainty based on random and bias error estimates see [2]_ - dhi† Amount of diffuse horizontal radiation recv'd during 60 minutes prior to timestamp, Wh/m^2 - DHI source See [1]_, Table 1-4 - DHI uncert (%) Uncertainty based on random and bias error estimates see [2]_ - GH illum (lx) Avg. total horizontal illuminance recv'd during the 60 minutes prior to timestamp, lx - GH illum source See [1]_, Table 1-4 - GH illum uncert (%) Uncertainty based on random and bias error estimates see [2]_ - DN illum (lx) Avg. direct normal illuminance recv'd during the 60 minutes prior to timestamp, lx - DN illum source See [1]_, Table 1-4 - DN illum uncert (%) Uncertainty based on random and bias error estimates see [2]_ - DH illum (lx) Avg. horizontal diffuse illuminance recv'd during the 60 minutes prior to timestamp, lx - DH illum source See [1]_, Table 1-4 - DH illum uncert (%) Uncertainty based on random and bias error estimates see [2]_ - Zenith lum (cd/m^2) Avg. luminance at the sky's zenith during the 60 minutes prior to timestamp, cd/m^2 - Zenith lum source See [1]_, Table 1-4 - Zenith lum uncert (%) Uncertainty based on random and bias error estimates see [1]_ section 2.10 - TotCld (tenths) Amount of sky dome covered by clouds or obscuring phenonema at time stamp, tenths of sky - TotCld source See [1]_, Table 1-5 - TotCld uncert (code) See [1]_, Table 1-6 - OpqCld (tenths) Amount of sky dome covered by clouds or obscuring phenonema that prevent observing the sky at time stamp, tenths of sky - OpqCld source See [1]_, Table 1-5 - OpqCld uncert (code) See [1]_, Table 1-6 - temp_air† Dry bulb temperature at the time indicated, deg C - Dry-bulb source See [1]_, Table 1-5 - Dry-bulb uncert (code) See [1]_, Table 1-6 - temp_dew† Dew-point temperature at the time indicated, deg C - Dew-point source See [1]_, Table 1-5 - Dew-point uncert (code) See [1]_, Table 1-6 - relative_humidity† Relatitudeive humidity at the time indicated, percent - RHum source See [1]_, Table 1-5 - RHum uncert (code) See [1]_, Table 1-6 - pressure† Station pressure at the time indicated, 1 mbar - Pressure source See [1]_, Table 1-5 - Pressure uncert (code) See [1]_, Table 1-6 - wind_direction† Wind direction at time indicated, degrees from north (360 = north; 0 = undefined,calm) - Wdir source See [1]_, Table 1-5 - Wdir uncert (code) See [1]_, Table 1-6 - wind_speed† Wind speed at the time indicated, meter/second - Wspd source See [1]_, Table 1-5 - Wspd uncert (code) See [1]_, Table 1-6 - Hvis (m) Distance to discernable remote objects at time indicated (7777=unlimited), meter - Hvis source See [1]_, Table 1-5 - Hvis uncert (coe) See [1]_, Table 1-6 - CeilHgt (m) Height of cloud base above local terrain (7777=unlimited), meter - CeilHgt source See [1]_, Table 1-5 - CeilHgt uncert (code) See [1]_, Table 1-6 - precipitable_water† Total precipitable water contained in a column of unit cross section from earth to top of atmosphere, cm - Pwat source See [1]_, Table 1-5 - Pwat uncert (code) See [1]_, Table 1-6 - AOD The broadband aerosol optical depth per unit of air mass due to extinction by aerosol component of atmosphere, unitless - AOD source See [1]_, Table 1-5 - AOD uncert (code) See [1]_, Table 1-6 - albedo† The ratio of reflected solar irradiance to global horizontal irradiance, unitless - Alb source See [1]_, Table 1-5 - Alb uncert (code) See [1]_, Table 1-6 - Lprecip depth (mm) The amount of liquid precipitation observed at indicated time for the period indicated in the liquid precipitation quantity field, millimeter - Lprecip quantity (hr) The period of accumulatitudeion for the liquid precipitation depth field, hour - Lprecip source See [1]_, Table 1-5 - Lprecip uncert (code) See [1]_, Table 1-6 - PresWth (METAR code) Present weather code, see [2]_. - PresWth source Present weather code source, see [2]_. - PresWth uncert (code) Present weather code uncertainty, see [2]_. - ===================== ====================================================================================================================================================== + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Index A pandas datetime index. NOTE, the index is timezone aware, and times are set to local standard time (daylight savings is not included) + ghi_extra† Extraterrestrial horizontal radiation recv'd during 60 minutes prior to timestamp, Wh/m^2 + dni_extra† Extraterrestrial normal radiation recv'd during 60 minutes prior to timestamp, Wh/m^2 + ghi† Direct and diffuse horizontal radiation recv'd during 60 minutes prior to timestamp, Wh/m^2 + GHI source See [1]_, Table 1-4 + GHI uncert (%) Uncertainty based on random and bias error estimates see [2]_ + dni† Amount of direct normal radiation (modeled) recv'd during 60 mintues prior to timestamp, Wh/m^2 + DNI source See [1]_, Table 1-4 + DNI uncert (%) Uncertainty based on random and bias error estimates see [2]_ + dhi† Amount of diffuse horizontal radiation recv'd during 60 minutes prior to timestamp, Wh/m^2 + DHI source See [1]_, Table 1-4 + DHI uncert (%) Uncertainty based on random and bias error estimates see [2]_ + GH illum (lx) Avg. total horizontal illuminance recv'd during the 60 minutes prior to timestamp, lx + GH illum source See [1]_, Table 1-4 + GH illum uncert (%) Uncertainty based on random and bias error estimates see [2]_ + DN illum (lx) Avg. direct normal illuminance recv'd during the 60 minutes prior to timestamp, lx + DN illum source See [1]_, Table 1-4 + DN illum uncert (%) Uncertainty based on random and bias error estimates see [2]_ + DH illum (lx) Avg. horizontal diffuse illuminance recv'd during the 60 minutes prior to timestamp, lx + DH illum source See [1]_, Table 1-4 + DH illum uncert (%) Uncertainty based on random and bias error estimates see [2]_ + Zenith lum (cd/m^2) Avg. luminance at the sky's zenith during the 60 minutes prior to timestamp, cd/m^2 + Zenith lum source See [1]_, Table 1-4 + Zenith lum uncert (%) Uncertainty based on random and bias error estimates see [1]_ section 2.10 + TotCld (tenths) Amount of sky dome covered by clouds or obscuring phenonema at time stamp, tenths of sky + TotCld source See [1]_, Table 1-5 + TotCld uncert (code) See [1]_, Table 1-6 + OpqCld (tenths) Amount of sky dome covered by clouds or obscuring phenonema that prevent observing the sky at time stamp, tenths of sky + OpqCld source See [1]_, Table 1-5 + OpqCld uncert (code) See [1]_, Table 1-6 + temp_air† Dry bulb temperature at the time indicated, deg C + Dry-bulb source See [1]_, Table 1-5 + Dry-bulb uncert (code) See [1]_, Table 1-6 + temp_dew† Dew-point temperature at the time indicated, deg C + Dew-point source See [1]_, Table 1-5 + Dew-point uncert (code) See [1]_, Table 1-6 + relative_humidity† Relatitudeive humidity at the time indicated, percent + RHum source See [1]_, Table 1-5 + RHum uncert (code) See [1]_, Table 1-6 + pressure† Station pressure at the time indicated, 1 mbar + Pressure source See [1]_, Table 1-5 + Pressure uncert (code) See [1]_, Table 1-6 + wind_direction† Wind direction at time indicated, degrees from north (360 = north; 0 = undefined,calm) + Wdir source See [1]_, Table 1-5 + Wdir uncert (code) See [1]_, Table 1-6 + wind_speed† Wind speed at the time indicated, meter/second + Wspd source See [1]_, Table 1-5 + Wspd uncert (code) See [1]_, Table 1-6 + Hvis (m) Distance to discernable remote objects at time indicated (7777=unlimited), meter + Hvis source See [1]_, Table 1-5 + Hvis uncert (coe) See [1]_, Table 1-6 + CeilHgt (m) Height of cloud base above local terrain (7777=unlimited), meter + CeilHgt source See [1]_, Table 1-5 + CeilHgt uncert (code) See [1]_, Table 1-6 + precipitable_water† Total precipitable water contained in a column of unit cross section from earth to top of atmosphere, cm + Pwat source See [1]_, Table 1-5 + Pwat uncert (code) See [1]_, Table 1-6 + AOD The broadband aerosol optical depth per unit of air mass due to extinction by aerosol component of atmosphere, unitless + AOD source See [1]_, Table 1-5 + AOD uncert (code) See [1]_, Table 1-6 + albedo† The ratio of reflected solar irradiance to global horizontal irradiance, unitless + Alb source See [1]_, Table 1-5 + Alb uncert (code) See [1]_, Table 1-6 + Lprecip depth (mm) The amount of liquid precipitation observed at indicated time for the period indicated in the liquid precipitation quantity field, millimeter + Lprecip quantity (hr) The period of accumulatitudeion for the liquid precipitation depth field, hour + Lprecip source See [1]_, Table 1-5 + Lprecip uncert (code) See [1]_, Table 1-6 + PresWth (METAR code) Present weather code, see [2]_. + PresWth source Present weather code source, see [2]_. + PresWth uncert (code) Present weather code uncertainty, see [2]_. + ======================== ====================================================================================================================================================== .. admonition:: Midnight representation From fe2f3438345afc81140e1b76826a0d3f20d91203 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Wed, 24 May 2023 14:38:43 +0200 Subject: [PATCH 42/43] More table stuff --- pvlib/iotools/tmy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index 5f08973e37..c1efa2f4fb 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -82,7 +82,7 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=None): ======================== ====================================================================================================================================================== - field description + field description ======================== ====================================================================================================================================================== **† denotes variables that are mapped when `map_variables` is True** ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- From 35d2d549b82c135f883a2e140b0bc4f3347dccd6 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Wed, 24 May 2023 14:39:03 +0200 Subject: [PATCH 43/43] Table stuff galore --- pvlib/iotools/tmy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/iotools/tmy.py b/pvlib/iotools/tmy.py index c1efa2f4fb..c80cf86a8f 100644 --- a/pvlib/iotools/tmy.py +++ b/pvlib/iotools/tmy.py @@ -120,14 +120,14 @@ def read_tmy3(filename, coerce_year=None, map_variables=None, recolumn=None): Dry-bulb source See [1]_, Table 1-5 Dry-bulb uncert (code) See [1]_, Table 1-6 temp_dew† Dew-point temperature at the time indicated, deg C - Dew-point source See [1]_, Table 1-5 + Dew-point source See [1]_, Table 1-5 Dew-point uncert (code) See [1]_, Table 1-6 relative_humidity† Relatitudeive humidity at the time indicated, percent RHum source See [1]_, Table 1-5 RHum uncert (code) See [1]_, Table 1-6 pressure† Station pressure at the time indicated, 1 mbar Pressure source See [1]_, Table 1-5 - Pressure uncert (code) See [1]_, Table 1-6 + Pressure uncert (code) See [1]_, Table 1-6 wind_direction† Wind direction at time indicated, degrees from north (360 = north; 0 = undefined,calm) Wdir source See [1]_, Table 1-5 Wdir uncert (code) See [1]_, Table 1-6