Skip to content

Workflow #1453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/asv_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI ASV check

# CI ASV CHECK is aimed to verify that the benchmarks execute without error.
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

80 changes: 62 additions & 18 deletions benchmarks/benchmarks/solarposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,16 @@
sun_rise_set_transit_spa = solarposition.get_sun_rise_set_transit


class SolarPosition:
class SolarPositionSlow:
params = [1, 10, 100] # number of days
param_names = ['ndays']

def setup(self, ndays):
self.times = pd.date_range(start='20180601', freq='1min',
periods=1440*ndays)
self.times_localized = self.times.tz_localize('Etc/GMT+7')
self.times_localized = pd.date_range(
start='20180601', freq='1min',
periods=1440 * ndays, tz='Etc/GMT+7')
self.lat = 35.1
self.lon = -106.6
self.times_daily = pd.date_range(
start='20180601', freq='24h', periods=ndays, tz='Etc/GMT+7')

# GH 512
def time_ephemeris(self, ndays):
solarposition.ephemeris(self.times, self.lat, self.lon)

# GH 512
def time_ephemeris_localized(self, ndays):
Expand All @@ -43,23 +37,73 @@ def time_spa_python(self, ndays):
def time_pyephem(self, ndays):
solarposition.pyephem(self.times_localized, self.lat, self.lon)

def time_nrel_earthsun_distance(self, ndays):
solarposition.nrel_earthsun_distance(self.times_localized)

def time_pyephem_earthsun_distance(self, ndays):
solarposition.pyephem_earthsun_distance(self.times_localized)


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_ephem(self, ndays):
solarposition.sun_rise_set_transit_ephem(
self.times_daily, self.lat, self.lon)

def time_sun_rise_set_transit_geometric_full_comparison(self, ndays):
dayofyear = self.times_daily.dayofyear
declination = solarposition.declination_spencer71(dayofyear)
equation_of_time = solarposition.equation_of_time_spencer71(dayofyear)
equationoftime = solarposition.equation_of_time_spencer71(dayofyear)
solarposition.sun_rise_set_transit_geometric(
self.times_daily, self.lat, self.lon, declination,
equation_of_time)
equationoftime)

def time_nrel_earthsun_distance(self, ndays):
solarposition.nrel_earthsun_distance(self.times_localized)
def time_sun_rise_set_transit_ephem(self, ndays):
solarposition.sun_rise_set_transit_ephem(
self.times_daily, self.lat, self.lon)


class SolarPositionCalcTime:
Expand Down
2 changes: 2 additions & 0 deletions docs/sphinx/source/whatsnew/v0.9.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ Documentation
Benchmarking
~~~~~~~~~~~~~
* Updated version of numba in asv.conf from 0.36.1 to 0.40.0 to solve numba/numpy conflict. (:issue:`1439`, :pull:`1440`)
* Improved the benchmark in solarposition.py (:issue:`1441`, :pull:`1443`)
Requirements
~~~~~~~~~~~~

Contributors
~~~~~~~~~~~~
* Naman Priyadarshi (:ghuser:`Naman-Priyadarshi`)
* Chencheng Luo (:ghuser:`roger-lcc`)