atmosphere.py tutorial

This tutorial needs your help to make it better!

This tutorial has been tested against the following package versions:

  • pvlib 0.3.0
  • Python 3.5.1
  • IPython 3.2
  • Pandas 0.18.0

It should work with other Python and Pandas versions. It requires pvlib > 0.3.0 and IPython > 3.0.

Authors:

  • Will Holmgren (@wholmgren), University of Arizona. 2015, March 2016.

In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
try:
    import seaborn as sns
    sns.set(rc={"figure.figsize": (12, 6)})
except ImportError:
    print('We suggest you install seaborn using conda or pip and rerun this cell')

# built in python modules
import datetime
import logging
import os
import inspect

# python add-ons
import numpy as np
import pandas as pd

In [2]:
import pvlib
from pvlib.location import Location

In [3]:
tus = Location(32.2, -111, 'US/Arizona', 700, 'Tucson')

In [4]:
print(tus)


Tucson: latitude=32.2, longitude=-111, tz=US/Arizona, altitude=700

In [5]:
times = pd.date_range(start=datetime.datetime(2014,6,24), end=datetime.datetime(2014,6,25), freq='1Min', tz=tus.tz)

pyephem_ephem = pvlib.solarposition.get_solarposition(times, tus.latitude, tus.longitude, method='pyephem')
print(pyephem_ephem.head())
pyephem_ephem.plot()


                           apparent_elevation  apparent_azimuth  elevation  \
2014-06-24 00:00:00-07:00          -34.039163        352.695587 -34.039163   
2014-06-24 00:01:00-07:00          -34.065565        352.970625 -34.065565   
2014-06-24 00:02:00-07:00          -34.090960        353.245855 -34.090960   
2014-06-24 00:03:00-07:00          -34.115343        353.521302 -34.115343   
2014-06-24 00:04:00-07:00          -34.138716        353.796969 -34.138716   

                              azimuth  apparent_zenith      zenith  
2014-06-24 00:00:00-07:00  352.695587       124.039163  124.039163  
2014-06-24 00:01:00-07:00  352.970625       124.065565  124.065565  
2014-06-24 00:02:00-07:00  353.245855       124.090960  124.090960  
2014-06-24 00:03:00-07:00  353.521302       124.115343  124.115343  
2014-06-24 00:04:00-07:00  353.796969       124.138716  124.138716  
Out[5]:
<matplotlib.axes._subplots.AxesSubplot at 0x10f0be240>

In [6]:
pvlib.atmosphere.relativeairmass(pyephem_ephem['zenith']).plot()
pvlib.atmosphere.relativeairmass(pyephem_ephem['apparent_zenith']).plot()
pvlib.atmosphere.relativeairmass(pyephem_ephem['zenith'], model='young1994').plot()
pvlib.atmosphere.relativeairmass(pyephem_ephem['zenith'], model='simple').plot()
plt.legend()
plt.ylim(0,100)


Out[6]:
(0, 100)

In [7]:
plt.plot(pyephem_ephem['zenith'], pvlib.atmosphere.relativeairmass(pyephem_ephem['zenith'], model='simple'), label='simple')
plt.plot(pyephem_ephem['zenith'], pvlib.atmosphere.relativeairmass(pyephem_ephem['apparent_zenith']), label='default')
plt.xlim(0,100)
plt.ylim(0,100)
plt.legend()


Out[7]:
<matplotlib.legend.Legend at 0x10ef4a3c8>

In [ ]: