Open cdeline opened 6 years ago
def readNSRDB(NSRDBfile, decimate= False, decimatestyle = "Mean" , decimatevalue = 5 ):
''' decimatestyle = "Mean" or "Skip" ''' day_all = []; month_all = []; year_all = []; hour_all = []; minute_all= [] global_all=[]; direct_all=[]; diffuse_all=[]; albedo_all=[]; temp_all=[]; pressure_all=[]; wind_all=[]; timestamps_all = []
headeracquired= 0
headererror = 0
yearloc=0
monthloc=1
dayloc=2
hourloc=3
minuteloc=4
directloc = 5
diffuseloc = 6
globalloc= 7
albedoloc=8
windspeedloc=9
temperatureloc=10
pressureloc=11
with open(NSRDBfile, "r") as filestream:
print "Reading NSRDBfile File: ", NSRDBfile
print "Decimation options: ", decimate
if decimate == True:
print "Decimate Style: ", decimatestyle, " to interval ", decimatevalue, " minutes."
headerline = filestream.readline() # read headers labels, read values
head1 = headerline.strip().split(',')
meta = dict(zip(head1, filestream.readline().rstrip('\n').split(",")))
for line in filestream:
if headeracquired == 0:
header = line.split(",")
if header[yearloc] != 'Year': print "Issue reading" + header [yearloc] ; headererror = 1
if header[directloc] != 'DHI': print "Issue reading" + header [directloc] ; headererror = 1
if header[diffuseloc] != 'DNI': print "Issue reading" + header [directloc] ; headererror = 1
if header[globalloc] != 'GHI': print "Issue reading" + header [globalloc] ; headererror = 1
headeracquired = 1
if headererror == 1:
print "STOPPING File Read because of headers issue (expected data might not be where we think it is! Stop roll and check!"
continue
else:
if headererror == 1:
continue
currentline=line.split(",")
year=int(currentline[yearloc])
month=int(currentline[monthloc])
day=int(currentline[dayloc])
hour=int(currentline[hourloc])
minute=int(currentline[minuteloc])
if decimate == True:
if decimatestyle == "Skip":
if minute%decimatevalue != 0:
continue
year_all.append(int(currentline[yearloc]))
month_all.append(int(currentline[monthloc]))
day_all.append(int(currentline[dayloc]))
hour_all.append(int(currentline[hourloc]))
minute_all.append(int(currentline[minuteloc]))
direct_all.append(float(currentline[directloc]))
diffuse_all.append(float(currentline[diffuseloc]))
global_all.append(float(currentline[globalloc]))
albedo_all.append(float(currentline[albedoloc]))
wind_all.append(float(currentline[windspeedloc]))
temp_all.append(float(currentline[temperatureloc]))
pressure_all.append(float(currentline[pressureloc]))
myTimestamp=datetime.datetime(year, month, day, hour, minute, 0, 0)
timestamps_all.append(myTimestamp)
NSRDB = ({'Month': month_all, 'Day': day_all, 'Year': year_all, 'Hour': hour_all, 'Minute': minute_all,
'Global': global_all, 'Direct': direct_all, 'Diffuse': diffuse_all,
'Temp': temp_all, 'Presure': pressure_all, 'Wind': wind_all, 'Albedo': albedo_all})
NSRDB = pd.DataFrame.from_records(NSRDB, index=timestamps_all)
if decimate == True:
if decimatestyle == "Mean":
if decimatevalue == 5:
NSRDB=NSRDB.resample('5Min', base=0).mean()
print "Data decimated to 5 min Interval by Average"
if decimatevalue == 10:
NSRDB=NSRDB.resample('10Min').mean()
print "Data decimated to 10 min Interval by Average"
if decimatevalue == 15:
NSRDB=NSRDB.resample('15Min').mean()
print "Data decimated to 15 min Interval by Average"
if decimatevalue == 60:
NSRDB=NSRDB.resample('60Min').mean()
print "Data decimated to 1 Hr Interval by Average"
return NSRDB, meta; `
Does this mean a SAM meteorological file can be read in Bifacial Radiance? If so would that include sub-annual albedo values and how would Radiance process these?
Hi Jenna,
It looks like we have an issue #68 open for this at the moment. This will be rolled into a future release that also allows multiple scene files to be generated at the same time with different albedo values. Thanks!
Chris Deline National Renewable Energy Laboratory (303) 384-6359
From: JennaKLH notifications@github.com Sent: Wednesday, April 24, 2019 9:14 AM To: NREL/bifacial_radiance bifacial_radiance@noreply.github.com Cc: Deline, Chris Chris.Deline@nrel.gov; Author author@noreply.github.com Subject: Re: [NREL/bifacial_radiance] Allow NSRDB (SAM) climate files to be read in. (#20)
Does this mean a SAM meteorological file can be read in Bifacial Radiance? If so would that include sub-annual albedo values and how would Radiance process these?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/NREL/bifacial_radiance/issues/20#issuecomment-486285007, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFRK2OHZMOB5AKXASV4EF2DPSB2K7ANCNFSM4GC6DAPA.
Now that we're on PVLib > 0.6.1 there are iotools functions to do this pretty easily.
@JennaKLH long long after revisiting your comment --- we are using albedo from TMY3 values since one or two releases ago. It can be a TMY3 style file with any time step you want, as long as it has the right column names that are being used.
Renaming this issue to be able to read NSRDB, PVGIS and any other format from the PVLib Iotools.
This is fixed in 2e45cc89ef1ac03387cfc167348ac1e29690480c, currently just in the development branch.
NSRDB no longer provides TMY files - their file is in SAM csv output. Include capability to read this in. (Silvana has the code already - just include it as a separate file and connect it to Master)