Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ __pycache__/

# emacs temp files
*~
#*#

# C extensions
*.so
Expand Down Expand Up @@ -68,6 +69,6 @@ coverage.xml
# vi
*.swp

#Ignore notebooks
#Ignore some notebooks
*.ipynb
!docs/tutorials/*.ipynb
33 changes: 33 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
language: python
python:
- 2.7
- 3.3
- 3.4
# setup miniconda for numpy, scipy, pandas
before_install:
- echo "before install"
- wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh
- chmod +x miniconda.sh
- ./miniconda.sh -b
- export PATH=/home/travis/miniconda/bin:$PATH
- conda update --yes conda
- sudo rm -rf /dev/shm
- sudo ln -s /run/shm /dev/shm
- date
- uname -a
- python -V

install:
- echo "install"
- conda install --yes python=$TRAVIS_PYTHON_VERSION numpy scipy pandas nose pytz ephem
- conda install --yes coverage
- pip install coveralls
- python setup.py install
# for nosetests to actually work since it alters the path
- python setup.py build_ext --inplace

script:
- nosetests -v --with-coverage --cover-package=pvlib pvlib

after_success:
coveralls
Empty file modified LICENSE
100755 → 100644
Empty file.
Empty file modified MANIFEST.in
100755 → 100644
Empty file.
5 changes: 4 additions & 1 deletion README.md
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
PVLIB_Python
============

![TravisCI](https://travis-ci.org/UARENForecasting/PVLIB_Python.svg)
[![Coverage Status](https://img.shields.io/coveralls/UARENForecasting/PVLIB_Python.svg)](https://coveralls.io/r/UARENForecasting/PVLIB_Python)

This repo is a fork of the [Sandia PVLIB_Python](https://github.com/Sandia-Labs/PVLIB_Python) project.

It provides a set of sometimes-well-documented and usually correct functions for simulating the performance of photovoltaic energy systems. The toolbox was originally developed at Sandia National Laboratories and it implements many of the models and methods developed at the Labs.
Expand Down Expand Up @@ -74,7 +77,7 @@ import pvlib.solarposition
import pvlib.clearsky

# make a location
tus = Location(32.2, -111, 700, 'MST')
tus = Location(32.2, -111, 'MST', 700)

# make a pandas DatetimeIndex for some day
times = pd.date_range(start=datetime.datetime(2014,6,24), end=datetime.datetime(2014,6,25), freq='1Min')
Expand Down
2 changes: 1 addition & 1 deletion pvlib/__init__.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import logging
logging.basicConfig()
from . import pvl_tools
from . import tools
from . import atmosphere
from . import clearsky
from . import irradiance
Expand Down
41 changes: 16 additions & 25 deletions pvlib/clearsky.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import pandas as pd
import scipy.io

from . import pvl_tools
from . import irradiance
from . import atmosphere
from . import solarposition
from pvlib import tools
from pvlib import irradiance
from pvlib import atmosphere
from pvlib import solarposition



Expand Down Expand Up @@ -193,7 +193,7 @@ def ineichen(time, location, linke_turbidity=None,
# We used the equation from pg 311 because of the existence of known typos
# in the pg 156 publication (notably the fh2-(TL-1) should be fh2 * (TL-1)).

cos_zenith = pvl_tools.cosd(ApparentZenith)
cos_zenith = tools.cosd(ApparentZenith)

clearsky_GHI = cg1 * I0 * cos_zenith * np.exp(-cg2*AMabsolute*(fh1 + fh2*(TL - 1))) * np.exp(0.01*AMabsolute**1.8)
clearsky_GHI[clearsky_GHI < 0] = 0
Expand Down Expand Up @@ -268,7 +268,7 @@ def haurwitz(ApparentZenith):
pvl_ineichen
'''

cos_zenith = pvl_tools.cosd(ApparentZenith)
cos_zenith = tools.cosd(ApparentZenith)

clearsky_GHI = 1098.0 * cos_zenith * np.exp(-0.059/cos_zenith)

Expand Down Expand Up @@ -353,29 +353,20 @@ def disc(GHI, SunZen, Time, pressure=101325):

'''

Vars=locals()
Expect={'GHI': ('array','num','x>=0'),
'SunZen': ('array','num','x<=180','x>=0'),
'Time':'',
'pressure':('num','default','default=101325','x>=0'),
}

var=pvl_tools.Parse(Vars,Expect)

#create a temporary dataframe to house masked values, initially filled with NaN
temp=pd.DataFrame(index=var.Time,columns=['A','B','C'])
temp=pd.DataFrame(index=Time,columns=['A','B','C'])


var.pressure=101325
doy=var.Time.dayofyear
pressure=101325
doy=Time.dayofyear
DayAngle=2.0 * np.pi*((doy - 1)) / 365
re=1.00011 + 0.034221*(np.cos(DayAngle)) + (0.00128)*(np.sin(DayAngle)) + 0.000719*(np.cos(2.0 * DayAngle)) + (7.7e-05)*(np.sin(2.0 * DayAngle))
I0=re*(1370)
I0h=I0*(np.cos(np.radians(var.SunZen)))
Ztemp=var.SunZen
Ztemp[var.SunZen > 87]=87
AM=1.0 / (np.cos(np.radians(Ztemp)) + 0.15*(((93.885 - Ztemp) ** (- 1.253))))*(var.pressure) / 101325
Kt=var.GHI / (I0h)
I0h=I0*(np.cos(np.radians(SunZen)))
Ztemp=SunZen
Ztemp[SunZen > 87]=87
AM=1.0 / (np.cos(np.radians(Ztemp)) + 0.15*(((93.885 - Ztemp) ** (- 1.253))))*(pressure) / 101325
Kt=GHI / (I0h)
Kt[Kt < 0]=0
Kt[Kt > 2]=np.NaN
temp.A[Kt > 0.6]=- 5.743 + 21.77*(Kt[Kt > 0.6]) - 27.49*(Kt[Kt > 0.6] ** 2) + 11.56*(Kt[Kt > 0.6] ** 3)
Expand All @@ -391,8 +382,8 @@ def disc(GHI, SunZen, Time, pressure=101325):
Kn=Knc - delKn
DNI=(Kn)*(I0)

DNI[var.SunZen > 87]=np.NaN
DNI[var.GHI < 1]=np.NaN
DNI[SunZen > 87]=np.NaN
DNI[GHI < 1]=np.NaN
DNI[DNI < 0]=np.NaN

DFOut=pd.DataFrame({'DNI_gen_DISC':DNI})
Expand Down
36 changes: 18 additions & 18 deletions pvlib/irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
except ImportError as e:
pvl_logger.warning('PyEphem not found.')

from . import pvl_tools
from pvlib import tools


SURFACE_ALBEDOS = {'urban':0.18,
Expand Down Expand Up @@ -155,7 +155,7 @@ def aoi_projection(surf_tilt, surf_az, sun_zen, sun_az):
float or Series. Dot product of panel normal and solar angle.
"""

projection = pvl_tools.cosd(surf_tilt)*pvl_tools.cosd(sun_zen) + pvl_tools.sind(surf_tilt)*pvl_tools.sind(sun_zen)*pvl_tools.cosd(sun_az - surf_az)
projection = tools.cosd(surf_tilt)*tools.cosd(sun_zen) + tools.sind(surf_tilt)*tools.sind(sun_zen)*tools.cosd(sun_az - surf_az)

try:
projection.name = 'aoi_projection'
Expand Down Expand Up @@ -229,7 +229,7 @@ def poa_horizontal_ratio(surf_tilt, surf_az, sun_zen, sun_az):

cos_poa_zen = aoi_projection(surf_tilt, surf_az, sun_zen, sun_az)

cos_sun_zen = pvl_tools.cosd(sun_zen)
cos_sun_zen = tools.cosd(sun_zen)

# ratio of titled and horizontal beam irradiance
ratio = cos_poa_zen / cos_sun_zen
Expand Down Expand Up @@ -397,7 +397,7 @@ def globalinplane(SurfTilt,SurfAz,AOI,DNI,In_Plane_SkyDiffuse, GR):
'GR':('x>=0'),
}

var=pvl_tools.Parse(Vars,Expect)
var=tools.Parse(Vars,Expect)

Eb = var.DNI*np.cos(np.radians(var.AOI))
E = Eb + var.In_Plane_SkyDiffuse + var.GR
Expand Down Expand Up @@ -545,7 +545,7 @@ def isotropic(surf_tilt, DHI):

pvl_logger.debug('diffuse_sky.isotropic()')

sky_diffuse = DHI * (1 + pvl_tools.cosd(surf_tilt)) * 0.5
sky_diffuse = DHI * (1 + tools.cosd(surf_tilt)) * 0.5

return sky_diffuse

Expand Down Expand Up @@ -650,9 +650,9 @@ def klucher(surf_tilt, surf_az, DHI, GHI, sun_zen, sun_az):
except AttributeError:
F = 0

term1 = 0.5 * (1 + pvl_tools.cosd(surf_tilt))
term2 = 1 + F * (pvl_tools.sind(0.5*surf_tilt) ** 3)
term3 = 1 + F * (cos_tt ** 2) * (pvl_tools.sind(sun_zen) ** 3)
term1 = 0.5 * (1 + tools.cosd(surf_tilt))
term2 = 1 + F * (tools.sind(0.5*surf_tilt) ** 3)
term3 = 1 + F * (cos_tt ** 2) * (tools.sind(sun_zen) ** 3)

sky_diffuse = DHI * term1 * term2 * term3

Expand Down Expand Up @@ -748,7 +748,7 @@ def haydavies(surf_tilt, surf_az, DHI, DNI, DNI_ET, sun_zen, sun_az):

cos_tt = aoi_projection(surf_tilt, surf_az, sun_zen, sun_az)

cos_sun_zen = pvl_tools.cosd(sun_zen)
cos_sun_zen = tools.cosd(sun_zen)

# ratio of titled and horizontal beam irradiance
Rb = cos_tt / cos_sun_zen
Expand All @@ -758,7 +758,7 @@ def haydavies(surf_tilt, surf_az, DHI, DNI, DNI_ET, sun_zen, sun_az):

# these are actually the () and [] sub-terms of the second term of eqn 7
term1 = 1 - AI
term2 = 0.5 * (1 + pvl_tools.cosd(surf_tilt))
term2 = 0.5 * (1 + tools.cosd(surf_tilt))

sky_diffuse = DHI * ( AI*Rb + term1 * term2 )
sky_diffuse[sky_diffuse < 0] = 0
Expand Down Expand Up @@ -870,7 +870,7 @@ def reindl(surf_tilt, surf_az, DHI, DNI, GHI, DNI_ET, sun_zen, sun_az):

cos_tt = aoi_projection(surf_tilt, surf_az, sun_zen, sun_az)

cos_sun_zen = pvl_tools.cosd(sun_zen)
cos_sun_zen = tools.cosd(sun_zen)

# ratio of titled and horizontal beam irradiance
Rb = cos_tt / cos_sun_zen
Expand All @@ -884,8 +884,8 @@ def reindl(surf_tilt, surf_az, DHI, DNI, GHI, DNI_ET, sun_zen, sun_az):

# these are actually the () and [] sub-terms of the second term of eqn 8
term1 = 1 - AI
term2 = 0.5 * (1 + pvl_tools.cosd(surf_tilt))
term3 = 1 + np.sqrt(HB / GHI) * (pvl_tools.sind(0.5*surf_tilt) ** 3)
term2 = 0.5 * (1 + tools.cosd(surf_tilt))
term3 = 1 + np.sqrt(HB / GHI) * (tools.sind(0.5*surf_tilt) ** 3)

sky_diffuse = DHI * ( AI*Rb + term1 * term2 * term3 )
sky_diffuse[sky_diffuse < 0] = 0
Expand Down Expand Up @@ -949,7 +949,7 @@ def king(surf_tilt, DHI, GHI, sun_zen):

pvl_logger.debug('diffuse_sky.king()')

sky_diffuse = DHI * ((1 + pvl_tools.cosd(surf_tilt))) / 2 + GHI*((0.012 * sun_zen - 0.04))*((1 - pvl_tools.cosd(surf_tilt))) / 2
sky_diffuse = DHI * ((1 + tools.cosd(surf_tilt))) / 2 + GHI*((0.012 * sun_zen - 0.04))*((1 - tools.cosd(surf_tilt))) / 2
sky_diffuse[sky_diffuse < 0] = 0

return sky_diffuse
Expand Down Expand Up @@ -1137,15 +1137,15 @@ def perez(surf_tilt, surf_az, DHI, DNI, DNI_ET, sun_zen, sun_az, AM,
A = aoi_projection(surf_tilt, surf_az, sun_zen, sun_az)
A[A < 0] = 0

B = pvl_tools.cosd(sun_zen);
B[B < pvl_tools.cosd(85)] = pvl_tools.cosd(85)
B = tools.cosd(sun_zen);
B[B < tools.cosd(85)] = tools.cosd(85)


#Calculate Diffuse POA from sky dome

term1 = 0.5 * (1 - F1) * (1 + pvl_tools.cosd(surf_tilt))
term1 = 0.5 * (1 - F1) * (1 + tools.cosd(surf_tilt))
term2 = F1 * A[ebin.index] / B[ebin.index]
term3 = F2*pvl_tools.sind(surf_tilt)
term3 = F2*tools.sind(surf_tilt)

sky_diffuse = DHI[ebin.index] * (term1 + term2 + term3)
sky_diffuse[sky_diffuse < 0] = 0
Expand Down
Loading