8000 Fix inconsistencies by AdamRJensen · Pull Request #1268 · pvlib/pvlib-python · GitHub
[go: up one dir, main page]

Skip to content

Fix inconsistencies #1268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 38 commits into from
Aug 9, 2021
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d7deb80
Add cams.get_cams_radiation function
Feb 22, 2021
510f08e
Revert "Add cams.get_cams_radiation function"
Feb 22, 2021
8132943
Fix inconsistencies
AdamRJensen Jul 30, 2021
a93f38a
Merge branch 'master' into pvlib_inconsistencies
AdamRJensen Jul 30, 2021
95c029e
Merge remote-tracking branch 'upstream/master' into pvlib_inconsisten…
AdamRJensen Jul 30, 2021
1a10c67
Merge remote-tracking branch 'upstream/master' into pvlib_inconsisten…
AdamRJensen Jul 30, 2021
95efd76
Have station arg precede start/end in get_bsrn
AdamRJensen Jul 30, 2021
f4c2576
Update get_bsrn doc string
AdamRJensen Jul 30, 2021
082c3f8
Change output order in psm3
AdamRJensen Jul 30, 2021
b8bdd62
Add variable map to pvgis_tmy with depreciating warning
AdamRJensen Aug 2, 2021
b659af2
Add variable_map to pvgis_tmy
AdamRJensen Aug 2, 2021
146a8b5
Coverage for variable_map for read_pvigs_tmy
AdamRJensen Aug 2, 2021
2ac6185
Add "versionchanged" to psm3 docs
AdamRJensen Aug 2, 2021
5303e08
Update psm3 docs
AdamRJensen Aug 2, 2021
941eb30
Update versionchanged AdamRJensen Aug 2, 2021
ab4ac23
Update versionchange message
AdamRJensen Aug 3, 2021
b4a5228
Correct ouput for get_pvgis_tmy with epw format
AdamRJensen Aug 4, 2021
dbee07e
Update pvgis_tmy map test
AdamRJensen Aug 4, 2021
42db488
Update v0.9.0.rst
AdamRJensen Aug 4, 2021
58242b5
Implement comments from review by kanderso-nrel
AdamRJensen Aug 5, 2021
7f3b32c
Remove 'empty' columns when an empty dataframe is returned by bsrn
AdamRJensen Aug 5, 2021
d67a1e9
Remove admonition about pvgis renaming in introtutorial.rst
AdamRJensen Aug 5, 2021
d9bc9cb
Fix typo in pvigs_tmy documentation
AdamRJensen Aug 5, 2021
162cd2f
Fix references in whatsnew
AdamRJensen Aug 5, 2021
ecc549a
Refactor pvigs_tmy
AdamRJensen Aug 6, 2021
9cb3602
Fix stickler
AdamRJensen Aug 6, 2021
0b6ccb5
Fix issue references in whatsnew
AdamRJensen Aug 6, 2021
aedc064
Coverage for get_pvgis_tmy map_variables
AdamRJensen Aug 6, 2021
7dd2c3c
Fix errors in whatsnew
AdamRJensen Aug 6, 2021
6d1045c
Add double backticks in whatsnew
AdamRJensen Aug 9, 2021
01f5d3c
Add double backticks in whatsnew
AdamRJensen Aug 9, 2021
381870f
Add double backticks in whatsnew
AdamRJensen Aug 9, 2021
17f9138
Add double backticks in whatsnew
AdamRJensen Aug 9, 2021
c8e5a6a
Change fail version to 0.10 in test_modelchain
AdamRJensen Aug 9, 2021
8c77b65
Coverage for deprecation warnings
AdamRJensen Aug 9, 2021
351f549
Fix doublebackticks in whatsnew
AdamRJensen Aug 9, 2021
0aee6a8
Fix stickler
AdamRJensen Aug 9, 2021
6276ccc
Replace tab with spaces in introtutorial
AdamRJensen Aug 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add variable map to pvgis_tmy with depreciating warning
  • Loading branch information
AdamRJensen committed Aug 2, 2021
commit b8bdd62b6bc9d8939cf2f2f18df54a3a9a776c22
60 changes: 56 additions & 4 deletions pvlib/iotools/pvgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import requests
import pandas as pd
from pvlib.iotools import read_epw, parse_epw
import warnings
from pvlib._deprecation import pvlibDeprecationWarning

URL = 'https://re.jrc.ec.europa.eu/api/'

Expand Down Expand Up @@ -365,7 +367,7 @@ def read_pvgis_hourly(filename, pvgis_format=None, map_variables=True):

