Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/NREL/main' into silvana-issues-…
Browse files Browse the repository at this point in the history
…fixing
  • Loading branch information
cdeline committed Sep 8, 2024
2 parents 5287eb9 + c932849 commit d8c4452
Show file tree
Hide file tree
Showing 15 changed files with 308 additions and 144 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,30 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Print triggering event info
run: |
echo "${{ github.actor }} triggered run #${{ github.run_number }} with event type ${{ github.event_name }}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_NREL_USER }}
password: ${{ secrets.DOCKERHUB_NREL_TOKEN }}

- name: Login to GitHub Package Registry
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test
name: test

on: [pull_request, push]

Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
echo "/home/runner/work/bifacial_radiance/bifacial_radiance/SMARTS_295_Linux" >> $GITHUB_PATH
- name: Test with pytest ${{ matrix.env }}
uses: coactions/setup-xvfb@v1 # GUI testing requires xvfb
uses: coactions/setup-xvfb@6b00cf1889f4e1d5a48635647013c0508128ee1a # GUI testing requires xvfb
with:
run: |
pytest --cov=bifacial_radiance
Expand All @@ -69,6 +69,7 @@ jobs:
SMARTSPATH: /home/runner/work/bifacial_radiance/bifacial_radiance/SMARTS_295_Linux

- name: Coveralls
continue-on-error: true #prevent coveralls from blowing the test report
if: matrix.python-version == 3.11 # && ${{ matrix.env }} == '-r requirements.txt .[all]'
run: |
coveralls --service=github
Expand Down
258 changes: 166 additions & 92 deletions bifacial_radiance/main.py

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions bifacial_radiance/mismatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ def mismatch_fit3(data):
fit3 = 0.054*mad + 0.068*mad2

if fit3.__len__() == 1:
fit3 = float(fit3)
if isinstance(fit3, pd.Series):
fit3 = float(fit3.iloc[0])
else:
fit3 = float(fit3)

return fit3

Expand Down Expand Up @@ -240,7 +243,10 @@ def mismatch_fit2(data):
fit2 = 0.142*mad + 0.032*mad2

if fit2.__len__() == 1:
fit2 = float(fit2)
if isinstance(fit2, pd.Series):
fit2 = float(fit2.iloc[0])
else:
fit2 = float(fit2)

return fit2

Expand Down
3 changes: 2 additions & 1 deletion bifacial_radiance/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class ModuleObj(SuperClass):
Pass this object into makeScene or makeScene1axis.
"""


def __repr__(self):
return str(type(self)) + ' : ' + str(self.getDataDict())
def __init__(self, name=None, x=None, y=None, z=None, bifi=1,
modulefile=None, text=None, customtext='', xgap=0.01,
ygap=0.0, zgap=0.1, numpanels=1, rewriteModulefile=True,
Expand Down
28 changes: 19 additions & 9 deletions bifacial_radiance/performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""

import pvlib

import pandas as pd

def calculatePerformance(effective_irradiance, CECMod, temp_air=None, wind_speed=1, temp_cell=None, glassglass=False):
'''
Expand Down Expand Up @@ -50,17 +50,27 @@ def calculatePerformance(effective_irradiance, CECMod, temp_air=None, wind_speed

temp_cell = pvlib.temperature.sapm_cell(effective_irradiance, temp_air, wind_speed,
temp_model_params['a'], temp_model_params['b'], temp_model_params['deltaT'])


if isinstance(CECMod, pd.DataFrame):
#CECMod.to_pickle("CECMod.pkl")
if len(CECMod) == 1:
CECMod1 = CECMod.iloc[0]
else:
print("More than one Module passed. Error, using 1st one")
CECMod1 = CECMod.iloc[0]
else:
CECMod1 = CECMod

IL, I0, Rs, Rsh, nNsVth = pvlib.pvsystem.calcparams_cec(
effective_irradiance=effective_irradiance,
temp_cell=temp_cell,
alpha_sc=float(CECMod.alpha_sc),
a_ref=float(CECMod.a_ref),
I_L_ref=float(CECMod.I_L_ref),
I_o_ref=float(CECMod.I_o_ref),
R_sh_ref=float(CECMod.R_sh_ref),
R_s=float(CECMod.R_s),
Adjust=float(CECMod.Adjust)
alpha_sc=float(CECMod1.alpha_sc),
a_ref=float(CECMod1.a_ref),
I_L_ref=float(CECMod1.I_L_ref),
I_o_ref=float(CECMod1.I_o_ref),
R_sh_ref=float(CECMod1.R_sh_ref),
R_s=float(CECMod1.R_s),
Adjust=float(CECMod1.Adjust)
)

IVcurve_info = pvlib.pvsystem.singlediode(
Expand Down
4 changes: 2 additions & 2 deletions docs/sphinx/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def __getattr__(cls, name):
MOCK_MODULES = []
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
"""
# import distutils before calling pd.show_versions()
# import distutils before calling pd.show_versions(). not needed for pd >= 1.4.x
# https://github.com/pypa/setuptools/issues/3044
import distutils # noqa: F401
#import distutils # noqa: F401

