Skip to content

Commit 5a0265d

Browse files
committed
Merge remote-tracking branch 'upstream/main' into update_reindl_docs
2 parents 1773149 + 52afdcf commit 5a0265d

40 files changed

+1454
-894
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Set up Python
2323
uses: actions/setup-python@v2
2424
with:
25-
python-version: 3.8
25+
python-version: 3.9
2626

2727
- name: Install build tools
2828
run: |

.github/workflows/pytest-remote-data.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ jobs:
5656
strategy:
5757
fail-fast: false # don't cancel other matrix jobs when one fails
5858
matrix:
59-
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
59+
python-version: [3.9, "3.10", "3.11", "3.12"]
6060
suffix: [''] # the alternative to "-min"
6161
include:
62-
- python-version: 3.8
62+
- python-version: 3.9
6363
suffix: -min
6464

6565
runs-on: ubuntu-latest
@@ -103,7 +103,7 @@ jobs:
103103
run: pytest pvlib/tests/iotools --cov=./ --cov-report=xml --remote-data
104104

105105
- name: Upload coverage to Codecov
106-
if: matrix.python-version == 3.8 && matrix.suffix == ''
106+
if: matrix.python-version == 3.9 && matrix.suffix == ''
107107
uses: codecov/codecov-action@v4
108108
with:
109109
fail_ci_if_error: true

.github/workflows/pytest.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ jobs:
1212
fail-fast: false # don't cancel other matrix jobs when one fails
1313
matrix:
1414
os: [ubuntu-latest, macos-latest, windows-latest]
15-
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
15+
python-version: [3.9, "3.10", "3.11", "3.12"]
1616
environment-type: [conda, bare]
1717
suffix: [''] # placeholder as an alternative to "-min"
1818
include:
1919
- os: ubuntu-latest
20-
python-version: 3.8
20+
python-version: 3.9
2121
environment-type: conda
2222
suffix: -min
2323
exclude:
@@ -82,7 +82,7 @@ jobs:
8282
pytest pvlib --cov=./ --cov-report=xml --ignore=pvlib/tests/iotools
8383
8484
- name: Upload coverage to Codecov
85-
if: matrix.python-version == 3.8 && matrix.suffix == '' && matrix.os == 'ubuntu-latest' && matrix.environment-type == 'conda'
85+
if: matrix.python-version == 3.9 && matrix.suffix == '' && matrix.os == 'ubuntu-latest' && matrix.environment-type == 'conda'
8686
uses: codecov/codecov-action@v4
8787
with:
8888
fail_ci_if_error: true

