Skip to content

Commit

Permalink
Added groundscan
Browse files Browse the repository at this point in the history
  • Loading branch information
sofiatoropovaa committed Dec 14, 2023
1 parent 2430494 commit e460768
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 16 deletions.
Binary file not shown.
18 changes: 18 additions & 0 deletions bifacial_radiance/data/module.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
{
"PVmod": {
"bifi": 1,
"glass": false,
"modulefile": "objects/PVmod.rad",
"modulematerial": "black",
"numpanels": 1,
"offsetfromaxis": 0,
"scenex": 2.01,
"sceney": 1.0,
"scenez": 0.1,
"text": "! genbox black PVmod 2 1 0.02 | xform -t -1.0 -0.5 0 -a 1 -t 0 1.0 0",
"x": 2,
"xgap": 0.01,
"y": 1,
"ygap": 0.0,
"z": 0.02,
"zgap": 0.1
},
"PrismSolar-Bi60": {
"bifi": 1,
"cellModule": {
Expand Down
46 changes: 30 additions & 16 deletions bifacial_radiance/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2720,7 +2720,7 @@ def analysis1axis(self, trackerdict=None, singleindex=None, accuracy='low',
customname=None, modWanted=None, rowWanted=None,
sensorsy=9, sensorsx=1,
modscanfront = None, modscanback = None, relative=False,
debug=False ):
debug=False, sensorsground=None):
"""
Loop through trackerdict and runs linescans for each scene and scan in there.
Expand Down Expand Up @@ -2827,13 +2827,22 @@ def analysis1axis(self, trackerdict=None, singleindex=None, accuracy='low',
try: # look for missing data
analysis = AnalysisObj(octfile,name)
name = '1axis_%s%s'%(index,customname,)
frontscanind, backscanind = analysis.moduleAnalysis(scene=scene, modWanted=m,
rowWanted=r,
sensorsy=sensorsy,
sensorsx=sensorsx,
modscanfront=modscanfront, modscanback=modscanback,
relative=relative, debug=debug)
analysis.analysis(octfile=octfile,name=name,frontscan=frontscanind,backscan=backscanind,accuracy=accuracy)
if sensorsground is not None:
frontscanind, backscanind, groundscanid = analysis.moduleAnalysis(scene=scene, modWanted=m,
rowWanted=r,
sensorsy=sensorsy,
sensorsx=sensorsx,
modscanfront=modscanfront, modscanback=modscanback,
relative=relative, debug=debug, sensorsground=sensorsground)
analysis.analysis(octfile=octfile,name=name,frontscan=groundscanid,backscan=backscanind,accuracy=accuracy)
else:
frontscanind, backscanind = analysis.moduleAnalysis(scene=scene, modWanted=m,
rowWanted=r,
sensorsy=sensorsy,
sensorsx=sensorsx,
modscanfront=modscanfront, modscanback=modscanback,
relative=relative, debug=debug)
analysis.analysis(octfile=octfile,name=name,frontscan=frontscanind,backscan=backscanind,accuracy=accuracy)
Results['AnalysisObj']=analysis
except Exception as e: # problem with file. TODO: only catch specific error types here.
warnings.warn('Index: {}. Problem with file. Error: {}. Skipping'.format(index,e), Warning)
Expand Down Expand Up @@ -4326,7 +4335,7 @@ def _irrPlot(self, octfile, linepts, mytitle=None, plotflag=None,

return(out)

def _saveResults(self, data=None, reardata=None, savefile=None, RGB = False):
def _saveResults(self, data=None, reardata=None, savefile=None, RGB = False, savekey = None):
"""
Function to save output from _irrPlot
If rearvals is passed in, back ratio is saved
Expand Down Expand Up @@ -4355,6 +4364,9 @@ def _saveResults(self, data=None, reardata=None, savefile=None, RGB = False):
data_sub = {key:data[key] for key in ['x', 'y', 'z', 'mattype', 'Wm2','r', 'g', 'b' ]}
else:
data_sub = {key:data[key] for key in ['x', 'y', 'z', 'mattype','Wm2' ]}

if savekey is None:
savekey = ''

df = pd.DataFrame(data_sub)
df = df.rename(columns={'Wm2':'Wm2Front'})
Expand All @@ -4378,7 +4390,7 @@ def _saveResults(self, data=None, reardata=None, savefile=None, RGB = False):
df = df.rename(columns={'Wm2Front':'Wm2Back','mattype':'rearMat'})
# set attributes of analysis to equal columns of df
for col in df.columns:
setattr(self, col, list(df[col]))
setattr(self, savekey+col, list(df[col]))
# only save a subset
df = df.drop(columns=['rearX','rearY','backRatio'], errors='ignore')
df.to_csv(os.path.join("results", savefile), sep = ',',
Expand Down Expand Up @@ -4794,11 +4806,12 @@ def _checkSensors(sensors):
groundsensorspacing = pitch / (sensorsground - 1)
groundscan['xstart'] = x1
groundscan['ystart'] = y1
groundscan['zstart'] = 0.05 # Set it 5 cm from the ground.
groundscan['xinc'] = groundsensorspacing * np.sin(azimuth)
groundscan['yinc'] = groundsensorspacing * (-1 * np.cos(azimuth))
groundscan['zstart'] = 0.05
groundscan['xinc'] = groundsensorspacing * np.sin((azimuth)*dtor)
groundscan['yinc'] = groundsensorspacing * np.cos((azimuth)*dtor)
groundscan['zinc'] = 0
groundscan['Nx'] = 1
groundscan['Ny'] = sensorsground
groundscan['Nz'] = 0
groundscan['orient'] = '0 0 -1'

return frontscan2, backscan2, groundscan
Expand Down Expand Up @@ -5001,14 +5014,15 @@ def analysis(self, octfile, name, frontscan, backscan,
linepts = self._linePtsMakeDict(backscan)
backDict = self._irrPlot(octfile, linepts, name+'_Back',
plotflag=plotflag, accuracy=accuracy)

# don't save if _irrPlot returns an empty file.
if frontDict is not None:
if len(frontDict['Wm2']) != len(backDict['Wm2']):
self.Wm2Front = np.mean(frontDict['Wm2'])
self.Wm2Back = np.mean(backDict['Wm2'])
self.backRatio = self.Wm2Back / (self.Wm2Front + .001)
self._saveResults(frontDict, reardata=None, savefile='irr_%s.csv'%(name+'_Front'), RGB=RGB)
self._saveResults(data=None, reardata=backDict, savefile='irr_%s.csv'%(name+'_Back'), RGB=RGB)
self._saveResults(frontDict, reardata=None, savefile='irr_%s.csv'%(name+'_Front'), RGB=RGB, savekey = 'front')
self._saveResults(data=None, reardata=backDict, savefile='irr_%s.csv'%(name+'_Back'), RGB=RGB, savekey = 'back')
else:
self._saveResults(frontDict, backDict,'irr_%s.csv'%(name), RGB=RGB)

Expand Down

0 comments on commit e460768

Please sign in to comment.