Skip to content

more pep8 #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 23, 2016
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
25 changes: 17 additions & 8 deletions docs/sphinx/source/whatsnew/v0.4.2.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
.. _whatsnew_0420:

v0.4.2 ()
------------------------
v0.4.2 (October 31, 2016)
-------------------------

This is a minor release from 0.4.0. ....
This is a minor release from 0.4.1.


Bug fixes
~~~~~~~~~

* Fixed typo in __repr__ method of ModelChain and in its regarding test. (commit: b691358b)
* Fixed typo in __repr__ method of ModelChain and in its regarding test.
* PVSystem.pvwatts_ac could not use the eta_inv_ref kwarg and
PVSystem.pvwatts_dc could not use the temp_ref kwarg. Fixed. (:issue:`252`)
* Fixed typo in ModelChain.infer_spectral_model error message. (:issue:`251`)
Expand All @@ -18,15 +18,24 @@ Bug fixes
API Changes
~~~~~~~~~~~

* The run_model method of the ModelChain will use the weather parameter of all weather data instead of splitting it to irradiation and weather. The irradiation parameter still works but will be removed soon.(:issue:`239`)
* delta_t kwarg is now 67.0 instead of None. IMPORTANT: Setting delta_t as None will break the code for Numba calculation. This will be fixed in a future version. (:issue:`165`)
* The run_model method of the ModelChain will use the weather parameter
of all weather data instead of splitting it to irradiation and weather.
The irradiation parameter still works but will be removed soon.
(:issue:`239`)
* delta_t kwarg is now 67.0 instead of None. IMPORTANT: Setting delta_t
as None will break the code for the Numba accelerated calculations.
This will be fixed in a future version. (:issue:`165`)


Enhancements
~~~~~~~~~~~~

* Adding a complete_irradiance method to the ModelChain to make it possible to calculate missing irradiation data from the existing columns [beta] (:issue:`239`)
* Added calculate_deltat method to the spa module to calculate the time difference between terrestrial time and UT1. Specifying a scalar is sufficient for most calculations. (:issue:`165`)
* Adding a complete_irradiance method to the ModelChain to make it
possible to calculate missing irradiation data from the existing
columns [beta]. (:issue:`239`)
* Added calculate_deltat method to the spa module to calculate the
time difference between terrestrial time and UT1. Specifying a scalar
is sufficient for most calculations. (:issue:`165`)

