Skip to content

Commit

Permalink
Update tests, autoAPI and sphinx edits
Browse files Browse the repository at this point in the history
  • Loading branch information
cdeline committed Sep 11, 2024
1 parent 013fa7c commit 4b9e321
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 25 deletions.
11 changes: 6 additions & 5 deletions bifacial_radiance/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def __init__(self, name=None, path=None, hpc=False):
self.compiledResults = pd.DataFrame(None) # DataFrame of cumulative results, output from self.calculatePerformance1axis()

now = datetime.datetime.now()
self.nowstr = str(now.date())+'_'+str(now.hour)+str(now.minute)+str(now.second)
self.nowstr = str(now.date())+'_'+str(now.hour).zfill(2)+str(now.minute).zfill(2)+str(now.second).zfill(2)
_checkRaypath() # make sure we have RADIANCE path set up correctly

# DEFAULTS
Expand Down Expand Up @@ -2268,7 +2268,7 @@ def makeModule(self, name=None, x=None, y=None, z=None, modulefile=None,
zgap=0.1, numpanels=1, rewriteModulefile=True,
glass=False, modulematerial=None, bifi=1, **kwargs):
"""
pass module generation details into ModuleObj(). See ModuleObj()
pass module generation details into ModuleObj(). See ModuleObj
docstring for more details
"""
from bifacial_radiance import ModuleObj
Expand Down Expand Up @@ -3028,7 +3028,7 @@ def calculatePerformance1axis(self, trackerdict=None, module=None,
Parameters
----------
----------
module: ModuleObj from scene.module
It's best to set this in advance in the ModuleObj.
If passed in here, it overrides the value that may be set in the
Expand All @@ -3051,6 +3051,7 @@ def calculatePerformance1axis(self, trackerdict=None, module=None,
Pout_raw: power output calculated from POA_total, considers
wind speed and temp_amb if in trackerdict.
Pout: power output considering electrical mismatch
'''

from bifacial_radiance import performance
Expand Down Expand Up @@ -5460,7 +5461,7 @@ def calculatePerformance(self, meteo_data, cumulativesky, module,
considering electrical mismatch, using PVLib. Cell temperature is calculated
Parameters
----------
----------
meteo_data : Dict
Dictionary with meteorological data needed to run CEC model. Keys:
'temp_air', 'wind_speed', 'dni', 'dhi', 'ghi'
Expand All @@ -5481,7 +5482,7 @@ def calculatePerformance(self, meteo_data, cumulativesky, module,
'Mismatch': mismatch calculated from the MAD distribution of POA_total
'Pout_raw': power output calculated from POA_total, considers wind speed and temp_amb if in trackerdict.
'Pout': power output considering electrical mismatch
"""

from bifacial_radiance import performance
Expand Down
15 changes: 7 additions & 8 deletions bifacial_radiance/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,21 @@ 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='', customObject='', xgap=0.01, ygap=0.0, zgap=0.1,
numpanels=1, rewriteModulefile=True, cellModule=None,
glass=False, modulematerial='black', tubeParams=None,
frameParams=None, omegaParams=None, CECMod=None, hpc=False):

"""
Add module details to the .JSON module config file module.json.
Module definitions assume that the module .rad file is defined
with zero tilt, centered along the x-axis and y-axis for the center
of rotation of the module (+X/2, -X/2, +Y/2, -Y/2 on each side).
Tip: to define a module that is in 'portrait' mode, y > x.
Parameters
------------
name : str
Expand All @@ -55,7 +54,7 @@ def __init__(self, name=None, x=None, y=None, z=None, bifi=1, modulefile=None,
y : numeric
Length of module (meters)
bifi : numeric
Bifaciality of the panel (used for calculatePerformance). Between 0 (monofacial)
Bifaciality of the panel (used for calculatePerformance). Between 0 (monofacial)
and 1, default 1.
modulefile : str
Existing radfile location in \objects. Otherwise a default value is used
Expand All @@ -68,7 +67,7 @@ def __init__(self, name=None, x=None, y=None, z=None, bifi=1, modulefile=None,
generated module (unlike "text"), but adds to it at the end.
customObject : str
Append to the module object file a pre-genereated radfile. This
must start with the file path\name. Does not overwrite
must start with the file path name. Does not overwrite
generated module (unlike "text"), but adds to it at the end.
It automatically inserts radiance's text before the object name so
its inserted into scene properly ('!xform -rz 0')
Expand Down Expand Up @@ -107,9 +106,9 @@ def __init__(self, name=None, x=None, y=None, z=None, bifi=1, modulefile=None,
calling e.g. addTorquetube() after this will tend to write to the
module.json so pass all geometry parameters at once in to makeModule
for best response.
'"""

"""
self.keys = ['x', 'y', 'z', 'modulematerial', 'scenex','sceney',
'scenez','numpanels','bifi','text','modulefile', 'glass',
'offsetfromaxis','xgap','ygap','zgap']
Expand Down
1 change: 1 addition & 0 deletions docs/sphinx/source/manualapi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Functions and methods to generate modules
:toctree: generated/
:caption: Modules

ModuleObj.__init__
RadianceObj.makeModule
ModuleObj.addTorquetube
ModuleObj.addCellModule
Expand Down
8 changes: 4 additions & 4 deletions docs/sphinx/source/whatsnew/v0.4.3.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
.. _whatsnew_0430:

v0.4.3 (XX / XX / 2023)
v0.4.3 (08 / 27 / 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`)
* 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`)

Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx/source/whatsnew/v0.5.0.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. _whatsnew_050:

v0.5.0 (4 / XX / 2024)
v0.5.0 (XX / XX / 2024)
------------------------
Bugfix Release ...

Expand Down
5 changes: 4 additions & 1 deletion tests/test_bifacial_radiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@

def test_RadianceObj_set1axis():
# test set1axis. requires metdata for boulder.
name = "_test_set1axis"
#name = "_test_set1axis"
name = None
demo = bifacial_radiance.RadianceObj(name)
assert len(str(demo)) > 300 # Make sure something is printed out here for demo.__repr__

Expand All @@ -60,6 +61,8 @@ def test_RadianceObj_set1axis():
trackerdict = demo.set1axis()
assert trackerdict[0]['count'] == 78 #80
assert trackerdict[45]['count'] == 822 #
assert len(demo.name) == 17


def test_RadianceObj_fixed_tilt_end_to_end():
# just run the demo example. Rear irradiance fraction roughly 11.8% for 0.95m landscape panel
Expand Down
16 changes: 10 additions & 6 deletions tests/test_mismatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,7 @@ def test_MAD():


def test_analysisIrradianceandPowerMismatch():
#analysisIrradianceandPowerMismatch(testfolder, writefiletitle,
# portraitorlandscape, bififactor,
# numcells=72, downsamplingmethod='byCenter'):

#testfolder = r'C:\Users\cdeline\Documents\Python Scripts\Bifacial_Radiance\tests\results_mismatch'
#writefiletitle = r'C:\Users\cdeline\Documents\Python Scripts\Bifacial_Radiance\tests\mismatch.txt'

testfolder = os.path.join(TESTDIR,'results_mismatch')
writefiletitle = os.path.join(TESTDIR,'mismatch.txt')
bifacial_radiance.mismatch.analysisIrradianceandPowerMismatch(testfolder, writefiletitle,
Expand All @@ -88,6 +83,15 @@ def test_analysisIrradianceandPowerMismatch():
df_all = pd.read_csv(writefiletitle)
assert df_all.Mismatch_rel[0] == pytest.approx(0.376, abs = 0.001)
assert df_all["MAD/G_Total"][0] == pytest.approx(1.987, abs = 0.001)
bifacial_radiance.mismatch.analysisIrradianceandPowerMismatch(testfolder, writefiletitle,
'portrait', bififactor=1,
numcells=96, downsamplingmethod='byAverage')
df_all = pd.read_csv(writefiletitle)
assert df_all.Mismatch_rel[0] == pytest.approx(0.342, abs = 0.001)
assert df_all["MAD/G_Total"][0] == pytest.approx(1.9175, abs = 0.001)
# need case: sensorsy < cellsy
# need case: sensorsy == cellsy



def test_mismatch_fit3():
Expand Down

0 comments on commit 4b9e321

Please sign in to comment.