Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/source/whatsnew/releases/v0.7.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ Documentation
-------------


Notebooks
---------
- Make the ASTM live demo and custom-functions tutorial notebooks reproducible
offline by loading cached NSRDB TMY data (with ``USE_LIVE_*`` toggle for the
live API path), fixing ``nbval`` failures caused by stale stored outputs and
the PVGIS API being unreachable from CI. (:issue:`342`, :pull:`350`)


Deprecations
-------------

Expand Down
102 changes: 45 additions & 57 deletions tutorials/01_basics/04_weather_database_access.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,45 +50,29 @@
"execution_count": 1,
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-03T15:42:13.626699Z",
"iopub.status.busy": "2025-12-03T15:42:13.626456Z",
"iopub.status.idle": "2025-12-03T15:42:13.632347Z",
"shell.execute_reply": "2025-12-03T15:42:13.631558Z"
}
},
"outputs": [],
"source": [
"# if running on google colab, uncomment the next line and execute this cell to install the dependencies and prevent \"ModuleNotFoundError\" in later cells:\n",
"# !pip install pvdeg"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-03T15:42:13.634556Z",
"iopub.status.busy": "2025-12-03T15:42:13.634241Z",
"iopub.status.idle": "2025-12-03T15:42:17.912055Z",
"shell.execute_reply": "2025-12-03T15:42:17.910698Z"
"iopub.execute_input": "2026-06-30T16:53:21.590643Z",
"iopub.status.busy": "2026-06-30T16:53:21.589455Z",
"iopub.status.idle": "2026-06-30T16:53:31.669663Z",
"shell.execute_reply": "2026-06-30T16:53:31.668144Z"
},
"scrolled": true
},
"outputs": [],
"source": [
"import pvdeg\n",
"import json\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-03T15:42:17.915654Z",
"iopub.status.busy": "2025-12-03T15:42:17.914551Z",
"iopub.status.idle": "2025-12-03T15:42:17.921986Z",
"shell.execute_reply": "2025-12-03T15:42:17.920956Z"
"iopub.execute_input": "2026-06-30T16:53:31.674429Z",
"iopub.status.busy": "2026-06-30T16:53:31.673308Z",
"iopub.status.idle": "2026-06-30T16:53:31.681145Z",
"shell.execute_reply": "2026-06-30T16:53:31.680050Z"
}
},
"outputs": [
Expand All @@ -97,13 +81,13 @@
"output_type": "stream",
"text": [
"Working on a Windows 11\n",
"Python version 3.13.5 | packaged by Anaconda, Inc. | (main, Jun 12 2025, 16:37:03) [MSC v.1929 64 bit (AMD64)]\n",
"pvdeg version 0.5.1.dev857+g1a511e445.d20251004\n"
"Python version 3.13.13 | packaged by conda-forge | (main, Apr 8 2026, 01:56:49) [MSC v.1944 64 bit (AMD64)]\n",
"pvdeg version 0.7.2.dev86+gbddb1bdbc.d20260519\n"
]
}
],
"source": [
"# This information helps with debugging and getting support :)\n",
"# This information helps with debugging and getting support\n",
"import sys\n",
"import platform\n",
"\n",
Expand All @@ -129,13 +113,13 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-03T15:42:17.959558Z",
"iopub.status.busy": "2025-12-03T15:42:17.959029Z",
"iopub.status.idle": "2025-12-03T15:42:17.966043Z",
"shell.execute_reply": "2025-12-03T15:42:17.964813Z"
"iopub.execute_input": "2026-06-30T16:53:31.730258Z",
"iopub.status.busy": "2026-06-30T16:53:31.729564Z",
"iopub.status.idle": "2026-06-30T16:53:31.738299Z",
"shell.execute_reply": "2026-06-30T16:53:31.736857Z"
}
},
"outputs": [],
Expand Down Expand Up @@ -196,13 +180,13 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-03T15:42:17.969026Z",
"iopub.status.busy": "2025-12-03T15:42:17.968679Z",
"iopub.status.idle": "2025-12-03T15:42:18.182705Z",
"shell.execute_reply": "2025-12-03T15:42:18.181410Z"
"iopub.execute_input": "2026-06-30T16:53:31.741611Z",
"iopub.status.busy": "2026-06-30T16:53:31.741145Z",
"iopub.status.idle": "2026-06-30T16:53:32.000599Z",
"shell.execute_reply": "2026-06-30T16:53:31.998853Z"
}
},
"outputs": [
Expand All @@ -223,8 +207,6 @@
"source": [
"# Load pre-saved weather data for this tutorial\n",
"# This avoids API rate limits during testing and builds\n",
"import json\n",
"\n",
"weather_df = pd.read_csv(\"../data/psm4_golden.csv\", index_col=0, parse_dates=True)\n",
"with open(\"../data/meta_golden.json\", \"r\") as f:\n",
" meta = json.load(f)\n",
Expand Down Expand Up @@ -274,27 +256,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-03T15:42:18.187172Z",
"iopub.status.busy": "2025-12-03T15:42:18.186692Z",
"iopub.status.idle": "2025-12-03T15:42:20.552763Z",
"shell.execute_reply": "2025-12-03T15:42:20.551416Z"
"iopub.execute_input": "2026-06-30T16:53:32.005116Z",
"iopub.status.busy": "2026-06-30T16:53:32.004526Z",
"iopub.status.idle": "2026-06-30T16:53:32.283914Z",
"shell.execute_reply": "2026-06-30T16:53:32.281909Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The array surface_tilt angle was not provided, therefore the latitude of 24.7 was used.\n",
"The estimated T₉₈ of an insulated-back module is 89.6°C. \n",
"The estimated T₉₈ of an open-rack module is 63.8°C. \n",
"Level 0 certification is valid for a standoff greather than 9.3 cm. \n",
"Level 1 certification is required for a standoff between 9.3 cm, and 3.0 cm. \n",
"Level 2 certification is required for a standoff less than 3.0 cm.\n",
"{'latitude': 24.7136, 'longitude': 46.6753, 'altitude': 646.0, 'wind_height': 10, 'Source': 'PVGIS'}\n"
"The array surface_tilt angle was not provided, therefore the latitude of 39.7 was used.\n",
"{'x_cm': 1.8, 'T98_0_C': 75.9, 'T98_inf_C': 51.6}\n",
"{'Source': 'NSRDB', 'Location ID': '479494', 'City': '-', 'State': '-', 'Country': '-', 'Clearsky DHI Units': 'w/m2', 'Clearsky DNI Units': 'w/m2', 'Clearsky GHI Units': 'w/m2', 'Dew Point Units': 'c', 'DHI Units': 'w/m2', 'DNI Units': 'w/m2', 'GHI Units': 'w/m2', 'Solar Zenith Angle Units': 'Degree', 'Temperature Units': 'c', 'Pressure Units': 'mbar', 'Relative Humidity Units': '%', 'Precipitable Water Units': 'cm', 'Wind Direction Units': 'Degrees', 'Wind Speed Units': 'm/s', 'Cloud Type -15': 'N/A', 'Cloud Type 0': 'Clear', 'Cloud Type 1': 'Probably Clear', 'Cloud Type 2': 'Fog', 'Cloud Type 3': 'Water', 'Cloud Type 4': 'Super-Cooled Water', 'Cloud Type 5': 'Mixed', 'Cloud Type 6': 'Opaque Ice', 'Cloud Type 7': 'Cirrus', 'Cloud Type 8': 'Overlapping', 'Cloud Type 9': 'Overshooting', 'Cloud Type 10': 'Unknown', 'Cloud Type 11': 'Dust', 'Cloud Type 12': 'Smoke', 'Fill Flag 0': 'N/A', 'Fill Flag 1': 'Missing Image', 'Fill Flag 2': 'Low Irradiance', 'Fill Flag 3': 'Exceeds Clearsky', 'Fill Flag 4': 'Missing CLoud Properties', 'Fill Flag 5': 'Rayleigh Violation', 'Surface Albedo Units': 'N/A', 'Version': '4.1.2.dev4+g3b38bc8.d20250228', 'latitude': 39.73, 'longitude': -105.18, 'altitude': 1876, 'tz': -7, 'wind_height': 2}\n"
]
}
],
Expand All @@ -304,8 +282,18 @@
"weather_id = (24.7136, 46.6753) # Riyadh, Saudi Arabia\n",
"# weather_arg = {'map_variables': True}\n",
"\n",
"# TMY\n",
"weather_df, meta = pvdeg.weather.get(weather_db, weather_id)\n",
"# For reproducible notebook testing, default to cached local weather/meta.\n",
"# Set USE_LIVE_PVGIS = True to fetch live PVGIS data.\n",
"USE_LIVE_PVGIS = False\n",
"\n",
"if USE_LIVE_PVGIS:\n",
" # TMY from live PVGIS API\n",
" weather_df, meta = pvdeg.weather.get(weather_db, weather_id)\n",
"else:\n",
" # Cached sample weather to avoid SSL/network flakiness in CI\n",
" weather_df = pd.read_csv(\"../data/psm4_golden.csv\", index_col=0, parse_dates=True)\n",
" with open(\"../data/meta_golden.json\", \"r\") as f:\n",
" meta = json.load(f)\n",
"\n",
"# Perform calculation\n",
"res = pvdeg.standards.standoff(\n",
Expand Down Expand Up @@ -338,7 +326,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "pvdeg_313",
"display_name": "pvdeg2",
"language": "python",
"name": "python3"
},
Expand All @@ -352,7 +340,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.5"
"version": "3.13.13"
}
},
"nbformat": 4,
Expand Down
23 changes: 14 additions & 9 deletions tutorials/01_basics/scripts/04_weather_database_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,13 @@
# %% [markdown]
# # Single location example

