Skip to content

Commit

Permalink
Merge pull request #558 from NREL/501_yscan_array
Browse files Browse the repository at this point in the history
501 yscan array
  • Loading branch information
cdeline authored Oct 7, 2024
2 parents d4adec9 + a168a6a commit 74d0249
Show file tree
Hide file tree
Showing 7 changed files with 589 additions and 568 deletions.
38 changes: 21 additions & 17 deletions bifacial_radiance/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2769,9 +2769,9 @@ def makeScene1axis(self, trackerdict=None, module=None, sceneDict=None,
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,
modscanfront=None, modscanback=None, relative=False,
debug=False, sceneNum=0, append=True,
frontsurfaceoffset = None, backsurfaceoffset=None):
frontsurfaceoffset=None, backsurfaceoffset=None):
"""
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
Expand Down Expand Up @@ -3635,7 +3635,7 @@ def _makeSceneNxR(self, modulename=None, sceneDict=None, radname=None, addhubhei
''' INITIALIZE VARIABLES '''
text = '!xform '

text += '-rx %s -t %s %s %s ' %(tilt, 0, 0, hubheight)
text += '-rx %s -t %s %s %s ' %(tilt, 0, 0, np.float16(hubheight))

# create nMods-element array along x, nRows along y. 1cm module gap.
text += '-a %s -t %s 0 0 -a %s -t 0 %s 0 ' %(nMods, self.module.scenex, nRows, pitch)
Expand Down Expand Up @@ -3674,7 +3674,7 @@ def _makeSceneNxR(self, modulename=None, sceneDict=None, radname=None, addhubhei
with open(radfile, 'wb') as f:
f.write(text.encode('ascii'))

self.gcr = self.module.sceney / pitch
self.gcr = round(self.module.sceney / pitch, 6)
self.text = text
self.radfiles = radfile
self.sceneDict = sceneDict
Expand Down Expand Up @@ -4405,7 +4405,7 @@ def results(self):
def __printval__(self, attr):
try:
t = getattr(self,attr, None)[0]
except (TypeError, KeyError):
except (TypeError, KeyError, IndexError):
t = None
if isinstance(t, (np.floating, float)) :
return np.array(getattr(self,attr)).round(3).tolist()
Expand Down Expand Up @@ -4747,10 +4747,14 @@ def _saveResults(self, data=None, reardata=None, savefile=None, RGB = False):

# rename columns if only rear data was originally passed
if rearswapflag:
df = df.rename(columns={'Wm2Front':'Wm2Back','mattype':'rearMat'})
df = df.rename(columns={'Wm2Front':'Wm2Back','mattype':'rearMat',
'x':'rearX', 'y':'rearY', 'z':'rearZ'})
# set attributes of analysis to equal columns of df
for col in df.columns:
setattr(self, col, np.array(df[col])) #cdeline: changed from list to np.array on 3/16/24
setattr(self, col, np.array(df[col])) #cdeline: changed from list to np.array on 3/16/24
# swap back for the savefile
if rearswapflag:
df = df.rename(columns={'rearX':'x', 'rearY':'y', 'rearZ':'z'})
# only save a subset
df = df.drop(columns=['backRatio'], errors='ignore')
df.to_csv(os.path.join("results", savefile), sep=',',
Expand Down Expand Up @@ -5148,15 +5152,15 @@ def _checkSensors(sensors):
print("Final Start Coordinate Front", xstartfront, ystartfront, zstartfront)
print("Increase Coordinates", xinc_front, yinc_front, zinc_front)

frontscan = {'xstart': firstsensorxstartfront, 'ystart': firstsensorystartfront,
'zstart': firstsensorzstartfront,
'xinc':xinc_front, 'yinc': yinc_front, 'zinc':zinc_front,
frontscan = {'xstart': np.float16(firstsensorxstartfront), 'ystart': np.float16(firstsensorystartfront),
'zstart': np.float16(firstsensorzstartfront),
'xinc': np.float16(xinc_front), 'yinc': np.float16(yinc_front), 'zinc': np.float16(zinc_front),
'sx_xinc':sx_xinc_front, 'sx_yinc':sx_yinc_front,
'sx_zinc':sx_zinc_front,
'Nx': sensorsx_front, 'Ny':sensorsy_front, 'Nz':1, 'orient':front_orient }
backscan = {'xstart':firstsensorxstartback, 'ystart': firstsensorystartback,
'zstart': firstsensorzstartback,
'xinc':xinc_back, 'yinc': yinc_back, 'zinc':zinc_back,
backscan = {'xstart': np.float16(firstsensorxstartback), 'ystart': np.float16(firstsensorystartback),
'zstart': np.float16(firstsensorzstartback),
'xinc': np.float16(xinc_back), 'yinc': np.float16(yinc_back), 'zinc': np.float16(zinc_back),
'sx_xinc':sx_xinc_back, 'sx_yinc':sx_yinc_back,
'sx_zinc':sx_zinc_back,
'Nx': sensorsx_back, 'Ny':sensorsy_back, 'Nz':1, 'orient':back_orient }
Expand Down Expand Up @@ -5252,9 +5256,9 @@ def groundAnalysis(self, scene, modWanted=None, rowWanted=None,
yinc = groundsensorspacing * np.cos((azimuth)*dtor)
zinc = 0

groundscan = {'xstart': xstart, 'ystart': ystart,
'zstart': zstart,
'xinc':xinc, 'yinc': yinc, 'zinc':zinc,
groundscan = {'xstart': np.float16(xstart), 'ystart': np.float16(ystart),
'zstart': np.float16(zstart),
'xinc':np.float16(xinc), 'yinc': np.float16(yinc), 'zinc':np.float16(zinc),
'sx_xinc':0, 'sx_yinc':0,
'sx_zinc':0,
'Nx': sensorsgroundx, 'Ny':sensorsground, 'Nz':1,
Expand All @@ -5263,7 +5267,7 @@ def groundAnalysis(self, scene, modWanted=None, rowWanted=None,
return groundscan

def analyzeRow(self, octfile, scene, rowWanted=None, name=None,
sensorsy=None, sensorsx=None ):
sensorsy=9, sensorsx=1 ):
'''
Function to Analyze every module in the row.
Expand Down
3 changes: 3 additions & 0 deletions docs/sphinx/source/whatsnew/v0.5.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ Bug fixes
* Fixed typo on Opacity calculation factor (:issue:`426`)
* Updated Github Actions to use Node20: checkout@v4, setup-python@v5, coactions/setup-xvfb, setup-buildx-action@v3 (:pull:`517`)
* Fix PerformanceWarning and SettingWithCopyWarning (:issue:`515`)
* Fix error where rearX, rearY, rearZ parameters are not properly saved (:issue:`501`)
* More appropriate significant digits saved and displayed. (this changed some x,y,z values by < .003 due to rounding differences.) (:pull:`558`)
* :py:func:`bifacial_radiance.AnalysisObj.analyzeRow` default values changed for `sensorsy` and `sensorsx` from `None` to 9 and 1, respectively (:pull:`558`)

Documentation
~~~~~~~~~~~~~~
Expand Down
Loading

0 comments on commit 74d0249

Please sign in to comment.