Skip to content

Commit 4cda11a

Browse files
committed
Merge pull request #92 from wholmgren/logging
replace format with %s in logging calls
2 parents 9b2b368 + 965ff7c commit 4cda11a

File tree

11 files changed

+62
-36
lines changed

11 files changed

+62
-36
lines changed

docs/sphinx/source/whatsnew.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ What's New
66

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

9+
.. include:: whatsnew/v0.2.2.txt
910
.. include:: whatsnew/v0.2.1.txt
1011
.. include:: whatsnew/v0.2.0.txt
1112
.. include:: whatsnew/v0.1.0.txt
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.. _whatsnew_0220:
2+
3+
v0.2.2 (November, 2015)
4+
-----------------------
5+
6+
This is a minor release from 0.2.1.
7+
We recommend that all users upgrade to this version.
8+
9+
Enhancements
10+
~~~~~~~~~~~~
11+
12+
* Adds Python 3.5 compatibility (:issue:`87`)
13+
14+
15+
Bug fixes
16+
~~~~~~~~~
17+
18+
* Uses the ``logging`` module properly by replacing ``format``
19+
calls with ``args``. This results in a 5x speed increase for
20+
``tracking.singleaxis`` (:issue:`89`).
21+
* Adds a link to the 2015 PVSC paper (:issue:`81`)
22+
23+
Contributors
24+
~~~~~~~~~~~~
25+
26+
* Will Holmgren
27+
* dacoex

pvlib/atmosphere.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ def relativeairmass(zenith, model='kastenyoung1989'):
237237
AM = ( 1.0 / (np.cos(zenith_rad) +
238238
0.00176759*(z)*((94.37515 - z) ** - 1.21563)) )
239239
else:
240-
pvl_logger.warning("{} is not a valid model type for relative airmass. The 'kastenyoung1989' model was used."
241-
.format(model))
240+
pvl_logger.warning("%s is not a valid model type for relative airmass. The 'kastenyoung1989' model was used.",
241+
model)
242242
AM = ( 1.0 / (np.cos(zenith_rad) +
243243
0.50572*(((6.07995 + (90 - z)) ** - 1.6364))) )
244244

