Skip to content

Commit

Permalink
NSRDB starttime endtie
Browse files Browse the repository at this point in the history
  • Loading branch information
shirubana committed Apr 5, 2023
1 parent d6cf83b commit bea381f
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions bifacial_radiance/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,9 @@ def _tz_convert(metdata, metadata, tz_convert_val):

return self.metdata

def NSRDBWeatherData(self, metadata, metdata, label='center'):
def NSRDBWeatherData(self, metadata, metdata, starttime=None,
endtime=None, label=None,
coerce_year=None, label='center'):
"""
To be used when working with dataframes from the NSRDB h5 (i.e. Eagle)
Assigns the metdata and weatherdata from a dataframe and dictonary
Expand Down Expand Up @@ -998,7 +1000,17 @@ def NSRDBWeatherData(self, metadata, metdata, label='center'):

tempMetDatatitle = 'metdata_temp.csv'

tmydata_trunc = self._saveTempTMY(metdata, filename=tempMetDatatitle,
# Parse the start and endtime strings.
if starttime is not None:
starttime, coerce_year = _parseTimes(starttime, 1, coerce_year)
starttime = starttime.tz_localize(tzinfo)
if endtime is not None:
endtime, coerce_year = _parseTimes(endtime, 23, coerce_year)
endtime = endtime.tz_localize(tzinfo)

tmydata_trunc = self._saveTempTMY(metdata, filename=tempMetDatatitle,
starttime=starttime, endtime=endtime,
coerce_year=coerce_year,
label=label)

if tmydata_trunc.__len__() > 0:
Expand All @@ -1008,6 +1020,28 @@ def NSRDBWeatherData(self, metadata, metdata, label='center'):
raise Exception('Weather file returned zero points for the '
'starttime / endtime provided')

# Parse the start and endtime strings.
if starttime is not None:
starttime, coerce_year = _parseTimes(starttime, 1, coerce_year)
starttime = starttime.tz_localize(tzinfo)
if endtime is not None:
endtime, coerce_year = _parseTimes(endtime, 23, coerce_year)
endtime = endtime.tz_localize(tzinfo)
'''
#TODO: do we really need this check?
if coerce_year is not None and starttime is not None:
if coerce_year != starttime.year or coerce_year != endtime.year:
print("Warning: Coerce year does not match requested sampled "+
"date(s)'s years. Setting Coerce year to None.")
coerce_year = None
'''

tmydata_trunc = self._saveTempTMY(metdata, filename=tempMetDatatitle,
starttime=starttime, endtime=endtime,
coerce_year=coerce_year,
label=label)


return self.metdata


Expand Down

0 comments on commit bea381f

Please sign in to comment.