From 49dfc1c53851b930593237e0979102c9354c96a1 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Mon, 18 Mar 2024 18:39:14 -0400 Subject: [PATCH 1/3] address the many pandas deprecation warnings --- pvlib/inverter.py | 6 ++--- pvlib/iotools/bsrn.py | 2 +- pvlib/iotools/solcast.py | 7 +---- pvlib/iotools/srml.py | 2 +- pvlib/iotools/surfrad.py | 2 +- pvlib/tests/iotools/test_sodapro.py | 4 +-- pvlib/tests/test_clearsky.py | 10 +++---- pvlib/tests/test_irradiance.py | 14 +++++----- pvlib/tests/test_location.py | 2 +- pvlib/tests/test_modelchain.py | 42 ++++++++++++++--------------- pvlib/tests/test_pvsystem.py | 28 +++++++++---------- pvlib/tests/test_shading.py | 2 +- pvlib/tests/test_snow.py | 2 +- pvlib/tests/test_solarposition.py | 20 +++++++------- pvlib/tests/test_temperature.py | 8 +++--- pvlib/tests/test_tracking.py | 4 +-- 16 files changed, 75 insertions(+), 80 deletions(-) diff --git a/pvlib/inverter.py b/pvlib/inverter.py index 0b57e14d2d..8207e6bba9 100644 --- a/pvlib/inverter.py +++ b/pvlib/inverter.py @@ -532,9 +532,9 @@ def extract_c(x_d, add): p_s0 = solve_quad(a, b, c) # Add values to dataframe at index d - coeffs['a'][d] = a - coeffs['p_dc'][d] = p_dc - coeffs['p_s0'][d] = p_s0 + coeffs.loc[d, 'a'] = a + coeffs.loc[d, 'p_dc'] = p_dc + coeffs.loc[d, 'p_s0'] = p_s0 b_dc0, b_dc1, c1 = extract_c(x_d, coeffs['p_dc']) b_s0, b_s1, c2 = extract_c(x_d, coeffs['p_s0']) diff --git a/pvlib/iotools/bsrn.py b/pvlib/iotools/bsrn.py index 43fdbe919f..fa6ef9b81e 100644 --- a/pvlib/iotools/bsrn.py +++ b/pvlib/iotools/bsrn.py @@ -160,7 +160,7 @@ 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, end.replace(day=1) + pd.DateOffset(months=1), freq='1M')\ + start, end.replace(day=1) + pd.DateOffset(months=1), freq='1ME')\ .strftime(f"{station}%m%y.dat.gz").tolist() # Create FTP connection diff --git a/pvlib/iotools/solcast.py b/pvlib/iotools/solcast.py index 5abd9c724e..71c5c42ffa 100644 --- a/pvlib/iotools/solcast.py +++ b/pvlib/iotools/solcast.py @@ -413,14 +413,9 @@ def _solcast2pvlib(data): a pandas.DataFrame with the data cast to pvlib's conventions """ # move from period_end to period_middle as per pvlib convention - # to support Pandas 0.25 we cast PTXX to XX as ISO8601 - # durations without days aren't supported: - # https://github.com/pandas-dev/pandas/pull/37159\ - # Can remove once minimum supported Pandas version is >=1.2 - periods = data.period.str.replace("PT", "").str.replace("M", "m") data["period_mid"] = pd.to_datetime( - data.period_end) - pd.to_timedelta(periods) / 2 + data.period_end) - pd.to_timedelta(data.period.values) / 2 data = data.set_index("period_mid").drop(columns=["period_end", "period"]) # rename and convert variables diff --git a/pvlib/iotools/srml.py b/pvlib/iotools/srml.py index 83868f637c..9ae0ad7f67 100644 --- a/pvlib/iotools/srml.py +++ b/pvlib/iotools/srml.py @@ -297,7 +297,7 @@ def get_srml(station, start, end, filetype='PO', map_variables=True, # Generate list of months months = pd.date_range( - start, end.replace(day=1) + pd.DateOffset(months=1), freq='1M') + start, end.replace(day=1) + pd.DateOffset(months=1), freq='1ME') months_str = months.strftime('%y%m') # Generate list of filenames diff --git a/pvlib/iotools/surfrad.py b/pvlib/iotools/surfrad.py index d3e40d86a2..6efdccb1f4 100644 --- a/pvlib/iotools/surfrad.py +++ b/pvlib/iotools/surfrad.py @@ -146,7 +146,7 @@ def read_surfrad(filename, map_variables=True): metadata['surfrad_version'] = int(metadata_list[-1]) metadata['tz'] = 'UTC' - data = pd.read_csv(file_buffer, delim_whitespace=True, + data = pd.read_csv(file_buffer, sep=r'\s+', header=None, names=SURFRAD_COLUMNS) file_buffer.close() diff --git a/pvlib/tests/iotools/test_sodapro.py b/pvlib/tests/iotools/test_sodapro.py index 4729cf2c64..81d11e8dc7 100644 --- a/pvlib/tests/iotools/test_sodapro.py +++ b/pvlib/tests/iotools/test_sodapro.py @@ -17,8 +17,8 @@ testfile_radiation_monthly = DATA_DIR / 'cams_radiation_monthly.csv' -index_verbose = pd.date_range('2020-06-01 12', periods=4, freq='1T', tz='UTC') -index_monthly = pd.date_range('2020-01-01', periods=4, freq='1M') +index_verbose = pd.date_range('2020-06-01 12', periods=4, freq='1min', tz='UTC') +index_monthly = pd.date_range('2020-01-01', periods=4, freq='1ME') dtypes_mcclear_verbose = [ diff --git a/pvlib/tests/test_clearsky.py b/pvlib/tests/test_clearsky.py index fa4dee2cd0..9945ab64a7 100644 --- a/pvlib/tests/test_clearsky.py +++ b/pvlib/tests/test_clearsky.py @@ -225,7 +225,7 @@ 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') + freq='1ME', tz='America/Phoenix') expected = pd.Series( np.array([2.89918032787, 2.97540983607, 3.19672131148]), index=times ) @@ -235,7 +235,7 @@ 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') + freq='1ME', tz='America/Phoenix') expected = pd.Series( np.array([2.89918032787, 2.97540983607, 3.19672131148]), index=times ) @@ -245,14 +245,14 @@ 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='1ME', tz='America/Phoenix') 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='1ME', tz='America/Phoenix') out = clearsky.lookup_linke_turbidity(times, 32.125, -110.875, interp_turbidity=False) assert_series_equal(expected, out) @@ -745,7 +745,7 @@ def test__calc_stats(detect_clearsky_helper_data): def test_bird(): """Test Bird/Hulstrom Clearsky Model""" times = pd.date_range(start='1/1/2015 0:00', end='12/31/2015 23:00', - freq='H') + freq='h') tz = -7 # test timezone gmt_tz = pytz.timezone('Etc/GMT%+d' % -(tz)) times = times.tz_localize(gmt_tz) # set timezone diff --git a/pvlib/tests/test_irradiance.py b/pvlib/tests/test_irradiance.py index 8b5991c7e5..75847c655a 100644 --- a/pvlib/tests/test_irradiance.py +++ b/pvlib/tests/test_irradiance.py @@ -27,7 +27,7 @@ @pytest.fixture def times(): # must include night values - return pd.date_range(start='20140624', freq='6H', periods=4, + return pd.date_range(start='20140624', freq='6h', periods=4, tz='US/Arizona') @@ -349,7 +349,7 @@ def test_perez_driesse_components(irrad_data, ephem_data, dni_et, def test_perez_negative_horizon(): - times = pd.date_range(start='20190101 11:30:00', freq='1H', + times = pd.date_range(start='20190101 11:30:00', freq='1h', periods=5, tz='US/Central') # Avoid test dependencies on functionality not being tested by hard-coding @@ -711,7 +711,7 @@ def test_dirint_value(): def test_dirint_nans(): - times = pd.date_range(start='2014-06-24T12-0700', periods=5, freq='6H') + times = pd.date_range(start='2014-06-24T12-0700', periods=5, freq='6h') ghi = pd.Series([np.nan, 1038.62, 1038.62, 1038.62, 1038.62], index=times) zenith = pd.Series([10.567, np.nan, 10.567, 10.567, 10.567], index=times) pressure = pd.Series([93193., 93193., np.nan, 93193., 93193.], index=times) @@ -1226,7 +1226,7 @@ def test_clearsky_index(): expected = 0.01 assert_allclose(out, expected, atol=0.001) # series - times = pd.date_range(start='20180601', periods=2, freq='12H') + times = pd.date_range(start='20180601', periods=2, freq='12h') ghi_measured = pd.Series([100, 500], index=times) ghi_modeled = pd.Series([500, 1000], index=times) out = irradiance.clearsky_index(ghi_measured, ghi_modeled) @@ -1282,7 +1282,7 @@ def test_clearness_index(): expected = 0.725 assert_allclose(out, expected, atol=0.001) # series - times = pd.date_range(start='20180601', periods=2, freq='12H') + times = pd.date_range(start='20180601', periods=2, freq='12h') ghi = pd.Series([0, 1000], index=times) solar_zenith = pd.Series([90, 0], index=times) extra_radiation = pd.Series([1360, 1400], index=times) @@ -1316,7 +1316,7 @@ def test_clearness_index_zenith_independent(airmass_kt): expected = 0.443 assert_allclose(out, expected, atol=0.001) # series - times = pd.date_range(start='20180601', periods=2, freq='12H') + times = pd.date_range(start='20180601', periods=2, freq='12h') clearness_index = pd.Series([0, .5], index=times) airmass = pd.Series([np.nan, 2], index=times) out = irradiance.clearness_index_zenith_independent(clearness_index, @@ -1327,7 +1327,7 @@ def test_clearness_index_zenith_independent(airmass_kt): def test_complete_irradiance(): # Generate dataframe to test on - times = pd.date_range('2010-07-05 7:00:00-0700', periods=2, freq='H') + times = pd.date_range('2010-07-05 7:00:00-0700', periods=2, freq='h') i = pd.DataFrame({'ghi': [372.103976116, 497.087579068], 'dhi': [356.543700, 465.44400], 'dni': [49.63565561689957, 62.10624908037814]}, diff --git a/pvlib/tests/test_location.py b/pvlib/tests/test_location.py index b818b2fd94..53ba7b51cf 100644 --- a/pvlib/tests/test_location.py +++ b/pvlib/tests/test_location.py @@ -74,7 +74,7 @@ def test_location_print_pytz(): def times(): return pd.date_range(start='20160101T0600-0700', end='20160101T1800-0700', - freq='3H') + freq='3h') def test_get_clearsky(mocker, times): diff --git a/pvlib/tests/test_modelchain.py b/pvlib/tests/test_modelchain.py index 9fd4660602..dab135b462 100644 --- a/pvlib/tests/test_modelchain.py +++ b/pvlib/tests/test_modelchain.py @@ -268,7 +268,7 @@ def location(): @pytest.fixture def weather(): - times = pd.date_range('20160101 1200-0700', periods=2, freq='6H') + times = pd.date_range('20160101 1200-0700', periods=2, freq='6h') weather = pd.DataFrame({'ghi': [500, 0], 'dni': [800, 0], 'dhi': [100, 0]}, index=times) return weather @@ -350,7 +350,7 @@ def test_with_pvwatts(pvwatts_dc_pvwatts_ac_system, location, weather): def test_run_model_with_irradiance(sapm_dc_snl_ac_system, location): mc = ModelChain(sapm_dc_snl_ac_system, location) - times = pd.date_range('20160101 1200-0700', periods=2, freq='6H') + times = pd.date_range('20160101 1200-0700', periods=2, freq='6h') irradiance = pd.DataFrame({'dni': 900, 'ghi': 600, 'dhi': 150}, index=times) ac = mc.run_model(irradiance).results.ac @@ -417,7 +417,7 @@ def test_run_model_from_irradiance_arrays_no_loss( spectral_model='no_loss', losses_model='no_loss' ) - times = pd.date_range('20160101 1200-0700', periods=2, freq='6H') + times = pd.date_range('20160101 1200-0700', periods=2, freq='6h') irradiance = pd.DataFrame({'dni': 900, 'ghi': 600, 'dhi': 150}, index=times) mc_one.run_model(irradiance) @@ -457,7 +457,7 @@ def test_run_model_from_irradiance_arrays_no_loss_input_type( spectral_model='no_loss', losses_model='no_loss' ) - times = pd.date_range('20160101 1200-0700', periods=2, freq='6H') + times = pd.date_range('20160101 1200-0700', periods=2, freq='6h') irradiance = pd.DataFrame({'dni': 900, 'ghi': 600, 'dhi': 150}, index=times) mc_one.run_model(irradiance) @@ -487,7 +487,7 @@ def test_ModelChain_invalid_inverter_params_arrays( def test_prepare_inputs_multi_weather( sapm_dc_snl_ac_system_Array, location, input_type): times = pd.date_range(start='20160101 1200-0700', - end='20160101 1800-0700', freq='6H') + end='20160101 1800-0700', freq='6h') mc = ModelChain(sapm_dc_snl_ac_system_Array, location) weather = pd.DataFrame({'ghi': 1, 'dhi': 1, 'dni': 1}, index=times) @@ -502,7 +502,7 @@ def test_prepare_inputs_multi_weather( def test_prepare_inputs_albedo_in_weather( sapm_dc_snl_ac_system_Array, location, input_type): times = pd.date_range(start='20160101 1200-0700', - end='20160101 1800-0700', freq='6H') + end='20160101 1800-0700', freq='6h') mc = ModelChain(sapm_dc_snl_ac_system_Array, location) weather = pd.DataFrame({'ghi': 1, 'dhi': 1, 'dni': 1, 'albedo': 0.5}, index=times) @@ -564,14 +564,14 @@ def test_ModelChain_times_error_arrays(sapm_dc_snl_ac_system_Array, location): error_str = r"Input DataFrames must have same index\." mc = ModelChain(sapm_dc_snl_ac_system_Array, location) irradiance = {'ghi': [1, 2], 'dhi': [1, 2], 'dni': [1, 2]} - times_one = pd.date_range(start='1/1/2020', freq='6H', periods=2) - times_two = pd.date_range(start='1/1/2020 00:15', freq='6H', periods=2) + times_one = pd.date_range(start='1/1/2020', freq='6h', periods=2) + times_two = pd.date_range(start='1/1/2020 00:15', freq='6h', periods=2) weather_one = pd.DataFrame(irradiance, index=times_one) weather_two = pd.DataFrame(irradiance, index=times_two) with pytest.raises(ValueError, match=error_str): mc.prepare_inputs((weather_one, weather_two)) # test with overlapping, but differently sized indices. - times_three = pd.date_range(start='1/1/2020', freq='6H', periods=3) + times_three = pd.date_range(start='1/1/2020', freq='6h', periods=3) irradiance_three = irradiance irradiance_three['ghi'].append(3) irradiance_three['dhi'].append(3) @@ -588,7 +588,7 @@ def test_ModelChain_times_arrays(sapm_dc_snl_ac_system_Array, location): mc = ModelChain(sapm_dc_snl_ac_system_Array, location) irradiance_one = {'ghi': [1, 2], 'dhi': [1, 2], 'dni': [1, 2]} irradiance_two = {'ghi': [2, 1], 'dhi': [2, 1], 'dni': [2, 1]} - times = pd.date_range(start='1/1/2020', freq='6H', periods=2) + times = pd.date_range(start='1/1/2020', freq='6h', periods=2) weather_one = pd.DataFrame(irradiance_one, index=times) weather_two = pd.DataFrame(irradiance_two, index=times) mc.prepare_inputs((weather_one, weather_two)) @@ -617,7 +617,7 @@ def test_run_model_arrays_weather(sapm_dc_snl_ac_system_same_arrays, 'pvwatts': pvwatts_dc_pvwatts_ac_system_arrays} mc = ModelChain(system[ac_model], location, aoi_model='no_loss', spectral_model='no_loss') - times = pd.date_range('20200101 1200-0700', periods=2, freq='2H') + times = pd.date_range('20200101 1200-0700', periods=2, freq='2h') weather_one = pd.DataFrame({'dni': [900, 800], 'ghi': [600, 500], 'dhi': [150, 100]}, @@ -634,7 +634,7 @@ def test_run_model_arrays_weather(sapm_dc_snl_ac_system_same_arrays, def test_run_model_perez(sapm_dc_snl_ac_system, location): mc = ModelChain(sapm_dc_snl_ac_system, location, transposition_model='perez') - times = pd.date_range('20160101 1200-0700', periods=2, freq='6H') + times = pd.date_range('20160101 1200-0700', periods=2, freq='6h') irradiance = pd.DataFrame({'dni': 900, 'ghi': 600, 'dhi': 150}, index=times) ac = mc.run_model(irradiance).results.ac @@ -648,7 +648,7 @@ def test_run_model_gueymard_perez(sapm_dc_snl_ac_system, location): mc = ModelChain(sapm_dc_snl_ac_system, location, airmass_model='gueymard1993', transposition_model='perez') - times = pd.date_range('20160101 1200-0700', periods=2, freq='6H') + times = pd.date_range('20160101 1200-0700', periods=2, freq='6h') irradiance = pd.DataFrame({'dni': 900, 'ghi': 600, 'dhi': 150}, index=times) ac = mc.run_model(irradiance).results.ac @@ -812,7 +812,7 @@ def test_prepare_inputs_from_poa_arrays_different_indices( mc = ModelChain(sapm_dc_snl_ac_system_Array, location) poa = pd.concat([weather, total_irrad], axis=1) with pytest.raises(ValueError, match=error_str): - mc.prepare_inputs_from_poa((poa, poa.shift(periods=1, freq='6H'))) + mc.prepare_inputs_from_poa((poa, poa.shift(periods=1, freq='6h'))) def test_prepare_inputs_from_poa_arrays_missing_column( @@ -1078,7 +1078,7 @@ def test_run_model_from_effective_irradiance_arrays_error( with pytest.raises(ValueError, match=r"Input DataFrames must have same index\."): mc.run_model_from_effective_irradiance( - (data, data.shift(periods=1, freq='6H')) + (data, data.shift(periods=1, freq='6h')) ) @@ -1790,7 +1790,7 @@ def test_ModelChain_no_extra_kwargs(sapm_dc_snl_ac_system, location): def test_basic_chain_alt_az(sam_data, cec_inverter_parameters, sapm_temperature_cs5p_220m): times = pd.date_range(start='20160101 1200-0700', - end='20160101 1800-0700', freq='6H') + end='20160101 1800-0700', freq='6h') latitude = 32.2 longitude = -111 surface_tilt = 0 @@ -1812,7 +1812,7 @@ def test_basic_chain_alt_az(sam_data, cec_inverter_parameters, def test_basic_chain_altitude_pressure(sam_data, cec_inverter_parameters, sapm_temperature_cs5p_220m): times = pd.date_range(start='20160101 1200-0700', - end='20160101 1800-0700', freq='6H') + end='20160101 1800-0700', freq='6h') latitude = 32.2 longitude = -111 altitude = 700 @@ -1847,7 +1847,7 @@ def test_basic_chain_altitude_pressure(sam_data, cec_inverter_parameters, def test_complete_irradiance_clean_run(sapm_dc_snl_ac_system, location): """The DataFrame should not change if all columns are passed""" mc = ModelChain(sapm_dc_snl_ac_system, location) - times = pd.date_range('2010-07-05 9:00:00', periods=2, freq='H') + times = pd.date_range('2010-07-05 9:00:00', periods=2, freq='h') i = pd.DataFrame( {'dni': [2, 3], 'dhi': [4, 6], 'ghi': [9, 5]}, index=times) @@ -1864,7 +1864,7 @@ def test_complete_irradiance_clean_run(sapm_dc_snl_ac_system, location): def test_complete_irradiance(sapm_dc_snl_ac_system, location, mocker): """Check calculations""" mc = ModelChain(sapm_dc_snl_ac_system, location) - times = pd.date_range('2010-07-05 7:00:00-0700', periods=2, freq='H') + times = pd.date_range('2010-07-05 7:00:00-0700', periods=2, freq='h') i = pd.DataFrame({'dni': [49.756966, 62.153947], 'ghi': [372.103976116, 497.087579068], 'dhi': [356.543700, 465.44400]}, index=times) @@ -1897,7 +1897,7 @@ def test_complete_irradiance_arrays( sapm_dc_snl_ac_system_same_arrays, location, input_type): """ModelChain.complete_irradiance can accept a tuple of weather DataFrames.""" - times = pd.date_range(start='2020-01-01 0700-0700', periods=2, freq='H') + times = pd.date_range(start='2020-01-01 0700-0700', periods=2, freq='h') weather = pd.DataFrame({'dni': [2, 3], 'dhi': [4, 6], 'ghi': [9, 5]}, index=times) @@ -1932,7 +1932,7 @@ def test_complete_irradiance_arrays( def test_complete_irradiance_arrays_wrong_length( sapm_dc_snl_ac_system_same_arrays, location, input_type): mc = ModelChain(sapm_dc_snl_ac_system_same_arrays, location) - times = pd.date_range(start='2020-01-01 0700-0700', periods=2, freq='H') + times = pd.date_range(start='2020-01-01 0700-0700', periods=2, freq='h') weather = pd.DataFrame({'dni': [2, 3], 'dhi': [4, 6], 'ghi': [9, 5]}, index=times) diff --git a/pvlib/tests/test_pvsystem.py b/pvlib/tests/test_pvsystem.py index ebc59a838a..52de0fcc5b 100644 --- a/pvlib/tests/test_pvsystem.py +++ b/pvlib/tests/test_pvsystem.py @@ -183,7 +183,7 @@ def test_retrieve_sam_cecinverter(): def test_sapm(sapm_module_params): - times = pd.date_range(start='2015-01-01', periods=5, freq='12H') + times = pd.date_range(start='2015-01-01', periods=5, freq='12h') effective_irradiance = pd.Series([-1000, 500, 1100, np.nan, 1000], index=times) temp_cell = pd.Series([10, 25, 50, 25, np.nan], index=times) @@ -535,7 +535,7 @@ def test_PVSystem_noct_celltemp(mocker): np.array(wind_speed), model='noct_sam') assert_allclose(out, expected) dr = pd.date_range(start='2020-01-01 12:00:00', end='2020-01-01 13:00:00', - freq='1H') + freq='1h') out = system.get_cell_temperature(pd.Series(index=dr, data=poa_global), pd.Series(index=dr, data=temp_air), pd.Series(index=dr, data=wind_speed), @@ -565,7 +565,7 @@ def test_PVSystem_noct_celltemp_error(): @pytest.mark.parametrize("model", ['faiman', 'pvsyst', 'sapm', 'fuentes', 'noct_sam']) def test_PVSystem_multi_array_celltemp_functions(model, two_array_system): - times = pd.date_range(start='2020-08-25 11:00', freq='H', periods=3) + times = pd.date_range(start='2020-08-25 11:00', freq='h', periods=3) irrad_one = pd.Series(1000, index=times) irrad_two = pd.Series(500, index=times) temp_air = pd.Series(25, index=times) @@ -579,7 +579,7 @@ def test_PVSystem_multi_array_celltemp_functions(model, two_array_system): @pytest.mark.parametrize("model", ['faiman', 'pvsyst', 'sapm', 'fuentes', 'noct_sam']) def test_PVSystem_multi_array_celltemp_multi_temp(model, two_array_system): - times = pd.date_range(start='2020-08-25 11:00', freq='H', periods=3) + times = pd.date_range(start='2020-08-25 11:00', freq='h', periods=3) irrad = pd.Series(1000, index=times) temp_air_one = pd.Series(25, index=times) temp_air_two = pd.Series(5, index=times) @@ -604,7 +604,7 @@ def test_PVSystem_multi_array_celltemp_multi_temp(model, two_array_system): @pytest.mark.parametrize("model", ['faiman', 'pvsyst', 'sapm', 'fuentes', 'noct_sam']) def test_PVSystem_multi_array_celltemp_multi_wind(model, two_array_system): - times = pd.date_range(start='2020-08-25 11:00', freq='H', periods=3) + times = pd.date_range(start='2020-08-25 11:00', freq='h', periods=3) irrad = pd.Series(1000, index=times) temp_air = pd.Series(25, index=times) wind_speed_one = pd.Series(1, index=times) @@ -932,7 +932,7 @@ def test_calcparams_pvsyst_all_scalars(pvsyst_module_params): def test_calcparams_desoto(cec_module_params): - times = pd.date_range(start='2015-01-01', periods=3, freq='12H') + times = pd.date_range(start='2015-01-01', periods=3, freq='12h') df = pd.DataFrame({ 'effective_irradiance': [0.0, 800.0, 800.0], 'temp_cell': [25, 25, 50] @@ -964,7 +964,7 @@ def test_calcparams_desoto(cec_module_params): def test_calcparams_cec(cec_module_params): - times = pd.date_range(start='2015-01-01', periods=3, freq='12H') + times = pd.date_range(start='2015-01-01', periods=3, freq='12h') df = pd.DataFrame({ 'effective_irradiance': [0.0, 800.0, 800.0], 'temp_cell': [25, 25, 50] @@ -1007,7 +1007,7 @@ def test_calcparams_cec_extra_params_propagation(cec_module_params, mocker): checks that the latter is called with the expected parameters instead of some default values. """ - times = pd.date_range(start='2015-01-01', periods=3, freq='12H') + times = pd.date_range(start='2015-01-01', periods=3, freq='12h') effective_irradiance = pd.Series([0.0, 800.0, 800.0], index=times) temp_cell = pd.Series([25, 25, 50], index=times) extra_parameters = dict( @@ -1034,7 +1034,7 @@ def test_calcparams_cec_extra_params_propagation(cec_module_params, mocker): def test_calcparams_pvsyst(pvsyst_module_params): - times = pd.date_range(start='2015-01-01', periods=2, freq='12H') + times = pd.date_range(start='2015-01-01', periods=2, freq='12h') df = pd.DataFrame({ 'effective_irradiance': [0.0, 800.0], 'temp_cell': [25, 50] @@ -1526,7 +1526,7 @@ def test_mpp_series(): def test_singlediode_series(cec_module_params): - times = pd.date_range(start='2015-01-01', periods=2, freq='12H') + times = pd.date_range(start='2015-01-01', periods=2, freq='12h') effective_irradiance = pd.Series([0.0, 800.0], index=times) IL, I0, Rs, Rsh, nNsVth = pvsystem.calcparams_desoto( effective_irradiance, @@ -1616,7 +1616,7 @@ def test_singlediode_floats_ivcurve(): def test_singlediode_series_ivcurve(cec_module_params): - times = pd.date_range(start='2015-06-01', periods=3, freq='6H') + times = pd.date_range(start='2015-06-01', periods=3, freq='6h') effective_irradiance = pd.Series([0.0, 400.0, 800.0], index=times) IL, I0, Rs, Rsh, nNsVth = pvsystem.calcparams_desoto( effective_irradiance, @@ -1910,7 +1910,7 @@ def test_PVSystem_multiple_array_get_aoi(): @pytest.fixture def solar_pos(): times = pd.date_range(start='20160101 1200-0700', - end='20160101 1800-0700', freq='6H') + end='20160101 1800-0700', freq='6h') location = Location(latitude=32, longitude=-111) return location.get_solarposition(times) @@ -2368,10 +2368,10 @@ def test_PVSystem_single_array(): def test_combine_loss_factors(): - test_index = pd.date_range(start='1990/01/01T12:00', periods=365, freq='D') + test_index = pd.date_range(start='1990/01/01T12:00', periods=365, freq='d') loss_1 = pd.Series(.10, index=test_index) loss_2 = pd.Series(.05, index=pd.date_range(start='1990/01/01T12:00', - periods=365*2, freq='D')) + periods=365*2, freq='d')) loss_3 = pd.Series(.02, index=pd.date_range(start='1990/01/01', periods=12, freq='MS')) expected = pd.Series(.1621, index=test_index) diff --git a/pvlib/tests/test_shading.py b/pvlib/tests/test_shading.py index 8d609d1e3f..2f1e5b3410 100644 --- a/pvlib/tests/test_shading.py +++ b/pvlib/tests/test_shading.py @@ -132,7 +132,7 @@ def true_tracking_angle_and_inputs_NREL(): ), ) timedata.index = pd.date_range( - "2019-01-01T08", "2019-01-01T17", freq="1H", tz=tzinfo + "2019-01-01T08", "2019-01-01T17", freq="1h", tz=tzinfo ) timedata["Apparent Zenith"] = 90.0 - timedata["Apparent Elevation"] return (axis_tilt_angle, axis_azimuth_angle, timedata) diff --git a/pvlib/tests/test_snow.py b/pvlib/tests/test_snow.py index 26ede9a782..19e79b5179 100644 --- a/pvlib/tests/test_snow.py +++ b/pvlib/tests/test_snow.py @@ -42,7 +42,7 @@ def test_coverage_nrel_subhourly(): surface_tilt = 45 slide_amount_coefficient = 0.197 dt = pd.date_range(start="2019-1-1 11:00:00", end="2019-1-1 14:00:00", - freq='15T') + freq='15min') poa_irradiance = pd.Series([400, 200, 100, 1234, 134, 982, 100, 100, 100, 100, 100, 100, 0], index=dt) diff --git a/pvlib/tests/test_solarposition.py b/pvlib/tests/test_solarposition.py index 63e32a4c3c..472383acce 100644 --- a/pvlib/tests/test_solarposition.py +++ b/pvlib/tests/test_solarposition.py @@ -18,7 +18,7 @@ # setup times and locations to be tested. times = pd.date_range(start=datetime.datetime(2014, 6, 24), - end=datetime.datetime(2014, 6, 26), freq='15Min') + end=datetime.datetime(2014, 6, 26), freq='15min') tus = Location(32.2, -111, 'US/Arizona', 700) # no DST issues possible times_localized = times.tz_localize(tus.tz) @@ -547,7 +547,7 @@ def test_nrel_earthsun_distance(): def test_equation_of_time(): times = pd.date_range(start="1/1/2015 0:00", end="12/31/2015 23:00", - freq="H") + freq="h") output = solarposition.spa_python(times, 37.8, -122.25, 100) eot = output['equation_of_time'] eot_rng = eot.max() - eot.min() # range of values, around 30 minutes @@ -559,7 +559,7 @@ def test_equation_of_time(): def test_declination(): times = pd.date_range(start="1/1/2015 0:00", end="12/31/2015 23:00", - freq="H") + freq="h") atmos_refract = 0.5667 delta_t = spa.calculate_deltat(times.year, times.month) unixtime = np.array([calendar.timegm(t.timetuple()) for t in times]) @@ -578,7 +578,7 @@ def test_declination(): def test_analytical_zenith(): times = pd.date_range(start="1/1/2015 0:00", end="12/31/2015 23:00", - freq="H").tz_localize('Etc/GMT+8') + freq="h").tz_localize('Etc/GMT+8') lat, lon = 37.8, -122.25 lat_rad = np.deg2rad(lat) output = solarposition.spa_python(times, lat, lon, 100) @@ -599,7 +599,7 @@ def test_analytical_zenith(): def test_analytical_azimuth(): times = pd.date_range(start="1/1/2015 0:00", end="12/31/2015 23:00", - freq="H").tz_localize('Etc/GMT+8') + freq="h").tz_localize('Etc/GMT+8') lat, lon = 37.8, -122.25 lat_rad = np.deg2rad(lat) output = solarposition.spa_python(times, lat, lon, 100) @@ -753,7 +753,7 @@ def test__datetime_to_unixtime_units(unit, tz): def test_get_solarposition_microsecond_index(method, tz): # https://github.com/pvlib/pvlib-python/issues/1932 - kwargs = dict(start='2019-01-01', freq='H', periods=24, tz=tz) + kwargs = dict(start='2019-01-01', freq='h', periods=24, tz=tz) index_ns = pd.date_range(unit='ns', **kwargs) index_us = pd.date_range(unit='us', **kwargs) @@ -769,7 +769,7 @@ def test_get_solarposition_microsecond_index(method, tz): def test_nrel_earthsun_distance_microsecond_index(tz): # https://github.com/pvlib/pvlib-python/issues/1932 - kwargs = dict(start='2019-01-01', freq='H', periods=24, tz=tz) + kwargs = dict(start='2019-01-01', freq='h', periods=24, tz=tz) index_ns = pd.date_range(unit='ns', **kwargs) index_us = pd.date_range(unit='us', **kwargs) @@ -785,7 +785,7 @@ def test_nrel_earthsun_distance_microsecond_index(tz): def test_hour_angle_microsecond_index(tz): # https://github.com/pvlib/pvlib-python/issues/1932 - kwargs = dict(start='2019-01-01', freq='H', periods=24, tz=tz) + kwargs = dict(start='2019-01-01', freq='h', periods=24, tz=tz) index_ns = pd.date_range(unit='ns', **kwargs) index_us = pd.date_range(unit='us', **kwargs) @@ -801,7 +801,7 @@ def test_hour_angle_microsecond_index(tz): def test_rise_set_transit_spa_microsecond_index(tz): # https://github.com/pvlib/pvlib-python/issues/1932 - kwargs = dict(start='2019-01-01', freq='H', periods=24, tz=tz) + kwargs = dict(start='2019-01-01', freq='h', periods=24, tz=tz) index_ns = pd.date_range(unit='ns', **kwargs) index_us = pd.date_range(unit='us', **kwargs) @@ -817,7 +817,7 @@ def test_rise_set_transit_spa_microsecond_index(tz): def test_rise_set_transit_geometric_microsecond_index(tz): # https://github.com/pvlib/pvlib-python/issues/1932 - kwargs = dict(start='2019-01-01', freq='H', periods=24, tz=tz) + kwargs = dict(start='2019-01-01', freq='h', periods=24, tz=tz) index_ns = pd.date_range(unit='ns', **kwargs) index_us = pd.date_range(unit='us', **kwargs) diff --git a/pvlib/tests/test_temperature.py b/pvlib/tests/test_temperature.py index 6ab4b4730b..18560501fb 100644 --- a/pvlib/tests/test_temperature.py +++ b/pvlib/tests/test_temperature.py @@ -52,7 +52,7 @@ def test_sapm_ndarray(sapm_default): def test_sapm_series(sapm_default): - times = pd.date_range(start='2015-01-01', end='2015-01-02', freq='12H') + times = pd.date_range(start='2015-01-01', end='2015-01-02', freq='12h') temps = pd.Series([0, 10, 5], index=times) irrads = pd.Series([0, 500, 0], index=times) winds = pd.Series([10, 5, 0], index=times) @@ -89,7 +89,7 @@ def test_pvsyst_cell_ndarray(): def test_pvsyst_cell_series(): - times = pd.date_range(start="2015-01-01", end="2015-01-02", freq="12H") + times = pd.date_range(start="2015-01-01", end="2015-01-02", freq="12h") temps = pd.Series([0, 10, 5], index=times) irrads = pd.Series([0, 500, 0], index=times) winds = pd.Series([10, 5, 0], index=times) @@ -161,7 +161,7 @@ def test_ross(): def test_faiman_series(): - times = pd.date_range(start="2015-01-01", end="2015-01-02", freq="12H") + times = pd.date_range(start="2015-01-01", end="2015-01-02", freq="12h") temps = pd.Series([0, 10, 5], index=times) irrads = pd.Series([0, 500, 0], index=times) winds = pd.Series([10, 5, 0], index=times) @@ -255,7 +255,7 @@ def test_noct_sam(): np.array(module_efficiency)) assert_allclose(result, expected) dr = pd.date_range(start='2020-01-01 12:00:00', end='2020-01-01 13:00:00', - freq='1H') + freq='1h') result = temperature.noct_sam(pd.Series(index=dr, data=poa_global), pd.Series(index=dr, data=temp_air), pd.Series(index=dr, data=wind_speed), diff --git a/pvlib/tests/test_tracking.py b/pvlib/tests/test_tracking.py index 4febc73389..03536762b5 100644 --- a/pvlib/tests/test_tracking.py +++ b/pvlib/tests/test_tracking.py @@ -316,7 +316,7 @@ def test_calc_axis_tilt(): starttime = '2017-01-01T00:30:00-0300' stoptime = '2017-12-31T23:59:59-0300' lat, lon = -27.597300, -48.549610 - times = pd.DatetimeIndex(pd.date_range(starttime, stoptime, freq='H')) + times = pd.DatetimeIndex(pd.date_range(starttime, stoptime, freq='h')) solpos = pvlib.solarposition.get_solarposition(times, lat, lon) # singleaxis tracker w/slope data slope_azimuth, slope_tilt = 77.34, 10.1149 @@ -394,7 +394,7 @@ def test_singleaxis_aoi_gh1221(): # vertical tracker loc = pvlib.location.Location(40.1134, -88.3695) dr = pd.date_range( - start='02-Jun-1998 00:00:00', end='02-Jun-1998 23:55:00', freq='5T', + start='02-Jun-1998 00:00:00', end='02-Jun-1998 23:55:00', freq='5min', tz='Etc/GMT+6') sp = loc.get_solarposition(dr) tr = pvlib.tracking.singleaxis( From 305a6657c9d0fc648a43be75c5e05760a4250476 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Mon, 18 Mar 2024 19:28:13 -0400 Subject: [PATCH 2/3] roll back the change from M to ME looks like ME only exists for pandas 2.2+ --- pvlib/iotools/bsrn.py | 2 +- pvlib/iotools/srml.py | 2 +- pvlib/tests/iotools/test_sodapro.py | 2 +- pvlib/tests/test_clearsky.py | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pvlib/iotools/bsrn.py b/pvlib/iotools/bsrn.py index fa6ef9b81e..43fdbe919f 100644 --- a/pvlib/iotools/bsrn.py +++ b/pvlib/iotools/bsrn.py @@ -160,7 +160,7 @@ 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, end.replace(day=1) + pd.DateOffset(months=1), freq='1ME')\ + start, end.replace(day=1) + pd.DateOffset(months=1), freq='1M')\ .strftime(f"{station}%m%y.dat.gz").tolist() # Create FTP connection diff --git a/pvlib/iotools/srml.py b/pvlib/iotools/srml.py index 9ae0ad7f67..83868f637c 100644 --- a/pvlib/iotools/srml.py +++ b/pvlib/iotools/srml.py @@ -297,7 +297,7 @@ def get_srml(station, start, end, filetype='PO', map_variables=True, # Generate list of months months = pd.date_range( - start, end.replace(day=1) + pd.DateOffset(months=1), freq='1ME') + start, end.replace(day=1) + pd.DateOffset(months=1), freq='1M') months_str = months.strftime('%y%m') # Generate list of filenames diff --git a/pvlib/tests/iotools/test_sodapro.py b/pvlib/tests/iotools/test_sodapro.py index 81d11e8dc7..c0941d3e93 100644 --- a/pvlib/tests/iotools/test_sodapro.py +++ b/pvlib/tests/iotools/test_sodapro.py @@ -18,7 +18,7 @@ index_verbose = pd.date_range('2020-06-01 12', periods=4, freq='1min', tz='UTC') -index_monthly = pd.date_range('2020-01-01', periods=4, freq='1ME') +index_monthly = pd.date_range('2020-01-01', periods=4, freq='1M') dtypes_mcclear_verbose = [ diff --git a/pvlib/tests/test_clearsky.py b/pvlib/tests/test_clearsky.py index 9945ab64a7..4e353e997c 100644 --- a/pvlib/tests/test_clearsky.py +++ b/pvlib/tests/test_clearsky.py @@ -225,7 +225,7 @@ 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='1ME', tz='America/Phoenix') + freq='1M', tz='America/Phoenix') expected = pd.Series( np.array([2.89918032787, 2.97540983607, 3.19672131148]), index=times ) @@ -235,7 +235,7 @@ 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='1ME', tz='America/Phoenix') + freq='1M', tz='America/Phoenix') expected = pd.Series( np.array([2.89918032787, 2.97540983607, 3.19672131148]), index=times ) @@ -245,14 +245,14 @@ 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='1ME', tz='America/Phoenix') + freq='1M', tz='America/Phoenix') 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='1ME', tz='America/Phoenix') + freq='1M', tz='America/Phoenix') out = clearsky.lookup_linke_turbidity(times, 32.125, -110.875, interp_turbidity=False) assert_series_equal(expected, out) From c4be7c68fc2922343d8c907cd5a8518037bb5335 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Mon, 18 Mar 2024 19:28:24 -0400 Subject: [PATCH 3/3] lint --- pvlib/tests/iotools/test_sodapro.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pvlib/tests/iotools/test_sodapro.py b/pvlib/tests/iotools/test_sodapro.py index c0941d3e93..83983d2b68 100644 --- a/pvlib/tests/iotools/test_sodapro.py +++ b/pvlib/tests/iotools/test_sodapro.py @@ -17,7 +17,8 @@ testfile_radiation_monthly = DATA_DIR / 'cams_radiation_monthly.csv' -index_verbose = pd.date_range('2020-06-01 12', periods=4, freq='1min', tz='UTC') +index_verbose = pd.date_range('2020-06-01 12', periods=4, freq='1min', + tz='UTC') index_monthly = pd.date_range('2020-01-01', periods=4, freq='1M')