def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
userhorizon=None, startyear=None, endyear=None, url=URL,
timeout=30):
map_variables=None, timeout=30):
"""
Get TMY data from PVGIS. For more information see the PVGIS [1]_ TMY tool
documentation [2]_.
Expand All @@ -392,6 +394,9 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
last year to calculate TMY, must be at least 10 years from first year
url : str, default :const:`pvlib.iotools.pvgis.URL`
base url of PVGIS API, append ``tmy`` to get TMY endpoint
map_variables: bool, default: True
When true, renames columns of the Dataframe to pvlib variable names
where applicable. See variable PVGIS_VARIABLE_MAP.
timeout : int, default 30
time in seconds to wait for server response before timeout

Expand Down Expand Up @@ -452,7 +457,7 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
data = None, None, None, None
if outputformat == 'json':
src = res.json()
return _parse_pvgis_tmy_json(src)
data = _parse_pvgis_tmy_json(src)
elif outputformat == 'csv':
with io.BytesIO(res.content) as src:
data = _parse_pvgis_tmy_csv(src)
Expand All @@ -467,6 +472,18 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
# this line is never reached because if outputformat is not valid then
# the response is HTTP/1.1 400 BAD REQUEST which is handled earlier
pass

if map_variables is None:
warnings.warn(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to test that this warning is emitted and mark that test with the fail_on_pvlib_version decorator. This ensures that we don't forget to remove deprecated functionality.

Copy link
Member Author
@AdamRJensen AdamRJensen Aug 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wholmgren Very smart, thanks for showing me this!

I believe all of your comments have been addressed.

'PVGIS variable names will be renamed to pvlib conventions by '
'default starting in pvlib 0.10.0. Specify map_variables=True '
'to enable that behavior now, or specify map_variables=False '
'to hide this warning.', pvlibDeprecationWarning
)
map_variables = False
if map_variables:
data = data.rename(columns=PVGIS_VARIABLE_MAP)

return data


Expand Down Expand Up @@ -521,7 +538,7 @@ def _parse_pvgis_tmy_basic(src):
return data, None, None, None


def read_pvgis_tmy(filename, pvgis_format=None):
def read_pvgis_tmy(filename, pvgis_format=None, map_variables=None):
"""
Read a file downloaded from PVGIS.

Expand All @@ -537,6 +554,10 @@ def read_pvgis_tmy(filename, pvgis_format=None):
``outputformat='basic'``, please set `pvgis_format` to ``'basic'``. If
`filename` is a buffer, then `pvgis_format` is required and must be in
``['csv', 'epw', 'json', 'basic']``.
map_variables: bool, default: True
When true, renames columns of the Dataframe to pvlib variable names
where applicable. See variable PVGIS_VARIABLE_MAP.


Returns
-------
Expand Down Expand Up @@ -580,6 +601,16 @@ def read_pvgis_tmy(filename, pvgis_format=None):
data, meta = parse_epw(filename)
except AttributeError: # str/path has no .read() attribute
data, meta = read_epw(filename)
if map_variables is None:
warnings.warn(
'PVGIS variable names will be renamed to pvlib conventions by '
'default starting in pvlib 0.10.0. Specify map_variables=True '
'to enable that behavior now, or specify map_variables=False '
'to hide this warning.', pvlibDeprecationWarning
)
map_variables = False
if map_variables:
data = data.rename(columns=PVGIS_VARIABLE_MAP)
return data, None, None, meta

# NOTE: json, csv, and basic output formats have parsers defined as private
Expand All @@ -594,7 +625,18 @@ def read_pvgis_tmy(filename, pvgis_format=None):
except AttributeError: # str/path has no .read() attribute
with open(str(filename), 'r') as fbuf:
src = json.load(fbuf)
return _parse_pvgis_tmy_json(src)
data = _parse_pvgis_tmy_json(src)
if map_variables is None:
warnings.warn(
'PVGIS variable names will be renamed to pvlib conventions by '
'default starting in pvlib 0.10.0. Specify map_variables=True '
'to enable that behavior now, or specify map_variables=False '
'to hide this warning.', pvlibDeprecationWarning
)
map_variables = False
if map_variables:
data = data.rename(columns=PVGIS_VARIABLE_MAP)
return data

# CSV or basic: use the correct parser from this module
# eg: _parse_pvgis_tmy_csv() or _parse_pvgist_tmy_basic()
Expand All @@ -608,6 +650,16 @@ def read_pvgis_tmy(filename, pvgis_format=None):
except AttributeError: # str/path has no .read() attribute
with open(str(filename), 'rb') as fbuf:
pvgis_data = pvgis_parser(fbuf)
if map_variables is None:
warnings.warn(
'PVGIS variable names will be renamed to pvlib conventions by '
'default starting in pvlib 0.10.0. Specify map_variables=True '
'to enable that behavior now, or specify map_variables=False '
'to hide this warning.', pvlibDeprecationWarning
)
map_variables = False
if map_variables:
data = data.rename(columns=PVGIS_VARIABLE_MAP)
return pvgis_data

# raise exception if pvgis format isn't in ['csv', 'basic', 'epw', 'json']
Expand Down
0