Skip to content

Commit

Permalink
NSRDB fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shirubana committed Mar 8, 2023
1 parent 98d750d commit dd7a924
Showing 1 changed file with 42 additions and 43 deletions.
85 changes: 42 additions & 43 deletions bifacial_radiance/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,49 +966,48 @@ def _tz_convert(metdata, metadata, tz_convert_val):

return self.metdata

def NSRDBWeatherData(self, metadata, metdata, 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 input
Parameters
----------
weatherData : DataFrame
DataFrame with the weather information from NSRDB. Already localized.
metadata : Dict
dictionary of metadata for one NSRDB gid
"""
#from datetime import datetime


metadata['TZ'] = metadata['timezone']
metadata['Name'] = metadata['county']
metadata['altitude'] = metadata['elevation']
metadata['city'] = metadata['county']+','+metadata['state']+','+metadata['country']

metdata.rename(columns={'dni': 'DNI',
'dhi': 'DHI',
'ghi': 'GHI',
'air_temperature':'DryBulb',
'wind_speed':'Wspd',
'surface_albedo':'Alb'
}, inplace=True)

tempMetDatatitle = 'metdata_temp.csv'

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

if tmydata_trunc.__len__() > 0:
self.metdata = MetObj(tmydata_trunc, metadata, label = label)
else:
self.metdata = None
raise Exception('Weather file returned zero points for the '
'starttime / endtime provided')

return self.metdata


def NSRDBWeatherData(self, metadata, metdata, 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
Parameters
----------
weatherData : DataFrame
LOCALIZED DataFrame with the weather information from NSRDB
metadata : Dict
dictionary of metadata for one NSRDB gid
"""

metadata['TZ'] = metadata['timezone']
metadata['Name'] = metadata['county']
metadata['altitude'] = metadata['elevation']
metadata['city'] = (metadata['county'] + ',' + metadata['state'] +
',' + metadata['country'])

metdata.rename(columns={'dni': 'DNI',
'dhi': 'DHI',
'ghi': 'GHI',
'air_temperature': 'DryBulb',
'wind_speed': 'Wspd',
'surface_albedo': 'Alb'
}, inplace=True)

tempMetDatatitle = 'metdata_temp.csv'

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

if tmydata_trunc.__len__() > 0:
self.metdata = MetObj(tmydata_trunc, metadata, label=label)
else:
self.metdata = None
raise Exception('Weather file returned zero points for the '
'starttime / endtime provided')

return self.metdata


def _saveTempTMY(self, tmydata, filename=None, starttime=None, endtime=None,
coerce_year=None, label=None):
'''
Expand Down

0 comments on commit dd7a924

Please sign in to comment.