diff --git a/bifacial_radiance/main.py b/bifacial_radiance/main.py index b4c167e0..9e47c10b 100644 --- a/bifacial_radiance/main.py +++ b/bifacial_radiance/main.py @@ -265,9 +265,9 @@ def _subhourlydatatoGencumskyformat(gencumskydata, label='right'): #Resample to hourly. Gencumsky wants right-labeled data. try: - gencumskydata = gencumskydata.resample('60T', closed='right', label='right').mean() + gencumskydata = gencumskydata.resample('60min', closed='right', label='right').mean() except TypeError: # Pandas 2.0 error - gencumskydata = gencumskydata.resample('60T', closed='right', label='right').mean(numeric_only=True) + gencumskydata = gencumskydata.resample('60min', closed='right', label='right').mean(numeric_only=True) if label == 'left': #switch from left to right labeled by adding an hour gencumskydata.index = gencumskydata.index + pd.to_timedelta('1H') @@ -294,7 +294,7 @@ def _subhourlydatatoGencumskyformat(gencumskydata, label='right'): gencumskydata.loc[padend]=0 gencumskydata=gencumskydata.sort_index() # Fill empty timestamps with zeros - gencumskydata = gencumskydata.resample('60T').asfreq().fillna(0) + gencumskydata = gencumskydata.resample('60min').asfreq().fillna(0) # Mask leap year leapmask = ~(_is_leap_and_29Feb(gencumskydata)) gencumskydata = gencumskydata[leapmask] @@ -1174,16 +1174,27 @@ def _convertTMYdate(data, meta): import pvlib - #(tmydata, metadata) = pvlib.tmy.readtmy3(filename=tmyfile) #pvlib<=0.6 - (tmydata, metadata) = pvlib.iotools.tmy.read_tmy3(filename=tmyfile, - coerce_year=coerce_year) + try: + (tmydata, metadata) = pvlib.iotools.tmy.read_tmy3(filename=tmyfile, + coerce_year=coerce_year, + map_variables=True) + except TypeError: # pvlib < 0.10 + (tmydata, metadata) = pvlib.iotools.tmy.read_tmy3(filename=tmyfile, + coerce_year=coerce_year) try: tmydata = _convertTMYdate(tmydata, metadata) except KeyError: print('PVLib >= 0.8.0 is required for sub-hourly data input') - + + tmydata.rename(columns={'dni':'DNI', + 'dhi':'DHI', + 'temp_air':'DryBulb', + 'wind_speed':'Wspd', + 'ghi':'GHI', + 'albedo':'Alb' + }, inplace=True) #as of v0.11, PVLib changed tmy3 column names.. return tmydata, metadata @@ -1221,7 +1232,7 @@ def _readEPW(self, epwfile=None, label = 'right', coerce_year=None): #(tmydata, metadata) = readepw(epwfile) # (tmydata, metadata) = pvlib.iotools.epw.read_epw(epwfile, coerce_year=coerce_year) #pvlib>0.6.1 - #pvlib uses -1hr offset that needs to be un-done. Why did they do this? + #pvlib uses -1hr offset that needs to be un-done. tmydata.index = tmydata.index+pd.Timedelta(hours=1) # rename different field parameters to match output from diff --git a/requirements.txt b/requirements.txt index 2556d7b5..fa3d21bb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ coverage==7.2.1 cycler==0.11.0 idna==3.4 importlib-metadata==6.0.0 -ipython==8.10.0 +ipython==8.13.0 kiwisolver==1.4.4 matplotlib==3.5.1 more-itertools==9.1.0