PVfit: Photovoltaic (PV) Device Performance Measurement and Modeling
IMPORTANT: This code is pre-release, and so the code organiztion and Application Programming Interface (API) should be expected to change with minimal warning.
NOTICE: We are in the process of open-sourcing the single-diode equation (SDE) and
single-diode model (SDM) fitting algorithms (🎉), and thus moving the related code here.
The move is reasonably complete, but the code for SDM fitting using full I-V curves has
not yet been ported. Likewise, the documentation badly needs updating, so for now we
refer users to the demos/getting_started.py
modules in the various subpackages.
PVfit is currently focused on direct-current (DC) PV module performance measurement and
modeling. Following the standardized technical approach of most accredited PV
calibration laboratories for measuring current-voltage (I-V) curves using reference
devices, PVfit formulates it's DC performance models in terms of the effective
irradiance ratio (e.g., F = Isc / Isc0 = M * Isc,ref / Isc0,ref) to quantify the
effective irradiance on a PV device. This has benefits for both model calibration and
performane simulation. PVfit provides extensions for working with common
irradiance-based MET-station data, and PVfit also supports inference of
effective-irradiance ratio and cell temperature directly from I-V measurements, see
(poster). See
this paper for a more detailed introduction. Email
Mark Campanelli for support, etc. See the
demos/getting_started.py
in individual subpackages to get started with specific
functionalities—
- Measurement
- Current-Voltage (I-V) Data/Curves
- Spectral Mismatch Correction
- Quantum Efficiency/Spectral Response and Spectrum Types
- Spectral Mismatch Correction Computations
- Short-Circuit Current Calibration Using Absolute Spectral Response (FUTURE)
- Modeling
We still need to improve test coverage for certain subpackages, esp.the simple SDM.
pvfit
minimally requires python>=3.10,<3.13 with
numpy and scipy. It is tested with
CPython on recent versions of Ubuntu, macOS, and Windows. We suggest using a suitable
Python virtual environment that provides pip.
This package is available at PyPI, but it is still pre-v1. With
sufficiently recent versions of pip
and setuptools
, install pvfit
with the extra
packages needed for the demos using—
python -m pip install --upgrade pip setuptools
python -m pip install pvfit[demo]
Verify your installation—
python -c "from pvfit import __version__; print(__version__)"
which should print something similar to—
0.0.1
You should now be able to explore PVfit's functionality with the getting_started.py
modules in the various demos
directories of the various subpackages.
NOTES:
- You may want to install your own optimized versions of
numpy
andscipy
(e.g., using conda), otherwise this setup will grab the default versions from PyPI. - The
demo
option adds the matplotlib, pandas, and pvlib-python packages in order to run all the provided demonstrations in thedemos
directories. - You can also run
pvfit
on the bleeding edge. If you havegit
installed, then install from themain
branch using—
python -m pip install --upgrade "pvfit[demo] @ git+https://github.com/markcampanelli/pvfit"
Clone the repo at https://github.com/markcampanelli/pvfit using your preferred git method, and go to the repo's root directory.
Install pvfit
with all extras in editable (development) mode with pip
—
python -m pip install --upgrade pip setuptools
python -m pip install -e .[demo,dev,docs,test]
python -m pip install --progress-bar off "ivcurves @ git+https://github.com/cwhanse/ivcurves@7ae47284b23cfff167932b8cccae53c10ebf9bf9"
This also installs the libraries needed to test, develop the code demonstrations, and build documentation and source and wheel distributions.
Verify your installation—
python -c "from pvfit import __version__; print(__version__)"
which should print something similar to—
0.1.dev9+gadf7f38.d20190812
Next, make sure that the tests are passing.
From the root directory—
python -m pytest --doctest-modules --cov=pvfit --cov-report=html:htmlcov tests
The root of the generated coverage report is at artifacts/test/htmlcov/index.html
(not
committed).
From the docs subdirectory—
sphinx-apidoc -f -o . ../pvfit ../*_test.py
then—
make html
The root of the generated documentation is at docs/_build/html/pvfit.html
(not
committed).
PEP-517-compliant build is used to
generate distributions using setuptools as the
build backend (specified in pyproject.toml
). From the repo root, execute--
python -m build
Pure-Python *.whl
and *.tar.gz
files are placed in the dist
directory (not
committed).
Alternatively, nuitka can be used to transpile the
Python source code into faster-executing, compiled C code with the same Python
interface. With an appropriate setup for Nuitka (compilers, etc.), swap the
[build-system]
table in the pyproject.toml
, then--
python -m build
A platfrom-specific *.whl
file is placed in the dist
directory (not committed). The
included Python extension module has the same interface. Users may wish to remove
tests and demos before generating such wheel files.
Finally, the distribution manifests (cf. MANIFEST.in
) are checked using--
python -m check_manifest
Currently, numpy
and scipy
are
the only runtime dependencies. In order to ensure a straightforward, consistent, and
well-tested API, the decision has been made to avoid any dependecy of the core code on
pandas
. However, a design goal is for straightforward
integration with consumers that use pandas
, e.g., integrating computations with
Series
and
DataFrame
objects. To avoid bloat, we also avoid dependency on plotting libraries such as
matplotlib
. Any new dependencies or version ranges should
be appropriately recorded in pyproject.toml.
- Unit testing is a must, with a "collocation" scheme, i.e.,
module_test.py
to testmodule.py
in the same directory. 100% code coverage is the goal. - Type hints should be used throughout (WIP).
pylint
is used for linting, withblack
's default 88-character line limit (configured in pyproject.toml). Check before committing code using--
python -m pylint .
Skip troublesome lines (sparingly) with the suffix # pylint: disable=<code>
.
black
is used to autoformat code. Autoformat before committing code, using--
python -m black .
The author and maintainer of this code is Mark Campanelli, the proprietor of Intelligent Measurement Systems LLC (IMS), in Bozeman, MT, USA. Your suggestions/bug reports, questions/discussions, and contributions are welcome.