Skip to content

Commit 7b3cc76

Browse files
committed
Merge branch 'main' into refactor-docstring-params-2
2 parents 469edc2 + 63a2ca4 commit 7b3cc76

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2221
-479
lines changed

.github/workflows/publish.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,18 @@ jobs:
2828
run: |
2929
python -m pip install --upgrade pip
3030
python -m pip install build
31+
python -m pip install twine
3132
3233
- name: Build packages
3334
run: python -m build
3435

36+
- name: Check metadata verification
37+
run: python -m twine check --strict dist/*
38+
3539
# only publish distribution to PyPI for tagged commits
3640
- name: Publish distribution to PyPI
3741
if: startsWith(github.ref, 'refs/tags/v')
3842
uses: pypa/gh-action-pypi-publish@release/v1
3943
with:
4044
user: __token__
41-
password: ${{ secrets.pypi_password }}
45+
password: ${{ secrets.pypi_password }}

benchmarks/benchmarks/location.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pandas as pd
66
import pvlib
7-
from pkg_resources import parse_version
7+
from packaging.version import Version
88

99

1010
def set_solar_position(obj):
@@ -37,7 +37,7 @@ def time_location_get_clearsky(self):
3737
class Location_0_6_1:
3838

3939
def setup(self):
40-
if parse_version(pvlib.__version__) < parse_version('0.6.1'):
40+
if Version(pvlib.__version__) < Version('0.6.1'):
4141
raise NotImplementedError
4242

4343
set_solar_position(self)

benchmarks/benchmarks/solarposition.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
import pvlib
88
from pvlib import solarposition
99

10-
from pkg_resources import parse_version
10+
from packaging.version import Version
1111

1212

13-
if parse_version(pvlib.__version__) >= parse_version('0.6.1'):
13+
if Version(pvlib.__version__) >= Version('0.6.1'):
1414
sun_rise_set_transit_spa = solarposition.sun_rise_set_transit_spa
1515
else:
1616
sun_rise_set_transit_spa = solarposition.get_sun_rise_set_transit

benchmarks/benchmarks/solarposition_numba.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Try to keep relevant sections in sync with benchmarks/solarposition.py
88
"""
99

10-
from pkg_resources import parse_version
10+
from packaging.version import Version
1111
import pandas as pd
1212

1313
import os
@@ -18,7 +18,7 @@
1818
from pvlib import solarposition # NOQA: E402
1919

2020

21-
if parse_version(pvlib.__version__) >= parse_version('0.6.1'):
21+
if Version(pvlib.__version__) >= Version('0.6.1'):
2222
sun_rise_set_transit_spa = solarposition.sun_rise_set_transit_spa
2323
else:
2424
sun_rise_set_transit_spa = solarposition.get_sun_rise_set_transit

benchmarks/benchmarks/temperature.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pandas as pd
66
import pvlib
7-
from pkg_resources import parse_version
7+
from packaging.version import Version
88
from functools import partial
99

1010

@@ -20,7 +20,7 @@ class SAPM:
2020

2121
def setup(self):
2222
set_weather_data(self)
23-
if parse_version(pvlib.__version__) >= parse_version('0.7.0'):
23+
if Version(pvlib.__version__) >= Version('0.7.0'):
2424
kwargs = pvlib.temperature.TEMPERATURE_MODEL_PARAMETERS['sapm']
2525
kwargs = kwargs['open_rack_glass_glass']
2626
self.sapm_cell_wrapper = partial(pvlib.temperature.sapm_cell,
@@ -41,7 +41,7 @@ def time_sapm_cell(self):
4141
class Fuentes:
4242

4343
def setup(self):
44-
if parse_version(pvlib.__version__) < parse_version('0.8.0'):
44+
if Version(pvlib.__version__) < Version('0.8.0'):
4545
raise NotImplementedError
4646

4747
set_weather_data(self)

docs/examples/irradiance-decomposition/plot_diffuse_fraction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
# `NSRDB`_ user manuals.
204204
#
205205
# The Erbs and Boland models are correlations only based on the clearness index
206-
# kt, which is the ratio of GHI to the the horizontal component of the
206+
# kt, which is the ratio of GHI to the horizontal component of the
207207
# extra-terrestrial irradiance. At low sun elevation (zenith near 90 degrees),
208208
# especially near sunset, kt can explode because the denominator
209209
# (extra-terrestrial irradiance) approaches zero. In pvlib this behavior is

docs/examples/iv-modeling/plot_singlediode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@
118118
plt.xlabel('Module voltage [V]')
119119
plt.ylabel('Module current [A]')
120120
plt.title(parameters['Name'])
121-
plt.show()
122121
plt.gcf().set_tight_layout(True)
123122

124123

@@ -136,6 +135,7 @@ def draw_arrow(ax, label, x0, y0, rotation, size, direction):
136135
ax = plt.gca()
137136
draw_arrow(ax, 'Irradiance', 20, 2.5, 90, 15, 'r')
138137
draw_arrow(ax, 'Temperature', 35, 1, 0, 15, 'l')
138+
plt.show()
139139

140140
print(pd.DataFrame({
141141
'i_sc': curve_info['i_sc'],
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
"""
2+
Simple irradiance adjustment for horizon shading
3+
================================================
4+
5+
Example of applying horizon shading to dni and global poa. Using
6+
horizon profile data, this example interpolates it to time-series
7+
solar-position data, and adjust DNI and POA-global irradiance.
8+
"""
9+
10+
# %%
11+
# This example shows how to use horizon elevation angles with
12+
# corresponding horizon azimuth angles for simple horizon shading adjustments.
13+
#
14+
# After location information and a date range is established, solar position
15+
# data is calculated using :py:func:`pvlib.solarposition.get_solarposition`.
16+
# Horizon data is assigned, and interpolated to the solar azimuth time
17+
# series data. Finally, in times when solar elevation is greater than the
18+
# interpolated horizon elevation angle, DNI is set to 0.
19+
20+
import numpy as np
21+
import pandas as pd
22+
import pvlib
23+
24+
# Golden, CO
25+
latitude, longitude = 39.76, -105.22
26+
tz = 'MST'
27+
28+
# Set times in the morning of the December solstice.
29+
times = pd.date_range(
30+
'2020-12-20 6:30', '2020-12-20 9:00', freq='1T', tz=tz
31+
)
32+
33+
# Create location object, and get solar position and clearsky irradiance data.
34+
location = pvlib.location.Location(latitude, longitude, tz)
35+
solar_position = location.get_solarposition(times)
36+
clearsky = location.get_clearsky(times)
37+
38+
# Assign variable names for easier reading.
39+
surface_tilt = 30
40+
surface_azimuth = 180
41+
solar_azimuth = solar_position.azimuth
42+
solar_zenith = solar_position.apparent_zenith
43+
solar_elevation = solar_position.apparent_elevation
44+
dni = clearsky.dni
45+
ghi = clearsky.ghi
46+
dhi = clearsky.dhi
47+
48+
# %%
49+
# With basic inputs in place, let's perform the adjustment for horizon shading:
50+
51+
# Use hard-coded horizon profile data from location object above.
52+
horizon_profile = pd.Series([
53+
10.7, 11.8, 11.5, 10.3, 8.0, 6.5, 3.8, 2.3, 2.3, 2.3, 4.6, 8.0, 10.3, 11.1,
54+
10.7, 10.3, 9.2, 6.1, 5.3, 2.3, 3.1, 1.9, 1.9, 2.7, 3.8, 5.3, 6.5, 8.4,
55+
8.8, 8.4, 8.4, 8.4, 6.5, 6.1, 6.5, 6.1, 7.3, 9.2, 8.4, 8.0, 5.7, 5.3, 5.3,
56+
4.2, 4.2, 4.2, 7.3, 9.5
57+
], index=np.arange(0, 360, 7.5))
58+
59+
ax = horizon_profile.plot(xlim=(0, 360), ylim=(0, None), figsize=(6, 2.5))
60+
ax.set_title('Horizon profile')
61+
ax.set_xticks([0, 90, 180, 270, 360])
62+
ax.set_xlabel('Azimuth [°]')
63+
ax.set_ylabel('Horizon angle [°]')
64+
65+
# %%
66+
# .. admonition:: Horizon data from PVGIS
67+
#
68+
# Example of how to get the above horizon data from PVGIS
69+
#
70+
# horizon_profile, horizon_metadata = pvlib.iotools.get_pvgis_horizon(
71+
# latitutde, longitude)
72+
#
73+
74+
# Interpolate the horizon elevation data to the solar azimuth, and keep as a
75+
# numpy array.
76+
horizon_elevation_data = np.interp(
77+
solar_azimuth, horizon_profile.index, horizon_profile
78+
)
79+
80+
# Convert to Pandas Series for easier usage.
81+
horizon_elevation_data = pd.Series(horizon_elevation_data, times)
82+
83+
# Adjust DNI based on data - note this is returned as numpy array
84+
dni_adjusted = np.where(solar_elevation > horizon_elevation_data, dni, 0)
85+
86+
# Adjust GHI and set it to DHI for time-periods where 'dni_adjusted' is 0.
87+
# Note this is returned as numpy array
88+
ghi_adjusted = np.where(dni_adjusted == 0, dhi, ghi)
89+
90+
# Transposition using the original and adjusted irradiance components.
91+
irrad_pre_adj = pvlib.irradiance.get_total_irradiance(
92+
surface_tilt, surface_azimuth, solar_zenith, solar_azimuth, dni, ghi, dhi
93+
)
94+
95+
irrad_post_adj = pvlib.irradiance.get_total_irradiance(
96+
surface_tilt, surface_azimuth, solar_zenith, solar_azimuth, dni_adjusted,
97+
ghi_adjusted, dhi
98+
)
99+
100+
# Create and plot result DataFrames.
101+
poa_global_comparison = pd.DataFrame({
102+
'poa_global_pre-adjustment': irrad_pre_adj.poa_global,
103+
'poa_global_post-adjustment': irrad_post_adj.poa_global
104+
})
105+
106+
dni_comparison = pd.DataFrame({
107+
'dni_pre-adjustment': dni,
108+
'dni_post-adjustment': dni_adjusted
109+
})
110+
111+
# Plot results
112+
poa_global_comparison.plot(
113+
title='POA-Global: Before and after Horizon Adjustment',
114+
ylabel='Irradiance'
115+
)
116+
dni_comparison.plot(
117+
title='DNI: Before and after Horizon Adjustment', ylabel='Irradiance'
118+
)

docs/sphinx/source/reference/iotools.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ of sources and file formats relevant to solar energy modeling.
4242
iotools.get_acis_mpe
4343
iotools.get_acis_station_data
4444
iotools.get_acis_available_stations
45+
iotools.read_panond
46+
4547

4648
A :py:class:`~pvlib.location.Location` object may be created from metadata
4749
in some files.

docs/sphinx/source/reference/irradiance/decomposition.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ DNI estimation models
1212
irradiance.dirint
1313
irradiance.dirindex
1414
irradiance.erbs
15+
irradiance.erbs_driesse
1516
irradiance.orgill_hollands
1617
irradiance.boland
1718
irradiance.campbell_norman

docs/sphinx/source/reference/irradiance/transposition.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Transposition models
1010
irradiance.get_sky_diffuse
1111
irradiance.isotropic
1212
irradiance.perez
13+
irradiance.perez_driesse
1314
irradiance.haydavies
1415
irradiance.klucher
1516
irradiance.reindl

docs/sphinx/source/user_guide/faq.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ irradiance datasets, including the BSRN, SURFRAD, SRML, and NREL's MIDC.
6666
Can I use PVsyst (PAN/OND) files with pvlib?
6767
--------------------------------------------
6868

69-
Currently, pvlib does not have the ability to import any PVsyst file formats.
70-
Certain formats of particular interest (e.g. PAN files) may be added in a future
71-
version. Until then, these Google Group threads
69+
Although pvlib includes a function to read PAN and OND files
70+
(:py:func:`~pvlib.iotools.read_panond`), it is up to the user to determine
71+
whether and how the imported parameter values can be used with pvlib's models.
72+
Easier use of these parameter files with the rest of pvlib may be added
73+
in a future version. Until then, these Google Group threads
7274
(`one <https://groups.google.com/g/pvlib-python/c/PDDic0SS6ao/m/Z-WKj7C6BwAJ>`_
7375
and `two <https://groups.google.com/g/pvlib-python/c/b1mf4Y1qHBY/m/tK2FBCJyBgAJ>`_)
7476
may be useful for some users.

docs/sphinx/source/whatsnew.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ What's New
66

77
These are new features and improvements of note in each release.
88

9+
.. include:: whatsnew/v0.10.2.rst
910
.. include:: whatsnew/v0.10.1.rst
1011
.. include:: whatsnew/v0.10.0.rst
1112
.. include:: whatsnew/v0.9.5.rst
Lines changed: 56 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,86 @@
11
.. _whatsnew_01020:
22

33

4-
v0.10.2 (Anticipated September, 2023)
5-
-------------------------------------
6-
7-
8-
Deprecations
9-
~~~~~~~~~~~~
4+
v0.10.2 (September 21, 2023)
5+
----------------------------
106

117

128
Enhancements
139
~~~~~~~~~~~~
10+
* Added .pan/.ond reader function :py:func:`pvlib.iotools.read_panond`. (:issue:`1747`, :pull:`1749`)
1411
* Added support for dates to be specified as strings in the iotools get functions:
15-
:py:func:`pvlib.iotools.get_pvgis_hourly`, :py:func:`pvlib.iotools.get_cams`,
16-
:py:func:`pvlib.iotools.get_bsrn`, and :py:func:`pvlib.iotools.read_midc_raw_data_from_nrel`.
12+
:py:func:`~pvlib.iotools.get_pvgis_hourly`, :py:func:`~pvlib.iotools.get_cams`,
13+
:py:func:`~pvlib.iotools.get_bsrn`, and :py:func:`~pvlib.iotools.read_midc_raw_data_from_nrel`.
1714
(:pull:`1800`)
18-
* Added option to infer threshold values for
15+
* Added support for asymmetric limiting angles in :py:func:`pvlib.tracking.singleaxis`
16+
and :py:class:`~pvlib.pvsystem.SingleAxisTrackerMount`. (:issue:`1777`, :pull:`1809`, :pull:`1852`)
17+
* Added option to infer threshold values for
1918
:py:func:`pvlib.clearsky.detect_clearsky` (:issue:`1808`, :pull:`1784`)
19+
* Added a continuous version of the Erbs diffuse-fraction/decomposition model.
20+
:py:func:`pvlib.irradiance.erbs_driesse` (:issue:`1755`, :pull:`1834`)
21+
* Added :py:func:`~pvlib.iam.interp` option as AOI losses model in
22+
:py:class:`~pvlib.modelchain.ModelChain` and
23+
:py:class:`~pvlib.pvsystem.PVSystem`. (:issue:`1742`, :pull:`1832`)
24+
* :py:class:`~pvlib.pvsystem.PVSystem` objects with a single
25+
:py:class:`~pvlib.pvsystem.Array` can now be created without wrapping the
26+
``Array`` in a list first. (:issue:`1831`, :pull:`1854`)
2027

2128

2229
Bug fixes
2330
~~~~~~~~~
2431
* :py:func:`~pvlib.iotools.get_psm3` no longer incorrectly returns clear-sky
2532
DHI instead of clear-sky GHI when requesting ``ghi_clear``. (:pull:`1819`)
33+
* :py:func:`pvlib.singlediode.bishop88` with ``method='newton'`` no longer
34+
crashes when passed ``pandas.Series`` of length one.
35+
(:issue:`1787`, :pull:`1822`)
36+
* :py:class:`~pvlib.pvsystem.PVSystem` now correctly passes ``n_ar`` module
37+
parameter to :py:func:`pvlib.iam.physical` when this IAM model is specified
38+
or inferred. (:pull:`1832`)
39+
2640

2741
Testing
2842
~~~~~~~
2943
* Added GitHub action to lint file changes with Flake8, replacing Stickler-CI.
30-
(:issue:`776`, :issue:`1722`, :pull:`1786`)
44+
(:issue:`776`, :issue:`1722`, :pull:`1723`, :pull:`1786`)
45+
3146

3247
Documentation
3348
~~~~~~~~~~~~~
34-
* Removed Stickler-CI integration as the service has ceased June 2023.
35-
(:issue:`1722`, :pull:`1723`)
36-
37-
Requirements
38-
~~~~~~~~~~~~
49+
* Added docstring detail for :py:func:`pvlib.iam.schlick_diffuse`.
50+
(:issue:`1811`, :pull:`1812`)
51+
* Specified that :py:func:`pvlib.singlediode.bishop88`,
52+
:py:func:`pvlib.singlediode.bishop88_i_from_v`, and
53+
:py:func:`pvlib.singlediode.bishop88_v_from_i` parameters ``breakdown_factor``,
54+
``breakdown_voltage``, and ``breakdown_exp`` should be floats.
55+
(:issue:`1820`, :pull:`1821`)
56+
* Fix and update example in :py:func:`pvlib.pvsystem.retrieve_sam`.
57+
(:issue:`1741`, :pull:`1833`)
58+
* Fix error in :py:func:`pvlib.iotools.get_pvgis_hourly` documentation of ``surface_azimuth``.
59+
(:issue:`1724`, :pull:`1838`)
60+
* Update definition of ``snow_events`` parameter for :py:func:`pvlib.snow.loss_townsend`.
61+
(:issue:`1839`, :pull:`1840`)
62+
* Added gallery example demonstrating how horizon profile data from :py:func:`pvlib.iotools.get_pvgis_horizon`,
63+
can be used to apply horizon shading to time series dni and global poa data. (:pull:`1849`)
3964

4065

4166
Contributors
4267
~~~~~~~~~~~~
68+
* Connor Krening (:ghuser:`ckrening`)
4369
* Adam R. Jensen (:ghuser:`AdamRJensen`)
70+
* Michal Arieli (:ghuser:`MichalArieli`)
4471
* Abigail Jones (:ghuser:`ajonesr`)
4572
* Taos Transue (:ghuser:`reepoi`)
73+
* Echedey Luis (:ghuser:`echedey-ls`)
74+
* Todd Karin (:ghuser:`toddkarin`)
75+
* NativeSci (:ghuser:`nativesci`)
76+
* Anton Driesse (:ghuser:`adriesse`)
77+
* Lukas Grossar (:ghuser:`tongpu`)
78+
* Areeba Turabi (:ghuser:`aturabi`)
79+
* Saurabh Aneja (:ghuser:`spaneja`)
80+
* Miroslav Šedivý (:ghuser:`eumiro`)
81+
* kjsauer (:ghuser:`kjsauer`)
82+
* Jules Chéron (:ghuser:`jules-ch`)
83+
* Cliff Hansen (:ghuser:`cwhanse`)
84+
* Will Holmgren (:ghuser:`wholmgren`)
85+
* Mark Mikofski (:ghuser:`mikofski`)
86+
* Kevin Anderson (:ghuser:`kandersolar`)

0 commit comments

Comments
 (0)