From 0264ea242a4d64ccc52e9887c603484601e42946 Mon Sep 17 00:00:00 2001 From: roger-lcc Date: Thu, 21 Apr 2022 13:33:19 +0800 Subject: [PATCH 01/46] test --- benchmarks/benchmarks/solarposition.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/benchmarks/benchmarks/solarposition.py b/benchmarks/benchmarks/solarposition.py index cddf8bed..71bc3070 100644 --- a/benchmarks/benchmarks/solarposition.py +++ b/benchmarks/benchmarks/solarposition.py @@ -101,9 +101,9 @@ def time_sun_rise_set_transit_geometric_full_comparison(self, ndays): self.times_daily, self.lat, self.lon, declination, equationoftime) - # 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_ephem(self, ndays): + solarposition.sun_rise_set_transit_ephem( + self.times_daily, self.lat, self.lon) class SolarPositionCalcTime: From 9964ff3a565a495a6fd7197cbded24f1304cf010 Mon Sep 17 00:00:00 2001 From: roger-lcc Date: Thu, 21 Apr 2022 13:44:11 +0800 Subject: [PATCH 02/46] test --- benchmarks/benchmarks/soiling.py | 3 + benchmarks/benchmarks/solarposition.py | 256 +++++++++---------- benchmarks/benchmarks/solarposition_numba.py | 92 +++---- 3 files changed, 177 insertions(+), 174 deletions(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index 8d364925..61cec43b 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -20,6 +20,9 @@ def time_hsu(self, ndays): cleaningthreshold = 0.5 soiling.hsu(self.rainfall, cleaningthreshold, self.tilt, self.pm2_5, self.pm10) + + def time_test(self, nadys): + soiling.hsu(self.rainfall) def time_kimber(self, ndays): cleaningthreshold = 25 diff --git a/benchmarks/benchmarks/solarposition.py b/benchmarks/benchmarks/solarposition.py index 71bc3070..76ac5d44 100644 --- a/benchmarks/benchmarks/solarposition.py +++ b/benchmarks/benchmarks/solarposition.py @@ -1,128 +1,128 @@ -""" -ASV benchmarks for solarposition.py -""" - -import datetime -import pandas as pd -import pvlib -from pvlib import solarposition - -from pkg_resources import parse_version - - -if parse_version(pvlib.__version__) >= parse_version('0.6.1'): - sun_rise_set_transit_spa = solarposition.sun_rise_set_transit_spa -else: - sun_rise_set_transit_spa = solarposition.get_sun_rise_set_transit - - -class SolarPositionSlow: - params = [1, 10, 100] # number of days - 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.lat = 35.1 - self.lon = -106.6 - - # GH 512 - def time_ephemeris_localized(self, ndays): - solarposition.ephemeris(self.times_localized, self.lat, self.lon) - - def time_spa_python(self, ndays): - solarposition.spa_python(self.times_localized, self.lat, self.lon) - - 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) - - -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) - equationoftime = solarposition.equation_of_time_spencer71(dayofyear) - solarposition.sun_rise_set_transit_geometric( - self.times_daily, self.lat, self.lon, declination, - equationoftime) - - 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): - 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) - - 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_geometric_full_comparison(self, ndays): - dayofyear = self.times_daily.dayofyear - declination = solarposition.declination_spencer71(dayofyear) - equationoftime = solarposition.equation_of_time_spencer71(dayofyear) - solarposition.sun_rise_set_transit_geometric( - self.times_daily, self.lat, self.lon, declination, - equationoftime) - - def time_sun_rise_set_transit_ephem(self, ndays): - solarposition.sun_rise_set_transit_ephem( - self.times_daily, self.lat, self.lon) - - -class SolarPositionCalcTime: - - def setup(self): - # test calc_time for finding times at which sun is 3 degrees - # above the horizon. - # Tucson 2020-09-14 sunrise at 6:08 AM MST, 13:08 UTC - # according to google. - self.start = datetime.datetime(2020, 9, 14, 12) - self.end = datetime.datetime(2020, 9, 14, 15) - self.value = 0.05235987755982988 - self.lat = 32.2 - self.lon = -110.9 - self.attribute = 'alt' - - def time_calc_time(self): - # datetime.datetime(2020, 9, 14, 13, 24, 13, 861913, tzinfo=) - solarposition.calc_time( - self.start, self.end, self.lat, self.lon, self.attribute, - self.value - ) +# """ +# ASV benchmarks for solarposition.py +# """ +# +# import datetime +# import pandas as pd +# import pvlib +# from pvlib import solarposition +# +# from pkg_resources import parse_version +# +# +# if parse_version(pvlib.__version__) >= parse_version('0.6.1'): +# sun_rise_set_transit_spa = solarposition.sun_rise_set_transit_spa +# else: +# sun_rise_set_transit_spa = solarposition.get_sun_rise_set_transit +# +# +# class SolarPositionSlow: +# params = [1, 10, 100] # number of days +# 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.lat = 35.1 +# self.lon = -106.6 +# +# # GH 512 +# def time_ephemeris_localized(self, ndays): +# solarposition.ephemeris(self.times_localized, self.lat, self.lon) +# +# def time_spa_python(self, ndays): +# solarposition.spa_python(self.times_localized, self.lat, self.lon) +# +# 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) +# +# +# 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) +# equationoftime = solarposition.equation_of_time_spencer71(dayofyear) +# solarposition.sun_rise_set_transit_geometric( +# self.times_daily, self.lat, self.lon, declination, +# equationoftime) +# +# 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): +# 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) +# +# 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_geometric_full_comparison(self, ndays): +# dayofyear = self.times_daily.dayofyear +# declination = solarposition.declination_spencer71(dayofyear) +# equationoftime = solarposition.equation_of_time_spencer71(dayofyear) +# solarposition.sun_rise_set_transit_geometric( +# self.times_daily, self.lat, self.lon, declination, +# equationoftime) +# +# def time_sun_rise_set_transit_ephem(self, ndays): +# solarposition.sun_rise_set_transit_ephem( +# self.times_daily, self.lat, self.lon) +# +# +# class SolarPositionCalcTime: +# +# def setup(self): +# # test calc_time for finding times at which sun is 3 degrees +# # above the horizon. +# # Tucson 2020-09-14 sunrise at 6:08 AM MST, 13:08 UTC +# # according to google. +# self.start = datetime.datetime(2020, 9, 14, 12) +# self.end = datetime.datetime(2020, 9, 14, 15) +# self.value = 0.05235987755982988 +# self.lat = 32.2 +# self.lon = -110.9 +# self.attribute = 'alt' +# +# def time_calc_time(self): +# # datetime.datetime(2020, 9, 14, 13, 24, 13, 861913, tzinfo=) +# solarposition.calc_time( +# self.start, self.end, self.lat, self.lon, self.attribute, +# self.value +# ) diff --git a/benchmarks/benchmarks/solarposition_numba.py b/benchmarks/benchmarks/solarposition_numba.py index bcadfd18..44416f6f 100644 --- a/benchmarks/benchmarks/solarposition_numba.py +++ b/benchmarks/benchmarks/solarposition_numba.py @@ -1,46 +1,46 @@ -"""ASV benchmarks for solarposition.py using numba. - -We use a separate module so that we can control the pvlib import process -using an environment variable. This will force pvlib to compile the numba -code during setup. - -Try to keep relevant sections in sync with benchmarks/solarposition.py -""" - -from pkg_resources import parse_version -import pandas as pd - -import os -os.environ['PVLIB_USE_NUMBA'] = '1' - - -import pvlib # NOQA: E402 -from pvlib import solarposition # NOQA: E402 - - -if parse_version(pvlib.__version__) >= parse_version('0.6.1'): - sun_rise_set_transit_spa = solarposition.sun_rise_set_transit_spa -else: - sun_rise_set_transit_spa = solarposition.get_sun_rise_set_transit - - -class SolarPositionNumba: - 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.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_spa_python(self, ndays): - solarposition.spa_python( - self.times_localized, self.lat, self.lon, how='numba') - - def time_sun_rise_set_transit_spa(self, ndays): - sun_rise_set_transit_spa( - self.times_daily, self.lat, self.lon, how='numba') +# """ASV benchmarks for solarposition.py using numba. +# +# We use a separate module so that we can control the pvlib import process +# using an environment variable. This will force pvlib to compile the numba +# code during setup. +# +# Try to keep relevant sections in sync with benchmarks/solarposition.py +# """ +# +# from pkg_resources import parse_version +# import pandas as pd +# +# import os +# os.environ['PVLIB_USE_NUMBA'] = '1' +# +# +# import pvlib # NOQA: E402 +# from pvlib import solarposition # NOQA: E402 +# +# +# if parse_version(pvlib.__version__) >= parse_version('0.6.1'): +# sun_rise_set_transit_spa = solarposition.sun_rise_set_transit_spa +# else: +# sun_rise_set_transit_spa = solarposition.get_sun_rise_set_transit +# +# +# class SolarPositionNumba: +# 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.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_spa_python(self, ndays): +# solarposition.spa_python( +# self.times_localized, self.lat, self.lon, how='numba') +# +# def time_sun_rise_set_transit_spa(self, ndays): +# sun_rise_set_transit_spa( +# self.times_daily, self.lat, self.lon, how='numba') From 614c3d4c836d3b948def4895f8289e1e2fb2b931 Mon Sep 17 00:00:00 2001 From: roger-lcc Date: Thu, 21 Apr 2022 16:15:23 +0800 Subject: [PATCH 03/46] test --- benchmarks/benchmarks/soiling.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index 61cec43b..f489ea4f 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -20,9 +20,9 @@ def time_hsu(self, ndays): cleaningthreshold = 0.5 soiling.hsu(self.rainfall, cleaningthreshold, self.tilt, self.pm2_5, self.pm10) - + def time_test(self, nadys): - soiling.hsu(self.rainfall) + soiling.hsu(self.rainfall, ) def time_kimber(self, ndays): cleaningthreshold = 25 From 10aedb00d379b4e2e744e4e965855fb425f6c4dd Mon Sep 17 00:00:00 2001 From: roger-lcc Date: Thu, 21 Apr 2022 16:35:20 +0800 Subject: [PATCH 04/46] test --- benchmarks/benchmarks/soiling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index f489ea4f..b49004c7 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -22,7 +22,7 @@ def time_hsu(self, ndays): self.tilt, self.pm2_5, self.pm10) def time_test(self, nadys): - soiling.hsu(self.rainfall, ) + soiling.hsu(self.rainfall) def time_kimber(self, ndays): cleaningthreshold = 25 From 6816bbb4a396800eba53541c2625a5fd050c21be Mon Sep 17 00:00:00 2001 From: roger-lcc Date: Thu, 21 Apr 2022 16:48:29 +0800 Subject: [PATCH 05/46] test --- benchmarks/benchmarks/soiling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index b49004c7..3d903e59 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -22,7 +22,7 @@ def time_hsu(self, ndays): self.tilt, self.pm2_5, self.pm10) def time_test(self, nadys): - soiling.hsu(self.rainfall) + soiling.hsu(self.rainfall,) def time_kimber(self, ndays): cleaningthreshold = 25 From 476a7aa326ee137fa089dccde8f11056c364a763 Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Fri, 22 Apr 2022 22:19:47 +0800 Subject: [PATCH 06/46] test --- benchmarks/benchmarks/soiling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index 3d903e59..b49004c7 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -22,7 +22,7 @@ def time_hsu(self, ndays): self.tilt, self.pm2_5, self.pm10) def time_test(self, nadys): - soiling.hsu(self.rainfall,) + soiling.hsu(self.rainfall) def time_kimber(self, ndays): cleaningthreshold = 25 From 61ae7210f49b9d4f11845a411a9804fe6c41c3c8 Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Fri, 22 Apr 2022 22:32:02 +0800 Subject: [PATCH 07/46] test --- benchmarks/benchmarks/soiling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index b49004c7..f489ea4f 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -22,7 +22,7 @@ def time_hsu(self, ndays): self.tilt, self.pm2_5, self.pm10) def time_test(self, nadys): - soiling.hsu(self.rainfall) + soiling.hsu(self.rainfall, ) def time_kimber(self, ndays): cleaningthreshold = 25 From 634bef70d2a9e4847221290a78a31b36577eb137 Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Fri, 22 Apr 2022 22:43:35 +0800 Subject: [PATCH 08/46] test --- benchmarks/benchmarks/soiling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index f489ea4f..b49004c7 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -22,7 +22,7 @@ def time_hsu(self, ndays): self.tilt, self.pm2_5, self.pm10) def time_test(self, nadys): - soiling.hsu(self.rainfall, ) + soiling.hsu(self.rainfall) def time_kimber(self, ndays): cleaningthreshold = 25 From af81912c7f5170f6073d81a41e621481eab1c6df Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Fri, 22 Apr 2022 23:32:10 +0800 Subject: [PATCH 09/46] test --- benchmarks/benchmarks/soiling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index b49004c7..f489ea4f 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -22,7 +22,7 @@ def time_hsu(self, ndays): self.tilt, self.pm2_5, self.pm10) def time_test(self, nadys): - soiling.hsu(self.rainfall) + soiling.hsu(self.rainfall, ) def time_kimber(self, ndays): cleaningthreshold = 25 From e9eee8ea3e38afa20afd85dc7e3b99ba035e0315 Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Fri, 22 Apr 2022 23:39:18 +0800 Subject: [PATCH 10/46] test --- benchmarks/benchmarks/soiling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index f489ea4f..b49004c7 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -22,7 +22,7 @@ def time_hsu(self, ndays): self.tilt, self.pm2_5, self.pm10) def time_test(self, nadys): - soiling.hsu(self.rainfall, ) + soiling.hsu(self.rainfall) def time_kimber(self, ndays): cleaningthreshold = 25 From c6feaed2411283b2137344c49f136b299ea7763b Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Fri, 22 Apr 2022 23:51:25 +0800 Subject: [PATCH 11/46] test --- benchmarks/benchmarks/soiling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index b49004c7..f489ea4f 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -22,7 +22,7 @@ def time_hsu(self, ndays): self.tilt, self.pm2_5, self.pm10) def time_test(self, nadys): - soiling.hsu(self.rainfall) + soiling.hsu(self.rainfall, ) def time_kimber(self, ndays): cleaningthreshold = 25 From e48929f70c2ceb99958fc7b1422f04abad12387a Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Sat, 23 Apr 2022 00:00:49 +0800 Subject: [PATCH 12/46] test --- benchmarks/benchmarks/soiling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index f489ea4f..b49004c7 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -22,7 +22,7 @@ def time_hsu(self, ndays): self.tilt, self.pm2_5, self.pm10) def time_test(self, nadys): - soiling.hsu(self.rainfall, ) + soiling.hsu(self.rainfall) def time_kimber(self, ndays): cleaningthreshold = 25 From ab03f7498daab2dcd99c576191bc4ddb5f719815 Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Sat, 23 Apr 2022 00:13:10 +0800 Subject: [PATCH 13/46] test --- benchmarks/benchmarks/soiling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index b49004c7..f489ea4f 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -22,7 +22,7 @@ def time_hsu(self, ndays): self.tilt, self.pm2_5, self.pm10) def time_test(self, nadys): - soiling.hsu(self.rainfall) + soiling.hsu(self.rainfall, ) def time_kimber(self, ndays): cleaningthreshold = 25 From 8cba5e3331d7d580c562f9f4465a3d1a576779ed Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Sat, 23 Apr 2022 00:17:24 +0800 Subject: [PATCH 14/46] test --- benchmarks/benchmarks/soiling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index f489ea4f..b49004c7 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -22,7 +22,7 @@ def time_hsu(self, ndays): self.tilt, self.pm2_5, self.pm10) def time_test(self, nadys): - soiling.hsu(self.rainfall, ) + soiling.hsu(self.rainfall) def time_kimber(self, ndays): cleaningthreshold = 25 From 527ebb2e08a9a38c3161dbe2be5f62dc24cee1c1 Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Sat, 23 Apr 2022 00:21:49 +0800 Subject: [PATCH 15/46] test --- benchmarks/benchmarks/soiling.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index b49004c7..8d364925 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -21,9 +21,6 @@ def time_hsu(self, ndays): soiling.hsu(self.rainfall, cleaningthreshold, self.tilt, self.pm2_5, self.pm10) - def time_test(self, nadys): - soiling.hsu(self.rainfall) - def time_kimber(self, ndays): cleaningthreshold = 25 soiling.kimber(self.rainfall, cleaningthreshold) \ No newline at end of file From 7aa26c9a49dea6c67de813cbcc4ce9bcc8caf43e Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Sat, 23 Apr 2022 00:38:55 +0800 Subject: [PATCH 16/46] test --- benchmarks/benchmarks/solarposition.py | 256 +++++++++---------- benchmarks/benchmarks/solarposition_numba.py | 92 +++---- 2 files changed, 174 insertions(+), 174 deletions(-) diff --git a/benchmarks/benchmarks/solarposition.py b/benchmarks/benchmarks/solarposition.py index 76ac5d44..71bc3070 100644 --- a/benchmarks/benchmarks/solarposition.py +++ b/benchmarks/benchmarks/solarposition.py @@ -1,128 +1,128 @@ -# """ -# ASV benchmarks for solarposition.py -# """ -# -# import datetime -# import pandas as pd -# import pvlib -# from pvlib import solarposition -# -# from pkg_resources import parse_version -# -# -# if parse_version(pvlib.__version__) >= parse_version('0.6.1'): -# sun_rise_set_transit_spa = solarposition.sun_rise_set_transit_spa -# else: -# sun_rise_set_transit_spa = solarposition.get_sun_rise_set_transit -# -# -# class SolarPositionSlow: -# params = [1, 10, 100] # number of days -# 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.lat = 35.1 -# self.lon = -106.6 -# -# # GH 512 -# def time_ephemeris_localized(self, ndays): -# solarposition.ephemeris(self.times_localized, self.lat, self.lon) -# -# def time_spa_python(self, ndays): -# solarposition.spa_python(self.times_localized, self.lat, self.lon) -# -# 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) -# -# -# 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) -# equationoftime = solarposition.equation_of_time_spencer71(dayofyear) -# solarposition.sun_rise_set_transit_geometric( -# self.times_daily, self.lat, self.lon, declination, -# equationoftime) -# -# 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): -# 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) -# -# 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_geometric_full_comparison(self, ndays): -# dayofyear = self.times_daily.dayofyear -# declination = solarposition.declination_spencer71(dayofyear) -# equationoftime = solarposition.equation_of_time_spencer71(dayofyear) -# solarposition.sun_rise_set_transit_geometric( -# self.times_daily, self.lat, self.lon, declination, -# equationoftime) -# -# def time_sun_rise_set_transit_ephem(self, ndays): -# solarposition.sun_rise_set_transit_ephem( -# self.times_daily, self.lat, self.lon) -# -# -# class SolarPositionCalcTime: -# -# def setup(self): -# # test calc_time for finding times at which sun is 3 degrees -# # above the horizon. -# # Tucson 2020-09-14 sunrise at 6:08 AM MST, 13:08 UTC -# # according to google. -# self.start = datetime.datetime(2020, 9, 14, 12) -# self.end = datetime.datetime(2020, 9, 14, 15) -# self.value = 0.05235987755982988 -# self.lat = 32.2 -# self.lon = -110.9 -# self.attribute = 'alt' -# -# def time_calc_time(self): -# # datetime.datetime(2020, 9, 14, 13, 24, 13, 861913, tzinfo=) -# solarposition.calc_time( -# self.start, self.end, self.lat, self.lon, self.attribute, -# self.value -# ) +""" +ASV benchmarks for solarposition.py +""" + +import datetime +import pandas as pd +import pvlib +from pvlib import solarposition + +from pkg_resources import parse_version + + +if parse_version(pvlib.__version__) >= parse_version('0.6.1'): + sun_rise_set_transit_spa = solarposition.sun_rise_set_transit_spa +else: + sun_rise_set_transit_spa = solarposition.get_sun_rise_set_transit + + +class SolarPositionSlow: + params = [1, 10, 100] # number of days + 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.lat = 35.1 + self.lon = -106.6 + + # GH 512 + def time_ephemeris_localized(self, ndays): + solarposition.ephemeris(self.times_localized, self.lat, self.lon) + + def time_spa_python(self, ndays): + solarposition.spa_python(self.times_localized, self.lat, self.lon) + + 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) + + +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) + equationoftime = solarposition.equation_of_time_spencer71(dayofyear) + solarposition.sun_rise_set_transit_geometric( + self.times_daily, self.lat, self.lon, declination, + equationoftime) + + 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): + 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) + + 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_geometric_full_comparison(self, ndays): + dayofyear = self.times_daily.dayofyear + declination = solarposition.declination_spencer71(dayofyear) + equationoftime = solarposition.equation_of_time_spencer71(dayofyear) + solarposition.sun_rise_set_transit_geometric( + self.times_daily, self.lat, self.lon, declination, + equationoftime) + + def time_sun_rise_set_transit_ephem(self, ndays): + solarposition.sun_rise_set_transit_ephem( + self.times_daily, self.lat, self.lon) + + +class SolarPositionCalcTime: + + def setup(self): + # test calc_time for finding times at which sun is 3 degrees + # above the horizon. + # Tucson 2020-09-14 sunrise at 6:08 AM MST, 13:08 UTC + # according to google. + self.start = datetime.datetime(2020, 9, 14, 12) + self.end = datetime.datetime(2020, 9, 14, 15) + self.value = 0.05235987755982988 + self.lat = 32.2 + self.lon = -110.9 + self.attribute = 'alt' + + def time_calc_time(self): + # datetime.datetime(2020, 9, 14, 13, 24, 13, 861913, tzinfo=) + solarposition.calc_time( + self.start, self.end, self.lat, self.lon, self.attribute, + self.value + ) diff --git a/benchmarks/benchmarks/solarposition_numba.py b/benchmarks/benchmarks/solarposition_numba.py index 44416f6f..bcadfd18 100644 --- a/benchmarks/benchmarks/solarposition_numba.py +++ b/benchmarks/benchmarks/solarposition_numba.py @@ -1,46 +1,46 @@ -# """ASV benchmarks for solarposition.py using numba. -# -# We use a separate module so that we can control the pvlib import process -# using an environment variable. This will force pvlib to compile the numba -# code during setup. -# -# Try to keep relevant sections in sync with benchmarks/solarposition.py -# """ -# -# from pkg_resources import parse_version -# import pandas as pd -# -# import os -# os.environ['PVLIB_USE_NUMBA'] = '1' -# -# -# import pvlib # NOQA: E402 -# from pvlib import solarposition # NOQA: E402 -# -# -# if parse_version(pvlib.__version__) >= parse_version('0.6.1'): -# sun_rise_set_transit_spa = solarposition.sun_rise_set_transit_spa -# else: -# sun_rise_set_transit_spa = solarposition.get_sun_rise_set_transit -# -# -# class SolarPositionNumba: -# 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.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_spa_python(self, ndays): -# solarposition.spa_python( -# self.times_localized, self.lat, self.lon, how='numba') -# -# def time_sun_rise_set_transit_spa(self, ndays): -# sun_rise_set_transit_spa( -# self.times_daily, self.lat, self.lon, how='numba') +"""ASV benchmarks for solarposition.py using numba. + +We use a separate module so that we can control the pvlib import process +using an environment variable. This will force pvlib to compile the numba +code during setup. + +Try to keep relevant sections in sync with benchmarks/solarposition.py +""" + +from pkg_resources import parse_version +import pandas as pd + +import os +os.environ['PVLIB_USE_NUMBA'] = '1' + + +import pvlib # NOQA: E402 +from pvlib import solarposition # NOQA: E402 + + +if parse_version(pvlib.__version__) >= parse_version('0.6.1'): + sun_rise_set_transit_spa = solarposition.sun_rise_set_transit_spa +else: + sun_rise_set_transit_spa = solarposition.get_sun_rise_set_transit + + +class SolarPositionNumba: + 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.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_spa_python(self, ndays): + solarposition.spa_python( + self.times_localized, self.lat, self.lon, how='numba') + + def time_sun_rise_set_transit_spa(self, ndays): + sun_rise_set_transit_spa( + self.times_daily, self.lat, self.lon, how='numba') From 83d2ea5a7ed308f895e643e13cf31687d9a865cc Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Sat, 23 Apr 2022 14:11:02 +0800 Subject: [PATCH 17/46] test --- benchmarks/benchmarks/soiling.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index 8d364925..4d828377 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -23,4 +23,8 @@ def time_hsu(self, ndays): def time_kimber(self, ndays): cleaningthreshold = 25 - soiling.kimber(self.rainfall, cleaningthreshold) \ No newline at end of file + soiling.kimber(self.rainfall, cleaningthreshold) + + def time_test(self, ndays): + cleaningthreshold = 0.5 + soiling.hsu(self.rainfall, ) From 09f5af77faeb8681b7127f4714662ab0847c5350 Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Sat, 23 Apr 2022 14:39:58 +0800 Subject: [PATCH 18/46] test --- benchmarks/benchmarks/soiling.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index 4d828377..58453095 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -25,6 +25,6 @@ def time_kimber(self, ndays): cleaningthreshold = 25 soiling.kimber(self.rainfall, cleaningthreshold) - def time_test(self, ndays): - cleaningthreshold = 0.5 - soiling.hsu(self.rainfall, ) + # def time_test(self, ndays): + # cleaningthreshold = 0.5 + # soiling.hsu(self.rainfall, ) From 44ca35e03b97c400557313cf296311c52b04ffed Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Sat, 23 Apr 2022 14:44:28 +0800 Subject: [PATCH 19/46] test --- benchmarks/benchmarks/soiling.py | 1 + 1 file changed, 1 insertion(+) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index 58453095..1cfc5781 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -28,3 +28,4 @@ def time_kimber(self, ndays): # def time_test(self, ndays): # cleaningthreshold = 0.5 # soiling.hsu(self.rainfall, ) + From daaee31f82717f7e44ac352769fe7f5174c03f1c Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Sat, 23 Apr 2022 14:53:02 +0800 Subject: [PATCH 20/46] test --- benchmarks/benchmarks/soiling.py | 1 - 1 file changed, 1 deletion(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index 1cfc5781..58453095 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -28,4 +28,3 @@ def time_kimber(self, ndays): # def time_test(self, ndays): # cleaningthreshold = 0.5 # soiling.hsu(self.rainfall, ) - From 29a255b308cbceb48b7517fd3aa8fe7f14b56e8c Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Sat, 23 Apr 2022 14:58:09 +0800 Subject: [PATCH 21/46] test --- benchmarks/benchmarks/soiling.py | 1 + 1 file changed, 1 insertion(+) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index 58453095..1cfc5781 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -28,3 +28,4 @@ def time_kimber(self, ndays): # def time_test(self, ndays): # cleaningthreshold = 0.5 # soiling.hsu(self.rainfall, ) + From 36f5979b30d81f53646a1c7b014a1307b274c53f Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Sat, 23 Apr 2022 15:05:15 +0800 Subject: [PATCH 22/46] test --- benchmarks/benchmarks/soiling.py | 1 - 1 file changed, 1 deletion(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index 1cfc5781..58453095 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -28,4 +28,3 @@ def time_kimber(self, ndays): # def time_test(self, ndays): # cleaningthreshold = 0.5 # soiling.hsu(self.rainfall, ) - From 3f214365250ff268950dd3d67904f654cf967084 Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Sat, 23 Apr 2022 15:17:46 +0800 Subject: [PATCH 23/46] test --- benchmarks/benchmarks/soiling.py | 1 + 1 file changed, 1 insertion(+) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index 58453095..1cfc5781 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -28,3 +28,4 @@ def time_kimber(self, ndays): # def time_test(self, ndays): # cleaningthreshold = 0.5 # soiling.hsu(self.rainfall, ) + From 587176787aadca5bfc5b524a9fa04503479bf8a7 Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Sat, 23 Apr 2022 17:26:26 +0800 Subject: [PATCH 24/46] test --- benchmarks/benchmarks/location.py | 102 ++++---- benchmarks/benchmarks/solarposition.py | 256 +++++++++---------- benchmarks/benchmarks/solarposition_numba.py | 92 +++---- benchmarks/benchmarks/temperature.py | 102 ++++---- 4 files changed, 276 insertions(+), 276 deletions(-) diff --git a/benchmarks/benchmarks/location.py b/benchmarks/benchmarks/location.py index 2356ca1e..b729da4a 100644 --- a/benchmarks/benchmarks/location.py +++ b/benchmarks/benchmarks/location.py @@ -1,51 +1,51 @@ -""" -ASV benchmarks for location.py -""" - -import pandas as pd -import pvlib -from pkg_resources import parse_version - - -def set_solar_position(obj): - obj.location = pvlib.location.Location(32, -110, altitude=700, - tz='Etc/GMT+7') - obj.times = pd.date_range(start='20180601', freq='3min', - periods=1440) - obj.days = pd.date_range(start='20180101', freq='d', periods=365, - tz=obj.location.tz) - obj.solar_position = obj.location.get_solarposition(obj.times) - - -class Location: - - def setup(self): - set_solar_position(self) - - # GH 502 - def time_location_get_airmass(self): - self.location.get_airmass(solar_position=self.solar_position) - - def time_location_get_solarposition(self): - self.location.get_solarposition(times=self.times) - - def time_location_get_clearsky(self): - self.location.get_clearsky(times=self.times, - solar_position=self.solar_position) - - -class Location_0_6_1: - - def setup(self): - if parse_version(pvlib.__version__) < parse_version('0.6.1'): - raise NotImplementedError - - set_solar_position(self) - - def time_location_get_sun_rise_set_transit_pyephem(self): - self.location.get_sun_rise_set_transit(times=self.days, - method='pyephem') - - def time_location_get_sun_rise_set_transit_spa(self): - self.location.get_sun_rise_set_transit(times=self.days, - method='spa') +# """ +# ASV benchmarks for location.py +# """ +# +# import pandas as pd +# import pvlib +# from pkg_resources import parse_version +# +# +# def set_solar_position(obj): +# obj.location = pvlib.location.Location(32, -110, altitude=700, +# tz='Etc/GMT+7') +# obj.times = pd.date_range(start='20180601', freq='3min', +# periods=1440) +# obj.days = pd.date_range(start='20180101', freq='d', periods=365, +# tz=obj.location.tz) +# obj.solar_position = obj.location.get_solarposition(obj.times) +# +# +# class Location: +# +# def setup(self): +# set_solar_position(self) +# +# # GH 502 +# def time_location_get_airmass(self): +# self.location.get_airmass(solar_position=self.solar_position) +# +# def time_location_get_solarposition(self): +# self.location.get_solarposition(times=self.times) +# +# def time_location_get_clearsky(self): +# self.location.get_clearsky(times=self.times, +# solar_position=self.solar_position) +# +# +# class Location_0_6_1: +# +# def setup(self): +# if parse_version(pvlib.__version__) < parse_version('0.6.1'): +# raise NotImplementedError +# +# set_solar_position(self) +# +# def time_location_get_sun_rise_set_transit_pyephem(self): +# self.location.get_sun_rise_set_transit(times=self.days, +# method='pyephem') +# +# def time_location_get_sun_rise_set_transit_spa(self): +# self.location.get_sun_rise_set_transit(times=self.days, +# method='spa') diff --git a/benchmarks/benchmarks/solarposition.py b/benchmarks/benchmarks/solarposition.py index 71bc3070..76ac5d44 100644 --- a/benchmarks/benchmarks/solarposition.py +++ b/benchmarks/benchmarks/solarposition.py @@ -1,128 +1,128 @@ -""" -ASV benchmarks for solarposition.py -""" - -import datetime -import pandas as pd -import pvlib -from pvlib import solarposition - -from pkg_resources import parse_version - - -if parse_version(pvlib.__version__) >= parse_version('0.6.1'): - sun_rise_set_transit_spa = solarposition.sun_rise_set_transit_spa -else: - sun_rise_set_transit_spa = solarposition.get_sun_rise_set_transit - - -class SolarPositionSlow: - params = [1, 10, 100] # number of days - 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.lat = 35.1 - self.lon = -106.6 - - # GH 512 - def time_ephemeris_localized(self, ndays): - solarposition.ephemeris(self.times_localized, self.lat, self.lon) - - def time_spa_python(self, ndays): - solarposition.spa_python(self.times_localized, self.lat, self.lon) - - 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) - - -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) - equationoftime = solarposition.equation_of_time_spencer71(dayofyear) - solarposition.sun_rise_set_transit_geometric( - self.times_daily, self.lat, self.lon, declination, - equationoftime) - - 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): - 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) - - 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_geometric_full_comparison(self, ndays): - dayofyear = self.times_daily.dayofyear - declination = solarposition.declination_spencer71(dayofyear) - equationoftime = solarposition.equation_of_time_spencer71(dayofyear) - solarposition.sun_rise_set_transit_geometric( - self.times_daily, self.lat, self.lon, declination, - equationoftime) - - def time_sun_rise_set_transit_ephem(self, ndays): - solarposition.sun_rise_set_transit_ephem( - self.times_daily, self.lat, self.lon) - - -class SolarPositionCalcTime: - - def setup(self): - # test calc_time for finding times at which sun is 3 degrees - # above the horizon. - # Tucson 2020-09-14 sunrise at 6:08 AM MST, 13:08 UTC - # according to google. - self.start = datetime.datetime(2020, 9, 14, 12) - self.end = datetime.datetime(2020, 9, 14, 15) - self.value = 0.05235987755982988 - self.lat = 32.2 - self.lon = -110.9 - self.attribute = 'alt' - - def time_calc_time(self): - # datetime.datetime(2020, 9, 14, 13, 24, 13, 861913, tzinfo=) - solarposition.calc_time( - self.start, self.end, self.lat, self.lon, self.attribute, - self.value - ) +# """ +# ASV benchmarks for solarposition.py +# """ +# +# import datetime +# import pandas as pd +# import pvlib +# from pvlib import solarposition +# +# from pkg_resources import parse_version +# +# +# if parse_version(pvlib.__version__) >= parse_version('0.6.1'): +# sun_rise_set_transit_spa = solarposition.sun_rise_set_transit_spa +# else: +# sun_rise_set_transit_spa = solarposition.get_sun_rise_set_transit +# +# +# class SolarPositionSlow: +# params = [1, 10, 100] # number of days +# 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.lat = 35.1 +# self.lon = -106.6 +# +# # GH 512 +# def time_ephemeris_localized(self, ndays): +# solarposition.ephemeris(self.times_localized, self.lat, self.lon) +# +# def time_spa_python(self, ndays): +# solarposition.spa_python(self.times_localized, self.lat, self.lon) +# +# 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) +# +# +# 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) +# equationoftime = solarposition.equation_of_time_spencer71(dayofyear) +# solarposition.sun_rise_set_transit_geometric( +# self.times_daily, self.lat, self.lon, declination, +# equationoftime) +# +# 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): +# 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) +# +# 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_geometric_full_comparison(self, ndays): +# dayofyear = self.times_daily.dayofyear +# declination = solarposition.declination_spencer71(dayofyear) +# equationoftime = solarposition.equation_of_time_spencer71(dayofyear) +# solarposition.sun_rise_set_transit_geometric( +# self.times_daily, self.lat, self.lon, declination, +# equationoftime) +# +# def time_sun_rise_set_transit_ephem(self, ndays): +# solarposition.sun_rise_set_transit_ephem( +# self.times_daily, self.lat, self.lon) +# +# +# class SolarPositionCalcTime: +# +# def setup(self): +# # test calc_time for finding times at which sun is 3 degrees +# # above the horizon. +# # Tucson 2020-09-14 sunrise at 6:08 AM MST, 13:08 UTC +# # according to google. +# self.start = datetime.datetime(2020, 9, 14, 12) +# self.end = datetime.datetime(2020, 9, 14, 15) +# self.value = 0.05235987755982988 +# self.lat = 32.2 +# self.lon = -110.9 +# self.attribute = 'alt' +# +# def time_calc_time(self): +# # datetime.datetime(2020, 9, 14, 13, 24, 13, 861913, tzinfo=) +# solarposition.calc_time( +# self.start, self.end, self.lat, self.lon, self.attribute, +# self.value +# ) diff --git a/benchmarks/benchmarks/solarposition_numba.py b/benchmarks/benchmarks/solarposition_numba.py index bcadfd18..44416f6f 100644 --- a/benchmarks/benchmarks/solarposition_numba.py +++ b/benchmarks/benchmarks/solarposition_numba.py @@ -1,46 +1,46 @@ -"""ASV benchmarks for solarposition.py using numba. - -We use a separate module so that we can control the pvlib import process -using an environment variable. This will force pvlib to compile the numba -code during setup. - -Try to keep relevant sections in sync with benchmarks/solarposition.py -""" - -from pkg_resources import parse_version -import pandas as pd - -import os -os.environ['PVLIB_USE_NUMBA'] = '1' - - -import pvlib # NOQA: E402 -from pvlib import solarposition # NOQA: E402 - - -if parse_version(pvlib.__version__) >= parse_version('0.6.1'): - sun_rise_set_transit_spa = solarposition.sun_rise_set_transit_spa -else: - sun_rise_set_transit_spa = solarposition.get_sun_rise_set_transit - - -class SolarPositionNumba: - 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.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_spa_python(self, ndays): - solarposition.spa_python( - self.times_localized, self.lat, self.lon, how='numba') - - def time_sun_rise_set_transit_spa(self, ndays): - sun_rise_set_transit_spa( - self.times_daily, self.lat, self.lon, how='numba') +# """ASV benchmarks for solarposition.py using numba. +# +# We use a separate module so that we can control the pvlib import process +# using an environment variable. This will force pvlib to compile the numba +# code during setup. +# +# Try to keep relevant sections in sync with benchmarks/solarposition.py +# """ +# +# from pkg_resources import parse_version +# import pandas as pd +# +# import os +# os.environ['PVLIB_USE_NUMBA'] = '1' +# +# +# import pvlib # NOQA: E402 +# from pvlib import solarposition # NOQA: E402 +# +# +# if parse_version(pvlib.__version__) >= parse_version('0.6.1'): +# sun_rise_set_transit_spa = solarposition.sun_rise_set_transit_spa +# else: +# sun_rise_set_transit_spa = solarposition.get_sun_rise_set_transit +# +# +# class SolarPositionNumba: +# 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.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_spa_python(self, ndays): +# solarposition.spa_python( +# self.times_localized, self.lat, self.lon, how='numba') +# +# def time_sun_rise_set_transit_spa(self, ndays): +# sun_rise_set_transit_spa( +# self.times_daily, self.lat, self.lon, how='numba') diff --git a/benchmarks/benchmarks/temperature.py b/benchmarks/benchmarks/temperature.py index d8a8dad9..58867dd3 100644 --- a/benchmarks/benchmarks/temperature.py +++ b/benchmarks/benchmarks/temperature.py @@ -1,51 +1,51 @@ -""" -ASV benchmarks for irradiance.py -""" - -import pandas as pd -import pvlib -from pkg_resources import parse_version -from functools import partial - - -def set_weather_data(obj): - obj.times = pd.date_range(start='20180601', freq='1min', - periods=14400) - obj.poa = pd.Series(1000, index=obj.times) - obj.tamb = pd.Series(20, index=obj.times) - obj.wind_speed = pd.Series(2, index=obj.times) - - -class SAPM: - - def setup(self): - set_weather_data(self) - if parse_version(pvlib.__version__) >= parse_version('0.7.0'): - kwargs = pvlib.temperature.TEMPERATURE_MODEL_PARAMETERS['sapm'] - kwargs = kwargs['open_rack_glass_glass'] - self.sapm_cell_wrapper = partial(pvlib.temperature.sapm_cell, - **kwargs) - else: - sapm_celltemp = pvlib.pvsystem.sapm_celltemp - - def sapm_cell_wrapper(poa_global, temp_air, wind_speed): - # just swap order; model params are provided by default - return sapm_celltemp(poa_global, wind_speed, temp_air) - self.sapm_cell_wrapper = sapm_cell_wrapper - - def time_sapm_cell(self): - # use version-appropriate wrapper - self.sapm_cell_wrapper(self.poa, self.tamb, self.wind_speed) - - -class Fuentes: - - def setup(self): - if parse_version(pvlib.__version__) < parse_version('0.8.0'): - raise NotImplementedError - - set_weather_data(self) - - def time_fuentes(self): - pvlib.temperature.fuentes(self.poa, self.tamb, self.wind_speed, - noct_installed=45) +# """ +# ASV benchmarks for irradiance.py +# """ +# +# import pandas as pd +# import pvlib +# from pkg_resources import parse_version +# from functools import partial +# +# +# def set_weather_data(obj): +# obj.times = pd.date_range(start='20180601', freq='1min', +# periods=14400) +# obj.poa = pd.Series(1000, index=obj.times) +# obj.tamb = pd.Series(20, index=obj.times) +# obj.wind_speed = pd.Series(2, index=obj.times) +# +# +# class SAPM: +# +# def setup(self): +# set_weather_data(self) +# if parse_version(pvlib.__version__) >= parse_version('0.7.0'): +# kwargs = pvlib.temperature.TEMPERATURE_MODEL_PARAMETERS['sapm'] +# kwargs = kwargs['open_rack_glass_glass'] +# self.sapm_cell_wrapper = partial(pvlib.temperature.sapm_cell, +# **kwargs) +# else: +# sapm_celltemp = pvlib.pvsystem.sapm_celltemp +# +# def sapm_cell_wrapper(poa_global, temp_air, wind_speed): +# # just swap order; model params are provided by default +# return sapm_celltemp(poa_global, wind_speed, temp_air) +# self.sapm_cell_wrapper = sapm_cell_wrapper +# +# def time_sapm_cell(self): +# # use version-appropriate wrapper +# self.sapm_cell_wrapper(self.poa, self.tamb, self.wind_speed) +# +# +# class Fuentes: +# +# def setup(self): +# if parse_version(pvlib.__version__) < parse_version('0.8.0'): +# raise NotImplementedError +# +# set_weather_data(self) +# +# def time_fuentes(self): +# pvlib.temperature.fuentes(self.poa, self.tamb, self.wind_speed, +# noct_installed=45) From f017f226d887b294e05da60e2f0790d74f4b3ec5 Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Sat, 23 Apr 2022 17:29:30 +0800 Subject: [PATCH 25/46] test --- benchmarks/benchmarks/soiling.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index 1cfc5781..42b6d6ce 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -25,7 +25,7 @@ def time_kimber(self, ndays): cleaningthreshold = 25 soiling.kimber(self.rainfall, cleaningthreshold) - # def time_test(self, ndays): - # cleaningthreshold = 0.5 - # soiling.hsu(self.rainfall, ) + def time_test(self, ndays): + cleaningthreshold = 0.5 + soiling.hsu(self.rainfall, ) From b361b385edfa382931a08f1386b36fa550e6f491 Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Sat, 23 Apr 2022 17:35:28 +0800 Subject: [PATCH 26/46] test --- benchmarks/benchmarks/soiling.py | 1 - 1 file changed, 1 deletion(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index 42b6d6ce..4d828377 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -28,4 +28,3 @@ def time_kimber(self, ndays): def time_test(self, ndays): cleaningthreshold = 0.5 soiling.hsu(self.rainfall, ) - From f31c1098667a3a04757ac09fd3e926bd6b8cea37 Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Sat, 23 Apr 2022 17:38:09 +0800 Subject: [PATCH 27/46] test --- benchmarks/benchmarks/soiling.py | 1 + 1 file changed, 1 insertion(+) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index 4d828377..42b6d6ce 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -28,3 +28,4 @@ def time_kimber(self, ndays): def time_test(self, ndays): cleaningthreshold = 0.5 soiling.hsu(self.rainfall, ) + From 5752b043e44f012b2f084c0861bccf648a18b71d Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Sat, 23 Apr 2022 17:40:32 +0800 Subject: [PATCH 28/46] test --- benchmarks/benchmarks/soiling.py | 1 - 1 file changed, 1 deletion(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index 42b6d6ce..4d828377 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -28,4 +28,3 @@ def time_kimber(self, ndays): def time_test(self, ndays): cleaningthreshold = 0.5 soiling.hsu(self.rainfall, ) - From 6524640de8628337a4d25f66e1f4bfd514a18716 Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Sat, 23 Apr 2022 23:16:52 +0800 Subject: [PATCH 29/46] test --- benchmarks/benchmarks/soiling.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index 4d828377..58453095 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -25,6 +25,6 @@ def time_kimber(self, ndays): cleaningthreshold = 25 soiling.kimber(self.rainfall, cleaningthreshold) - def time_test(self, ndays): - cleaningthreshold = 0.5 - soiling.hsu(self.rainfall, ) + # def time_test(self, ndays): + # cleaningthreshold = 0.5 + # soiling.hsu(self.rainfall, ) From d5f846780aa3324bde62ec7d758acf341534d790 Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Sat, 23 Apr 2022 23:19:17 +0800 Subject: [PATCH 30/46] test --- pvlib/pvsystem.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 6bb89f34..fd6a6bf6 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -3,6 +3,7 @@ performance of PV modules and inverters. """ + from collections import OrderedDict import functools import io From c319dc89e30c02e01060a76ef0196121abb57ebb Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Sat, 23 Apr 2022 23:40:07 +0800 Subject: [PATCH 31/46] test --- pvlib/pvsystem.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index fd6a6bf6..6bb89f34 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -3,7 +3,6 @@ performance of PV modules and inverters. """ - from collections import OrderedDict import functools import io From cf9404350a3ce83c40687a7cac3e8c67e4ba575c Mon Sep 17 00:00:00 2001 From: roger-lcc <58332996+roger-lcc@users.noreply.github.com> Date: Tue, 26 Apr 2022 01:08:57 +0800 Subject: [PATCH 32/46] Delete asv.yml --- .github/workflows/asv.yml | 67 --------------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 .github/workflows/asv.yml diff --git a/.github/workflows/asv.yml b/.github/workflows/asv.yml deleted file mode 100644 index b1e0aed4..00000000 --- a/.github/workflows/asv.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: CI ASV check - -on: - push: - paths: - - 'benchmarks/benchmarks/**' - pull_request: - paths: - - 'benchmarks/benchmarks/**' - -jobs: - test: - env: - # we need to turn "3.6" into 36 to build the conda requirement filename, - # but there's no good way to do that via string manipulation. So set up - # a map that will be parsed as JSON later: - VERSIONMAP: '{"3.6": "36", "3.7": "37", "3.8": "38", "3.9": "39"}' - - strategy: - fail-fast: false # don't cancel other matrix jobs when one fails - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - python-version: [3.6, 3.7, 3.8, 3.9] - environment-type: [conda, bare] - suffix: [''] # placeholder as an alternative to "-min" - include: - - os: ubuntu-latest - python-version: 3.6 - environment-type: conda - suffix: -min - exclude: - - os: macos-latest - environment-type: conda - - os: windows-latest - environment-type: bare - - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v2 - - - name: Set up Python ${{ matrix.python-version }}${{ matrix.suffix }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - - name: Set up conda environment - if: matrix.environment-type == 'conda' - uses: conda-incubator/setup-miniconda@v2 - with: - activate-environment: test_env - environment-file: ${{ env.REQUIREMENTS }} - python-version: ${{ matrix.python-version }} - auto-activate-base: false - env: - # build requirement filename. First replacement is for the python - # version, mapping from "3.7" to "37", second is to add "-min" if needed - REQUIREMENTS: ci/requirements-py${{ fromJSON(env.VERSIONMAP)[matrix.python-version] }}${{ matrix.suffix }}.yml - - - name: Install asv - run: pip install asv - - - name: Run asv - run: | - asv machine --yes - asv run --quick - working-directory: ./benchmarks From 544addfe934756e73d02aaad277e53f6e9b7a156 Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Wed, 27 Apr 2022 11:31:51 +0800 Subject: [PATCH 33/46] test --- benchmarks/asv.conf.json | 1 - 1 file changed, 1 deletion(-) diff --git a/benchmarks/asv.conf.json b/benchmarks/asv.conf.json index 443636cf..878175d3 100644 --- a/benchmarks/asv.conf.json +++ b/benchmarks/asv.conf.json @@ -13,7 +13,6 @@ // project being benchmarked "repo": "..", - "branches": "main", // The Python project's subdirectory in your repo. If missing or // the empty string, the project is assumed to be located at the root From ffc42bde15c38fc776fdfa08c3a167526844dfc4 Mon Sep 17 00:00:00 2001 From: roger-lcc <58332996+roger-lcc@users.noreply.github.com> Date: Wed, 27 Apr 2022 11:33:09 +0800 Subject: [PATCH 34/46] Create main.yml --- .github/workflows/main.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..537016df --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,37 @@ +name: CI ASV check + +on: [pull_request, push] + +jobs: + test: + runs-on: ubuntu-latest + defaults: + run: + shell: bash -el {0} + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install Python + uses: actions/setup-python@v3 + with: + python-version: '3.9.7' + + - name: Install asv + run: | + pip install . + pip install ephem==3.7.6.0 + pip install numba==0.40.0 + pip install asv==0.4.2 + + - name: Run asv benchmarks + run: | + cd benchmarks + asv machine --yes + asv run --quick --dry-run --show-stderr | sed "/failed$/ s/^/##[error]/" | tee benchmarks.log + if grep "failed" benchmarks.log > /dev/null ; then + exit 1 + fi + From e4aeac9cd7514543a88b66e6fc046e43695c0b87 Mon Sep 17 00:00:00 2001 From: roger-lcc <58332996+roger-lcc@users.noreply.github.com> Date: Wed, 27 Apr 2022 12:31:37 +0800 Subject: [PATCH 35/46] Delete main.yml --- .github/workflows/main.yml | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 537016df..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: CI ASV check - -on: [pull_request, push] - -jobs: - test: - runs-on: ubuntu-latest - defaults: - run: - shell: bash -el {0} - - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Install Python - uses: actions/setup-python@v3 - with: - python-version: '3.9.7' - - - name: Install asv - run: | - pip install . - pip install ephem==3.7.6.0 - pip install numba==0.40.0 - pip install asv==0.4.2 - - - name: Run asv benchmarks - run: | - cd benchmarks - asv machine --yes - asv run --quick --dry-run --show-stderr | sed "/failed$/ s/^/##[error]/" | tee benchmarks.log - if grep "failed" benchmarks.log > /dev/null ; then - exit 1 - fi - From b6a0b53a0246ea72e1703f5391baa6ec4f5eca5e Mon Sep 17 00:00:00 2001 From: roger-lcc <58332996+roger-lcc@users.noreply.github.com> Date: Wed, 27 Apr 2022 12:31:51 +0800 Subject: [PATCH 36/46] Create main.yml --- .github/workflows/main.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..36acbcb3 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,38 @@ +name: CI ASV check + +on: [pull_request, push] + +jobs: + test: + runs-on: ubuntu-latest + defaults: + run: + shell: bash -el {0} + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install Python + uses: actions/setup-python@v3 + with: + python-version: '3.9.7' + + - name: Install asv + run: | + pip install . + pip install ephem==3.7.6.0 + pip install numba==0.40.0 + pip install asv==0.4.2 + + - name: Run asv benchmarks + run: | + cd benchmarks + asv machine --yes + asv run --quick --dry-run --show-stderr --python=same + sed "/failed$/ s/^/##[error]/" | tee benchmarks.log + if grep "failed" benchmarks.log > /dev/null ; then + exit 1 + fi + From 84478ead88b3b5744226c5ab897bad62b3edaa13 Mon Sep 17 00:00:00 2001 From: roger-lcc <58332996+roger-lcc@users.noreply.github.com> Date: Wed, 27 Apr 2022 12:34:58 +0800 Subject: [PATCH 37/46] Update main.yml --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 36acbcb3..06f53eb0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,7 +31,6 @@ jobs: cd benchmarks asv machine --yes asv run --quick --dry-run --show-stderr --python=same - sed "/failed$/ s/^/##[error]/" | tee benchmarks.log if grep "failed" benchmarks.log > /dev/null ; then exit 1 fi From 4b19337bf2a27fcc3863f1d61bce63b361b31a7f Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Wed, 27 Apr 2022 12:38:39 +0800 Subject: [PATCH 38/46] test --- benchmarks/benchmarks/soiling.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/benchmarks/benchmarks/soiling.py b/benchmarks/benchmarks/soiling.py index b36754bf..e1d76a2a 100644 --- a/benchmarks/benchmarks/soiling.py +++ b/benchmarks/benchmarks/soiling.py @@ -25,12 +25,6 @@ def time_kimber(self, ndays): cleaningthreshold = 25 soiling.kimber(self.rainfall, cleaningthreshold) -<<<<<<< HEAD - # def time_test(self, ndays): - # cleaningthreshold = 0.5 - # soiling.hsu(self.rainfall, ) -======= def time_hsu(self, ndays): cleaningthreshold = 0.5 soiling.hsu(self.rainfall, ) ->>>>>>> main From 90057fe58c9ce56191826049ca7cb6bcfc3dca9f Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Wed, 27 Apr 2022 12:45:55 +0800 Subject: [PATCH 39/46] test --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 06f53eb0..fa8d8fd8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,7 +30,8 @@ jobs: run: | cd benchmarks asv machine --yes - asv run --quick --dry-run --show-stderr --python=same + asv run --quick --dry-run --show-stderr --python=same + sed "/failed$/ s/^/##[error]/" | tee benchmarks.log if grep "failed" benchmarks.log > /dev/null ; then exit 1 fi From 05b4e68fe245697d9a5dc97cb3a23255a0b794ae Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Wed, 27 Apr 2022 12:50:24 +0800 Subject: [PATCH 40/46] test --- .github/workflows/main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fa8d8fd8..46656fa4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,8 +30,7 @@ jobs: run: | cd benchmarks asv machine --yes - asv run --quick --dry-run --show-stderr --python=same - sed "/failed$/ s/^/##[error]/" | tee benchmarks.log + asv run --quick --dry-run --show-stderr --python=same | sed "/failed$/ s/^/##[error]/" | tee benchmarks.log if grep "failed" benchmarks.log > /dev/null ; then exit 1 fi From abdd0c9f3890ea59e23717dc85eb76106c6e503e Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Wed, 27 Apr 2022 13:39:35 +0800 Subject: [PATCH 41/46] test --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 46656fa4..c3120355 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,7 +30,7 @@ jobs: run: | cd benchmarks asv machine --yes - asv run --quick --dry-run --show-stderr --python=same | sed "/failed$/ s/^/##[error]/" | tee benchmarks.log + asv run --quick --dry-run --show-stderr --python=same | sed "s/failed$/;s/^/##[Error]/" | tee benchmarks.log if grep "failed" benchmarks.log > /dev/null ; then exit 1 fi From 150e9c6e2c26bdd586a6e9d9c55c3cf4ddc413ec Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Wed, 27 Apr 2022 13:55:21 +0800 Subject: [PATCH 42/46] test --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c3120355..89aa41a6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,7 +30,7 @@ jobs: run: | cd benchmarks asv machine --yes - asv run --quick --dry-run --show-stderr --python=same | sed "s/failed$/;s/^/##[Error]/" | tee benchmarks.log + asv run --quick --dry-run --show-stderr --python=same | sed "/failed$/ s/^/##[error]/;/^TypeError/ s/^/##[error]" | tee benchmarks.log if grep "failed" benchmarks.log > /dev/null ; then exit 1 fi From 65cc1add0436d650b93f40ede5ee5ddc695b9a2a Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Wed, 27 Apr 2022 13:59:46 +0800 Subject: [PATCH 43/46] test --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 89aa41a6..851b03b9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,7 +30,7 @@ jobs: run: | cd benchmarks asv machine --yes - asv run --quick --dry-run --show-stderr --python=same | sed "/failed$/ s/^/##[error]/;/^TypeError/ s/^/##[error]" | tee benchmarks.log + asv run --quick --dry-run --show-stderr --python=same | sed "/^TypeError/ s/^/##[error]/" | tee benchmarks.log if grep "failed" benchmarks.log > /dev/null ; then exit 1 fi From 918294c903299b0d4ef891b906e97e5f4ad71ef1 Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Wed, 27 Apr 2022 14:04:58 +0800 Subject: [PATCH 44/46] test --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 851b03b9..4046c68e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,7 +30,8 @@ jobs: run: | cd benchmarks asv machine --yes - asv run --quick --dry-run --show-stderr --python=same | sed "/^TypeError/ s/^/##[error]/" | tee benchmarks.log + asv run --quick --dry-run --show-stderr --python=same + | sed "/failed$/ s/^/##[error]/" | tee benchmarks.log if grep "failed" benchmarks.log > /dev/null ; then exit 1 fi From 003f3cf42cd3ccd73b39bb0556941a3987eeb805 Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Wed, 27 Apr 2022 14:12:30 +0800 Subject: [PATCH 45/46] test --- .github/workflows/main.yml | 2 +- benchmarks/benchmarks/location.py | 102 ++++---- benchmarks/benchmarks/solarposition.py | 256 +++++++++---------- benchmarks/benchmarks/solarposition_numba.py | 92 +++---- benchmarks/benchmarks/temperature.py | 102 ++++---- 5 files changed, 277 insertions(+), 277 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4046c68e..85262c54 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,7 +30,7 @@ jobs: run: | cd benchmarks asv machine --yes - asv run --quick --dry-run --show-stderr --python=same + asv run --quick --dry-run --show-stderr --python=same\ | sed "/failed$/ s/^/##[error]/" | tee benchmarks.log if grep "failed" benchmarks.log > /dev/null ; then exit 1 diff --git a/benchmarks/benchmarks/location.py b/benchmarks/benchmarks/location.py index b729da4a..2356ca1e 100644 --- a/benchmarks/benchmarks/location.py +++ b/benchmarks/benchmarks/location.py @@ -1,51 +1,51 @@ -# """ -# ASV benchmarks for location.py -# """ -# -# import pandas as pd -# import pvlib -# from pkg_resources import parse_version -# -# -# def set_solar_position(obj): -# obj.location = pvlib.location.Location(32, -110, altitude=700, -# tz='Etc/GMT+7') -# obj.times = pd.date_range(start='20180601', freq='3min', -# periods=1440) -# obj.days = pd.date_range(start='20180101', freq='d', periods=365, -# tz=obj.location.tz) -# obj.solar_position = obj.location.get_solarposition(obj.times) -# -# -# class Location: -# -# def setup(self): -# set_solar_position(self) -# -# # GH 502 -# def time_location_get_airmass(self): -# self.location.get_airmass(solar_position=self.solar_position) -# -# def time_location_get_solarposition(self): -# self.location.get_solarposition(times=self.times) -# -# def time_location_get_clearsky(self): -# self.location.get_clearsky(times=self.times, -# solar_position=self.solar_position) -# -# -# class Location_0_6_1: -# -# def setup(self): -# if parse_version(pvlib.__version__) < parse_version('0.6.1'): -# raise NotImplementedError -# -# set_solar_position(self) -# -# def time_location_get_sun_rise_set_transit_pyephem(self): -# self.location.get_sun_rise_set_transit(times=self.days, -# method='pyephem') -# -# def time_location_get_sun_rise_set_transit_spa(self): -# self.location.get_sun_rise_set_transit(times=self.days, -# method='spa') +""" +ASV benchmarks for location.py +""" + +import pandas as pd +import pvlib +from pkg_resources import parse_version + + +def set_solar_position(obj): + obj.location = pvlib.location.Location(32, -110, altitude=700, + tz='Etc/GMT+7') + obj.times = pd.date_range(start='20180601', freq='3min', + periods=1440) + obj.days = pd.date_range(start='20180101', freq='d', periods=365, + tz=obj.location.tz) + obj.solar_position = obj.location.get_solarposition(obj.times) + + +class Location: + + def setup(self): + set_solar_position(self) + + # GH 502 + def time_location_get_airmass(self): + self.location.get_airmass(solar_position=self.solar_position) + + def time_location_get_solarposition(self): + self.location.get_solarposition(times=self.times) + + def time_location_get_clearsky(self): + self.location.get_clearsky(times=self.times, + solar_position=self.solar_position) + + +class Location_0_6_1: + + def setup(self): + if parse_version(pvlib.__version__) < parse_version('0.6.1'): + raise NotImplementedError + + set_solar_position(self) + + def time_location_get_sun_rise_set_transit_pyephem(self): + self.location.get_sun_rise_set_transit(times=self.days, + method='pyephem') + + def time_location_get_sun_rise_set_transit_spa(self): + self.location.get_sun_rise_set_transit(times=self.days, + method='spa') diff --git a/benchmarks/benchmarks/solarposition.py b/benchmarks/benchmarks/solarposition.py index 76ac5d44..71bc3070 100644 --- a/benchmarks/benchmarks/solarposition.py +++ b/benchmarks/benchmarks/solarposition.py @@ -1,128 +1,128 @@ -# """ -# ASV benchmarks for solarposition.py -# """ -# -# import datetime -# import pandas as pd -# import pvlib -# from pvlib import solarposition -# -# from pkg_resources import parse_version -# -# -# if parse_version(pvlib.__version__) >= parse_version('0.6.1'): -# sun_rise_set_transit_spa = solarposition.sun_rise_set_transit_spa -# else: -# sun_rise_set_transit_spa = solarposition.get_sun_rise_set_transit -# -# -# class SolarPositionSlow: -# params = [1, 10, 100] # number of days -# 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.lat = 35.1 -# self.lon = -106.6 -# -# # GH 512 -# def time_ephemeris_localized(self, ndays): -# solarposition.ephemeris(self.times_localized, self.lat, self.lon) -# -# def time_spa_python(self, ndays): -# solarposition.spa_python(self.times_localized, self.lat, self.lon) -# -# 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) -# -# -# 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) -# equationoftime = solarposition.equation_of_time_spencer71(dayofyear) -# solarposition.sun_rise_set_transit_geometric( -# self.times_daily, self.lat, self.lon, declination, -# equationoftime) -# -# 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): -# 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) -# -# 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_geometric_full_comparison(self, ndays): -# dayofyear = self.times_daily.dayofyear -# declination = solarposition.declination_spencer71(dayofyear) -# equationoftime = solarposition.equation_of_time_spencer71(dayofyear) -# solarposition.sun_rise_set_transit_geometric( -# self.times_daily, self.lat, self.lon, declination, -# equationoftime) -# -# def time_sun_rise_set_transit_ephem(self, ndays): -# solarposition.sun_rise_set_transit_ephem( -# self.times_daily, self.lat, self.lon) -# -# -# class SolarPositionCalcTime: -# -# def setup(self): -# # test calc_time for finding times at which sun is 3 degrees -# # above the horizon. -# # Tucson 2020-09-14 sunrise at 6:08 AM MST, 13:08 UTC -# # according to google. -# self.start = datetime.datetime(2020, 9, 14, 12) -# self.end = datetime.datetime(2020, 9, 14, 15) -# self.value = 0.05235987755982988 -# self.lat = 32.2 -# self.lon = -110.9 -# self.attribute = 'alt' -# -# def time_calc_time(self): -# # datetime.datetime(2020, 9, 14, 13, 24, 13, 861913, tzinfo=) -# solarposition.calc_time( -# self.start, self.end, self.lat, self.lon, self.attribute, -# self.value -# ) +""" +ASV benchmarks for solarposition.py +""" + +import datetime +import pandas as pd +import pvlib +from pvlib import solarposition + +from pkg_resources import parse_version + + +if parse_version(pvlib.__version__) >= parse_version('0.6.1'): + sun_rise_set_transit_spa = solarposition.sun_rise_set_transit_spa +else: + sun_rise_set_transit_spa = solarposition.get_sun_rise_set_transit + + +class SolarPositionSlow: + params = [1, 10, 100] # number of days + 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.lat = 35.1 + self.lon = -106.6 + + # GH 512 + def time_ephemeris_localized(self, ndays): + solarposition.ephemeris(self.times_localized, self.lat, self.lon) + + def time_spa_python(self, ndays): + solarposition.spa_python(self.times_localized, self.lat, self.lon) + + 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) + + +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) + equationoftime = solarposition.equation_of_time_spencer71(dayofyear) + solarposition.sun_rise_set_transit_geometric( + self.times_daily, self.lat, self.lon, declination, + equationoftime) + + 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): + 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) + + 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_geometric_full_comparison(self, ndays): + dayofyear = self.times_daily.dayofyear + declination = solarposition.declination_spencer71(dayofyear) + equationoftime = solarposition.equation_of_time_spencer71(dayofyear) + solarposition.sun_rise_set_transit_geometric( + self.times_daily, self.lat, self.lon, declination, + equationoftime) + + def time_sun_rise_set_transit_ephem(self, ndays): + solarposition.sun_rise_set_transit_ephem( + self.times_daily, self.lat, self.lon) + + +class SolarPositionCalcTime: + + def setup(self): + # test calc_time for finding times at which sun is 3 degrees + # above the horizon. + # Tucson 2020-09-14 sunrise at 6:08 AM MST, 13:08 UTC + # according to google. + self.start = datetime.datetime(2020, 9, 14, 12) + self.end = datetime.datetime(2020, 9, 14, 15) + self.value = 0.05235987755982988 + self.lat = 32.2 + self.lon = -110.9 + self.attribute = 'alt' + + def time_calc_time(self): + # datetime.datetime(2020, 9, 14, 13, 24, 13, 861913, tzinfo=) + solarposition.calc_time( + self.start, self.end, self.lat, self.lon, self.attribute, + self.value + ) diff --git a/benchmarks/benchmarks/solarposition_numba.py b/benchmarks/benchmarks/solarposition_numba.py index 44416f6f..bcadfd18 100644 --- a/benchmarks/benchmarks/solarposition_numba.py +++ b/benchmarks/benchmarks/solarposition_numba.py @@ -1,46 +1,46 @@ -# """ASV benchmarks for solarposition.py using numba. -# -# We use a separate module so that we can control the pvlib import process -# using an environment variable. This will force pvlib to compile the numba -# code during setup. -# -# Try to keep relevant sections in sync with benchmarks/solarposition.py -# """ -# -# from pkg_resources import parse_version -# import pandas as pd -# -# import os -# os.environ['PVLIB_USE_NUMBA'] = '1' -# -# -# import pvlib # NOQA: E402 -# from pvlib import solarposition # NOQA: E402 -# -# -# if parse_version(pvlib.__version__) >= parse_version('0.6.1'): -# sun_rise_set_transit_spa = solarposition.sun_rise_set_transit_spa -# else: -# sun_rise_set_transit_spa = solarposition.get_sun_rise_set_transit -# -# -# class SolarPositionNumba: -# 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.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_spa_python(self, ndays): -# solarposition.spa_python( -# self.times_localized, self.lat, self.lon, how='numba') -# -# def time_sun_rise_set_transit_spa(self, ndays): -# sun_rise_set_transit_spa( -# self.times_daily, self.lat, self.lon, how='numba') +"""ASV benchmarks for solarposition.py using numba. + +We use a separate module so that we can control the pvlib import process +using an environment variable. This will force pvlib to compile the numba +code during setup. + +Try to keep relevant sections in sync with benchmarks/solarposition.py +""" + +from pkg_resources import parse_version +import pandas as pd + +import os +os.environ['PVLIB_USE_NUMBA'] = '1' + + +import pvlib # NOQA: E402 +from pvlib import solarposition # NOQA: E402 + + +if parse_version(pvlib.__version__) >= parse_version('0.6.1'): + sun_rise_set_transit_spa = solarposition.sun_rise_set_transit_spa +else: + sun_rise_set_transit_spa = solarposition.get_sun_rise_set_transit + + +class SolarPositionNumba: + 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.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_spa_python(self, ndays): + solarposition.spa_python( + self.times_localized, self.lat, self.lon, how='numba') + + def time_sun_rise_set_transit_spa(self, ndays): + sun_rise_set_transit_spa( + self.times_daily, self.lat, self.lon, how='numba') diff --git a/benchmarks/benchmarks/temperature.py b/benchmarks/benchmarks/temperature.py index 58867dd3..d8a8dad9 100644 --- a/benchmarks/benchmarks/temperature.py +++ b/benchmarks/benchmarks/temperature.py @@ -1,51 +1,51 @@ -# """ -# ASV benchmarks for irradiance.py -# """ -# -# import pandas as pd -# import pvlib -# from pkg_resources import parse_version -# from functools import partial -# -# -# def set_weather_data(obj): -# obj.times = pd.date_range(start='20180601', freq='1min', -# periods=14400) -# obj.poa = pd.Series(1000, index=obj.times) -# obj.tamb = pd.Series(20, index=obj.times) -# obj.wind_speed = pd.Series(2, index=obj.times) -# -# -# class SAPM: -# -# def setup(self): -# set_weather_data(self) -# if parse_version(pvlib.__version__) >= parse_version('0.7.0'): -# kwargs = pvlib.temperature.TEMPERATURE_MODEL_PARAMETERS['sapm'] -# kwargs = kwargs['open_rack_glass_glass'] -# self.sapm_cell_wrapper = partial(pvlib.temperature.sapm_cell, -# **kwargs) -# else: -# sapm_celltemp = pvlib.pvsystem.sapm_celltemp -# -# def sapm_cell_wrapper(poa_global, temp_air, wind_speed): -# # just swap order; model params are provided by default -# return sapm_celltemp(poa_global, wind_speed, temp_air) -# self.sapm_cell_wrapper = sapm_cell_wrapper -# -# def time_sapm_cell(self): -# # use version-appropriate wrapper -# self.sapm_cell_wrapper(self.poa, self.tamb, self.wind_speed) -# -# -# class Fuentes: -# -# def setup(self): -# if parse_version(pvlib.__version__) < parse_version('0.8.0'): -# raise NotImplementedError -# -# set_weather_data(self) -# -# def time_fuentes(self): -# pvlib.temperature.fuentes(self.poa, self.tamb, self.wind_speed, -# noct_installed=45) +""" +ASV benchmarks for irradiance.py +""" + +import pandas as pd +import pvlib +from pkg_resources import parse_version +from functools import partial + + +def set_weather_data(obj): + obj.times = pd.date_range(start='20180601', freq='1min', + periods=14400) + obj.poa = pd.Series(1000, index=obj.times) + obj.tamb = pd.Series(20, index=obj.times) + obj.wind_speed = pd.Series(2, index=obj.times) + + +class SAPM: + + def setup(self): + set_weather_data(self) + if parse_version(pvlib.__version__) >= parse_version('0.7.0'): + kwargs = pvlib.temperature.TEMPERATURE_MODEL_PARAMETERS['sapm'] + kwargs = kwargs['open_rack_glass_glass'] + self.sapm_cell_wrapper = partial(pvlib.temperature.sapm_cell, + **kwargs) + else: + sapm_celltemp = pvlib.pvsystem.sapm_celltemp + + def sapm_cell_wrapper(poa_global, temp_air, wind_speed): + # just swap order; model params are provided by default + return sapm_celltemp(poa_global, wind_speed, temp_air) + self.sapm_cell_wrapper = sapm_cell_wrapper + + def time_sapm_cell(self): + # use version-appropriate wrapper + self.sapm_cell_wrapper(self.poa, self.tamb, self.wind_speed) + + +class Fuentes: + + def setup(self): + if parse_version(pvlib.__version__) < parse_version('0.8.0'): + raise NotImplementedError + + set_weather_data(self) + + def time_fuentes(self): + pvlib.temperature.fuentes(self.poa, self.tamb, self.wind_speed, + noct_installed=45) From ae513c430e70c727bb13bdb31b3fa45f6ef26ded Mon Sep 17 00:00:00 2001 From: roger-lcc <953120129@qq.com> Date: Thu, 28 Apr 2022 00:48:23 +0800 Subject: [PATCH 46/46] test --- .github/workflows/main.yml | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 85262c54..c2d240c6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,11 +1,12 @@ -name: CI ASV check +name: asv +# CI ASV CHECK is aimed to verify that the benchmarks execute without error. on: [pull_request, push] jobs: - test: + quick: runs-on: ubuntu-latest - defaults: + defaults: run: shell: bash -el {0} @@ -20,18 +21,13 @@ jobs: python-version: '3.9.7' - name: Install asv - run: | - pip install . - pip install ephem==3.7.6.0 - pip install numba==0.40.0 - pip install asv==0.4.2 + run: pip install asv==0.4.2 - name: Run asv benchmarks run: | cd benchmarks asv machine --yes - asv run --quick --dry-run --show-stderr --python=same\ - | sed "/failed$/ s/^/##[error]/" | tee benchmarks.log + asv run HEAD^! --quick --dry-run --show-stderr | sed "/failed$/ s/^/##[error]/" | tee benchmarks.log if grep "failed" benchmarks.log > /dev/null ; then exit 1 fi