Use nonzeromean() to exclude zero values from albedo averages with gencumsky.  Account for zero albedo in _makeGroundString.  Fixes
@@ -2382,7 +2382,8 @@ class GroundObj:
materialOrAlbedo[:,2])
self.ReflAvg = np.round(np.mean(materialOrAlbedo, axis=1),4)
print(f'Loading albedo, {self.ReflAvg.__len__()} value(s), '
- f'{np.nanmean(self.ReflAvg):0.3f} avg')
+ f'{np.nanmean(self.ReflAvg):0.3f} avg\n'
+ f'{self.ReflAvg[self.ReflAvg != 0].__len__()} nonzero albedo values.')
except IndexError as e:
print('albedo.shape should be 3 column (N x 3)')
raise e
@@ -2440,12 +2441,18 @@ class GroundObj:
groundstring: text with albedo details to append to sky.rad in
gendaylit
'''
+ def _nonzeromean(val):
+ ''' array mean excluding zero. return zero if everything's zero'''
+ tempmean = np.nanmean(val)
+ if tempmean > 0:
+ tempmean = np.nanmean(val[val !=0])
+ return tempmean
try:
if cumulativesky is True:
- Rrefl = self.Rrefl.mean()
- Grefl = self.Grefl.mean()
- Brefl = self.Brefl.mean()
+ Rrefl = _nonzeromean(self.Rrefl)
+ Grefl = _nonzeromean(self.Grefl)
+ Brefl = _nonzeromean(self.Brefl)
normval = _normRGB(Rrefl, Grefl, Brefl)
else:
Rrefl = self.Rrefl[index]
