Skip to content

Commit

Permalink
spectral_utils
Browse files Browse the repository at this point in the history
standardizing some variable names to follow convention
  • Loading branch information
mcbrown042 committed Apr 26, 2023
1 parent b4e86ab commit 83c7fcf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions bifacial_radiance/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2999,7 +2999,7 @@ def calculateResults(self, CECMod=None, glassglass=False, bifacialityfactor=None

return trackerdict

def generate_spectra(self, metdata=None, simulationPath=None, groundMaterial=None, scale_spectra=False,
def generate_spectra(self, metdata=None, simulation_path=None, ground_material=None, scale_spectra=False,
scale_albedo=False, scale_albedo_nonspectral_sim=False, scale_upper_bound=2500):
'''
Generate spectral irradiance files for spectral simulations using pySMARTS
Expand All @@ -3010,9 +3010,9 @@ def generate_spectra(self, metdata=None, simulationPath=None, groundMaterial=Non
----------
metdata : radianceObject.metdata, optional
DESC
simulationPath : path object or string, optional
simulation_path : path object or string, optional
path of current simulation directory
groundMaterial : str or (R,G,B), optional
ground_material : str or (R,G,B), optional
ground material string from pySMARTS glossary or compatible
(R,G,B) tuple.
scale_spectra : boolean, default=False
Expand Down Expand Up @@ -3047,8 +3047,8 @@ def generate_spectra(self, metdata=None, simulationPath=None, groundMaterial=Non
'''
if metdata == None:
metdata = self.metdata
if simulationPath == None:
simulationPath = self.path
if simulation_path == None:
simulation_path = self.path

from bifacial_radiance import spectral_utils as su

Expand All @@ -3057,7 +3057,7 @@ def generate_spectra(self, metdata=None, simulationPath=None, groundMaterial=Non
os.mkdir(spectra_path)

(spectral_alb, spectral_dni, spectral_dhi, weighted_alb) = su.generate_spectra(metdata=metdata,
simulationPath=simulationPath, groundMaterial=groundMaterial, spectra_folder=spectra_path,
simulation_path=simulation_path, ground_material=ground_material, spectra_folder=spectra_path,
scale_spectra=scale_spectra, scale_albedo=scale_albedo,
scale_albedo_nonspectral_sim=scale_albedo_nonspectral_sim,
scale_upper_bound=scale_upper_bound)
Expand Down
26 changes: 13 additions & 13 deletions bifacial_radiance/spectral_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def spectral_albedo_smarts_SRRL(YEAR, MONTH, DAY, HOUR, ZONE,
smarts_res['Wvlgth'], interpolation='linear')


def generate_spectra(metdata, simulationPath, groundMaterial='Gravel', spectra_folder=None, scale_spectra=False,
def generate_spectra(metdata, simulation_path, ground_material='Gravel', spectra_folder=None, scale_spectra=False,
scale_albedo=False, scale_albedo_nonspectral_sim=False, scale_upper_bound=2500):
"""
generate spectral curve for particular material. Requires pySMARTS
Expand All @@ -245,9 +245,9 @@ def generate_spectra(metdata, simulationPath, groundMaterial='Gravel', spectra_f
----------
metdata : bifacial_radiance MetObj
DESCRIPTION.
simulationPath: bifacial_radiance MetObj
simulation_path: bifacial_radiance MetObj
path of simulation directory
groundMaterial : string, optional
ground_material : string, optional
type of ground material for spectral simulation. Options include:
Grass, Gravel, Snow, Seasonal etc.
The default is 'Gravel'.
Expand Down Expand Up @@ -303,10 +303,10 @@ def generate_spectra(metdata, simulationPath, groundMaterial='Gravel', spectra_f

# create file names
suffix = f'_{str(dt.year)[-2:]}_{dt.month:02}_{dt.day:02}_{dt.hour:02}.txt'
dni_file = os.path.join(simulationPath, spectra_folder, "dni"+suffix)
dhi_file = os.path.join(simulationPath, spectra_folder, "dhi"+suffix)
ghi_file = os.path.join(simulationPath, spectra_folder, "ghi"+suffix)
alb_file = os.path.join(simulationPath, spectra_folder, "alb"+suffix)
dni_file = os.path.join(simulation_path, spectra_folder, "dni"+suffix)
dhi_file = os.path.join(simulation_path, spectra_folder, "dhi"+suffix)
ghi_file = os.path.join(simulation_path, spectra_folder, "ghi"+suffix)
alb_file = os.path.join(simulation_path, spectra_folder, "alb"+suffix)

# generate the base spectra
try:
Expand Down Expand Up @@ -339,18 +339,18 @@ def generate_spectra(metdata, simulationPath, groundMaterial='Gravel', spectra_f
if lat < 0: winter = north
if lat > 0: winter = south

if groundMaterial == 'Seasonal':
if ground_material == 'Seasonal':
MONTH = metdata.datetime[idx].month
if MONTH in winter :
if alb >= 0.6:
groundMaterial = 'Snow'
ground_material = 'Snow'
else:
groundMaterial = 'DryGrass'
ground_material = 'DryGrass'
else:
groundMaterial = 'Grass'
ground_material = 'Grass'

# Generate base spectral albedo
spectral_alb = spectral_albedo_smarts(zen, azm, groundMaterial, min_wavelength=280)
spectral_alb = spectral_albedo_smarts(zen, azm, ground_material, min_wavelength=280)

# Limit albedo by upper bound wavelength
talb = spectral_alb.data[spectral_alb.data.index <= scale_upper_bound]
Expand Down Expand Up @@ -384,7 +384,7 @@ def generate_spectra(metdata, simulationPath, groundMaterial='Gravel', spectra_f

# save a basic csv of weighted albedo, indexed by datetime
if scale_albedo_nonspectral_sim:
walbPath = os.path.join(simulationPath,spectra_folder,'albedo_scaled_nonSpec.csv')
walbPath = os.path.join(simulation_path,spectra_folder,'albedo_scaled_nonSpec.csv')
walb.to_csv(walbPath)
print('Weighted albedo CSV saved.')
weighted_alb = walb
Expand Down

0 comments on commit 83c7fcf

Please sign in to comment.