import pandas as pd
pd.show_versions()
Expand Down
1 change: 1 addition & 0 deletions docs/sphinx/source/whatsnew.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ What's New

These are new features and improvements of note in each release.

.. include:: whatsnew/v0.4.3.rst
.. include:: whatsnew/v0.4.2.rst
.. include:: whatsnew/v0.4.1.rst
.. include:: whatsnew/v0.4.0.rst
Expand Down
24 changes: 8 additions & 16 deletions docs/sphinx/source/whatsnew/pending.rst
Original file line number Diff line number Diff line change
@@ -1,37 +1,29 @@
.. _whatsnew_0430:
.. _whatsnew_0440:

v0.4.3 (XX / XX / 2023)
v0.4.4 (XX / XX / 2024)
------------------------
Bugfix Release ...


API Changes
~~~~~~~~~~~~
*A new function can now be called to compile results and report out final irradiance and performance data: :py:class:`~bifacial_radiance.RadianceObj.compileResults`.
*Multiple modules and rows can now be selected in a single analysis scan. ``modWanted`` and ``rowWanted`` inputs in :py:class:`~bifacial_radiance.RadianceObj.analysis1axis` can now be a list, to select multiple rows and modules for scans. (:issue:`405`)(:pull:`408`)
*To support multiple modules and row scans for 1axis simulations, outputs like Wm2Front are now stored in ``trackerdict``.``Results`` (:issue:`405`)(:pull:`408`)
* ``mismatch.mad_fn`` has new functionality and input parameter `axis`. If a 2D matrix or dataframe is passed in as data, MAD is calculated along the row (default) or along the columns by passing 'axis=1'
* :func:`bifacial_radiance.mismatch.mismatch_fit3` has been deprecated in favour of :func:`bifacial_radiance.mismatch.mismatch_fit2` which has a greater agreement with anual energy yield data (:issue:`520`)
*

Enhancements
~~~~~~~~~~~~
* Added :func:`bifacial_radiance.mismatch.mismatch_fit2`, similar to :func:`bifacial_radiance.mismatch.mismatch_fit3`, with the recommended coefficients of the original publication. (:pull:`520`)
* Conduct an automated check for proper radiance RAYPATH setting (:issue:`525`)(:pull:`537`)


Bug fixes
~~~~~~~~~
* Fixed Pandas 2.0 errors by re-factoring ``mismatch.mad_fn`` (:issue:`449`)
* Switch from un-supported Versioneer to setuptools_scm (:issue:`519`)
* Numpy 2.0 compatibility bug (:issue:`521`)
* Fixed bug in :func:`bifacial_radiance.mismatch.mismatch_fit3` where the function was not returning the correct values. It has also been deprecated in favour of :func:`bifacial_radiance.mismatch.mismatch_fit2` which has a greater agreement with anual energy yield data (:issue:`520`)
* versioning with setuptools_scm- set fallback_version to bifirad v0.4.3 to prevent crashes if git is not present (:issue:`535`)(:pull:`539`)

Documentation
~~~~~~~~~~~~~~
* Edge effects evaluation tutorial 23, with the new functionality of multiple modules/rows on the same analysis scan.
* Updates to example notebooks
* No longer provide a warning message when both `hub_height` and `clearance_height` are passed to :py:class:`~bifacial_radiance.AnalysisObj.moduleAnalysis` (:pull:`540`)
* More useful __repr__ output in :py:class:`~bifacial_radiance.AnalysisObj and :py:class:`~bifacial_radiance.MetObj (:issue:`471`)

Contributors
~~~~~~~~~~~~
* Silvana Ayala (:ghuser:`shirubana`)
* Chris Deline (:ghuser:`cdeline`)
* Kevin Anderson (:ghuser:`kandersolar`)
* Echedey Luis (:ghuser:`echedey-ls`)
47 changes: 47 additions & 0 deletions docs/sphinx/source/whatsnew/v0.4.3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.. _whatsnew_0430:

