From bd8b8b397fc700e774040aea07d33748c46bc43a Mon Sep 17 00:00:00 2001 From: roger-lcc Date: Thu, 14 Apr 2022 16:42:04 +0800 Subject: [PATCH 01/10] Improved benchmark in solarposition.py --- benchmarks/benchmarks/solarposition.py | 71 ++++++++++++++++++++------ docs/sphinx/source/whatsnew/v0.9.2.rst | 2 + 2 files changed, 57 insertions(+), 16 deletions(-) diff --git a/benchmarks/benchmarks/solarposition.py b/benchmarks/benchmarks/solarposition.py index 4fac0ea470..a2bffd5d3e 100644 --- a/benchmarks/benchmarks/solarposition.py +++ b/benchmarks/benchmarks/solarposition.py @@ -16,22 +16,15 @@ sun_rise_set_transit_spa = solarposition.get_sun_rise_set_transit -class SolarPosition: +class SolarPositionSlow: params = [1, 10, 100] # number of days param_names = ['ndays'] def setup(self, ndays): - self.times = pd.date_range(start='20180601', freq='1min', - periods=1440*ndays) - self.times_localized = self.times.tz_localize('Etc/GMT+7') + self.times_localized = pd.date_range(start='20180601', freq='1min', + periods=1440*ndays, tz='Etc/GMT+7') self.lat = 35.1 self.lon = -106.6 - self.times_daily = pd.date_range( - start='20180601', freq='24h', periods=ndays, tz='Etc/GMT+7') - - # GH 512 - def time_ephemeris(self, ndays): - solarposition.ephemeris(self.times, self.lat, self.lon) # GH 512 def time_ephemeris_localized(self, ndays): @@ -43,13 +36,58 @@ def time_spa_python(self, ndays): def time_pyephem(self, ndays): solarposition.pyephem(self.times_localized, self.lat, self.lon) + def time_nrel_earthsun_distance(self, ndays): + solarposition.nrel_earthsun_distance(self.times_localized) + + def time_pyephem_earthsun_distance(self, ndays): + solarposition.pyephem_earthsun_distance((self.times_localized)) + + def time_get_solarposition(self, ndays): + solarposition.get_solarposition(self.times_localized, self.lat, self.lon) + + +class SolarPositionFast: + params = [1, 365 * 10, 365 * 100] + param_names = ['ndays'] # provide informative names for the parameters + + def setup(self, ndays): + self.lat = 35.1 + self.lon = -106.6 + self.times_daily = pd.date_range( + start='20180601', freq='24h', periods=ndays, tz='Etc/GMT+7') + + def time_sun_rise_set_transit_geometric_full_comparison(self, ndays): + dayofyear = self.times_daily.dayofyear + declination = solarposition.declination_spencer71(dayofyear) + equation_of_time = solarposition.equation_of_time_spencer71(dayofyear) + solarposition.sun_rise_set_transit_geometric( + self.times_daily, self.lat, self.lon, declination, + equation_of_time) + + def time__local_times_from_hours_since_midnight_full_comparison(self, ndays): + equation_of_time = solarposition.equation_of_time_spencer71(self.times_daily.dayofyear) + hourangle = solarposition.hour_angle(self.times_daily, self.lon, equation_of_time) + solarposition._hour_angle_to_hours(self.times_daily, hourangle, self.lon, equation_of_time) + + def time_solar_azimuth_analytical_full_comparison(self, nadys): + equation_of_time = solarposition.equation_of_time_spencer71(self.times_daily.dayofyear) + declination = solarposition.declination_spencer71(self.times_daily.dayofyear) + hourangle = solarposition.hour_angle(self.times_daily, self.lon, equation_of_time) + zenith = solarposition.solar_zenith_analytical(self.lat, hourangle, declination) + solarposition.solar_azimuth_analytical(self.lat, hourangle, declination, zenith) + + def time_calculate_simple_day_angle(self, ndays): + solarposition._calculate_simple_day_angle(self.times_daily.dayofyear) + + def time_equation_of_time_pvcdrom(self, ndays): + solarposition.equation_of_time_pvcdrom(self.times_daily.dayofyear) + + def time_declination_cooper69(self, ndays): + solarposition.declination_cooper69(self.times_daily.dayofyear) + def time_sun_rise_set_transit_spa(self, ndays): sun_rise_set_transit_spa(self.times_daily, self.lat, self.lon) - def time_sun_rise_set_transit_ephem(self, ndays): - solarposition.sun_rise_set_transit_ephem( - self.times_daily, self.lat, self.lon) - def time_sun_rise_set_transit_geometric_full_comparison(self, ndays): dayofyear = self.times_daily.dayofyear declination = solarposition.declination_spencer71(dayofyear) @@ -58,8 +96,9 @@ def time_sun_rise_set_transit_geometric_full_comparison(self, ndays): self.times_daily, self.lat, self.lon, declination, equation_of_time) - def time_nrel_earthsun_distance(self, ndays): - solarposition.nrel_earthsun_distance(self.times_localized) + def time_sun_rise_set_transit_ephem(self, ndays): + solarposition.sun_rise_set_transit_ephem( + self.times_daily, self.lat, self.lon) class SolarPositionCalcTime: diff --git a/docs/sphinx/source/whatsnew/v0.9.2.rst b/docs/sphinx/source/whatsnew/v0.9.2.rst index 1982759bf5..af1ba98a1d 100644 --- a/docs/sphinx/source/whatsnew/v0.9.2.rst +++ b/docs/sphinx/source/whatsnew/v0.9.2.rst @@ -23,9 +23,11 @@ Documentation Benchmarking ~~~~~~~~~~~~~ * Updated version of numba in asv.conf from 0.36.1 to 0.40.0 to solve numba/numpy conflict. (:issue:`1439`, :pull:`1440`) +* Improved the benchmark in solarposition.py (:issue:`1441`) Requirements ~~~~~~~~~~~~ Contributors ~~~~~~~~~~~~ * Naman Priyadarshi (:ghuser:`Naman-Priyadarshi`) +* Chencheng Luo (:ghuser:`roger-lcc`) From 3c508d53ebca0611b577a3f1bcda8c4531dcc20b Mon Sep 17 00:00:00 2001 From: roger-lcc Date: Fri, 15 Apr 2022 23:37:18 +0800 Subject: [PATCH 02/10] Improved benchmark in solarposition.py --- docs/sphinx/source/whatsnew/v0.9.2.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sphinx/source/whatsnew/v0.9.2.rst b/docs/sphinx/source/whatsnew/v0.9.2.rst index af1ba98a1d..f676bde632 100644 --- a/docs/sphinx/source/whatsnew/v0.9.2.rst +++ b/docs/sphinx/source/whatsnew/v0.9.2.rst @@ -23,7 +23,7 @@ Documentation Benchmarking ~~~~~~~~~~~~~ * Updated version of numba in asv.conf from 0.36.1 to 0.40.0 to solve numba/numpy conflict. (:issue:`1439`, :pull:`1440`) -* Improved the benchmark in solarposition.py (:issue:`1441`) +* Improved the benchmark in solarposition.py (:issue:`1441`, :pull:`1443`) Requirements ~~~~~~~~~~~~ From 981aa5e231e1c1b16f62fde410642161844e2945 Mon Sep 17 00:00:00 2001 From: roger-lcc Date: Sun, 17 Apr 2022 22:19:37 +0800 Subject: [PATCH 03/10] improved benchmark in solarposition.py --- benchmarks/benchmarks/solarposition.py | 43 +++++++++++++++++--------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/benchmarks/benchmarks/solarposition.py b/benchmarks/benchmarks/solarposition.py index a2bffd5d3e..01205b558b 100644 --- a/benchmarks/benchmarks/solarposition.py +++ b/benchmarks/benchmarks/solarposition.py @@ -21,11 +21,16 @@ class SolarPositionSlow: param_names = ['ndays'] def setup(self, ndays): - self.times_localized = pd.date_range(start='20180601', freq='1min', - periods=1440*ndays, tz='Etc/GMT+7') + self.times = pd.date_range(start='20180601', freq='1min', + periods=1440 * ndays) + self.times_localized = self.times.tz_localize('Etc/GMT+7') self.lat = 35.1 self.lon = -106.6 + # GH 512 + # def time_ephemeris(self, ndays): + # solarposition.ephemeris(self.times, self.lat, self.lon) + # GH 512 def time_ephemeris_localized(self, ndays): solarposition.ephemeris(self.times_localized, self.lat, self.lon) @@ -40,10 +45,11 @@ def time_nrel_earthsun_distance(self, ndays): solarposition.nrel_earthsun_distance(self.times_localized) def time_pyephem_earthsun_distance(self, ndays): - solarposition.pyephem_earthsun_distance((self.times_localized)) + solarposition.pyephem_earthsun_distance(self.times_localized) def time_get_solarposition(self, ndays): - solarposition.get_solarposition(self.times_localized, self.lat, self.lon) + solarposition.get_solarposition(self.times_localized, + self.lat, self.lon) class SolarPositionFast: @@ -59,22 +65,29 @@ def setup(self, ndays): def time_sun_rise_set_transit_geometric_full_comparison(self, ndays): dayofyear = self.times_daily.dayofyear declination = solarposition.declination_spencer71(dayofyear) - equation_of_time = solarposition.equation_of_time_spencer71(dayofyear) + equationoftime = solarposition.equation_of_time_spencer71(dayofyear) solarposition.sun_rise_set_transit_geometric( self.times_daily, self.lat, self.lon, declination, - equation_of_time) + equationoftime) - def time__local_times_from_hours_since_midnight_full_comparison(self, ndays): - equation_of_time = solarposition.equation_of_time_spencer71(self.times_daily.dayofyear) - hourangle = solarposition.hour_angle(self.times_daily, self.lon, equation_of_time) - solarposition._hour_angle_to_hours(self.times_daily, hourangle, self.lon, equation_of_time) + def time__local_times_from_hours_full_comparison(self, ndays): + dayofyear = self.times_daily.dayofyear + equationoftime = solarposition.equation_of_time_spencer71(dayofyear) + hourangle = solarposition.hour_angle(self.times_daily, + self.lon, equationoftime) + solarposition._hour_angle_to_hours(self.times_daily, + hourangle, self.lon, equationoftime) def time_solar_azimuth_analytical_full_comparison(self, nadys): - equation_of_time = solarposition.equation_of_time_spencer71(self.times_daily.dayofyear) - declination = solarposition.declination_spencer71(self.times_daily.dayofyear) - hourangle = solarposition.hour_angle(self.times_daily, self.lon, equation_of_time) - zenith = solarposition.solar_zenith_analytical(self.lat, hourangle, declination) - solarposition.solar_azimuth_analytical(self.lat, hourangle, declination, zenith) + dayofyear = self.times_daily.dayofyear + equationoftime = solarposition.equation_of_time_spencer71(dayofyear) + declination = solarposition.declination_spencer71(dayofyear) + hourangle = solarposition.hour_angle(self.times_daily, + self.lon, equationoftime) + zenith = solarposition.solar_zenith_analytical(self.lat, + hourangle, declination) + solarposition.solar_azimuth_analytical(self.lat, + hourangle, declination, zenith) def time_calculate_simple_day_angle(self, ndays): solarposition._calculate_simple_day_angle(self.times_daily.dayofyear) From 3c248c3837d9d2ecc51aa17869e9f6c8bf99ddb9 Mon Sep 17 00:00:00 2001 From: roger-lcc Date: Tue, 19 Apr 2022 15:55:37 +0800 Subject: [PATCH 04/10] deleting useless benchmark --- benchmarks/benchmarks/solarposition.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/benchmarks/benchmarks/solarposition.py b/benchmarks/benchmarks/solarposition.py index 01205b558b..53afa12dc3 100644 --- a/benchmarks/benchmarks/solarposition.py +++ b/benchmarks/benchmarks/solarposition.py @@ -27,10 +27,6 @@ def setup(self, ndays): self.lat = 35.1 self.lon = -106.6 - # GH 512 - # def time_ephemeris(self, ndays): - # solarposition.ephemeris(self.times, self.lat, self.lon) - # GH 512 def time_ephemeris_localized(self, ndays): solarposition.ephemeris(self.times_localized, self.lat, self.lon) @@ -47,10 +43,6 @@ def time_nrel_earthsun_distance(self, ndays): def time_pyephem_earthsun_distance(self, ndays): solarposition.pyephem_earthsun_distance(self.times_localized) - def time_get_solarposition(self, ndays): - solarposition.get_solarposition(self.times_localized, - self.lat, self.lon) - class SolarPositionFast: params = [1, 365 * 10, 365 * 100] From 221bc5576f56ee44ab4a5ec5dcad23411b93781c Mon Sep 17 00:00:00 2001 From: roger-lcc Date: Tue, 19 Apr 2022 16:47:47 +0800 Subject: [PATCH 05/10] deleting useless benchmark --- benchmarks/benchmarks/solarposition.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/benchmarks/solarposition.py b/benchmarks/benchmarks/solarposition.py index 53afa12dc3..1884040c6a 100644 --- a/benchmarks/benchmarks/solarposition.py +++ b/benchmarks/benchmarks/solarposition.py @@ -22,7 +22,7 @@ class SolarPositionSlow: def setup(self, ndays): self.times = pd.date_range(start='20180601', freq='1min', - periods=1440 * ndays) + periods=1440*ndays) self.times_localized = self.times.tz_localize('Etc/GMT+7') self.lat = 35.1 self.lon = -106.6 From 98be326e6b711499cd91b25c780cd7af00e893e1 Mon Sep 17 00:00:00 2001 From: roger-lcc Date: Tue, 19 Apr 2022 17:40:43 +0800 Subject: [PATCH 06/10] change for wrong checks --- benchmarks/benchmarks/solarposition.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/benchmarks/benchmarks/solarposition.py b/benchmarks/benchmarks/solarposition.py index 1884040c6a..f80f7c12a7 100644 --- a/benchmarks/benchmarks/solarposition.py +++ b/benchmarks/benchmarks/solarposition.py @@ -21,9 +21,8 @@ class SolarPositionSlow: param_names = ['ndays'] def setup(self, ndays): - self.times = pd.date_range(start='20180601', freq='1min', - periods=1440*ndays) - self.times_localized = self.times.tz_localize('Etc/GMT+7') + self.times_localized = pd.date_range(start='20180601', freq='1min', + periods=1440 * ndays, tz='Etc/GMT+7') self.lat = 35.1 self.lon = -106.6 @@ -96,10 +95,10 @@ def time_sun_rise_set_transit_spa(self, ndays): def time_sun_rise_set_transit_geometric_full_comparison(self, ndays): dayofyear = self.times_daily.dayofyear declination = solarposition.declination_spencer71(dayofyear) - equation_of_time = solarposition.equation_of_time_spencer71(dayofyear) + equationoftime = solarposition.equation_of_time_spencer71(dayofyear) solarposition.sun_rise_set_transit_geometric( self.times_daily, self.lat, self.lon, declination, - equation_of_time) + equationoftime) def time_sun_rise_set_transit_ephem(self, ndays): solarposition.sun_rise_set_transit_ephem( From 9480d41980f6af772caf4908a3bf84b40d2e5469 Mon Sep 17 00:00:00 2001 From: roger-lcc Date: Tue, 19 Apr 2022 17:48:01 +0800 Subject: [PATCH 07/10] change for stickler-ci --- benchmarks/benchmarks/solarposition.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/benchmarks/benchmarks/solarposition.py b/benchmarks/benchmarks/solarposition.py index f80f7c12a7..71bc307076 100644 --- a/benchmarks/benchmarks/solarposition.py +++ b/benchmarks/benchmarks/solarposition.py @@ -21,8 +21,9 @@ class SolarPositionSlow: param_names = ['ndays'] def setup(self, ndays): - self.times_localized = pd.date_range(start='20180601', freq='1min', - periods=1440 * ndays, tz='Etc/GMT+7') + self.times_localized = pd.date_range( + start='20180601', freq='1min', + periods=1440 * ndays, tz='Etc/GMT+7') self.lat = 35.1 self.lon = -106.6 From 68b280008d7b8fcb8f3ce2fffd287170de4f8181 Mon Sep 17 00:00:00 2001 From: roger-lcc Date: Tue, 19 Apr 2022 19:44:46 +0800 Subject: [PATCH 08/10] change for Test_conda_linux --- benchmarks/benchmarks/solarposition.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/benchmarks/benchmarks/solarposition.py b/benchmarks/benchmarks/solarposition.py index 71bc307076..10638099ae 100644 --- a/benchmarks/benchmarks/solarposition.py +++ b/benchmarks/benchmarks/solarposition.py @@ -21,9 +21,9 @@ class SolarPositionSlow: param_names = ['ndays'] def setup(self, ndays): - self.times_localized = pd.date_range( - start='20180601', freq='1min', - periods=1440 * ndays, tz='Etc/GMT+7') + self.times = pd.date_range(start='20180601', freq='1min', + periods=1440 * ndays) + self.times_localized = self.times.tz_localize('Etc/GMT+7') self.lat = 35.1 self.lon = -106.6 @@ -96,10 +96,10 @@ def time_sun_rise_set_transit_spa(self, ndays): def time_sun_rise_set_transit_geometric_full_comparison(self, ndays): dayofyear = self.times_daily.dayofyear declination = solarposition.declination_spencer71(dayofyear) - equationoftime = solarposition.equation_of_time_spencer71(dayofyear) + equation_of_time = solarposition.equation_of_time_spencer71(dayofyear) solarposition.sun_rise_set_transit_geometric( self.times_daily, self.lat, self.lon, declination, - equationoftime) + equation_of_time) def time_sun_rise_set_transit_ephem(self, ndays): solarposition.sun_rise_set_transit_ephem( @@ -125,4 +125,4 @@ def time_calc_time(self): solarposition.calc_time( self.start, self.end, self.lat, self.lon, self.attribute, self.value - ) + ) \ No newline at end of file From ad3b469ef319dc0c8972a002c774e9874945c53d Mon Sep 17 00:00:00 2001 From: roger-lcc Date: Tue, 19 Apr 2022 21:39:23 +0800 Subject: [PATCH 09/10] deleting useless benchmark --- benchmarks/benchmarks/solarposition.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/benchmarks/benchmarks/solarposition.py b/benchmarks/benchmarks/solarposition.py index 10638099ae..71bc307076 100644 --- a/benchmarks/benchmarks/solarposition.py +++ b/benchmarks/benchmarks/solarposition.py @@ -21,9 +21,9 @@ class SolarPositionSlow: param_names = ['ndays'] def setup(self, ndays): - self.times = pd.date_range(start='20180601', freq='1min', - periods=1440 * ndays) - self.times_localized = self.times.tz_localize('Etc/GMT+7') + self.times_localized = pd.date_range( + start='20180601', freq='1min', + periods=1440 * ndays, tz='Etc/GMT+7') self.lat = 35.1 self.lon = -106.6 @@ -96,10 +96,10 @@ def time_sun_rise_set_transit_spa(self, ndays): def time_sun_rise_set_transit_geometric_full_comparison(self, ndays): dayofyear = self.times_daily.dayofyear declination = solarposition.declination_spencer71(dayofyear) - equation_of_time = solarposition.equation_of_time_spencer71(dayofyear) + equationoftime = solarposition.equation_of_time_spencer71(dayofyear) solarposition.sun_rise_set_transit_geometric( self.times_daily, self.lat, self.lon, declination, - equation_of_time) + equationoftime) def time_sun_rise_set_transit_ephem(self, ndays): solarposition.sun_rise_set_transit_ephem( @@ -125,4 +125,4 @@ def time_calc_time(self): solarposition.calc_time( self.start, self.end, self.lat, self.lon, self.attribute, self.value - ) \ No newline at end of file + ) From 6d26829be13f5a8a6e6c99be6b6c11c06d04e592 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Fri, 11 Nov 2022 12:10:17 -0500 Subject: [PATCH 10/10] move whatsnew entry from 0.9.2 to 0.9.4 --- docs/sphinx/source/whatsnew/v0.9.2.rst | 1 - docs/sphinx/source/whatsnew/v0.9.4.rst | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/sphinx/source/whatsnew/v0.9.2.rst b/docs/sphinx/source/whatsnew/v0.9.2.rst index b7aca2c7be..463baf29f1 100644 --- a/docs/sphinx/source/whatsnew/v0.9.2.rst +++ b/docs/sphinx/source/whatsnew/v0.9.2.rst @@ -56,7 +56,6 @@ Documentation Benchmarking ~~~~~~~~~~~~~ * Updated version of numba in asv.conf from 0.36.1 to 0.40.0 to solve numba/numpy conflict. (:issue:`1439`, :pull:`1440`) -* Improved the benchmark in solarposition.py (:issue:`1441`, :pull:`1443`) * Added benchmarks for the `pvlib.scaling` module (:pull:`1445`) * Added a basic CI asv check (:issue:`1446`, :pull:`1454`) * Added benchmarks for the ``pvlib.scaling`` module. (:pull:`1445`) diff --git a/docs/sphinx/source/whatsnew/v0.9.4.rst b/docs/sphinx/source/whatsnew/v0.9.4.rst index 8a67c201f0..c1aaf28a86 100644 --- a/docs/sphinx/source/whatsnew/v0.9.4.rst +++ b/docs/sphinx/source/whatsnew/v0.9.4.rst @@ -34,6 +34,7 @@ Documentation Benchmarking ~~~~~~~~~~~~~ * Removed ``time_tracker_singleaxis`` function from tracking.py (:issue:`1508`, :pull:`1535`) +* More comprehensive benchmarking for solarposition.py (:issue:`1441`, :pull:`1443`) Requirements @@ -48,3 +49,4 @@ Contributors * Marcus Boumans (:ghuser:`bowie2211`) * Karel De Brabandere (:ghuser:`kdebrab`) * Naman Priyadarshi (:ghuser:`Naman-Priyadarshi`) +* Chencheng Luo (:ghuser:`roger-lcc`)