benchmarks/asv.conf.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,19 @@
113113
"include": [
114114
// minimum supported versions
115115
{
116-
"python": "3.8",
116+
"python": "3.9",
117117
"build": "",
118-
"numpy": "1.17.5",
118+
"numpy": "1.19.5",
119119
"pandas": "1.3.0",
120120
"scipy": "1.6.0",
121121
// Note: these don't have a minimum in setup.py
122122
"h5py": "3.1.0",
123-
"ephem": "3.7.7.0", // first version to support py 3.8
124-
"numba": "0.47.0", // first version to support py 3.8
123+
"ephem": "4.0.0.1", // first version to support py 3.9
124+
"numba": "0.53.0", // first version to support py 3.9
125125
},
126126
// latest versions available
127127
{
128-
"python": "3.8",
128+
"python": "3.9",
129129
"build": "",
130130
"numpy": "",
131131
"pandas": "",

ci/requirements-py3.8.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

ci/requirements-py3.8-min.yml renamed to ci/requirements-py3.9-min.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ dependencies:
88
- pytest-cov
99
- pytest-mock
1010
- pytest-timeout
11-
- python=3.8
11+
- python=3.9
1212
- pytz
1313
- requests
1414
- pip:
15-
- dataclasses
16-
- h5py==2.10.0 # chosen for compatibility with numpy 1.17.3 and py3.8
17-
- numpy==1.17.3
18-
- pandas==1.3.0
15+
- h5py==3.0.0
16+
- numpy==1.19.3
17+
- pandas==1.3.0 # min version of pvlib
1918
- scipy==1.6.0
2019
- pytest-rerunfailures # conda version is >3.6
2120
- pytest-remotedata # conda package is 0.3.0, needs > 0.3.1

docs/examples/irradiance-transposition/plot_seasonal_tilt.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class SeasonalTiltMount(pvsystem.AbstractMount):
3232
surface_azimuth: float = 180.0
3333

3434
def get_orientation(self, solar_zenith, solar_azimuth):
35+
# note: determining tilt based on month may produce different
36+
# results depending on the time zone of the timestamps
3537
tilts = [self.monthly_tilts[m-1] for m in solar_zenith.index.month]
3638
return pd.DataFrame({
3739
'surface_tilt': tilts,
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
"""
2+
Use different Perez coefficients with the ModelChain
3+
====================================================
4+
5+
This example demonstrates how to customize the ModelChain
6+
to use site-specific Perez transposition coefficients.
7+
"""
8+
9+
# %%
10+
# The :py:class:`pvlib.modelchain.ModelChain` object provides a useful method
11+
# for easily constructing a PV system model with a simple, unified interface.
12+
# However, a user may want to customize the steps
13+
# in the system model in various ways.
14+
# One such example is during the irradiance transposition step.
15+
# The Perez model perform very well on field data, but
16+
# it requires a set of fitted coefficients from various sites.
17+
# It has been noted that these coefficients can be specific to
18+
# various climates, so users may see improved model accuracy
19+
# when using a site-specific set of coefficients.
20+
# However, the base :py:class:`~pvlib.modelchain.ModelChain`
21+
# only supports the default coefficients.
22+
# This example shows how the :py:class:`~pvlib.modelchain.ModelChain` can
23+
# be adjusted to use a different set of Perez coefficients.
24+
25+
import pandas as pd
26+
from pvlib.pvsystem import PVSystem
27+
from pvlib.modelchain import ModelChain
28+
from pvlib.temperature import TEMPERATURE_MODEL_PARAMETERS
29+
from pvlib import iotools, location, irradiance
30+
import pvlib
31+
import os
32+
import matplotlib.pyplot as plt
33+
34+
# load in TMY weather data from North Carolina included with pvlib
35+
PVLIB_DIR = pvlib.__path__[0]
36+
DATA_FILE = os.path.join(PVLIB_DIR, 'data', '723170TYA.CSV')
37+
38+
tmy, metadata = iotools.read_tmy3(DATA_FILE, coerce_year=1990,
39+
map_variables=True)
40+
41+
weather_data = tmy[['ghi', 'dhi', 'dni', 'temp_air', 'wind_speed']]
42+
43+
loc = location.Location.from_tmy(metadata)
44+
45+
#%%
46+
# Now, let's set up a standard PV model using the ``ModelChain``
47+
48+
surface_tilt = metadata['latitude']
49+
surface_azimuth = 180
50+
51+
# define an example module and inverter
52+
sandia_modules = pvlib.pvsystem.retrieve_sam('SandiaMod')
53+
cec_inverters = pvlib.pvsystem.retrieve_sam('cecinverter')
54+
sandia_module = sandia_modules['Canadian_Solar_CS5P_220M___2009_']
55+
cec_inverter = cec_inverters['ABB__MICRO_0_25_I_OUTD_US_208__208V_']
56+
57+
temp_params = TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_glass']
58+
59+
# define the system and ModelChain
60+
system = PVSystem(arrays=None,
61+
surface_tilt=surface_tilt,
62+
surface_azimuth=surface_azimuth,
63+
module_parameters=sandia_module,
64+
inverter_parameters=cec_inverter,
65+
temperature_model_parameters=temp_params)
66+
67+
mc = ModelChain(system, location=loc)
68+
69+
# %%
70+
# Now, let's calculate POA irradiance values outside of the ``ModelChain``.
71+
# We do this for both the default Perez coefficients and the desired
72+
# alternative Perez coefficients. This enables comparison at the end.
73+
74+
# Cape Canaveral seems like the most likely match for climate
75+
model_perez = 'capecanaveral1988'
76+
77+
solar_position = loc.get_solarposition(times=weather_data.index)
78+
dni_extra = irradiance.get_extra_radiation(weather_data.index)
79+
80+
POA_irradiance = irradiance.get_total_irradiance(
81+
surface_tilt=surface_tilt,
82+
surface_azimuth=surface_azimuth,
83+
dni=weather_data['dni'],
84+
ghi=weather_data['ghi'],
85+
dhi=weather_data['dhi'],
86+
solar_zenith=solar_position['apparent_zenith'],
87+
solar_azimuth=solar_position['azimuth'],
88+
model='perez',
89+
dni_extra=dni_extra)
90+
91+
POA_irradiance_new_perez = irradiance.get_total_irradiance(
92+
surface_tilt=surface_tilt,
93+
surface_azimuth=surface_azimuth,
94+
dni=weather_data['dni'],
95+
ghi=weather_data['ghi'],
96+
dhi=weather_data['dhi'],
97+
solar_zenith=solar_position['apparent_zenith'],
98+
solar_azimuth=solar_position['azimuth'],
99+
model='perez',
100+
model_perez=model_perez,
101+
dni_extra=dni_extra)
102+
103+
# %%
104+
# Now, run the ``ModelChain`` with both sets of irradiance data and compare
105+
# (note that to use POA irradiance as input to the ModelChain the method
106+
# `.run_model_from_poa` is used):
107+
108+
mc.run_model_from_poa(POA_irradiance)
109+
ac_power_default = mc.results.ac
110+
111+
mc.run_model_from_poa(POA_irradiance_new_perez)
112+
ac_power_new_perez = mc.results.ac
113+
114+
start, stop = '1990-05-05 06:00:00', '1990-05-05 19:00:00'
115+
plt.plot(ac_power_default.loc[start:stop],
116+
label="Default Composite Perez Model")
117+
plt.plot(ac_power_new_perez.loc[start:stop],
118+
label="Cape Canaveral Perez Model")
119+
plt.xticks(rotation=90)
120+
plt.ylabel("AC Power ($W$)")
121+
plt.legend()
122+
plt.tight_layout()
123+
plt.show()
124+
# %%
125+
# Note that there is a small, but noticeable difference from the default
126+
# coefficients that may add up over longer periods of time.

docs/examples/iv-modeling/plot_singlediode.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@
114114
# mark the MPP
115115
plt.plot([v_mp], [i_mp], ls='', marker='o', c='k')
116116

117+
plt.xlim(left=0)
118+
plt.ylim(bottom=0)
117119
plt.legend(loc=(1.0, 0))
118120
plt.xlabel('Module voltage [V]')
119121
plt.ylabel('Module current [A]')

0 commit comments

Comments
 (0)