|
24 | 24 |
|
25 | 25 | import pvlib |
26 | 26 | import pandas as pd |
| 27 | +import numpy as np |
27 | 28 | import matplotlib.pyplot as plt |
28 | 29 |
|
29 | 30 | # %% |
|
37 | 38 | location = pvlib.location.Location(latitude, longitude) |
38 | 39 |
|
39 | 40 | # %% |
40 | | -# Create simple synthetic weather data |
41 | | -# ------------------------------------- |
| 41 | +# Generate clear-sky weather data |
| 42 | +# -------------------------------- |
42 | 43 | # |
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. |
50 | 47 | times = pd.date_range( |
51 | 48 | "2019-06-01 00:00", |
52 | 49 | "2019-06-07 23:00", |
53 | 50 | freq="1h", |
54 | 51 | tz="Etc/GMT+7", |
55 | 52 | ) |
56 | 53 |
|
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 |
64 | 63 |
|
65 | 64 | # %% |
66 | 65 | # Define a simple PV system |
|
167 | 166 | # through the temperature coefficient, differences |
168 | 167 | # between temperature models can propagate into |
169 | 168 | # performance results. |
| 169 | + |
| 170 | +#%% |
170 | 171 | fig, ax = plt.subplots(figsize=(10, 4)) |
171 | 172 | mc_sapm.results.cell_temperature.plot(ax=ax, label="SAPM") |
172 | 173 | mc_faiman.results.cell_temperature.plot(ax=ax, label="Faiman") |
|
175 | 176 | ax.set_title("Comparison of Temperature Models") |
176 | 177 | ax.legend() |
177 | 178 | plt.tight_layout() |
178 | | -plt.show() |
179 | 179 |
|
180 | 180 | # %% |
181 | 181 | # Compare AC power output |
|
184 | 184 | # Finally, we compare the resulting AC power. Even small |
185 | 185 | # differences in temperature modeling can lead to noticeable |
186 | 186 | # differences in predicted energy production. |
| 187 | + |
| 188 | +#%% |
187 | 189 | fig, ax = plt.subplots(figsize=(10, 4)) |
188 | 190 | mc_sapm.results.ac.plot(ax=ax, label="SAPM") |
189 | 191 | mc_faiman.results.ac.plot(ax=ax, label="Faiman") |
|
192 | 194 | ax.set_title("AC Output with Different Temperature Models") |
193 | 195 | ax.legend() |
194 | 196 | plt.tight_layout() |
195 | | -plt.show() |
|
0 commit comments