Skip to content

Commit 6f9ad5e

Browse files
PiercePierce
Pierce
authored and
Pierce
committed
merge2
2 parents 43951a2 + 97ee479 commit 6f9ad5e

File tree

4 files changed

+95
-97
lines changed

4 files changed

+95
-97
lines changed

pvlib/horizon.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
gdal, osgeo, geoio, and scikit-image.
77
'''
88
import numpy as np
9-
from pathlib import Path
9+
1010

1111
def dni_horizon_adjustment(horizon_angles, solar_zenith, solar_azimuth):
1212
'''
@@ -46,6 +46,7 @@ def dni_horizon_adjustment(horizon_angles, solar_zenith, solar_azimuth):
4646
adjustment[mask] = 0
4747
return adjustment
4848

49+
4950
def calculate_dtf(horizon_azimuths, horizon_angles,
5051
surface_tilt, surface_azimuth):
5152
"""
@@ -115,6 +116,7 @@ def calculate_dtf(horizon_azimuths, horizon_angles,
115116
dtf += 2 * (first_term + second_term) / num_points
116117
return dtf
117118

119+
118120
def collection_plane_elev_angle(surface_tilt, surface_azimuth, direction):
119121
"""
120122
Determine the elevation angle created by the surface of a tilted plane

pvlib/iotools/cgiar.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ def download_SRTM(latitude, longitude, srtm_arc_sec=3,
7575
org_url = 'https://srtm.csi.cgiar.org/'
7676
base_url = org_url + 'wp-content/uploads/files/srtm_5x5/TIFF/'
7777
query_URL = base_url + f'srtm_{long:02d}_{lat:02d}.zip'
78-
res = requests.get(query_URL, proxies = proxies, verify = False)
78+
res = requests.get(query_URL, proxies=proxies, verify=False)
7979
res.raise_for_status()
80-
80+
8181
# unzip download
8282
zipfile = ZipFile(io.BytesIO(res.content))
8383
ext = '.tif'
8484
files = zipfile.namelist()
85-
file = [ f for f in files if ext in f ][0]
86-
path = zipfile.extract(file, path = path_to_save)
85+
file = [f for f in files if ext in f][0]
86+
path = zipfile.extract(file, path=path_to_save)
8787
img = skimage.io.imread(path)
8888
return img, path

pvlib/iotools/pvgis.py

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
URL = 'https://re.jrc.ec.europa.eu/api/'
2828

2929
# Dictionary mapping PVGIS names to pvlib names
30-
VARIABLE_MAP = {
30+
PVGIS_VARIABLE_MAP = {
3131
'G(h)': 'ghi',
3232
'Gb(n)': 'dni',
3333
'Gd(h)': 'dhi',
@@ -113,11 +113,10 @@ def get_pvgis_hourly(latitude, longitude, start=None, end=None,
113113
documentation [2]_ for more info.
114114
url: str, default: :const:`pvlib.iotools.pvgis.URL`
115115
Base url of PVGIS API. ``seriescalc`` is appended to get hourly data
116-
endpoint. Note, a specific PVGIS version can be specified, e.g.,
117-
https://re.jrc.ec.europa.eu/api/v5_2/
116+
endpoint.
118117
map_variables: bool, default: True
119118
When true, renames columns of the Dataframe to pvlib variable names
120-
where applicable. See variable :const:`VARIABLE_MAP`.
119+
where applicable. See variable PVGIS_VARIABLE_MAP.
121120
timeout: int, default: 30
122121
Time in seconds to wait for server response before timeout
123122
@@ -140,10 +139,10 @@ def get_pvgis_hourly(latitude, longitude, start=None, end=None,
140139
Hint
141140
----
142141
PVGIS provides access to a number of different solar radiation datasets,
143-
including satellite-based (SARAH, SARAH2, and NSRDB PSM3) and re-analysis
144-
products (ERA5). Each data source has a different geographical coverage and
145-
time stamp convention, e.g., SARAH and SARAH2 provide instantaneous values,
146-
whereas values from ERA5 are averages for the hour.
142+
including satellite-based (SARAH, CMSAF, and NSRDB PSM3) and re-analysis
143+
products (ERA5 and COSMO). Each data source has a different geographical
144+
coverage and time stamp convention, e.g., SARAH and CMSAF provide
145+
instantaneous values, whereas values from ERA5 are averages for the hour.
147146
148147
Notes
149148
-----
@@ -174,12 +173,6 @@ def get_pvgis_hourly(latitude, longitude, start=None, end=None,
174173
--------
175174
pvlib.iotools.read_pvgis_hourly, pvlib.iotools.get_pvgis_tmy
176175
177-
Examples
178-
--------
179-
>>> # Retrieve two years of irradiance data from PVGIS:
180-
>>> data, meta, inputs = pvlib.iotools.get_pvgis_hourly( # doctest: +SKIP
181-
>>> latitude=45, longitude=8, start=2015, end=2016) # doctest: +SKIP
182-
183176
References
184177
----------
185178
.. [1] `PVGIS <https://ec.europa.eu/jrc/en/pvgis>`_
@@ -236,7 +229,7 @@ def _parse_pvgis_hourly_json(src, map_variables):
236229
data = data.drop('time', axis=1)
237230
data = data.astype(dtype={'Int': 'int'}) # The 'Int' column to be integer
238231
if map_variables:
239-
data = data.rename(columns=VARIABLE_MAP)
232+
data = data.rename(columns=PVGIS_VARIABLE_MAP)
240233
return data, inputs, metadata
241234

242235

@@ -278,7 +271,7 @@ def _parse_pvgis_hourly_csv(src, map_variables):
278271
data.index = pd.to_datetime(data['time'], format='%Y%m%d:%H%M', utc=True)
279272
data = data.drop('time', axis=1)
280273
if map_variables:
281-
data = data.rename(columns=VARIABLE_MAP)
274+
data = data.rename(columns=PVGIS_VARIABLE_MAP)
282275
# All columns should have the dtype=float, except 'Int' which should be
283276
# integer. It is necessary to convert to float, before converting to int
284277
data = data.astype(float).astype(dtype={'Int': 'int'})
@@ -305,7 +298,7 @@ def read_pvgis_hourly(filename, pvgis_format=None, map_variables=True):
305298
``pvgis_format`` is required and must be in ``['csv', 'json']``.
306299
map_variables: bool, default True
307300
When true, renames columns of the DataFrame to pvlib variable names
308-
where applicable. See variable :const:`VARIABLE_MAP`.
301+
where applicable. See variable PVGIS_VARIABLE_MAP.
309302
310303
Returns
311304
-------
@@ -377,9 +370,8 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
377370
userhorizon=None, startyear=None, endyear=None, url=URL,
378371
map_variables=None, timeout=30):
379372
"""
380-
Get TMY data from PVGIS.
381-
382-
For more information see the PVGIS [1]_ TMY tool documentation [2]_.
373+
Get TMY data from PVGIS. For more information see the PVGIS [1]_ TMY tool
374+
documentation [2]_.
383375
384376
Parameters
385377
----------
@@ -405,7 +397,7 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
405397
base url of PVGIS API, append ``tmy`` to get TMY endpoint
406398
map_variables: bool
407399
When true, renames columns of the Dataframe to pvlib variable names
408-
where applicable. See variable const:`VARIABLE_MAP`.
400+
where applicable. See variable PVGIS_VARIABLE_MAP.
409401
timeout : int, default 30
410402
time in seconds to wait for server response before timeout
411403
@@ -437,12 +429,13 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
437429
the error message in the response will be raised as an exception,
438430
otherwise raise whatever ``HTTP/1.1`` error occurred
439431
440-
See Also
432+
See also
441433
--------
442434
read_pvgis_tmy
443435
444436
References
445437
----------
438+
446439
.. [1] `PVGIS <https://ec.europa.eu/jrc/en/pvgis>`_
447440
.. [2] `PVGIS TMY tool <https://ec.europa.eu/jrc/en/PVGIS/tools/tmy>`_
448441
.. [3] `PVGIS horizon profile tool
@@ -500,7 +493,7 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True,
500493
)
501494
map_variables = False
502495
if map_variables:
503-
data = data.rename(columns=VARIABLE_MAP)
496+
data = data.rename(columns=PVGIS_VARIABLE_MAP)
504497

505498
return data, months_selected, inputs, meta
506499

@@ -574,7 +567,7 @@ def read_pvgis_tmy(filename, pvgis_format=None, map_variables=None):
574567
be in ``['csv', 'epw', 'json', 'basic']``.
575568
map_variables: bool
576569
When true, renames columns of the Dataframe to pvlib variable names
577-
where applicable. See variable :const:`VARIABLE_MAP`.
570+
where applicable. See variable PVGIS_VARIABLE_MAP.
578571
579572
580573
Returns
@@ -597,7 +590,7 @@ def read_pvgis_tmy(filename, pvgis_format=None, map_variables=None):
597590
TypeError
598591
if ``pvgis_format`` is ``None`` and ``filename`` is a buffer
599592
600-
See Also
593+
See also
601594
--------
602595
get_pvgis_tmy
603596
"""
@@ -663,7 +656,7 @@ def read_pvgis_tmy(filename, pvgis_format=None, map_variables=None):
663656
)
664657
map_variables = False
665658
if map_variables:
666-
data = data.rename(columns=VARIABLE_MAP)
659+
data = data.rename(columns=PVGIS_VARIABLE_MAP)
667660

668661
return data, months_selected, inputs, meta
669662

@@ -695,11 +688,13 @@ def get_pvgis_horizon(latitude, longitude, proxies=None, url=URL):
695688
# the horizon data is given in a different format then the others
696689
# numpy has an easier time decoding it
697690
array = np.genfromtxt(io.StringIO(string),
698-
skip_header = 4, skip_footer = 7)
691+
skip_header=4, skip_footer=7)
699692
df = pd.DataFrame(array)
700-
693+
701694
# Set the column names
702695
df.columns = ['horizon_azimuth', 'horizon_angles',
703-
'azimuth_sun_winter_solstice', 'elevation_sun_winter_solstice',
704-
'azimuth_sun_summer_solstice', 'elevation_sun_summer_solstice']
696+
'azimuth_sun_winter_solstice',
697+
'elevation_sun_winter_solstice',
698+
'azimuth_sun_summer_solstice',
699+
'elevation_sun_summer_solstice']
705700
return df

0 commit comments

Comments
 (0)