{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Forecast to Power Tutorial\n", "\n", "This tutorial will walk through the process of going from Unidata forecast model data to AC power using the SAPM.\n", "\n", "Table of contents:\n", "1. [Setup](#Setup)\n", "2. [Load Forecast data](#Load-Forecast-data)\n", "2. [Calculate modeling intermediates](#Calculate-modeling-intermediates)\n", "2. [DC power using SAPM](#DC-power-using-SAPM)\n", "2. [AC power using SAPM](#AC-power-using-SAPM)\n", "\n", "This tutorial has been tested against the following package versions:\n", "* Python 3.5.2\n", "* IPython 5.0.0\n", "* pandas 0.18.0\n", "* matplotlib 1.5.1\n", "* netcdf4 1.2.1\n", "* siphon 0.4.0\n", "\n", "It should work with other Python and Pandas versions. It requires pvlib >= 0.3.0 and IPython >= 3.0.\n", "\n", "Authors:\n", "* Derek Groenendyk (@moonraker), University of Arizona, November 2015\n", "* Will Holmgren (@wholmgren), University of Arizona, November 2015, January 2016, April 2016, July 2016" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setup" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "These are just your standard interactive scientific python imports that you'll get very used to using." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/holmgren/git_repos/pvlib-python/pvlib/forecast.py:22: UserWarning: The forecast module algorithms and features are highly experimental. The API may change, the functionality may be consolidated into an io module, or the module may be separated into its own package.\n", " 'module, or the module may be separated into its own package.')\n" ] } ], "source": [ "# built-in python modules\n", "import datetime\n", "import inspect\n", "import os\n", "\n", "# scientific python add-ons\n", "import numpy as np\n", "import pandas as pd\n", "\n", "# plotting stuff\n", "# first line makes the plots appear in the notebook\n", "%matplotlib inline \n", "import matplotlib.pyplot as plt\n", "import matplotlib as mpl\n", "# seaborn makes your plots look better\n", "try:\n", " import seaborn as sns\n", " sns.set(rc={\"figure.figsize\": (12, 6)})\n", " sns.set_color_codes()\n", "except ImportError:\n", " print('We suggest you install seaborn using conda or pip and rerun this cell')\n", "\n", "# finally, we import the pvlib library\n", "from pvlib import solarposition,irradiance,atmosphere,pvsystem\n", "from pvlib.forecast import GFS, NAM, NDFD, RAP, HRRR" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load Forecast data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "pvlib forecast module only includes several models. To see the full list of forecast models visit the Unidata website:\n", "\n", "http://www.unidata.ucar.edu/data/#tds" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Choose a location.\n", "# Tucson, AZ\n", "latitude = 32.2\n", "longitude = -110.9\n", "tz = 'US/Mountain'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Define some PV system parameters." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [], "source": [ "surface_tilt = 30\n", "surface_azimuth = 180 # pvlib uses 0=North, 90=East, 180=South, 270=West convention\n", "albedo = 0.2" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [], "source": [ "start = pd.Timestamp(datetime.date.today(), tz=tz) # today's date\n", "end = start + pd.Timedelta(days=7) # 7 days from today" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Define forecast model\n", "fm = GFS()\n", "#fm = NAM()\n", "#fm = NDFD()\n", "#fm = RAP()\n", "#fm = HRRR()" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Retrieve data\n", "forecast_data = fm.get_processed_data(latitude, longitude, start, end)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's look at the downloaded version of the forecast data." ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", " | temp_air | \n", "wind_speed | \n", "ghi | \n", "dni | \n", "dhi | \n", "total_clouds | \n", "low_clouds | \n", "mid_clouds | \n", "high_clouds | \n", "
---|---|---|---|---|---|---|---|---|---|
2016-07-27 06:00:00-06:00 | \n", "30.149994 | \n", "1.916377 | \n", "0.000000 | \n", "0.000000 | \n", "0.000000 | \n", "7.0 | \n", "0.0 | \n", "3.0 | \n", "5.0 | \n", "
2016-07-27 09:00:00-06:00 | \n", "28.450012 | \n", "0.990202 | \n", "374.978175 | \n", "468.494996 | \n", "150.358998 | \n", "20.0 | \n", "0.0 | \n", "7.0 | \n", "17.0 | \n", "
2016-07-27 12:00:00-06:00 | \n", "27.450012 | \n", "3.230511 | \n", "765.140377 | \n", "427.065650 | \n", "375.447762 | \n", "25.0 | \n", "0.0 | \n", "6.0 | \n", "22.0 | \n", "
2016-07-27 15:00:00-06:00 | \n", "32.350006 | \n", "1.501533 | \n", "325.739565 | \n", "18.348873 | \n", "308.994555 | \n", "99.0 | \n", "0.0 | \n", "77.0 | \n", "96.0 | \n", "
2016-07-27 18:00:00-06:00 | \n", "46.050018 | \n", "4.222464 | \n", "240.470023 | \n", "87.506983 | \n", "198.519719 | \n", "68.0 | \n", "0.0 | \n", "44.0 | \n", "64.0 | \n", "