diff --git a/pvlib/clearsky.py b/pvlib/clearsky.py index d29601038a..d54f57767b 100644 --- a/pvlib/clearsky.py +++ b/pvlib/clearsky.py @@ -558,7 +558,7 @@ def _calc_taud(w, aod700, p): # set up nan-tolerant masks aod700_lt_0p05 = np.full_like(aod700, False, dtype='bool') np.less(aod700, 0.05, where=~np.isnan(aod700), out=aod700_lt_0p05) - aod700_mask = np.array([aod700_lt_0p05, ~aod700_lt_0p05], dtype=np.int) + aod700_mask = np.array([aod700_lt_0p05, ~aod700_lt_0p05], dtype=int) # create tuples of coefficients for # aod700 < 0.05, aod700 >= 0.05 diff --git a/pvlib/tests/iotools/test_ecmwf_macc.py b/pvlib/tests/iotools/test_ecmwf_macc.py index 4537d22203..b3387817ef 100644 --- a/pvlib/tests/iotools/test_ecmwf_macc.py +++ b/pvlib/tests/iotools/test_ecmwf_macc.py @@ -57,7 +57,7 @@ def test_read_ecmwf_macc(expected_test_data): expected_times = [ 1351738800, 1351749600, 1351760400, 1351771200, 1351782000, 1351792800, 1351803600, 1351814400] - assert np.allclose(data.index.astype(int) // 1000000000, expected_times) + assert np.allclose(data.index.view(np.int64) // 1000000000, expected_times) expected_aod = np.array([ 0.39531226, 0.22371339, 0.18373083, 0.15010143, 0.130809, 0.11172834, 0.09741255, 0.0921606]) diff --git a/pvlib/tests/iotools/test_tmy.py b/pvlib/tests/iotools/test_tmy.py index d8c1c6efcb..7e4b76c294 100644 --- a/pvlib/tests/iotools/test_tmy.py +++ b/pvlib/tests/iotools/test_tmy.py @@ -67,7 +67,7 @@ def test_gh865_read_tmy3_feb_leapyear_hr24(): assert all(data.index[:-1].year == 1990) assert data.index[-1].year == 1991 # let's do a quick sanity check, are the indices monotonically increasing? - assert all(np.diff(data.index.astype(int)) == 3600000000000) + assert all(np.diff(data.index.view(np.int64)) == 3600000000000) # according to the TMY3 manual, each record corresponds to the previous # hour so check that the 1st hour is 1AM and the last hour is midnite assert data.index[0].hour == 1 diff --git a/pvlib/tests/test_modelchain.py b/pvlib/tests/test_modelchain.py index b42acfa54e..17887dc693 100644 --- a/pvlib/tests/test_modelchain.py +++ b/pvlib/tests/test_modelchain.py @@ -717,7 +717,7 @@ def test_run_model_with_weather_noct_sam_temp(sapm_dc_snl_ac_system, location, weather, mocker): weather['wind_speed'] = 5 weather['temp_air'] = 10 - sapm_dc_snl_ac_system.temperature_model_parameters = { + sapm_dc_snl_ac_system.arrays[0].temperature_model_parameters = { 'noct': 45, 'module_efficiency': 0.2 } mc = ModelChain(sapm_dc_snl_ac_system, location) diff --git a/pvlib/tests/test_solarposition.py b/pvlib/tests/test_solarposition.py index 513a7f18d1..7578506561 100644 --- a/pvlib/tests/test_solarposition.py +++ b/pvlib/tests/test_solarposition.py @@ -204,21 +204,18 @@ def test_sun_rise_set_transit_ephem(expected_rise_set_ephem, golden): expected = pd.DataFrame(index=times, columns=['sunrise', 'sunset'], dtype='datetime64[ns]') - expected['sunrise'] = pd.Series(index=times, data=[ - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunrise'], - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'sunrise'], - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'sunrise'], - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'sunrise']]) - expected['sunset'] = pd.Series(index=times, data=[ - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunset'], - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunset'], - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunset'], - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'sunset']]) - expected['transit'] = pd.Series(index=times, data=[ - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'transit'], - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'transit'], - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'transit'], - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'transit']]) + idx_sunrise = pd.to_datetime(['2015-01-02', '2015-01-03', '2015-01-03', + '2015-01-03']).tz_localize('MST') + expected['sunrise'] = \ + expected_rise_set_ephem.loc[idx_sunrise, 'sunrise'].tolist() + idx_sunset = pd.to_datetime(['2015-01-02', '2015-01-02', '2015-01-02', + '2015-01-03']).tz_localize('MST') + expected['sunset'] = \ + expected_rise_set_ephem.loc[idx_sunset, 'sunset'].tolist() + idx_transit = pd.to_datetime(['2015-01-02', '2015-01-02', '2015-01-03', + '2015-01-03']).tz_localize('MST') + expected['transit'] = \ + expected_rise_set_ephem.loc[idx_transit, 'transit'].tolist() result = solarposition.sun_rise_set_transit_ephem(times, golden.latitude, @@ -243,21 +240,18 @@ def test_sun_rise_set_transit_ephem(expected_rise_set_ephem, golden): expected = pd.DataFrame(index=times, columns=['sunrise', 'sunset'], dtype='datetime64[ns]') - expected['sunrise'] = pd.Series(index=times, data=[ - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 1), 'sunrise'], - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunrise'], - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunrise'], - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'sunrise']]) - expected['sunset'] = pd.Series(index=times, data=[ - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 1), 'sunset'], - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 1), 'sunset'], - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunset'], - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'sunset']]) - expected['transit'] = pd.Series(index=times, data=[ - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 1), 'transit'], - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 1), 'transit'], - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 2), 'transit'], - expected_rise_set_ephem.loc[datetime.datetime(2015, 1, 3), 'transit']]) + idx_sunrise = pd.to_datetime(['2015-01-01', '2015-01-02', '2015-01-02', + '2015-01-03']).tz_localize('MST') + expected['sunrise'] = \ + expected_rise_set_ephem.loc[idx_sunrise, 'sunrise'].tolist() + idx_sunset = pd.to_datetime(['2015-01-01', '2015-01-01', '2015-01-02', + '2015-01-02']).tz_localize('MST') + expected['sunset'] = \ + expected_rise_set_ephem.loc[idx_sunset, 'sunset'].tolist() + idx_transit = pd.to_datetime(['2015-01-01', '2015-01-01', '2015-01-02', + '2015-01-03']).tz_localize('MST') + expected['transit'] = \ + expected_rise_set_ephem.loc[idx_transit, 'transit'].tolist() result = solarposition.sun_rise_set_transit_ephem( times, diff --git a/pvlib/tests/test_spa.py b/pvlib/tests/test_spa.py index ecd28a5123..0730f3403e 100644 --- a/pvlib/tests/test_spa.py +++ b/pvlib/tests/test_spa.py @@ -28,7 +28,7 @@ times = (pd.date_range('2003-10-17 12:30:30', periods=1, freq='D') .tz_localize('MST')) -unixtimes = np.array(times.tz_convert('UTC').astype(np.int64)*1.0/10**9) +unixtimes = np.array(times.tz_convert('UTC').view(np.int64)*1.0/10**9) lat = 39.742476 lon = -105.1786 @@ -266,15 +266,15 @@ def test_transit_sunrise_sunset(self): times = pd.DatetimeIndex([dt.datetime(1996, 7, 5, 0), dt.datetime(2004, 12, 4, 0)] ).tz_localize( - 'UTC').astype(np.int64)*1.0/10**9 + 'UTC').view(np.int64)*1.0/10**9 sunrise = pd.DatetimeIndex([dt.datetime(1996, 7, 5, 7, 8, 15), dt.datetime(2004, 12, 4, 4, 38, 57)] ).tz_localize( - 'UTC').astype(np.int64)*1.0/10**9 + 'UTC').view(np.int64)*1.0/10**9 sunset = pd.DatetimeIndex([dt.datetime(1996, 7, 5, 17, 1, 4), dt.datetime(2004, 12, 4, 19, 2, 2)] ).tz_localize( - 'UTC').astype(np.int64)*1.0/10**9 + 'UTC').view(np.int64)*1.0/10**9 times = np.array(times) sunrise = np.array(sunrise) sunset = np.array(sunset) @@ -284,13 +284,13 @@ def test_transit_sunrise_sunset(self): times = pd.DatetimeIndex([dt.datetime(1994, 1, 2), ] ).tz_localize( - 'UTC').astype(np.int64)*1.0/10**9 + 'UTC').view(np.int64)*1.0/10**9 sunset = pd.DatetimeIndex([dt.datetime(1994, 1, 2, 16, 59, 55), ] ).tz_localize( - 'UTC').astype(np.int64)*1.0/10**9 + 'UTC').view(np.int64)*1.0/10**9 sunrise = pd.DatetimeIndex([dt.datetime(1994, 1, 2, 7, 8, 12), ] ).tz_localize( - 'UTC').astype(np.int64)*1.0/10**9 + 'UTC').view(np.int64)*1.0/10**9 times = np.array(times) sunrise = np.array(sunrise) sunset = np.array(sunset) @@ -305,19 +305,19 @@ def test_transit_sunrise_sunset(self): dt.datetime(2015, 8, 2), dt.datetime(2015, 12, 2)], ).tz_localize( - 'UTC').astype(np.int64)*1.0/10**9 + 'UTC').view(np.int64)*1.0/10**9 sunrise = pd.DatetimeIndex([dt.datetime(2015, 1, 2, 7, 19), dt.datetime(2015, 4, 2, 5, 43), dt.datetime(2015, 8, 2, 5, 1), dt.datetime(2015, 12, 2, 7, 1)], ).tz_localize( - 'MST').astype(np.int64)*1.0/10**9 + 'MST').view(np.int64)*1.0/10**9 sunset = pd.DatetimeIndex([dt.datetime(2015, 1, 2, 16, 49), dt.datetime(2015, 4, 2, 18, 24), dt.datetime(2015, 8, 2, 19, 10), dt.datetime(2015, 12, 2, 16, 38)], ).tz_localize( - 'MST').astype(np.int64)*1.0/10**9 + 'MST').view(np.int64)*1.0/10**9 times = np.array(times) sunrise = np.array(sunrise) sunset = np.array(sunset) @@ -331,18 +331,18 @@ def test_transit_sunrise_sunset(self): dt.datetime(2015, 8, 2), dt.datetime(2015, 12, 2)], ).tz_localize( - 'UTC').astype(np.int64)*1.0/10**9 + 'UTC').view(np.int64)*1.0/10**9 sunrise = pd.DatetimeIndex([dt.datetime(2015, 1, 2, 7, 36), dt.datetime(2015, 4, 2, 5, 58), dt.datetime(2015, 8, 2, 5, 13), dt.datetime(2015, 12, 2, 7, 17)], - ).tz_localize('Asia/Shanghai').astype( + ).tz_localize('Asia/Shanghai').view( np.int64)*1.0/10**9 sunset = pd.DatetimeIndex([dt.datetime(2015, 1, 2, 17, 0), dt.datetime(2015, 4, 2, 18, 39), dt.datetime(2015, 8, 2, 19, 28), dt.datetime(2015, 12, 2, 16, 50)], - ).tz_localize('Asia/Shanghai').astype( + ).tz_localize('Asia/Shanghai').view( np.int64)*1.0/10**9 times = np.array(times) sunrise = np.array(sunrise) @@ -355,7 +355,7 @@ def test_transit_sunrise_sunset(self): def test_earthsun_distance(self): times = (pd.date_range('2003-10-17 12:30:30', periods=1, freq='D') .tz_localize('MST')) - unixtimes = times.tz_convert('UTC').astype(np.int64)*1.0/10**9 + unixtimes = times.tz_convert('UTC').view(np.int64)*1.0/10**9 unixtimes = np.array(unixtimes) result = self.spa.earthsun_distance(unixtimes, 64.0, 1) assert_almost_equal(R, result, 6) diff --git a/pvlib/tests/test_tracking.py b/pvlib/tests/test_tracking.py index 7e51adc956..c88c92b248 100644 --- a/pvlib/tests/test_tracking.py +++ b/pvlib/tests/test_tracking.py @@ -7,7 +7,7 @@ import pvlib from pvlib import tracking -from .conftest import DATA_DIR, assert_frame_equal +from .conftest import DATA_DIR, assert_frame_equal, assert_series_equal from pvlib._deprecation import pvlibDeprecationWarning SINGLEAXIS_COL_ORDER = ['tracker_theta', 'aoi', @@ -462,21 +462,21 @@ def test_slope_aware_backtracking(): """ Test validation data set from https://www.nrel.gov/docs/fy20osti/76626.pdf """ - expected_data = np.array( - [('2019-01-01T08:00-0500', 2.404287, 122.79177, -84.440, -10.899), - ('2019-01-01T09:00-0500', 11.263058, 133.288729, -72.604, -25.747), - ('2019-01-01T10:00-0500', 18.733558, 145.285552, -59.861, -59.861), - ('2019-01-01T11:00-0500', 24.109076, 158.939435, -45.578, -45.578), - ('2019-01-01T12:00-0500', 26.810735, 173.931802, -28.764, -28.764), - ('2019-01-01T13:00-0500', 26.482495, 189.371536, -8.475, -8.475), - ('2019-01-01T14:00-0500', 23.170447, 204.13681, 15.120, 15.120), - ('2019-01-01T15:00-0500', 17.296785, 217.446538, 39.562, 39.562), - ('2019-01-01T16:00-0500', 9.461862, 229.102218, 61.587, 32.339), - ('2019-01-01T17:00-0500', 0.524817, 239.330401, 79.530, 5.490)], - dtype=[ - ('Time', '