Skip to content

replace format with %s in logging calls #92

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 28, 2015
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
1 change: 1 addition & 0 deletions docs/sphinx/source/whatsnew.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ What's New

These are new features and improvements of note in each release.

.. include:: whatsnew/v0.2.2.txt
.. include:: whatsnew/v0.2.1.txt
.. include:: whatsnew/v0.2.0.txt
.. include:: whatsnew/v0.1.0.txt
27 changes: 27 additions & 0 deletions docs/sphinx/source/whatsnew/v0.2.2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.. _whatsnew_0220:

v0.2.2 (November, 2015)
-----------------------

This is a minor release from 0.2.1.
We recommend that all users upgrade to this version.

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

* Adds Python 3.5 compatibility (:issue:`87`)


Bug fixes
~~~~~~~~~

* Uses the ``logging`` module properly by replacing ``format``
calls with ``args``. This results in a 5x speed increase for
``tracking.singleaxis`` (:issue:`89`).
* Adds a link to the 2015 PVSC paper (:issue:`81`)

Contributors
~~~~~~~~~~~~

* Will Holmgren
* dacoex
4 changes: 2 additions & 2 deletions pvlib/atmosphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ def relativeairmass(zenith, model='kastenyoung1989'):
AM = ( 1.0 / (np.cos(zenith_rad) +
0.00176759*(z)*((94.37515 - z) ** - 1.21563)) )
else:
pvl_logger.warning("{} is not a valid model type for relative airmass. The 'kastenyoung1989' model was used."
.format(model))
pvl_logger.warning("%s is not a valid model type for relative airmass. The 'kastenyoung1989' model was used.",
model)
AM = ( 1.0 / (np.cos(zenith_rad) +
0.50572*(((6.07995 + (90 - z)) ** - 1.6364))) )

