Skip to content

Commit 7360834

Browse files
committed
enable execution of system-models examples in Sphinx Gallery
1 parent b49cd1c commit 7360834

2 files changed

Lines changed: 20 additions & 19 deletions

File tree

docs/examples/system-models/plot_modelchain_model_variations.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import pvlib
2626
import pandas as pd
27+
import numpy as np
2728
import matplotlib.pyplot as plt
2829

2930
# %%
@@ -37,30 +38,28 @@
3738
location = pvlib.location.Location(latitude, longitude)
3839

3940
# %%
40-
# Create simple synthetic weather data
41-
# -------------------------------------
41+
# Generate clear-sky weather data
42+
# --------------------------------
4243
#
43-
# To keep this example lightweight and fully reproducible,
44-
# we generate a small synthetic weather dataset instead of
45-
# downloading data from an external source.
46-
#
47-
# The weather values are kept constant so that any differences
48-
# in results arise solely from the chosen temperature model.
49-
44+
# We generate clear-sky irradiance using pvlib and create a
45+
# varying air temperature profile instead of using constant
46+
# values.
5047
times = pd.date_range(
5148
"2019-06-01 00:00",
5249
"2019-06-07 23:00",
5350
freq="1h",
5451
tz="Etc/GMT+7",
5552
)
5653

57-
weather_subset = pd.DataFrame({
58-
"ghi": 800,
59-
"dni": 600,
60-
"dhi": 200,
61-
"temp_air": 25,
62-
"wind_speed": 1,
63-
}, index=times)
54+
# Clear-sky irradiance
55+
clearsky = location.get_clearsky(times)
56+
57+
# Create a simple daily temperature cycle
58+
temp_air = 20 + 10 * np.sin(2 * np.pi * (times.hour - 6) / 24)
59+
60+
weather_subset = clearsky.copy()
61+
weather_subset["temp_air"] = temp_air
62+
weather_subset["wind_speed"] = 1
6463

6564
# %%
6665
# Define a simple PV system
@@ -167,6 +166,8 @@
167166
# through the temperature coefficient, differences
168167
# between temperature models can propagate into
169168
# performance results.
169+
170+
#%%
170171
fig, ax = plt.subplots(figsize=(10, 4))
171172
mc_sapm.results.cell_temperature.plot(ax=ax, label="SAPM")
172173
mc_faiman.results.cell_temperature.plot(ax=ax, label="Faiman")
@@ -175,7 +176,6 @@
175176
ax.set_title("Comparison of Temperature Models")
176177
ax.legend()
177178
plt.tight_layout()
178-
plt.show()
179179

180180
# %%
181181
# Compare AC power output
@@ -184,6 +184,8 @@
184184
# Finally, we compare the resulting AC power. Even small
185185
# differences in temperature modeling can lead to noticeable
186186
# differences in predicted energy production.
187+
188+
#%%
187189
fig, ax = plt.subplots(figsize=(10, 4))
188190
mc_sapm.results.ac.plot(ax=ax, label="SAPM")
189191
mc_faiman.results.ac.plot(ax=ax, label="Faiman")
@@ -192,4 +194,3 @@
192194
ax.set_title("AC Output with Different Temperature Models")
193195
ax.legend()
194196
plt.tight_layout()
195-
plt.show()

docs/sphinx/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ def setup(app):
389389
'examples_dirs': ['../../examples'], # location of gallery scripts
390390
'gallery_dirs': ['gallery'], # location of generated output
391391
# execute all scripts except for ones in the "system-models" directory:
392-
'filename_pattern': '^((?!system-models).)*$',
392+
'filename_pattern': 'plot_',
393393

394394
# directory where function/class granular galleries are stored
395395
'backreferences_dir': 'reference/generated/gallery_backreferences',

0 commit comments

Comments
 (0)