@@ -387,7 +387,7 @@ def read_pvgis_hourly(filename, pvgis_format=None, map_variables=True):
387
387
return _parse_pvgis_hourly_json (src , map_variables = map_variables )
388
388
389
389
# CSV: use _parse_pvgis_hourly_csv()
390
- if outputformat == 'csv' :
390
+ elif outputformat == 'csv' :
391
391
try :
392
392
pvgis_data = _parse_pvgis_hourly_csv (
393
393
filename , map_variables = map_variables )
@@ -397,11 +397,12 @@ def read_pvgis_hourly(filename, pvgis_format=None, map_variables=True):
397
397
fbuf , map_variables = map_variables )
398
398
return pvgis_data
399
399
400
- # raise exception if pvgis format isn't in ['csv', 'json']
401
- err_msg = (
402
- "pvgis format '{:s}' was unknown, must be either 'json' or 'csv'" )\
403
- .format (outputformat )
404
- raise ValueError (err_msg )
400
+ else :
401
+ # raise exception if pvgis format isn't in ['csv', 'json']
402
+ err_msg = (
403
+ "pvgis format '{:s}' was unknown, must be either 'json' or 'csv'" )\
404
+ .format (outputformat )
405
+ raise ValueError (err_msg )
405
406
406
407
407
408
def _coerce_and_roll_tmy (tmy_data , tz , year ):
@@ -446,7 +447,7 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
446
447
longitude : float
447
448
Longitude in degrees east
448
449
outputformat : str, default 'json'
449
- Must be in ``['csv', 'basic', ' epw', 'json']``. See PVGIS TMY tool
450
+ Must be in ``['csv', 'epw', 'json']``. See PVGIS TMY tool
450
451
documentation [2]_ for more info.
451
452
usehorizon : bool, default True
452
453
include effects of horizon
@@ -478,11 +479,11 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
478
479
data : pandas.DataFrame
479
480
the weather data
480
481
months_selected : list
481
- TMY year for each month, ``None`` for basic and EPW
482
+ TMY year for each month, ``None`` for EPW
482
483
inputs : dict
483
- the inputs, ``None`` for basic and EPW
484
+ the inputs, ``None`` for EPW
484
485
metadata : list or dict
485
- file metadata, ``None`` for basic
486
+ file metadata
486
487
487
488
Raises
488
489
------
@@ -533,17 +534,14 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
533
534
elif outputformat == 'csv' :
534
535
with io .BytesIO (res .content ) as src :
535
536
data , months_selected , inputs , meta = _parse_pvgis_tmy_csv (src )
536
- elif outputformat == 'basic' :
537
- with io .BytesIO (res .content ) as src :
538
- data , months_selected , inputs , meta = _parse_pvgis_tmy_basic (src )
539
537
elif outputformat == 'epw' :
540
538
with io .StringIO (res .content .decode ('utf-8' )) as src :
541
539
data , meta = parse_epw (src )
542
540
months_selected , inputs = None , None
543
- else :
544
- # this line is never reached because if outputformat is not valid then
545
- # the response is HTTP/1.1 400 BAD REQUEST which is handled earlier
546
- pass
541
+ elif outputformat == 'basic' :
542
+ err_msg = ( "outputformat='basic' is no longer supported by pvlib, "
543
+ "please use outputformat='csv' instead." )
544
+ raise ValueError ( err_msg )
547
545
548
546
if map_variables :
549
547
data = data .rename (columns = VARIABLE_MAP )
@@ -607,17 +605,9 @@ def _parse_pvgis_tmy_csv(src):
607
605
return data , months_selected , inputs , meta
608
606
609
607
610
- def _parse_pvgis_tmy_basic (src ):
611
- data = pd .read_csv (src )
612
- data .index = pd .to_datetime (
613
- data ['time(UTC)' ], format = '%Y%m%d:%H%M' , utc = True )
614
- data = data .drop ('time(UTC)' , axis = 1 )
615
- return data , None , None , None
616
-
617
-
618
608
def read_pvgis_tmy (filename , pvgis_format = None , map_variables = True ):
619
609
"""
620
- Read a file downloaded from PVGIS.
610
+ Read a TMY file downloaded from PVGIS.
621
611
622
612
Parameters
623
613
----------
@@ -627,11 +617,9 @@ def read_pvgis_tmy(filename, pvgis_format=None, map_variables=True):
627
617
Format of PVGIS file or buffer. Equivalent to the ``outputformat``
628
618
parameter in the PVGIS TMY API. If ``filename`` is a file and
629
619
``pvgis_format`` is not specified then the file extension will be used
630
- to determine the PVGIS format to parse. For PVGIS files from the API
631
- with ``outputformat='basic'``, please set ``pvgis_format`` to
632
- ``'basic'``.
620
+ to determine the PVGIS format to parse.
633
621
If ``filename`` is a buffer, then ``pvgis_format`` is required and must
634
- be in ``['csv', 'epw', 'json', 'basic' ]``.
622
+ be in ``['csv', 'epw', 'json']``.
635
623
map_variables: bool, default True
636
624
When true, renames columns of the Dataframe to pvlib variable names
637
625
where applicable. See variable :const:`VARIABLE_MAP`.
@@ -642,18 +630,18 @@ def read_pvgis_tmy(filename, pvgis_format=None, map_variables=True):
642
630
data : pandas.DataFrame
643
631
the weather data
644
632
months_selected : list
645
- TMY year for each month, ``None`` for basic and EPW
633
+ TMY year for each month, ``None`` for EPW
646
634
inputs : dict
647
- the inputs, ``None`` for basic and EPW
635
+ the inputs, ``None`` for EPW
648
636
metadata : list or dict
649
- file metadata, ``None`` for basic
637
+ file metadata
650
638
651
639
Raises
652
640
------
653
641
ValueError
654
642
if ``pvgis_format`` is not specified and the file extension is neither
655
643
``.csv``, ``.json``, nor ``.epw``, or if ``pvgis_format`` is provided
656
- as input but isn't in ``['csv', 'epw', 'json', 'basic' ]``
644
+ as input but isn't in ``['csv', 'epw', 'json']``
657
645
TypeError
658
646
if ``pvgis_format`` is not specified and ``filename`` is a buffer
659
647
@@ -669,8 +657,7 @@ def read_pvgis_tmy(filename, pvgis_format=None, map_variables=True):
669
657
outputformat = Path (filename ).suffix [1 :].lower ()
670
658
else :
671
659
outputformat = pvgis_format
672
- # parse the pvgis file based on the output format, either 'epw', 'json',
673
- # 'csv', or 'basic'
660
+ # parse pvgis file based on outputformat, either 'epw', 'json', or 'csv'
674
661
675
662
# EPW: use the EPW parser from the pvlib.iotools epw.py module
676
663
if outputformat == 'epw' :
@@ -680,7 +667,7 @@ def read_pvgis_tmy(filename, pvgis_format=None, map_variables=True):
680
667
data , meta = read_epw (filename )
681
668
months_selected , inputs = None , None
682
669
683
- # NOTE: json, csv, and basic output formats have parsers defined as private
670
+ # NOTE: json and csv output formats have parsers defined as private
684
671
# functions in this module
685
672
686
673
# JSON: use Python built-in json module to convert file contents to a
@@ -694,24 +681,25 @@ def read_pvgis_tmy(filename, pvgis_format=None, map_variables=True):
694
681
src = json .load (fbuf )
695
682
data , months_selected , inputs , meta = _parse_pvgis_tmy_json (src )
696
683
697
- # CSV or basic: use the correct parser from this module
698
- # eg: _parse_pvgis_tmy_csv() or _parse_pvgist_tmy_basic()
699
- elif outputformat in ['csv' , 'basic' ]:
700
- # get the correct parser function for this output format from globals()
701
- pvgis_parser = globals ()['_parse_pvgis_tmy_{:s}' .format (outputformat )]
702
- # NOTE: pvgis_parse() is a pvgis parser function from this module,
703
- # either _parse_pvgis_tmy_csv() or _parse_pvgist_tmy_basic()
684
+ elif outputformat == 'csv' :
704
685
try :
705
- data , months_selected , inputs , meta = pvgis_parser (filename )
686
+ data , months_selected , inputs , meta = \
687
+ _parse_pvgis_tmy_csv (filename )
706
688
except AttributeError : # str/path has no .read() attribute
707
689
with open (str (filename ), 'rb' ) as fbuf :
708
- data , months_selected , inputs , meta = pvgis_parser (fbuf )
690
+ data , months_selected , inputs , meta = \
691
+ _parse_pvgis_tmy_csv (fbuf )
692
+
693
+ elif outputformat == 'basic' :
694
+ err_msg = "outputformat='basic' is no longer supported, please use " \
695
+ "outputformat='csv' instead."
696
+ raise ValueError (err_msg )
709
697
710
698
else :
711
- # raise exception if pvgis format isn't in ['csv','basic',' epw','json']
699
+ # raise exception if pvgis format isn't in ['csv','epw','json']
712
700
err_msg = (
713
- "pvgis format '{:s}' was unknown, must be either 'epw ', 'json', "
714
- "'csv', or 'basic '" ).format (outputformat )
701
+ "pvgis format '{:s}' was unknown, must be either 'json ', 'csv', "
702
+ "or 'epw '" ).format (outputformat )
715
703
raise ValueError (err_msg )
716
704
717
705
if map_variables :
0 commit comments