Code Contributors
~~~~~~~~~~~~~~~~~
Expand Down
16 changes: 7 additions & 9 deletions pvlib/atmosphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,26 +422,24 @@ def first_solar_spectral_correction(pw, airmass_absolute, module_type=None,
warn('Exceptionally low Pwat values replaced with 0.1 cm to prevent' +
' model divergence')


# Warn user about Pwat data that is exceptionally high
if np.max(pw) > 8:
warn('Exceptionally high Pwat values. Check input data:' +
' model may diverge in this range')


# *** AMa ***
# Replace Extremely High AM with AM 10 to prevent model divergence
# AM > 10 will only occur very close to sunset
if np.max(airmass_absolute) > 10:
airmass_absolute = np.minimum(airmass_absolute, 10)
airmass_absolute = np.minimum(airmass_absolute, 10)

# Warn user about AMa data that is exceptionally low
if np.min(airmass_absolute) < 0.58:
warn('Exceptionally low air mass: ' +
'model not intended for extra-terrestrial use')
# pvl_absoluteairmass(1,pvl_alt2pres(4340)) = 0.58 Elevation of
# Mina Pirquita, Argentian = 4340 m. Highest elevation city with
# population over 50,000.
warn('Exceptionally low air mass: ' +
'model not intended for extra-terrestrial use')
# pvl_absoluteairmass(1,pvl_alt2pres(4340)) = 0.58 Elevation of
# Mina Pirquita, Argentian = 4340 m. Highest elevation city with
# population over 50,000.

_coefficients = {}
_coefficients['cdte'] = (
Expand All @@ -465,7 +463,7 @@ def first_solar_spectral_correction(pw, airmass_absolute, module_type=None,
coeff = coefficients
ama = airmass_absolute
modifier = (
coeff[0] + coeff[1]*ama + coeff[2]*pw + coeff[3]*np.sqrt(ama) +
coeff[0] + coeff[1]*ama + coeff[2]*pw + coeff[3]*np.sqrt(ama) +
coeff[4]*np.sqrt(pw) + coeff[5]*ama/np.sqrt(pw))

return modifier
10 changes: 5 additions & 5 deletions pvlib/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from xml.etree.ElementTree import ParseError

from pvlib.location import Location
from pvlib.irradiance import liujordan, extraradiation, disc, dirint
from pvlib.irradiance import liujordan, extraradiation, disc
from siphon.catalog import TDSCatalog
from siphon.ncss import NCSS

Expand Down Expand Up @@ -166,7 +166,7 @@ def set_query_latlon(self):
'''

if (isinstance(self.longitude, list) and
isinstance(self.latitude, list)):
isinstance(self.latitude, list)):
self.lbox = True
# west, east, south, north
self.query.lonlat_box(self.latitude[0], self.latitude[1],
Expand Down Expand Up @@ -678,7 +678,7 @@ def __init__(self, resolution='half', set_type='best'):
'total_clouds',
'low_clouds',
'mid_clouds',
'high_clouds',]
'high_clouds']

super(GFS, self).__init__(model_type, model, set_type)

Expand Down Expand Up @@ -763,7 +763,7 @@ def __init__(self, set_type='best'):
'total_clouds',
'low_clouds',
'mid_clouds',
'high_clouds',]
'high_clouds']

super(HRRR_ESRL, self).__init__(model_type, model, set_type)

Expand Down Expand Up @@ -844,7 +844,7 @@ def __init__(self, set_type='best'):
'total_clouds',
'low_clouds',
'mid_clouds',
'high_clouds',]
'high_clouds']

super(NAM, self).__init__(model_type, model, set_type)

Expand Down
4 changes: 0 additions & 4 deletions pvlib/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def __repr__(self):
.format(self.name, self.latitude, self.longitude,
self.tz, self.altitude))


@classmethod
def from_tmy(cls, tmy_metadata, tmy_data=None, **kwargs):
"""
Expand Down Expand Up @@ -133,7 +132,6 @@ def from_tmy(cls, tmy_metadata, tmy_data=None, **kwargs):

return new_object


def get_solarposition(self, times, pressure=None, temperature=12,
**kwargs):
"""
Expand Down Expand Up @@ -166,7 +164,6 @@ def get_solarposition(self, times, pressure=None, temperature=12,
temperature=temperature,
**kwargs)


def get_clearsky(self, times, model='ineichen', solar_position=None,
dni_extra=None, **kwargs):
"""
Expand Down Expand Up @@ -239,7 +236,6 @@ def get_clearsky(self, times, model='ineichen', solar_position=None,

return cs


def get_airmass(self, times=None, solar_position=None,
model='kastenyoung1989'):
"""
Expand Down
57 changes: 29 additions & 28 deletions pvlib/modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,22 +609,23 @@ def effective_irradiance_model(self):

def complete_irradiance(self, times=None, weather=None):
"""
Determine the missing irradiation columns. Only two of the following
data columns (dni, ghi, dhi) are needed to calculate the missing data.
Determine the missing irradiation columns. Only two of the
following data columns (dni, ghi, dhi) are needed to calculate
the missing data.

This function is not safe at the moment. Results can be too high or
negative. Please contribute and help to improve this function on
https://github.com/pvlib/pvlib-python
This function is not safe at the moment. Results can be too high
or negative. Please contribute and help to improve this function
on https://github.com/pvlib/pvlib-python

Parameters
----------
times : DatetimeIndex
Times at which to evaluate the model. Can be None if attribute
`times` is already set.
Times at which to evaluate the model. Can be None if
attribute `times` is already set.
weather : pandas.DataFrame
Table with at least two columns containing one of the following data
sets: dni, dhi, ghi. Can be None if attribute `weather` is already
set.
Table with at least two columns containing one of the
following data sets: dni, dhi, ghi. Can be None if attribute
`weather` is already set.

Returns
-------
Expand All @@ -635,8 +636,8 @@ def complete_irradiance(self, times=None, weather=None):
Examples
--------
This example does not work until the parameters `my_system`,
`my_location`, `my_datetime` and `my_weather` are not defined properly
but shows the basic idea how this method can be used.
`my_location`, `my_datetime` and `my_weather` are not defined
properly but shows the basic idea how this method can be used.

>>> from pvlib.modelchain import ModelChain

Expand Down Expand Up @@ -686,25 +687,26 @@ def prepare_inputs(self, times=None, irradiance=None, weather=None):
Parameters
----------
times : DatetimeIndex
Times at which to evaluate the model. Can be None if attribute
`times` is already set.
Times at which to evaluate the model. Can be None if
attribute `times` is already set.
irradiance : None or DataFrame
This parameter is deprecated. Please use `weather` instead.
weather : None or DataFrame
If None, the weather attribute is used. If the weather attribute is
also None assumes air temperature is 20 C, wind speed is 0 m/s and
irradiation calculated from clear sky data.
Column names must be 'wind_speed', 'temp_air', 'dni', 'ghi', 'dhi'.
Do not pass incomplete irradiation data.
Use method
If None, the weather attribute is used. If the weather
attribute is also None assumes air temperature is 20 C, wind
speed is 0 m/s and irradiation calculated from clear sky
data. Column names must be 'wind_speed', 'temp_air', 'dni',
'ghi', 'dhi'. Do not pass incomplete irradiation data. Use
method
:py:meth:`~pvlib.modelchain.ModelChain.complete_irradiance`
instead.

Returns
-------
self

Assigns attributes: times, solar_position, airmass, total_irrad, aoi
Assigns attributes: times, solar_position, airmass, total_irrad,
aoi
"""
if weather is not None:
self.weather = weather
Expand Down Expand Up @@ -792,16 +794,15 @@ def run_model(self, times=None, irradiance=None, weather=None):
Parameters
----------
times : DatetimeIndex
Times at which to evaluate the model. Can be None if attribute
`times` is already set.
Times at which to evaluate the model. Can be None if
attribute `times` is already set.
irradiance : None or DataFrame
This parameter is deprecated. Please use `weather` instead.
weather : None or DataFrame
If None, assumes air temperature is 20 C, wind speed is 0 m/s and
irradiation calculated from clear sky data.
Column names must be 'wind_speed', 'temp_air', 'dni', 'ghi', 'dhi'.
Do not pass incomplete irradiation data.
Use method
If None, assumes air temperature is 20 C, wind speed is 0
m/s and irradiation calculated from clear sky data. Column
names must be 'wind_speed', 'temp_air', 'dni', 'ghi', 'dhi'.
Do not pass incomplete irradiation data. Use method
:py:meth:`~pvlib.modelchain.ModelChain.complete_irradiance`
instead.

Expand Down
4 changes: 0 additions & 4 deletions pvlib/pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,9 +1109,6 @@ def retrieve_sam(name=None, path=None):
Name: AE_Solar_Energy__AE6_0__277V__277V__CEC_2012_, dtype: float64
'''

pvlib_path = os.path.dirname(os.path.abspath(__file__))
filepath = os.path.join(pvlib_path, 'data', 'LinkeTurbidities.mat')

if name is not None:
name = name.lower()
data_path = os.path.join(
Expand Down Expand Up @@ -1263,7 +1260,6 @@ def sapm(effective_irradiance, temp_cell, module):
T0 = 25
q = 1.60218e-19 # Elementary charge in units of coulombs
kb = 1.38066e-23 # Boltzmann's constant in units of J/K
E0 = 1000

Ee = effective_irradiance

Expand Down
31 changes: 16 additions & 15 deletions pvlib/solarposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

from __future__ import division
import os
import logging
pvl_logger = logging.getLogger('pvlib')
import datetime as dt
try:
from importlib import reload
Expand All @@ -20,13 +18,14 @@
except ImportError:
pass

import warnings

import numpy as np
import pandas as pd

from pvlib import atmosphere
from pvlib.tools import localize_to_utc, datetime_to_djd, djd_to_datetime
from pvlib.tools import datetime_to_djd, djd_to_datetime

import logging
pvl_logger = logging.getLogger('pvlib')


def get_solarposition(time, latitude, longitude,
Expand Down Expand Up @@ -154,7 +153,8 @@ def spa_c(time, latitude, longitude, pressure=101325, altitude=0,
----------
NREL SPA code: http://rredc.nrel.gov/solar/codesandalgorithms/spa/

USNO delta T: http://www.usno.navy.mil/USNO/earth-orientation/eo-products/long-term
USNO delta T:
http://www.usno.navy.mil/USNO/earth-orientation/eo-products/long-term

See also
--------
Expand Down Expand Up @@ -184,7 +184,7 @@ def spa_c(time, latitude, longitude, pressure=101325, altitude=0,
hour=date.hour,
minute=date.minute,
second=date.second,
timezone=0, # must input localized or utc times
timezone=0, # must input localized or utc time
latitude=latitude,
longitude=longitude,
elevation=altitude,
Expand Down Expand Up @@ -298,7 +298,8 @@ def spa_python(time, latitude, longitude,
[2] I. Reda and A. Andreas, Corrigendum to Solar position algorithm for
solar radiation applications. Solar Energy, vol. 81, no. 6, p. 838, 2007.

[3] USNO delta T: http://www.usno.navy.mil/USNO/earth-orientation/eo-products/long-term
[3] USNO delta T:
http://www.usno.navy.mil/USNO/earth-orientation/eo-products/long-term

See also
--------
Expand Down Expand Up @@ -328,9 +329,9 @@ def spa_python(time, latitude, longitude,

delta_t = delta_t or spa.calculate_deltat(time.year, time.month)

app_zenith, zenith, app_elevation, elevation, azimuth, eot = spa.solar_position(
unixtime, lat, lon, elev, pressure, temperature, delta_t,
atmos_refract, numthreads)
app_zenith, zenith, app_elevation, elevation, azimuth, eot = \
spa.solar_position(unixtime, lat, lon, elev, pressure, temperature,
delta_t, atmos_refract, numthreads)

result = pd.DataFrame({'apparent_zenith': app_zenith, 'zenith': zenith,
'apparent_elevation': app_elevation,
Expand Down Expand Up @@ -814,7 +815,7 @@ def nrel_earthsun_distance(time, how='numpy', delta_t=67.0, numthreads=4):

Returns
-------
R : pd.Series
dist : pd.Series
Earth-sun distance in AU.

References
Expand All @@ -836,11 +837,11 @@ def nrel_earthsun_distance(time, how='numpy', delta_t=67.0, numthreads=4):

delta_t = delta_t or spa.calculate_deltat(time.year, time.month)

R = spa.earthsun_distance(unixtime, delta_t, numthreads)
dist = spa.earthsun_distance(unixtime, delta_t, numthreads)

R = pd.Series(R, index=time)
dist = pd.Series(dist, index=time)

return R
return dist


def _calculate_simple_day_angle(dayofyear):
Expand Down
Loading