@@ -395,7 +395,9 @@ def _coerce_and_roll_pvgis_tmy(pvgis_data, tz, year):
395
395
After converting TZ, roll dataframe so timeseries starts at midnight
396
396
and force all indices to a common year. Only works for integer TZ.
397
397
"""
398
- tzname = pytz .timezone (f'Etc/GMT{ - tz :+d} ' )
398
+ tzname = (
399
+ pytz .timezone (f'Etc/GMT{ - tz :+d} ' ) if tz != 0
400
+ else pytz .timezone ('UTC' ))
399
401
new_index = [
400
402
timestamp .replace (year = year , tzinfo = tzname )
401
403
for timestamp in pvgis_data .index ]
@@ -409,7 +411,7 @@ def _coerce_and_roll_pvgis_tmy(pvgis_data, tz, year):
409
411
def get_pvgis_tmy (latitude , longitude , outputformat = 'json' , usehorizon = True ,
410
412
userhorizon = None , startyear = None , endyear = None ,
411
413
map_variables = True , url = URL , timeout = 30 ,
412
- utc_offset = None , coerce_year = None ):
414
+ roll_utc_offset = None , coerce_year = None ):
413
415
"""
414
416
Get TMY data from PVGIS.
415
417
@@ -441,13 +443,13 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
441
443
base url of PVGIS API, append ``tmy`` to get TMY endpoint
442
444
timeout : int, default 30
443
445
time in seconds to wait for server response before timeout
444
- utc_offset : int, default None
446
+ roll_utc_offset : int, default None
445
447
Use to specify a time zone other than the default UTC zero and roll
446
- dataframe by ``utc_offset `` so it starts at midnight on January 1st.
447
- Ignored if ``None``, otherwise will also force year to ``coerce_year``.
448
+ dataframe by ``roll_utc_offset `` so it starts at midnight on January
449
+ 1st. Ignored if ``None``, otherwise will force year to ``coerce_year``.
448
450
coerce_year: int, default None
449
451
Use to force indices to desired year. Will default to 1990 if
450
- ``coerce_year`` is ``None``, but ``utc_offset `` is not ``None``.
452
+ ``coerce_year`` is ``None``, but ``roll_utc_offset `` is not ``None``.
451
453
452
454
Returns
453
455
-------
@@ -534,15 +536,15 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
534
536
if map_variables :
535
537
data = data .rename (columns = VARIABLE_MAP )
536
538
537
- if utc_offset is not None or coerce_year is not None :
539
+ if roll_utc_offset is not None or coerce_year is not None :
538
540
# XXX: be explicit, test for identity not implicit booleaness
539
- # utc_offset None but coerce_year isn't, set year with utc zero
540
- if utc_offset is None : # XXX: None and zero are both False
541
- utc_offset = 0
541
+ # roll_utc_offset None but coerce_year isn't, set year with utc zero
542
+ if roll_utc_offset is None : # XXX: None and zero are both False
543
+ roll_utc_offset = 0
542
544
# coerce_year is None but utc_off isn't, set year to 1990
543
545
if coerce_year is None : # more explicit than (coerce_year or 1990)
544
546
coerce_year = 1990
545
- data = _coerce_and_roll_pvgis_tmy (data , utc_offset , coerce_year )
547
+ data = _coerce_and_roll_pvgis_tmy (data , roll_utc_offset , coerce_year )
546
548
547
549
return data , months_selected , inputs , meta
548
550
0 commit comments