Skip to content

Add page documenting PSM3 variable names, units, and accessibility by endpoint #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ This project uses many open-source software packages, including:
pages/tmy-vs-single
pages/numerical-precision
pages/2300-artifact
pages/variables
389 changes: 389 additions & 0 deletions source/pages/variables.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,389 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "341b7567-ade5-47fb-9798-7f45c7e19b59",
"metadata": {},
"source": [
"# Variables\n",
"\n",
"This page documents several aspects of the variables available via the PSM3 API endpoints, including:\n",
"\n",
"- What variables are available at each endpoint?\n",
"- What are the request and response names for each variable?\n",
"- What units are the variable values in?"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "e8049d34-b90c-4f8f-ae9e-76458ff334c0",
"metadata": {},
"outputs": [],
"source": [
"import pvlib\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "3ed5de9c-d935-4989-b5b0-a47b77261611",
"metadata": {},
"outputs": [],
"source": [
"cases = [('TMY', 'tmy', 60), ('Hourly', 2020, 60), ('5-minute', 2020, 5)]"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "63a7dda0-9ae0-49af-926d-d68335311a60",
"metadata": {},
"outputs": [],
"source": [
"units = {}\n",
"presence = {}\n",
"for label, dataset, interval in cases:\n",
" df, meta = pvlib.iotools.get_psm3(40, -80, 'DEMO_KEY', '[email protected]',\n",
" names=dataset, interval=interval,\n",
" attributes=[], # a trick to get all variables\n",
" map_variables=False, leap_day=True)\n",
" columns = df.columns[5:] # drop timestamp columns\n",
" for column in columns:\n",
" units[column] = meta.get(column + \" Units\", \"?\")\n",
" presence[label] = {column: '✓' for column in columns}"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "d40ddf73-86a5-4442-9156-fe837308879b",
"metadata": {},
"outputs": [],
"source": [
"# TODO: once pvlib 0.9.5 is released with pvlib #1648,\n",
"# determine this mapping dynamically instead of hardcoding it\n",
"\n",
"column_map = {\n",
" 'Clearsky DHI': 'clearsky_dhi',\n",
" 'Clearsky DNI': 'clearsky_dni',\n",
" 'Clearsky GHI': 'clearsky_ghi',\n",
" 'Cloud Type': 'cloud_type',\n",
" 'DHI': 'dhi',\n",
" 'DNI': 'dni',\n",
" 'Dew Point': 'dew_point',\n",
" 'Fill Flag': 'fill_flag',\n",
" 'GHI': 'ghi',\n",
" 'Global Horizontal UV Irradiance (280-400nm)': 'ghuv-280-400',\n",
" 'Global Horizontal UV Irradiance (295-385nm)': 'ghuv-295-385',\n",
" 'Precipitable Water': 'total_precipitable_water',\n",
" 'Pressure': 'surface_pressure',\n",
" 'Relative Humidity': 'relative_humidity',\n",
" 'Solar Zenith Angle': 'solar_zenith_angle',\n",
" 'Surface Albedo': 'surface_albedo',\n",
" 'Temperature': 'air_temperature',\n",
" 'Wind Direction': 'wind_direction',\n",
" 'Wind Speed': 'wind_speed'\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "f2439f4a-ff3e-4d63-9dd2-621e4119de6a",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Response Name</th>\n",
" <th>Request Name</th>\n",
" <th>Units</th>\n",
" <th>TMY</th>\n",
" <th>Hourly</th>\n",
" <th>5-minute</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Dew Point</td>\n",
" <td>dew_point</td>\n",
" <td>c</td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>DHI</td>\n",
" <td>dhi</td>\n",
" <td>w/m2</td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>DNI</td>\n",
" <td>dni</td>\n",
" <td>w/m2</td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>GHI</td>\n",
" <td>ghi</td>\n",
" <td>w/m2</td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Surface Albedo</td>\n",
" <td>surface_albedo</td>\n",
" <td>N/A</td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Pressure</td>\n",
" <td>surface_pressure</td>\n",
" <td>mbar</td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Temperature</td>\n",
" <td>air_temperature</td>\n",
" <td>c</td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>Wind Direction</td>\n",
" <td>wind_direction</td>\n",
" <td>Degrees</td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>Wind Speed</td>\n",
" <td>wind_speed</td>\n",
" <td>m/s</td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>Clearsky DHI</td>\n",
" <td>clearsky_dhi</td>\n",
" <td>w/m2</td>\n",
" <td></td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>Clearsky DNI</td>\n",
" <td>clearsky_dni</td>\n",
" <td>w/m2</td>\n",
" <td></td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>Clearsky GHI</td>\n",
" <td>clearsky_ghi</td>\n",
" <td>w/m2</td>\n",
" <td></td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>Cloud Type</td>\n",
" <td>cloud_type</td>\n",
" <td>?</td>\n",
" <td></td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>Fill Flag</td>\n",
" <td>fill_flag</td>\n",
" <td>?</td>\n",
" <td></td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>Relative Humidity</td>\n",
" <td>relative_humidity</td>\n",
" <td>%</td>\n",
" <td></td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>Solar Zenith Angle</td>\n",
" <td>solar_zenith_angle</td>\n",
" <td>Degree</td>\n",
" <td></td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>Precipitable Water</td>\n",
" <td>total_precipitable_water</td>\n",
" <td>cm</td>\n",
" <td></td>\n",
" <td>✓</td>\n",
" <td>✓</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>Global Horizontal UV Irradiance (280-400nm)</td>\n",
" <td>ghuv-280-400</td>\n",
" <td>?</td>\n",
" <td></td>\n",
" <td>✓</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>Global Horizontal UV Irradiance (295-385nm)</td>\n",
" <td>ghuv-295-385</td>\n",
" <td>?</td>\n",
" <td></td>\n",
" <td>✓</td>\n",
" <td></td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Response Name Request Name \\\n",
"0 Dew Point dew_point \n",
"1 DHI dhi \n",
"2 DNI dni \n",
"3 GHI ghi \n",
"4 Surface Albedo surface_albedo \n",
"5 Pressure surface_pressure \n",
"6 Temperature air_temperature \n",
"7 Wind Direction wind_direction \n",
"8 Wind Speed wind_speed \n",
"9 Clearsky DHI clearsky_dhi \n",
"10 Clearsky DNI clearsky_dni \n",
"11 Clearsky GHI clearsky_ghi \n",
"12 Cloud Type cloud_type \n",
"13 Fill Flag fill_flag \n",
"14 Relative Humidity relative_humidity \n",
"15 Solar Zenith Angle solar_zenith_angle \n",
"16 Precipitable Water total_precipitable_water \n",
"17 Global Horizontal UV Irradiance (280-400nm) ghuv-280-400 \n",
"18 Global Horizontal UV Irradiance (295-385nm) ghuv-295-385 \n",
"\n",
" Units TMY Hourly 5-minute \n",
"0 c ✓ ✓ ✓ \n",
"1 w/m2 ✓ ✓ ✓ \n",
"2 w/m2 ✓ ✓ ✓ \n",
"3 w/m2 ✓ ✓ ✓ \n",
"4 N/A ✓ ✓ ✓ \n",
"5 mbar ✓ ✓ ✓ \n",
"6 c ✓ ✓ ✓ \n",
"7 Degrees ✓ ✓ ✓ \n",
"8 m/s ✓ ✓ ✓ \n",
"9 w/m2 ✓ ✓ \n",
"10 w/m2 ✓ ✓ \n",
"11 w/m2 ✓ ✓ \n",
"12 ? ✓ ✓ \n",
"13 ? ✓ ✓ \n",
"14 % ✓ ✓ \n",
"15 Degree ✓ ✓ \n",
"16 cm ✓ ✓ \n",
"17 ? ✓ \n",
"18 ? ✓ "
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pd.concat([\n",
" pd.Series({v: column_map[v] for v in units}, name='Request Name'),\n",
" pd.Series(units, name='Units'),\n",
" pd.DataFrame(presence).fillna(\"\"),\n",
"], axis=1).rename_axis(index='Response Name').reset_index()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "79915e61-6b9b-405d-a737-828ac117ac5f",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
}