{ "cells": [ { "cell_type": "markdown", "source": [ "# National Solar Radiation Database (NSRDB)\n", "\n", "> The National Solar Radiation Database (NSRDB) is a serially complete collection of meteorological and solar irradiance data sets for the United States and a growing list of international locations. The data are publicly available at no cost to the user and maintained by NREL. " ], "metadata": {} }, { "cell_type": "markdown", "source": [ "Let's set our NREL API key." ], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "import os\n", "from nrel_dev_api import set_nrel_api_key\n", "from nrel_dev_api.solar import NSRDB_DataQuery, get_nsrdb_download_links, download_nsrdb_data\n", "\n", "\n", "# get and set NREL developer API key\n", "NREL_API_KEY = os.environ[\"NREL_API_KEY\"]\n", "set_nrel_api_key(NREL_API_KEY)" ], "outputs": [], "metadata": {} }, { "cell_type": "markdown", "source": [ "## Data Query\n", "\n", ">Find NSRDB datasets for a location" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "Get information for a single location point using latitude and longitude." ], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "nsrdb_data_query = NSRDB_DataQuery(lat=21.204, lon=72.839)\n", "\n", "# check the outputs\n", "nsrdb_data_query.outputs" ], "outputs": [], "metadata": {} }, { "cell_type": "markdown", "source": [ "Using a well-known text (WKT) representation of the geometry for which to extract data" ], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "nsrdb_data_query = NSRDB_DataQuery(wkt=\"POINT(91.287 23.832)\")\n", "\n", "# check the outputs\n", "nsrdb_data_query.outputs" ], "outputs": [], "metadata": { "collapsed": true, "jupyter": { "outputs_hidden": true } } }, { "cell_type": "markdown", "source": [ "## Data Downloader\n", "\n", "> Download solar irradiance and meteorological data for a location." ], "metadata": {} }, { "cell_type": "markdown", "source": [ "Let's get all the available links for the year 2016." ], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "links = get_nsrdb_download_links(year=2016, lat=47.6, lon=-122.3)\n", "links" ], "outputs": [], "metadata": {} }, { "cell_type": "markdown", "source": [ "Once we have the available links, we can download the data of interest.\n", "\n", "Here, we will download from the first link." ], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "df = download_nsrdb_data(links[0], email=os.environ[\"EMAIL\"])" ], "outputs": [], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "df.columns" ], "outputs": [], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "df[[\"Temperature\", \"GHI\", \"Pressure\", \"Wind Speed\", \"Precipitable Water\"]]" ], "outputs": [], "metadata": {} }, { "cell_type": "markdown", "source": [ "> The index in the `DataFrame` returned automatically accounts for the leap years." ], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "feb = df.loc[\"2016-02\"][[\"Year\", \"Month\", \"Day\", \"Minute\"]]\n", "feb.tail()" ], "outputs": [], "metadata": {} } ], "metadata": { "kernelspec": { "display_name": "Python [conda env:nrel-dev-api]", "language": "python", "name": "conda-env-nrel-dev-api-py" }, "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.8.8" } }, "nbformat": 4, "nbformat_minor": 4 }