From 51e48c671d13ebc5349fad50df3db9cd52793cd7 Mon Sep 17 00:00:00 2001 From: cdeline Date: Wed, 28 Aug 2024 14:35:58 -0600 Subject: [PATCH 1/6] Add checks for RAYPATH. Fixes #525 --- bifacial_radiance/main.py | 20 +++++++++++++++++- docs/sphinx/source/whatsnew/pending.rst | 28 +++++++++++++++++++++++++ tests/test_bifacial_radiance.py | 16 +++++++++++++- 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 docs/sphinx/source/whatsnew/pending.rst diff --git a/bifacial_radiance/main.py b/bifacial_radiance/main.py index 4088d6b6..20a5be82 100644 --- a/bifacial_radiance/main.py +++ b/bifacial_radiance/main.py @@ -302,7 +302,24 @@ def _subhourlydatatoGencumskyformat(gencumskydata, label='right'): if (gencumskydata.index.year[-1] == gencumskydata.index.year[-2]+1) and len(gencumskydata)>8760: gencumskydata = gencumskydata[:-1] return gencumskydata - # end _subhourlydatatoGencumskyformat + # end _subhourlydatatoGencumskyformat + +def _checkRaypath(): + # Ensure that os.environ['RAYPATH'] exists and contains current directory '.' + if os.name == 'nt': + splitter = ';' + else: + splitter = ':' + try: + raypath = os.getenv('RAYPATH', default=None) + if not raypath: + raise KeyError() + raysplit = raypath.split(splitter) + if not '.' in raysplit: + os.environ['RAYPATH'] = splitter.join(filter(None, raysplit + ['.'+splitter])) + except (KeyError, AttributeError, TypeError): + raise Exception('No RAYPATH set for RADIANCE. Please check your RADIANCE installation.') + class RadianceObj: @@ -361,6 +378,7 @@ def __init__(self, name=None, path=None, hpc=False): now = datetime.datetime.now() self.nowstr = str(now.date())+'_'+str(now.hour)+str(now.minute)+str(now.second) + _checkRaypath() # make sure we have RADIANCE path set up correctly # DEFAULTS diff --git a/docs/sphinx/source/whatsnew/pending.rst b/docs/sphinx/source/whatsnew/pending.rst new file mode 100644 index 00000000..a086decc --- /dev/null +++ b/docs/sphinx/source/whatsnew/pending.rst @@ -0,0 +1,28 @@ +.. _whatsnew_0440: + +v0.4.4 (XX / XX / 2024) +------------------------ +Bugfix Release ... + + +API Changes +~~~~~~~~~~~~ +* + +Enhancements +~~~~~~~~~~~~ +* Conduct an automated check for proper radiance RAYPATH setting (:issue:`525`) + + +Bug fixes +~~~~~~~~~ +* + +Documentation +~~~~~~~~~~~~~~ +* + +Contributors +~~~~~~~~~~~~ +* Silvana Ayala (:ghuser:`shirubana`) +* Chris Deline (:ghuser:`cdeline`) diff --git a/tests/test_bifacial_radiance.py b/tests/test_bifacial_radiance.py index 7df11da3..2bad7492 100644 --- a/tests/test_bifacial_radiance.py +++ b/tests/test_bifacial_radiance.py @@ -575,4 +575,18 @@ def test_customTrackerAngles(): trackerdict = demo.set1axis(azimuth=90, useMeasuredTrackerAngle=True) assert trackerdict[-20]['count'] == 3440 trackerdict = demo.set1axis(azimuth=90, useMeasuredTrackerAngle=False) - assert trackerdict[-20]['count'] == 37 \ No newline at end of file + assert trackerdict[-20]['count'] == 37 + +def test_raypath(): + # test errors and raypath updates + import re + raypath0 = os.getenv('RAYPATH', default=None) + + os.environ['RAYPATH'] = '' + with pytest.raises(Exception): + bifacial_radiance.main._checkRaypath() + os.environ['RAYPATH'] = 'test' + bifacial_radiance.main._checkRaypath() + assert '.' in re.split(':|;', os.environ['RAYPATH']) + + os.environ['RAYPATH'] = raypath0 \ No newline at end of file From e924ddefeaa995f3f6b91fc1641f861d971d7575 Mon Sep 17 00:00:00 2001 From: cdeline Date: Wed, 28 Aug 2024 15:42:35 -0600 Subject: [PATCH 2/6] Update call to scm_setuptools to avoid git errors. Fixes #535 --- docs/sphinx/source/whatsnew/pending.rst | 2 +- setup.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/sphinx/source/whatsnew/pending.rst b/docs/sphinx/source/whatsnew/pending.rst index a086decc..9c633aa0 100644 --- a/docs/sphinx/source/whatsnew/pending.rst +++ b/docs/sphinx/source/whatsnew/pending.rst @@ -16,7 +16,7 @@ Enhancements Bug fixes ~~~~~~~~~ -* +* pip install setup no longer crashes if command line git is not present. (:issue:`535`) Documentation ~~~~~~~~~~~~~~ diff --git a/setup.py b/setup.py index 9e5e54a0..37909a0a 100644 --- a/setup.py +++ b/setup.py @@ -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", From 950946007f7afa4d106e3b4d834e10a56e636aef Mon Sep 17 00:00:00 2001 From: cdeline Date: Wed, 28 Aug 2024 16:00:24 -0600 Subject: [PATCH 3/6] update whatsnew/pending.rst --- docs/sphinx/source/whatsnew/pending.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sphinx/source/whatsnew/pending.rst b/docs/sphinx/source/whatsnew/pending.rst index 9c633aa0..9a9bcb95 100644 --- a/docs/sphinx/source/whatsnew/pending.rst +++ b/docs/sphinx/source/whatsnew/pending.rst @@ -11,12 +11,12 @@ API Changes Enhancements ~~~~~~~~~~~~ -* Conduct an automated check for proper radiance RAYPATH setting (:issue:`525`) +* Conduct an automated check for proper radiance RAYPATH setting (:issue:`525`)(:pull:`537`) Bug fixes ~~~~~~~~~ -* pip install setup no longer crashes if command line git is not present. (:issue:`535`) +* 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 ~~~~~~~~~~~~~~ From 0e1647ce2e12dbc098c3be9d70c734f6b6679094 Mon Sep 17 00:00:00 2001 From: cdeline Date: Wed, 28 Aug 2024 16:40:58 -0600 Subject: [PATCH 4/6] Suppress hub-height warnings when both clearance_height and hub_height are passed to internal functions. Fixes #536 --- bifacial_radiance/main.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/bifacial_radiance/main.py b/bifacial_radiance/main.py index 20a5be82..b10107f1 100644 --- a/bifacial_radiance/main.py +++ b/bifacial_radiance/main.py @@ -168,7 +168,8 @@ def _modDict(originaldict, moddict, relative=False): return newdict -def _heightCasesSwitcher(sceneDict, preferred='hub_height', nonpreferred='clearance_height'): +def _heightCasesSwitcher(sceneDict, preferred='hub_height', nonpreferred='clearance_height', + suppress_warning=False): """ Parameters @@ -184,7 +185,9 @@ def _heightCasesSwitcher(sceneDict, preferred='hub_height', nonpreferred='cleara nonpreferred : TYPE, optional When sceneDict has hub_height and clearance_height, it wil ldelete this nonpreferred option. The default is 'clearance_height'. - + suppress_warning : Bool, default False + If both heights passed in SceneDict, suppress the warning + Returns ------- sceneDict : TYPE @@ -239,9 +242,10 @@ def _heightCasesSwitcher(sceneDict, preferred='hub_height', nonpreferred='cleara del sceneDict[nonpreferred] elif heightCases == '_clearance_height__hub_height__': - print("sceneDict Warning: 'hub_height' and 'clearance_height'"+ - " are being passed. Using "+preferred+ - " and removing "+ nonpreferred) + if not suppress_warning: + print("sceneDict Warning: 'hub_height' and 'clearance_height'"+ + " are being passed. Using "+preferred+ + " and removing "+ nonpreferred) del sceneDict[nonpreferred] else: @@ -4101,7 +4105,8 @@ def _checkSensors(sensors): sceneDict, use_clearanceheight = _heightCasesSwitcher(sceneDict, preferred = 'hub_height', - nonpreferred = 'clearance_height') + nonpreferred = 'clearance_height', + suppress_warning=True) if use_clearanceheight : height = sceneDict['clearance_height'] + 0.5* \ From 14d0c8d950d3689da371d0125ff4a54b9572ff99 Mon Sep 17 00:00:00 2001 From: cdeline Date: Fri, 30 Aug 2024 14:36:26 -0600 Subject: [PATCH 5/6] update whatsnew/pending.rst about removed warnings in moduleAnalysis --- docs/sphinx/source/whatsnew/pending.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sphinx/source/whatsnew/pending.rst b/docs/sphinx/source/whatsnew/pending.rst index 9a9bcb95..43d4e7a2 100644 --- a/docs/sphinx/source/whatsnew/pending.rst +++ b/docs/sphinx/source/whatsnew/pending.rst @@ -20,7 +20,7 @@ Bug fixes Documentation ~~~~~~~~~~~~~~ -* +* No longer provide a warning message when both `hub_height` and `clearance_height` are passed to :py:class:`~bifacial_radiance.AnalysisObj.moduleAnalysis` (:pull:`540`) Contributors ~~~~~~~~~~~~ From 4b13d48d68fa1210f03605f13421fec94a7938a5 Mon Sep 17 00:00:00 2001 From: cdeline Date: Fri, 30 Aug 2024 16:15:04 -0600 Subject: [PATCH 6/6] bump to pandas 1.4.4 and numba 0.58.1 in requirements.txt --- docs/sphinx/source/conf.py | 4 ++-- requirements.txt | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/sphinx/source/conf.py b/docs/sphinx/source/conf.py index a7d5a544..03adb108 100644 --- a/docs/sphinx/source/conf.py +++ b/docs/sphinx/source/conf.py @@ -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() diff --git a/requirements.txt b/requirements.txt index fa3d21bb..77b53b66 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,8 +7,9 @@ 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