Expand Down
8 changes: 4 additions & 4 deletions pvlib/clearsky.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def ineichen(time, location, linke_turbidity=None,

# consider putting this code at module level
this_path = os.path.dirname(os.path.abspath(__file__))
logger.debug('this_path={}'.format(this_path))
logger.debug('this_path=%s', this_path)

mat = scipy.io.loadmat(os.path.join(this_path, 'data', 'LinkeTurbidities.mat'))
linke_turbidity = mat['LinkeTurbidity']
Expand All @@ -153,7 +153,7 @@ def ineichen(time, location, linke_turbidity=None,
LT = pd.DataFrame(time.month, index=time)
LT = LT.apply(ApplyMonth, axis=1)
TL = LT / 20.
logger.info('using TL=\n{}'.format(TL))
logger.info('using TL=\n%s', TL)
else:
TL = linke_turbidity

Expand All @@ -170,7 +170,7 @@ def ineichen(time, location, linke_turbidity=None,
fh2 = np.exp(-location.altitude/1250.)
cg1 = 5.09e-05 * location.altitude + 0.868
cg2 = 3.92e-05 * location.altitude + 0.0387
logger.debug('fh1={}, fh2={}, cg1={}, cg2={}'.format(fh1, fh2, cg1, cg2))
logger.debug('fh1=%s, fh2=%s, cg1=%s, cg2=%s', fh1, fh2, cg1, cg2)

# Dan's note on the TL correction: By my reading of the publication on
# pages 151-157, Ineichen and Perez introduce (among other things) three
Expand Down Expand Up @@ -203,7 +203,7 @@ def ineichen(time, location, linke_turbidity=None,
# BncI == "normal beam clear sky radiation"
b = 0.664 + 0.163/fh1
BncI = b * I0 * np.exp( -0.09 * AMabsolute * (TL - 1) )
logger.debug('b={}'.format(b))
logger.debug('b=%s', b)

# "empirical correction" SE 73, 157 & SE 73, 312.
BncI_2 = ( clearsky_GHI *
Expand Down
14 changes: 7 additions & 7 deletions pvlib/irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,8 @@ def grounddiffuse(surface_tilt, ghi, albedo=.25, surface_type=None):

if surface_type is not None:
albedo = SURFACE_ALBEDOS[surface_type]
pvl_logger.info('surface_type={} mapped to albedo={}'
.format(surface_type, albedo))
pvl_logger.info('surface_type=%s mapped to albedo=%s',
surface_type, albedo)

diffuse_irrad = ghi * albedo * (1 - np.cos(np.radians(surface_tilt))) * 0.5

Expand Down Expand Up @@ -1489,7 +1489,7 @@ def dirint(ghi, zenith, times, pressure=101325, use_delta_kt_prime=True,
kt_prime = kt / (1.031 * np.exp(-1.4/(0.9+9.4/airmass)) + 0.1)
kt_prime[kt_prime > 0.82] = 0.82 # From SRRL code. consider np.NaN
kt_prime.fillna(0, inplace=True)
pvl_logger.debug('kt_prime:\n{}'.format(kt_prime))
pvl_logger.debug('kt_prime:\n%s', kt_prime)

# wholmgren:
# the use_delta_kt_prime statement is a port of the MATLAB code.
Expand Down Expand Up @@ -1519,7 +1519,7 @@ def dirint(ghi, zenith, times, pressure=101325, use_delta_kt_prime=True,
kt_prime_bin[(kt_prime>=0.56) & (kt_prime<0.7)] = 4
kt_prime_bin[(kt_prime>=0.7) & (kt_prime<0.8)] = 5
kt_prime_bin[(kt_prime>=0.8) & (kt_prime<=1)] = 6
pvl_logger.debug('kt_prime_bin:\n{}'.format(kt_prime_bin))
pvl_logger.debug('kt_prime_bin:\n%s', kt_prime_bin)

# Create zenith angle bins
zenith_bin = pd.Series(index=times)
Expand All @@ -1529,7 +1529,7 @@ def dirint(ghi, zenith, times, pressure=101325, use_delta_kt_prime=True,
zenith_bin[(zenith>=55) & (zenith<70)] = 4
zenith_bin[(zenith>=70) & (zenith<80)] = 5
zenith_bin[(zenith>=80)] = 6
pvl_logger.debug('zenith_bin:\n{}'.format(zenith_bin))
pvl_logger.debug('zenith_bin:\n%s', zenith_bin)

# Create the bins for w based on dew point temperature
w_bin = pd.Series(index=times)
Expand All @@ -1538,7 +1538,7 @@ def dirint(ghi, zenith, times, pressure=101325, use_delta_kt_prime=True,
w_bin[(w>=2) & (w<3)] = 3
w_bin[(w>=3)] = 4
w_bin[(w == -1)] = 5
pvl_logger.debug('w_bin:\n{}'.format(w_bin))
pvl_logger.debug('w_bin:\n%s', w_bin)

# Create delta_kt_prime binning.
delta_kt_prime_bin = pd.Series(index=times)
Expand All @@ -1549,7 +1549,7 @@ def dirint(ghi, zenith, times, pressure=101325, use_delta_kt_prime=True,
delta_kt_prime_bin[(delta_kt_prime>=0.15) & (delta_kt_prime<0.3)] = 5
delta_kt_prime_bin[(delta_kt_prime>=0.3) & (delta_kt_prime<=1)] = 6
delta_kt_prime_bin[delta_kt_prime == -1] = 7
pvl_logger.debug('delta_kt_prime_bin:\n{}'.format(delta_kt_prime_bin))
pvl_logger.debug('delta_kt_prime_bin:\n%s', delta_kt_prime_bin)

# subtract 1 to account for difference between MATLAB-style bin
# assignment and Python-style array lookup.
Expand Down
3 changes: 1 addition & 2 deletions pvlib/pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ def retrieve_sam(name=None, samfile=None):
raise ValueError('must supply name or samfile')

if samfile is None:
pvl_logger.info('retrieving {} from {}'.format(name, url))
pvl_logger.info('retrieving %s from %s', name, url)
response = urlopen(url)
csvdata = io.StringIO(response.read().decode(errors='ignore'))
elif samfile == 'select':
Expand Down Expand Up @@ -1115,7 +1115,6 @@ def i_from_v(resistance_shunt, resistance_series, nNsVth, voltage,
np.exp( Rsh*(Rs*(IL+I0)+V) / (nNsVth*(Rs+Rsh)) ) /
(nNsVth*(Rs + Rsh)) )
lambertwterm = lambertw(argW)
pvl_logger.debug('argW: {}, lambertwterm{}'.format(argW, lambertwterm))

# Eqn. 4 in Jain and Kapoor, 2004
I = -V/(Rs + Rsh) - (nNsVth/Rs)*lambertwterm + Rsh*(IL + I0)/(Rs + Rsh)
Expand Down
4 changes: 2 additions & 2 deletions pvlib/solarposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,8 @@ def ephemeris(time, location, pressure=101325, temperature=12):
# This helps a little bit:
# http://www.cv.nrao.edu/~rfisher/Ephemerides/times.html

pvl_logger.debug('location={}, temperature={}, pressure={}'.format(
location, temperature, pressure))
pvl_logger.debug('location=%s, temperature=%s, pressure=%s',
location, temperature, pressure)

# the inversion of longitude is due to the fact that this code was
# originally written for the convention that positive longitude were for
Expand Down
4 changes: 2 additions & 2 deletions pvlib/spa.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,8 +983,8 @@ def solar_position_numba(unixtime, lat, lon, elev, pressure, temp, delta_t,

if ulength < numthreads:
pvl_logger.warning('The number of threads is more than the length of' +
' the time array. Only using {} threads.'.format(
ulength))
' the time array. Only using %s threads.',
ulength)
numthreads = ulength

if numthreads <= 1:
Expand Down
2 changes: 1 addition & 1 deletion pvlib/tmy.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ def _parsemeta_tmy2(columns, line):
meta.append(float(rawmeta[10]))

meta_dict = dict(zip(columns.split(','),meta)) #Creates a dictionary of metadata
pvl_logger.debug('meta: {}'.format(meta_dict))
pvl_logger.debug('meta: %s', meta_dict)

return meta_dict

Expand Down
4 changes: 2 additions & 2 deletions pvlib/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ def localize_to_utc(time, location):
pvl_logger.debug('tz_convert to UTC')
except TypeError:
time_utc = time.tz_localize(location.tz).tz_convert('UTC')
pvl_logger.debug('tz_localize to {} and then tz_convert to UTC'
.format(location.tz))
pvl_logger.debug('tz_localize to %s and then tz_convert to UTC',
location.tz)


return time_utc
Expand Down
27 changes: 13 additions & 14 deletions pvlib/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,12 @@ def singleaxis(apparent_zenith, apparent_azimuth,

pvl_logger.debug('tracking.singleaxis')

pvl_logger.debug(('axis_tilt={}, axis_azimuth={}, max_angle={}, ' +
'backtrack={}, gcr={:.3f}')
.format(axis_tilt, axis_azimuth, max_angle, backtrack,
gcr))
pvl_logger.debug('axis_tilt=%s, axis_azimuth=%s, max_angle=%s, ' +
'backtrack=%s, gcr=%.3f',
axis_tilt, axis_azimuth, max_angle, backtrack, gcr)

pvl_logger.debug('\napparent_zenith=\n{}\napparent_azimuth=\n{}'
.format(apparent_zenith.head(), apparent_azimuth.head()))
pvl_logger.debug('\napparent_zenith=\n%s\napparent_azimuth=\n%s',
apparent_zenith.head(), apparent_azimuth.head())

# MATLAB to Python conversion by
# Will Holmgren (@wholmgren), U. Arizona. March, 2015.
Expand Down Expand Up @@ -139,7 +138,7 @@ def singleaxis(apparent_zenith, apparent_azimuth,
# wholmgren: strange to see axis_azimuth calculated differently from az,
# (not that it matters, or at least it shouldn't...).
axis_azimuth_south = axis_azimuth - 180
pvl_logger.debug('axis_azimuth_south={}'.format(axis_azimuth_south))
pvl_logger.debug('axis_azimuth_south=%s', axis_azimuth_south)

# translate input array tilt angle axis_tilt to [1] coordinate system.

Expand Down Expand Up @@ -254,34 +253,34 @@ def singleaxis(apparent_zenith, apparent_azimuth,
rot_x = np.array([[1, 0, 0],
[0, cosd(-axis_tilt), -sind(-axis_tilt)],
[0, sind(-axis_tilt), cosd(-axis_tilt)]])
pvl_logger.debug('rot_x=\n{}'.format(rot_x))
pvl_logger.debug('rot_x=\n%s', rot_x)

# panel_norm_earth contains the normal vector
# expressed in earth-surface coordinates
# (z normal to surface, y aligned with tracker axis parallel to earth)
panel_norm_earth = np.dot(rot_x, panel_norm).T
pvl_logger.debug('panel_norm_earth={}'.format(panel_norm_earth))
pvl_logger.debug('panel_norm_earth=%s', panel_norm_earth)

# projection to plane tangent to earth surface,
# in earth surface coordinates
projected_normal = np.array([panel_norm_earth[:,0],
panel_norm_earth[:,1],
panel_norm_earth[:,2]*0]).T
pvl_logger.debug('projected_normal={}'.format(projected_normal))
pvl_logger.debug('projected_normal=%s', projected_normal)

# calculate vector magnitudes
panel_norm_earth_mag = np.sqrt(np.nansum(panel_norm_earth**2, axis=1))
projected_normal_mag = np.sqrt(np.nansum(projected_normal**2, axis=1))
pvl_logger.debug('panel_norm_earth_mag={}, projected_normal_mag={}'
.format(panel_norm_earth_mag, projected_normal_mag))
pvl_logger.debug('panel_norm_earth_mag=%s, projected_normal_mag=%s',
panel_norm_earth_mag, projected_normal_mag)

# renormalize the projected vector
# avoid creating nan values.
non_zeros = projected_normal_mag != 0
projected_normal[non_zeros] = (projected_normal[non_zeros].T /
projected_normal_mag[non_zeros]).T
pvl_logger.debug('renormalized projected_normal={}'
.format(projected_normal))
pvl_logger.debug('renormalized projected_normal=%s',
projected_normal)

# calculation of surface_azimuth
# 1. Find the angle.
Expand Down