# %%
# if running on google colab, uncomment the next line and execute this cell to install the dependencies and prevent "ModuleNotFoundError" in later cells:
# # !pip install pvdeg

# %%
import pvdeg
import json
import pandas as pd

# %%
# This information helps with debugging and getting support :)
# This information helps with debugging and getting support
import sys
import platform

Expand Down Expand Up @@ -108,8 +105,6 @@
# %%
# Load pre-saved weather data for this tutorial
# This avoids API rate limits during testing and builds
import json

weather_df = pd.read_csv("../data/psm4_golden.csv", index_col=0, parse_dates=True)
with open("../data/meta_golden.json", "r") as f:
meta = json.load(f)
Expand Down Expand Up @@ -158,8 +153,18 @@
weather_id = (24.7136, 46.6753) # Riyadh, Saudi Arabia
# weather_arg = {'map_variables': True}

# TMY
weather_df, meta = pvdeg.weather.get(weather_db, weather_id)
# For reproducible notebook testing, default to cached local weather/meta.
# Set USE_LIVE_PVGIS = True to fetch live PVGIS data.
USE_LIVE_PVGIS = False

if USE_LIVE_PVGIS:
# TMY from live PVGIS API
weather_df, meta = pvdeg.weather.get(weather_db, weather_id)
else:
# Cached sample weather to avoid SSL/network flakiness in CI
weather_df = pd.read_csv("../data/psm4_golden.csv", index_col=0, parse_dates=True)
with open("../data/meta_golden.json", "r") as f:
meta = json.load(f)

# Perform calculation
res = pvdeg.standards.standoff(
Expand Down
Loading
Loading