{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# TMY to Power Tutorial\n", "\n", "This tutorial will walk through the process of going from TMY data to AC power using the SAPM.\n", "\n", "Table of contents:\n", "1. [Setup](#Setup)\n", "2. [Load TMY data](#Load-TMY-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 requires pvlib >= 0.6.0.\n", "\n", "Authors:\n", "* Will Holmgren (@wholmgren), University of Arizona, July 2015, March 2016, August 2018.\n", "* Rob Andrews (@Calama-Consulting), Heliolytics, June 2014" ] }, { "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": {}, "outputs": [], "source": [ "# built-in python modules\n", "import os\n", "import inspect\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", "\n", "# finally, we import the pvlib library\n", "import pvlib" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load TMY data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "pvlib comes with a couple of TMY files, and we'll use one of them for simplicity. You could also load a file from disk, or specify a url. See this NREL website for a list of TMY files:\n", "\n", "http://rredc.nrel.gov/solar/old_data/nsrdb/1991-2005/tmy3/by_state_and_city.html" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# Find the absolute file path to your pvlib installation\n", "pvlib_abspath = os.path.dirname(os.path.abspath(inspect.getfile(pvlib)))\n", "\n", "# absolute path to a data file\n", "datapath = os.path.join(pvlib_abspath, 'data', '703165TY.csv')\n", "\n", "# read tmy data with year values coerced to a single year\n", "tmy_data, meta = pvlib.iotools.read_tmy3(datapath, coerce_year=2015)\n", "tmy_data.index.name = 'Time'\n", "\n", "# TMY data seems to be given as hourly data with time stamp at the end\n", "# shift the index 30 Minutes back for calculation of sun positions\n", "tmy_data = tmy_data.shift(freq='-30Min')['2015']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The file handling above looks complicated because we're trying to account for the many different ways that people will run this notebook on their systems. You can just put a simple string path into the ``read_tmy3`` function if you know where the file is." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's look at the imported version of the TMY file." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Date (MM/DD/YYYY) | \n", "Time (HH:MM) | \n", "ETR | \n", "ETRN | \n", "GHI | \n", "GHISource | \n", "GHIUncertainty | \n", "DNI | \n", "DNISource | \n", "DNIUncertainty | \n", "... | \n", "AOD | \n", "AODSource | \n", "AODUncertainty | \n", "Alb | \n", "AlbSource | \n", "AlbUncertainty | \n", "Lprecipdepth | \n", "Lprecipquantity | \n", "LprecipSource | \n", "LprecipUncertainty | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Time | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
2015-01-01 00:30:00-09:00 | \n", "01/01/1997 | \n", "01:00 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "... | \n", "0.051 | \n", "F | \n", "8 | \n", "0.24 | \n", "F | \n", "8 | \n", "-9900 | \n", "-9900 | \n", "? | \n", "0 | \n", "
2015-01-01 01:30:00-09:00 | \n", "01/01/1997 | \n", "02:00 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "... | \n", "0.051 | \n", "F | \n", "8 | \n", "0.24 | \n", "F | \n", "8 | \n", "-9900 | \n", "-9900 | \n", "? | \n", "0 | \n", "
2015-01-01 02:30:00-09:00 | \n", "01/01/1997 | \n", "03:00 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "... | \n", "0.051 | \n", "F | \n", "8 | \n", "0.24 | \n", "F | \n", "8 | \n", "-9900 | \n", "-9900 | \n", "? | \n", "0 | \n", "
2015-01-01 03:30:00-09:00 | \n", "01/01/1997 | \n", "04:00 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "... | \n", "0.051 | \n", "F | \n", "8 | \n", "0.24 | \n", "F | \n", "8 | \n", "-9900 | \n", "-9900 | \n", "? | \n", "0 | \n", "
2015-01-01 04:30:00-09:00 | \n", "01/01/1997 | \n", "05:00 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "... | \n", "0.051 | \n", "F | \n", "8 | \n", "0.24 | \n", "F | \n", "8 | \n", "-9900 | \n", "-9900 | \n", "? | \n", "0 | \n", "
5 rows × 68 columns
\n", "\n", " | sapm | \n", "sd | \n", "
---|---|---|
count | \n", "8760.000000 | \n", "8760.000000 | \n", "
mean | \n", "23.214159 | \n", "24.359824 | \n", "
std | \n", "42.869990 | \n", "43.498806 | \n", "
min | \n", "-0.075000 | \n", "-0.075000 | \n", "
25% | \n", "-0.075000 | \n", "-0.075000 | \n", "
50% | \n", "-0.075000 | \n", "-0.075000 | \n", "
75% | \n", "27.849403 | \n", "30.768026 | \n", "
max | \n", "215.045605 | \n", "217.109196 | \n", "