From 1ff113fed3c5002065865bdb73c24f1b2cc94213 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Thu, 5 Jun 2025 11:48:01 -0600 Subject: [PATCH 1/4] Change freq M to MS --- pvlib/iotools/bsrn.py | 3 +-- pvlib/iotools/srml.py | 3 +-- tests/test_clearsky.py | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pvlib/iotools/bsrn.py b/pvlib/iotools/bsrn.py index 3cca48c959..9356685d30 100644 --- a/pvlib/iotools/bsrn.py +++ b/pvlib/iotools/bsrn.py @@ -162,8 +162,7 @@ def get_bsrn(station, start, end, username, password, end = pd.to_datetime(end) # Generate list files to download based on start/end (SSSMMYY.dat.gz) - filenames = pd.date_range( - start, end.replace(day=1) + pd.DateOffset(months=1), freq='1M')\ + filenames = pd.date_range(start, end, freq='1MS')\ .strftime(f"{station}%m%y.dat.gz").tolist() # Create FTP connection diff --git a/pvlib/iotools/srml.py b/pvlib/iotools/srml.py index 728c3a7093..3bcb1f09e9 100644 --- a/pvlib/iotools/srml.py +++ b/pvlib/iotools/srml.py @@ -236,8 +236,7 @@ def get_srml(station, start, end, filetype='PO', map_variables=True, end = pd.to_datetime(end) # Generate list of months - months = pd.date_range( - start, end.replace(day=1) + pd.DateOffset(months=1), freq='1M') + months = pd.date_range(start, end, freq='1MS') months_str = months.strftime('%y%m') # Generate list of filenames diff --git a/tests/test_clearsky.py b/tests/test_clearsky.py index ef943ac39d..e5348ea505 100644 --- a/tests/test_clearsky.py +++ b/tests/test_clearsky.py @@ -234,8 +234,8 @@ def test_lookup_linke_turbidity_months(): def test_lookup_linke_turbidity_months_leapyear(): - times = pd.date_range(start='2016-04-01', end='2016-07-01', - freq='1M', tz='America/Phoenix') + times = pd.date_range(start='2014-05-01', end='2014-07-01', + freq='1ME', tz='America/Phoenix') expected = pd.Series( np.array([2.89918032787, 2.97540983607, 3.19672131148]), index=times ) From f4346460c6543ddd645c9a18eaaed7378c91abf0 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Thu, 5 Jun 2025 12:00:51 -0600 Subject: [PATCH 2/4] Use MS for test_clearsky --- tests/test_clearsky.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/test_clearsky.py b/tests/test_clearsky.py index e5348ea505..0ef5dfeacd 100644 --- a/tests/test_clearsky.py +++ b/tests/test_clearsky.py @@ -224,8 +224,9 @@ def test_lookup_linke_turbidity_nointerp(): def test_lookup_linke_turbidity_months(): - times = pd.date_range(start='2014-04-01', end='2014-07-01', - freq='1M', tz='America/Phoenix') + times = pd.date_range(start='2014-05-01', end='2014-07-01', + freq='1MS', tz='America/Phoenix', + ) - pd.Timedelta(days=1) expected = pd.Series( np.array([2.89918032787, 2.97540983607, 3.19672131148]), index=times ) @@ -234,8 +235,9 @@ def test_lookup_linke_turbidity_months(): def test_lookup_linke_turbidity_months_leapyear(): - times = pd.date_range(start='2014-05-01', end='2014-07-01', - freq='1ME', tz='America/Phoenix') + times = pd.date_range(start='2016-05-01', end='2016-07-01', + freq='1MS', tz='America/Phoenix', + ) - pd.Timedelta(days=1) expected = pd.Series( np.array([2.89918032787, 2.97540983607, 3.19672131148]), index=times ) @@ -245,14 +247,16 @@ def test_lookup_linke_turbidity_months_leapyear(): def test_lookup_linke_turbidity_nointerp_months(): times = pd.date_range(start='2014-04-10', end='2014-07-10', - freq='1M', tz='America/Phoenix') + freq='1MS', tz='America/Phoenix', + ) - pd.Timedelta(days=1) expected = pd.Series(np.array([2.85, 2.95, 3.]), index=times) out = clearsky.lookup_linke_turbidity(times, 32.125, -110.875, interp_turbidity=False) assert_series_equal(expected, out) # changing the dates shouldn't matter if interp=False times = pd.date_range(start='2014-04-05', end='2014-07-05', - freq='1M', tz='America/Phoenix') + freq='1MS', tz='America/Phoenix', + ) - pd.Timedelta(days=1) out = clearsky.lookup_linke_turbidity(times, 32.125, -110.875, interp_turbidity=False) assert_series_equal(expected, out) From 59b0f8b6f02bfd3b7244b362fdf607dc77cd9912 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Fri, 6 Jun 2025 13:58:31 -0600 Subject: [PATCH 3/4] Change to start.date().replace(day=1) --- pvlib/iotools/bsrn.py | 3 ++- pvlib/iotools/srml.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pvlib/iotools/bsrn.py b/pvlib/iotools/bsrn.py index 9356685d30..63a2628811 100644 --- a/pvlib/iotools/bsrn.py +++ b/pvlib/iotools/bsrn.py @@ -162,7 +162,8 @@ def get_bsrn(station, start, end, username, password, end = pd.to_datetime(end) # Generate list files to download based on start/end (SSSMMYY.dat.gz) - filenames = pd.date_range(start, end, freq='1MS')\ + filenames = pd.date_range(start.date().replace(day=1), end, freq='1MS')\ + .strftime(f"{station}%m%y.dat.gz").tolist() # Create FTP connection diff --git a/pvlib/iotools/srml.py b/pvlib/iotools/srml.py index 3bcb1f09e9..c9b630ec6e 100644 --- a/pvlib/iotools/srml.py +++ b/pvlib/iotools/srml.py @@ -236,7 +236,7 @@ def get_srml(station, start, end, filetype='PO', map_variables=True, end = pd.to_datetime(end) # Generate list of months - months = pd.date_range(start, end, freq='1MS') + months = pd.date_range(start.date().replace(day=1), end, freq='1MS') months_str = months.strftime('%y%m') # Generate list of filenames From 42e767baf2ca3fecf70501e723d6cec8223e29c0 Mon Sep 17 00:00:00 2001 From: "Adam R. Jensen" <39184289+AdamRJensen@users.noreply.github.com> Date: Fri, 6 Jun 2025 14:08:37 -0600 Subject: [PATCH 4/4] Fix linter --- pvlib/iotools/bsrn.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pvlib/iotools/bsrn.py b/pvlib/iotools/bsrn.py index 63a2628811..7830853826 100644 --- a/pvlib/iotools/bsrn.py +++ b/pvlib/iotools/bsrn.py @@ -163,7 +163,6 @@ def get_bsrn(station, start, end, username, password, # Generate list files to download based on start/end (SSSMMYY.dat.gz) filenames = pd.date_range(start.date().replace(day=1), end, freq='1MS')\ - .strftime(f"{station}%m%y.dat.gz").tolist() # Create FTP connection