8000 more pep8 (#256) · shiyuning/pvlib-python@50829ae · GitHub
[go: up one dir, main page]

Skip to content

Commit 50829ae

Browse files
authored
more pep8 (pvlib#256)
* pep8 attack * clean up tmy.py
1 parent 9c75c27 commit 50829ae

File tree

10 files changed

+307
-318
lines changed

10 files changed

+307
-318
lines changed

docs/sphinx/source/whatsnew/v0.4.2.txt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
.. _whatsnew_0420:
22

3-
v0.4.2 ()
4-
------------------------
3+
v0.4.2 (October 31, 2016)
4+
-------------------------
55

6-
This is a minor release from 0.4.0. ....
6+
This is a minor release from 0.4.1.
77

88

99
Bug fixes
1010
~~~~~~~~~
1111

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

21-
* 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`)
22-
* 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`)
21+
* The run_model method of the ModelChain will use the weather parameter
22+
of all weather data instead of splitting it to irradiation and weather.
23+
The irradiation parameter still works but will be removed soon.
24+
(:issue:`239`)
25+
* delta_t kwarg is now 67.0 instead of None. IMPORTANT: Setting delta_t
26+
as None will break the code for the Numba accelerated calculations.
27+
This will be fixed in a future version. (:issue:`165`)
2328

2429

2530
Enhancements
2631
~~~~~~~~~~~~
2732

28-
* Adding a complete_irradiance method to the ModelChain to make it possible to calculate missing irradiation data from the existing columns [beta] (:issue:`239`)
29-
* 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`)
33+
* Adding a complete_irradiance method to the ModelChain to make it
34+
possible to calculate missing irradiation data from the existing
35+
columns [beta]. (:issue:`239`)
36+
* Added calculate_deltat method to the spa module to calculate the
37+
time difference between terrestrial time and UT1. Specifying a scalar
38+
is sufficient for most calculations. (:issue:`165`)
3039

3140
Code Contributors
3241
~~~~~~~~~~~~~~~~~

pvlib/atmosphere.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -422,26 +422,24 @@ def first_solar_spectral_correction(pw, airmass_absolute, module_type=None,
422422
warn('Exceptionally low Pwat values replaced with 0.1 cm to prevent' +
423423
' model divergence')
424424

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

431-
432430
# *** AMa ***
433431
# Replace Extremely High AM with AM 10 to prevent model divergence
434432
# AM > 10 will only occur very close to sunset
435433
if np.max(airmass_absolute) > 10:
436-
airmass_absolute = np.minimum(airmass_absolute, 10)
434+
airmass_absolute = np.minimum(airmass_absolute, 10)
437435

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

446444
_coefficients = {}
447445
_coefficients['cdte'] = (
@@ -465,7 +463,7 @@ def first_solar_spectral_correction(pw, airmass_absolute, module_type=None,
465463
coeff = coefficients
466464
ama = airmass_absolute
467465
modifier = (
468-
coeff[0] + coeff[1]*ama + coeff[2]*pw + coeff[3]*np.sqrt(ama) +
466+
coeff[0] + coeff[1]*ama + coeff[2]*pw + coeff[3]*np.sqrt(ama) +
469467
coeff[4]*np.sqrt(pw) + coeff[5]*ama/np.sqrt(pw))
470468

471469
return modifier

pvlib/forecast.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from xml.etree.ElementTree import ParseError
1111

1212
from pvlib.location import Location
13-
from pvlib.irradiance import liujordan, extraradiation, disc, dirint
13+
from pvlib.irradiance import liujordan, extraradiation, disc
1414
from siphon.catalog import TDSCatalog
1515
from siphon.ncss import NCSS
1616

@@ -166,7 +166,7 @@ def set_query_latlon(self):
166166
'''
167167

168168
if (isinstance(self.longitude, list) and
169-
isinstance(self.latitude, list)):
169+
isinstance(self.latitude, list)):
170170
self.lbox = True
171171
# west, east, south, north
172172
self.query.lonlat_box(self.latitude[0], self.latitude[1],
@@ -678,7 +678,7 @@ def __init__(self, resolution='half', set_type='best'):
678678
'total_clouds',
679679
'low_clouds',
680680
'mid_clouds',
681-
'high_clouds',]
681+
'high_clouds']
682682

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

@@ -763,7 +763,7 @@ def __init__(self, set_type='best'):
763763
'total_clouds',
764764
'low_clouds',
765765
'mid_clouds',
766-
'high_clouds',]
766+
'high_clouds']
767767

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

@@ -844,7 +844,7 @@ def __init__(self, set_type='best'):
844844
'total_clouds',
845845
'low_clouds',
846846
'mid_clouds',
847-
'high_clouds',]
847+
'high_clouds']
848848

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

pvlib/location.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ def __repr__(self):
8888
.format(self.name, self.latitude, self.longitude,
8989
self.tz, self.altitude))
9090

91-
9291
@classmethod
9392
def from_tmy(cls, tmy_metadata, tmy_data=None, **kwargs):
9493
"""
@@ -133,7 +132,6 @@ def from_tmy(cls, tmy_metadata, tmy_data=None, **kwargs):
133132

134133
return new_object
135134

136-
137135
def get_solarposition(self, times, pressure=None, temperature=12,
138136
**kwargs):
139137
"""
@@ -166,7 +164,6 @@ def get_solarposition(self, times, pressure=None, temperature=12,
166164
temperature=temperature,
167165
**kwargs)
168166

169-
170167
def get_clearsky(self, times, model='ineichen', solar_position=None,
171168
dni_extra=None, **kwargs):
172169
"""
@@ -239,7 +236,6 @@ def get_clearsky(self, times, model='ineichen', solar_position=None,
239236

240237
return cs
241238

242-
243239
def get_airmass(self, times=None, solar_position=None,
244240
model='kastenyoung1989'):
245241
"""

pvlib/modelchain.py

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -609,22 +609,23 @@ def effective_irradiance_model(self):
609609

610610
def complete_irradiance(self, times=None, weather=None):
611611
"""
612-
Determine the missing irradiation columns. Only two of the following
613-
data columns (dni, ghi, dhi) are needed to calculate the missing data.
612+
Determine the missing irradiation columns. Only two of the
613+
following data columns (dni, ghi, dhi) are needed to calculate
614+
the missing data.
614615
615-
This function is not safe at the moment. Results can be too high or
616-
negative. Please contribute and help to improve this function on
617-
https://github.com/pvlib/pvlib-python
616+
This function is not safe at the moment. Results can be too high
617+
or negative. Please contribute and help to improve this function
618+
on https://github.com/pvlib/pvlib-python
618619
619620
Parameters
620621
----------
621622
times : DatetimeIndex
622-
Times at which to evaluate the model. Can be None if attribute
623-
`times` is already set.
623+
Times at which to evaluate the model. Can be None if
624+
attribute `times` is already set.
624625
weather : pandas.DataFrame
625-
Table with at least two columns containing one of the following data
626-
sets: dni, dhi, ghi. Can be None if attribute `weather` is already
627-
set.
626+
Table with at least two columns containing one of the
627+
following data sets: dni, dhi, ghi. Can be None if attribute
628+
`weather` is already set.
628629
629630
Returns
630631
-------
@@ -635,8 +636,8 @@ def complete_irradiance(self, times=None, weather=None):
635636
Examples
636637
---- 1241 ----
637638
This example does not work until the parameters `my_system`,
638-
`my_location`, `my_datetime` and `my_weather` are not defined properly
639-
but shows the basic idea how this method can be used.
639+
`my_location`, `my_datetime` and `my_weather` are not defined
640+
properly but shows the basic idea how this method can be used.
640641
641642
>>> from pvlib.modelchain import ModelChain
642643
@@ -686,25 +687,26 @@ def prepare_inputs(self, times=None, irradiance=None, weather=None):
686687
Parameters
687688
----------
688689
times : DatetimeIndex
689-
Times at which to evaluate the model. Can be None if attribute
690-
`times` is already set.
690+
Times at which to evaluate the model. Can be None if
691+
attribute `times` is already set.
691692
irradiance : None or DataFrame
692693
This parameter is deprecated. Please use `weather` instead.
693694
weather : None or DataFrame
694-
If None, the weather attribute is used. If the weather attribute is
695-
also None assumes air temperature is 20 C, wind speed is 0 m/s and
696-
irradiation calculated from clear sky data.
697-
Column names must be 'wind_speed', 'temp_air', 'dni', 'ghi', 'dhi'.
698-
Do not pass incomplete irradiation data.
699-
Use method
695+
If None, the weather attribute is used. If the weather
696+
attribute is also None assumes air temperature is 20 C, wind
697+
speed is 0 m/s and irradiation calculated from clear sky
698+
data. Column names must be 'wind_speed', 'temp_air', 'dni',
699+
'ghi', 'dhi'. Do not pass incomplete irradiation data. Use
700+
method
700701
:py:meth:`~pvlib.modelchain.ModelChain.complete_irradiance`
701702
instead.
702703
703704
Returns
704705
-------
705706
self
706707
707-
Assigns attributes: times, solar_position, airmass, total_irrad, aoi
708+
Assigns attributes: times, solar_position, airmass, total_irrad,
709+
aoi
708710
"""
709711
if weather is not None:
710712
self.weather = weather
@@ -792,16 +794,15 @@ def run_model(self, times=None, irradiance=None, weather=None):
792794
Parameters
793795
----------
794796
times : DatetimeIndex
795-
Times at which to evaluate the model. Can be None if attribute
796-
`times` is already set.
797+
Times at which to evaluate the model. Can be None if
798+
attribute `times` is already set.
797799
irradiance : None or DataFrame
798800
This parameter is deprecated. Please use `weather` instead.
799801
weather : None or DataFrame
800-
If None, assumes air temperature is 20 C, wind speed is 0 m/s and
801-
irradiation calculated from clear sky data.
802-
Column names must be 'wind_speed', 'temp_air', 'dni', 'ghi', 'dhi'.
803-
Do not pass incomplete irradiation data.
804-
Use method
802+
If None, assumes air temperature is 20 C, wind speed is 0
803+
m/s and irradiation calculated from clear sky data. Column
804+
names must be 'wind_speed', 'temp_air', 'dni', 'ghi', 'dhi'.
805+
Do not pass incomplete irradiation data. Use method
805806
:py:meth:`~pvlib.modelchain.ModelChain.complete_irradiance`
806807
instead.
807808

pvlib/pvsystem.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,9 +1109,6 @@ def retrieve_sam(name=None, path=None):
11091109
Name: AE_Solar_Energy__AE6_0__277V__277V__CEC_2012_, dtype: float64
11101110
'''
11111111

1112-
pvlib_path = os.path.dirname(os.path.abspath(__file__))
1113-
filepath = os.path.join(pvlib_path, 'data', 'LinkeTurbidities.mat')
1114-
11151112
if name is not None:
11161113
name = name.lower()
11171114
data_path = os.path.join(
@@ -1263,7 +1260,6 @@ def sapm(effective_irradiance, temp_cell, module):
12631260
T0 = 25
12641261
q = 1.60218e-19 # Elementary charge in units of coulombs
12651262
kb = 1.38066e-23 # Boltzmann's constant in units of J/K
1266-
E0 = 1000
12671263

12681264
Ee = effective_irradiance
12691265

pvlib/solarposition.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
from __future__ import division
1111
import os
12-
import logging
13-
pvl_logger = logging.getLogger('pvlib')
1412
import datetime as dt
1513
try:
1614
from importlib import reload
@@ -20,13 +18,14 @@
2018
except ImportError:
2119
pass
2220

23-
import warnings
24-
2521
import numpy as np
2622
import pandas as pd
2723

2824
from pvlib import atmosphere
29-
from pvlib.tools import localize_to_utc, datetime_to_djd, djd_to_datetime
25+
from pvlib.tools import datetime_to_djd, djd_to_datetime
26+
27+
import logging
28+
pvl_logger = logging.getLogger('pvlib')
3029

3130

3231
def get_solarposition(time, latitude, longitude,
@@ -154,7 +153,8 @@ def spa_c(time, latitude, longitude, pressure=101325, altitude=0,
154153
----------
155154
NREL SPA code: http://rredc.nrel.gov/solar/codesandalgorithms/spa/
156155
157-
USNO delta T: http://www.usno.navy.mil/USNO/earth-orientation/eo-products/long-term
156+
USNO delta T:
157+
http://www.usno.navy.mil/USNO/earth-orientation/eo-products/long-term
158158
159159
See also
160160
--------
@@ -184,7 +184,7 @@ def spa_c(time, latitude, longitude, pressure=101325, altitude=0,
184184
hour=date.hour,
185185
minute=date.minute,
186186
second=date.second,
187-
timezone=0, # must input localized or utc times
187+
timezone=0, # must input localized or utc time
188188
latitude=latitude,
189189
longitude=longitude,
190190
elevation=altitude,
@@ -298,7 +298,8 @@ def spa_python(time, latitude, longitude,
298298
[2] I. Reda and A. Andreas, Corrigendum to Solar position algorithm for
299299
solar radiation applications. Solar Energy, vol. 81, no. 6, p. 838, 2007.
300300
301-
[3] USNO delta T: http://www.usno.navy.mil/USNO/earth-orientation/eo-products/long-term
301+
[3] USNO delta T:
302+
http://www.usno.navy.mil/USNO/earth-orientation/eo-products/long-term
302303
303304
See also
304305
--------
@@ -328,9 +329,9 @@ def spa_python(time, latitude, longitude,
328329

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

331-
app_zenith, zenith, app_elevation, elevation, azimuth, eot = spa.solar_position(
332-
unixtime, lat, lon, elev, pressure, temperature, delta_t,
333-
atmos_refract, numthreads)
332+
app_zenith, zenith, app_elevation, elevation, azimuth, eot = \
333+
spa.solar_position(unixtime, lat, lon, elev, pressure, temperature,
334+
delta_t, atmos_refract, numthreads)
334335

335336
result = pd.DataFrame({'apparent_zenith': app_zenith, 'zenith': zenith,
336337
'apparent_elevation': app_elevation,
@@ -814,7 +815,7 @@ def nrel_earthsun_distance(time, how='numpy', delta_t=67.0, numthreads=4):
814815
815816
Returns
816817
-------
817-
R : pd.Series
818+
dist : pd.Series
818819
Earth-sun distance in AU.
819820
820821
References
@@ -836,11 +837,11 @@ def nrel_earthsun_distance(time, how='numpy', delta_t=67.0, numthreads=4):
836837

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

839-
R = spa.earthsun_distance(unixtime, delta_t, numthreads)
840+
dist = spa.earthsun_distance(unixtime, delta_t, numthreads)
840841

841-
R = pd.Series(R, index=time)
842+
dist = pd.Series(dist, index=time)
842843

843-
return R
844+
return dist
844845

845846

846847
def _calculate_simple_day_angle(dayofyear):

0 commit comments

Comments
 (0)
0