Skip to content

Commit

Permalink
Tutorial 21 functional
Browse files Browse the repository at this point in the history
  • Loading branch information
cdeline committed Sep 3, 2024
1 parent 2e7fbf2 commit a33f7fc
Show file tree
Hide file tree
Showing 5 changed files with 280 additions and 196 deletions.
15 changes: 8 additions & 7 deletions bifacial_radiance/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def __init__(self, name=None, path=None, hpc=False):
#self.nMods = None # number of modules per row
#self.nRows = None # number of rows per scene
self.hpc = hpc # HPC simulation is being run. Some read/write functions are modified
self.CompiledResults = None # DataFrame of cumulative results, output from self.calculateResults()
self.CompiledResults = None # DataFrame of cumulative results, output from self.calculateResults1axis()

now = datetime.datetime.now()
self.nowstr = str(now.date())+'_'+str(now.hour)+str(now.minute)+str(now.second)
Expand Down Expand Up @@ -2731,7 +2731,7 @@ def analysis1axis(self, trackerdict=None, singleindex=None, accuracy='low',
Loop through trackerdict and runs linescans for each scene and scan in there.
If multiple scenes exist in the trackerdict, only ONE scene can be analyzed at a
time.
Todo: how to run calculateResults with array of multiple results
TODO: how to run calculateResults with array of multiple results
Parameters
----------------
Expand Down Expand Up @@ -3075,7 +3075,7 @@ def _printRow(analysisobj, key):
if module is None:
module_local = trackerdict[key]['scenes'][analysis.sceneNum].module
else:
module_local = None
module_local = module
power_data = analysis.calc_performance(meteo_data=meteo_data,
module=module_local,
cumulativesky=self.cumulativesky,
Expand Down Expand Up @@ -3104,7 +3104,7 @@ def _printRow(analysisobj, key):
self.CompiledResults = performance.calculateResultsGencumsky1axis(results=self.CompiledResults,
bifacialityfactor=1.0,
fillcleanedSensors=True, agriPV=False)

self.CompiledResults.to_csv(os.path.join('results', 'Cumulative_Results.csv'))

self.trackerdict = trackerdict
Expand Down Expand Up @@ -3450,7 +3450,7 @@ def __init__(self, module=None, name=None, hpc=False):
self.module = ModuleObj(name=module)


elif type(module) == ModuleObj: # try moduleObj
elif str(type(module)) == "<class 'bifacial_radiance.module.ModuleObj'>": # try moduleObj
self.module = module

#self.moduleDict = self.module.getDataDict()
Expand Down Expand Up @@ -4357,13 +4357,13 @@ def __init__(self, octfile=None, name=None, hpc=False):

def getResults(self):
"""
go through the AnalysisObj and return a dict of irraidance result keys,
This can be passed into CompileResults
go through the AnalysisObj and return a dict of irradiance result keys.
Returns
-------
Results : dict. irradiance scan results
"""
#TODO (optional?) Merge power_data to returned values??
keylist = ['rowWanted', 'modWanted', 'sceneNum', 'name', 'x', 'y','z',
'Wm2Front', 'Wm2Back', 'Wm2Ground', 'backRatio', 'mattype', 'rearMat' ]
resultdict = {k: v for k, v in self.__dict__.items() if k in keylist}
Expand Down Expand Up @@ -5431,6 +5431,7 @@ def calc_performance(self, meteo_data, cumulativesky, module,
from bifacial_radiance import performance
from bifacial_radiance import ModuleObj

#TODO: make this operate on the MetObj class, not special dictionary!
#TODO: Check that meteo_data only includes correct kwargs
# 'dni', 'ghi', 'dhi', 'temp_air', 'wind_speed'

Expand Down
26 changes: 6 additions & 20 deletions bifacial_radiance/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,33 +98,20 @@ def __init__(self, name=None, x=None, y=None, z=None, bifi=1, modulefile=None,
omegaParams : dict
Dictionary with input parameters for creating a omega or module support
structure. Shortcut for ModuleObj.addOmega()
CECMod : Dictionary
CECMod : Dictionary with performance parameters needed for self.calculatePerformance()
lpha_sc, a_ref, I_L_ref, I_o_ref, R_sh_ref, R_s, Adjust
hpc : bool (default False)
Set up module in HPC mode. Namely turn off read/write to module.json
and just pass along the details in the module object. Note that
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.
#Efficiency=None, Temp_coeff=None, Peak_Power=None, Module_name=None):
# TODO: REMOVE THESE INPUT PARAMETERS?
Efficiency : float (default None)
Information about module efficiency in percentage. Not currently
used to calculate performance.
Temp_coeff : float (default None)
Information about module temperature coefficient in %. Not
currently used to calculate performance.
Peak_Power : float (default None)
Information about module Peak Power in Watts. Not currently used to
calculate performance.
Module name : string (default None)
Information about module's name.
'"""

self.keys = ['x', 'y', 'z', 'modulematerial', 'scenex','sceney',
'scenez','numpanels','bifi','text','modulefile', 'glass',
'offsetfromaxis','xgap','ygap','zgap', 'CECMod' ]
'offsetfromaxis','xgap','ygap','zgap']

#replace whitespace with underlines. what about \n and other weird characters?
# TODO: Address above comment?
Expand Down Expand Up @@ -184,8 +171,7 @@ def __init__(self, name=None, x=None, y=None, z=None, bifi=1, modulefile=None,
if cellModule:
self.addCellModule(**cellModule, recompile=False)

if CECMod:
self.addCEC(CECMod, glass)
self.addCEC(CECMod, glass, bifi=bifi)

if self._manual_text:
print('Warning: Module text manually passed and not '
Expand Down Expand Up @@ -721,8 +707,8 @@ def addCEC(self, CECMod, glassglass=False, bifi=None):

self.CECMod = CECMod
self.glassglass = glassglass
if bifi is None:
bifi = self.bifi
if bifi:
self.bifi = bifi



Expand Down
Loading

0 comments on commit a33f7fc

Please sign in to comment.