pvlib/clearsky.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def ineichen(time, location, linke_turbidity=None,
135135

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

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

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

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

208208
# "empirical correction" SE 73, 157 & SE 73, 312.
209209
BncI_2 = ( clearsky_GHI *

pvlib/irradiance.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,8 @@ def grounddiffuse(surface_tilt, ghi, albedo=.25, surface_type=None):
513513

514514
if surface_type is not None:
515515
albedo = SURFACE_ALBEDOS[surface_type]
516-
pvl_logger.info('surface_type={} mapped to albedo={}'
517-
.format(surface_type, albedo))
516+
pvl_logger.info('surface_type=%s mapped to albedo=%s',
517+
surface_type, albedo)
518518

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

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

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

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

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

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

15541554
# subtract 1 to account for difference between MATLAB-style bin
15551555
# assignment and Python-style array lookup.

pvlib/pvsystem.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ def retrieve_sam(name=None, samfile=None):
547547
raise ValueError('must supply name or samfile')
548548

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

11201119
# Eqn. 4 in Jain and Kapoor, 2004
11211120
I = -V/(Rs + Rsh) - (nNsVth/Rs)*lambertwterm + Rsh*(IL + I0)/(Rs + Rsh)

pvlib/solarposition.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,8 @@ def ephemeris(time, location, pressure=101325, temperature=12):
536536
# This helps a little bit:
537537
# http://www.cv.nrao.edu/~rfisher/Ephemerides/times.html
538538

539-
pvl_logger.debug('location={}, temperature={}, pressure={}'.format(
540-
location, temperature, pressure))
539+
pvl_logger.debug('location=%s, temperature=%s, pressure=%s',
540+
location, temperature, pressure)
541541

542542
# the inversion of longitude is due to the fact that this code was
543543
# originally written for the convention that positive longitude were for

pvlib/spa.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,8 +983,8 @@ def solar_position_numba(unixtime, lat, lon, elev, pressure, temp, delta_t,
983983

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

990990
if numthreads <= 1:

pvlib/tmy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ def _parsemeta_tmy2(columns, line):
428428
meta.append(float(rawmeta[10]))
429429

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

433433
return meta_dict
434434

pvlib/tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ def localize_to_utc(time, location):
130130
pvl_logger.debug('tz_convert to UTC')
131131
except TypeError:
132132
time_utc = time.tz_localize(location.tz).tz_convert('UTC')
133-
pvl_logger.debug('tz_localize to {} and then tz_convert to UTC'
134-
.format(location.tz))
133+
pvl_logger.debug('tz_localize to %s and then tz_convert to UTC',
134+
location.tz)
135135

136136

137137
return time_utc

pvlib/tracking.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,12 @@ def singleaxis(apparent_zenith, apparent_azimuth,
9393

9494
pvl_logger.debug('tracking.singleaxis')
9595

96-
pvl_logger.debug(('axis_tilt={}, axis_azimuth={}, max_angle={}, ' +
97-
'backtrack={}, gcr={:.3f}')
98-
.format(axis_tilt, axis_azimuth, max_angle, backtrack,
99-
gcr))
96+
pvl_logger.debug('axis_tilt=%s, axis_azimuth=%s, max_angle=%s, ' +
97+
'backtrack=%s, gcr=%.3f',
98+
axis_tilt, axis_azimuth, max_angle, backtrack, gcr)
10099

101-
pvl_logger.debug('\napparent_zenith=\n{}\napparent_azimuth=\n{}'
102-
.format(apparent_zenith.head(), apparent_azimuth.head()))
100+
pvl_logger.debug('\napparent_zenith=\n%s\napparent_azimuth=\n%s',
101+
apparent_zenith.head(), apparent_azimuth.head())
103102

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

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

@@ -254,34 +253,34 @@ def singleaxis(apparent_zenith, apparent_azimuth,
254253
rot_x = np.array([[1, 0, 0],
255254
[0, cosd(-axis_tilt), -sind(-axis_tilt)],
256255
[0, sind(-axis_tilt), cosd(-axis_tilt)]])
257-
pvl_logger.debug('rot_x=\n{}'.format(rot_x))
256+
pvl_logger.debug('rot_x=\n%s', rot_x)
258257

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

265264
# projection to plane tangent to earth surface,
266265
# in earth surface coordinates
267266
projected_normal = np.array([panel_norm_earth[:,0],
268267
panel_norm_earth[:,1],
269268
panel_norm_earth[:,2]*0]).T
270-
pvl_logger.debug('projected_normal={}'.format(projected_normal))
269+
pvl_logger.debug('projected_normal=%s', projected_normal)
271270

272271
# calculate vector magnitudes
273272
panel_norm_earth_mag = np.sqrt(np.nansum(panel_norm_earth**2, axis=1))
274273
projected_normal_mag = np.sqrt(np.nansum(projected_normal**2, axis=1))
275-
pvl_logger.debug('panel_norm_earth_mag={}, projected_normal_mag={}'
276-
.format(panel_norm_earth_mag, projected_normal_mag))
274+
pvl_logger.debug('panel_norm_earth_mag=%s, projected_normal_mag=%s',
275+
panel_norm_earth_mag, projected_normal_mag)
277276

278277
# renormalize the projected vector
279278
# avoid creating nan values.
280279
non_zeros = projected_normal_mag != 0
281280
projected_normal[non_zeros] = (projected_normal[non_zeros].T /
282281
projected_normal_mag[non_zeros]).T
283-
pvl_logger.debug('renormalized projected_normal={}'
284-
.format(projected_normal))
282+
pvl_logger.debug('renormalized projected_normal=%s',
283+
projected_normal)
285284

286285
# calculation of surface_azimuth
287286
# 1. Find the angle.

0 commit comments

Comments
 (0)