Skip to content

Simplify Numba usage; numba-fy temperature.fuentes #1098

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 23 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
10 changes: 7 additions & 3 deletions benchmarks/benchmarks/solarposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@

import datetime
import pandas as pd
import pvlib
from pvlib import solarposition

from pkg_resources import parse_version

# Numba is installed in the benchmark environments, but we'll disable it here.
# so pvlib will switch to numpy functions (see NUMBA_ACTIVE in pvlib.tools).
import numba
numba.config.DISABLE_JIT = 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
Expand Down
8 changes: 2 additions & 6 deletions benchmarks/benchmarks/solarposition_numba.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@
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
import pvlib
from pvlib import solarposition


if parse_version(pvlib.__version__) >= parse_version('0.6.1'):
Expand Down
2 changes: 2 additions & 0 deletions ci/azure/conda_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
Python36-min:
python.version: '36'
suffix: '-min'
coverage: true # report coverage for both 36 and 36-min to combine
# coverage for both numba and non-numba codepaths
Python36:
python.version: '36'
coverage: true
Expand Down
2 changes: 2 additions & 0 deletions docs/sphinx/source/api.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _api:

.. currentmodule:: pvlib

#############
Expand Down
28 changes: 28 additions & 0 deletions docs/sphinx/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,34 @@ To install the NREL SPA algorithm for use with pvlib:
#. From the ``pvlib-python`` directory, run ``pip uninstall pvlib``
followed by ``pip install .``


.. _using_numba:

Numba Acceleration
------------------

Some of the models offered by pvlib-python are difficult to implement
using vectorized numpy code and instead use comparatively inefficient
python code. To avoid the slowdown of using basic python, some functions
in pvlib-python include optional JIT-compiling support through the
`numba <https://numba.pydata.org/>`_ python package. Installing numba
is not required to run these functions, but it will improve the runtime
of these functions significantly. Functions that can be accelerated
with numba have a corresponding note on their page in the :ref:`api`.

By default, numba is used automatically if it is present in your
python environment. However, it can be disabled by using the
``NUMBA_DISABLE_JIT`` environment variable. The same can be accomplished
by importing and configuring numba prior to importing pvlib, like this::

import numba
numba.config.DISABLE_JIT = 1
import pvlib

For more details, see numba's
`documentation <https://numba.pydata.org/numba-doc/dev/user/troubleshoot.html#disabling-jit-compilation>`_.


.. _references:

References
Expand Down
16 changes: 8 additions & 8 deletions pvlib/modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def basic_chain(times, latitude, longitude,
surface_tilt=None, surface_azimuth=None,
orientation_strategy=None,
transposition_model='haydavies',
solar_position_method='nrel_numpy',
solar_position_method='nrel',
airmass_model='kastenyoung1989',
altitude=None, pressure=None,
**kwargs):
Expand Down Expand Up @@ -132,7 +132,7 @@ def basic_chain(times, latitude, longitude,
transposition_model : str, default 'haydavies'
Passed to system.get_irradiance.

solar_position_method : str, default 'nrel_numpy'
solar_position_method : str, default 'nrel'
Passed to solarposition.get_solarposition.

airmass_model : str, default 'kastenyoung1989'
Expand Down Expand Up @@ -344,7 +344,7 @@ class ModelChain:
transposition_model : str, default 'haydavies'
Passed to system.get_irradiance.

solar_position_method : str, default 'nrel_numpy'
solar_position_method : str, default 'nrel'
Passed to location.get_solarposition.

airmass_model : str, default 'kastenyoung1989'
Expand Down Expand Up @@ -398,7 +398,7 @@ def __init__(self, system, location,
orientation_strategy=None,
clearsky_model='ineichen',
transposition_model='haydavies',
solar_position_method='nrel_numpy',
solar_position_method='nrel',
airmass_model='kastenyoung1989',
dc_model=None, ac_model=None, aoi_model=None,
spectral_model=None, temperature_model=None,
Expand Down Expand Up @@ -505,7 +505,7 @@ def with_pvwatts(cls, system, location,
orientation_strategy: None
clearsky_model: ineichen
transposition_model: perez
solar_position_method: nrel_numpy
solar_position_method: nrel
airmass_model: kastenyoung1989
dc_model: pvwatts_dc
ac_model: pvwatts_inverter
Expand All @@ -530,7 +530,7 @@ def with_sapm(cls, system, location,
orientation_strategy=None,
clearsky_model='ineichen',
transposition_model='haydavies',
solar_position_method='nrel_numpy',
solar_position_method='nrel',
airmass_model='kastenyoung1989',
name=None,
**kwargs):
Expand Down Expand Up @@ -560,7 +560,7 @@ def with_sapm(cls, system, location,
transposition_model : str, default 'haydavies'
Passed to system.get_irradiance.

solar_position_method : str, default 'nrel_numpy'
solar_position_method : str, default 'nrel'
Passed to location.get_solarposition.

airmass_model : str, default 'kastenyoung1989'
Expand Down Expand Up @@ -592,7 +592,7 @@ def with_sapm(cls, system, location,
orientation_strategy: None
clearsky_model: ineichen
transposition_model: haydavies
solar_position_method: nrel_numpy
solar_position_method: nrel
airmass_model: kastenyoung1989
dc_model: sapm
ac_model: snlinverter
Expand Down
Loading