v0.4.3 (XX / XX / 2023)
------------------------
Bugfix Release ...


API Changes
~~~~~~~~~~~~
*A new function can now be called to compile results and report out final irradiance and performance data: :py:class:`~bifacial_radiance.RadianceObj.compileResults`.
*Multiple modules and rows can now be selected in a single analysis scan. ``modWanted`` and ``rowWanted`` inputs in :py:class:`~bifacial_radiance.RadianceObj.analysis1axis` can now be a list, to select multiple rows and modules for scans. (:issue:`405`)(:pull:`408`)
*To support multiple modules and row scans for 1axis simulations, outputs like Wm2Front are now stored in ``trackerdict``.``Results`` (:issue:`405`)(:pull:`408`)
* ``mismatch.mad_fn`` has new functionality and input parameter `axis`. If a 2D matrix or dataframe is passed in as data, MAD is calculated along the row (default) or along the columns by passing 'axis=1'
* :func:`bifacial_radiance.mismatch.mismatch_fit3` has been deprecated in favour of :func:`bifacial_radiance.mismatch.mismatch_fit2` which has a greater agreement with anual energy yield data (:issue:`520`)
Enhancements
~~~~~~~~~~~~
* Added :func:`bifacial_radiance.mismatch.mismatch_fit2`, similar to :func:`bifacial_radiance.mismatch.mismatch_fit3`, with the recommended coefficients of the original publication. (:pull:`520`)
* Including `pyRadiance` as a requirement to help streamline RADIANCE installation and calls in a future release. (:pull:`532`)

Bug fixes
~~~~~~~~~
* Fixed error passing all of `sceneDict` into :py:class:`~bifacial_radiance.makeScene1axis`. (:issue:`502`)
* Fixed Pandas 2.0 errors by re-factoring ``mismatch.mad_fn`` (:issue:`449`)
* Switch from un-supported Versioneer to setuptools_scm (:issue:`519`)
* Numpy 2.0 compatibility bug (:issue:`521`)
* Fixed bug in :func:`bifacial_radiance.mismatch.mismatch_fit3` where the function was not returning the correct values. It has also been deprecated in favour of :func:`bifacial_radiance.mismatch.mismatch_fit2` which has a greater agreement with anual energy yield data (:issue:`520`)
* Updated Github Actions to use Node20: checkout@v4, setup-python@v5, coactions/setup-xvfb, setup-buildx-action@v3 (:pull:`517`)
* Updated Github Actions to make Coveralls fail silently if it has an internal server error (:pull:`517`)
* Fix PerformanceWarning and SettingWithCopyWarning (:issue:`515`)
* Switch from Versioneer to setuptools_scm (:pull:`522`)
* Enable `coerce_year`=None if the TMYfile is all the same year (:issue:`526`)

Documentation
~~~~~~~~~~~~~~
* Edge effects evaluation tutorial 23, with the new functionality of multiple modules/rows on the same analysis scan.
* Updates to example notebooks
* Reduce number of digits in makeScene .rad file titles. (:pull:`503`)
* Reduce number of digits saved to files in \results (:pull:`534`)
* In the sceneDict reported in the trackerdict, save both `clearance_height` and `hub_height` parameters. (:pull:`503`)

Contributors
~~~~~~~~~~~~
* Silvana Ayala (:ghuser:`shirubana`)
* Chris Deline (:ghuser:`cdeline`)
* Kevin Anderson (:ghuser:`kandersolar`)
* Echedey Luis (:ghuser:`echedey-ls`)
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ coverage==7.2.1
cycler==0.11.0
idna==3.4
importlib-metadata==6.0.0
ipython==8.10.0
ipython==8.13.0
kiwisolver==1.4.4
matplotlib==3.5.1
more-itertools==9.1.0
numba==0.58.1
numpy==1.24.2
pandas==1.3.5
pandas==1.4.4
pluggy==1.0.0
pvlib==0.9.4
pvmismatch==4.1
Expand Down
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
# version='0.3.4',
#version=versioneer.get_version(),
#cmdclass=versioneer.get_cmdclass(),
use_scm_version=True,
use_scm_version={"fallback_version":"0.4.3"},
description='Tools to interface with Radiance for the PV researcher',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down Expand Up @@ -99,7 +97,7 @@
'pvmismatch',
'configparser',
'requests',

'pyradiance',
],

# List additional groups of dependencies here (e.g. development
Expand Down
Loading

0 comments on commit d8c4452

Please sign in to comment.