diff --git a/docs/sphinx/source/whatsnew.rst b/docs/sphinx/source/whatsnew.rst index 9c0089047c..dadc0ecaef 100644 --- a/docs/sphinx/source/whatsnew.rst +++ b/docs/sphinx/source/whatsnew.rst @@ -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 diff --git a/docs/sphinx/source/whatsnew/v0.2.2.txt b/docs/sphinx/source/whatsnew/v0.2.2.txt new file mode 100644 index 0000000000..f3d9ea2040 --- /dev/null +++ b/docs/sphinx/source/whatsnew/v0.2.2.txt @@ -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 diff --git a/pvlib/atmosphere.py b/pvlib/atmosphere.py index 4e6b4ae624..0ba96bf855 100644 --- a/pvlib/atmosphere.py +++ b/pvlib/atmosphere.py @@ -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))) ) diff --git a/pvlib/clearsky.py b/pvlib/clearsky.py index f1c9fe0f2f..cd16284d21 100644 --- a/pvlib/clearsky.py +++ b/pvlib/clearsky.py @@ -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'] @@ -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 @@ -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 @@ -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 * diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py index 7fc7d6b92d..4c03e16ba5 100644 --- a/pvlib/irradiance.py +++ b/pvlib/irradiance.py @@ -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 @@ -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. @@ -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) @@ -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) @@ -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) @@ -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. diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index c055b2d8b2..66bff02a1f 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -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': @@ -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) diff --git a/pvlib/solarposition.py b/pvlib/solarposition.py index 00eccd9cd1..1420cf92e8 100644 --- a/pvlib/solarposition.py +++ b/pvlib/solarposition.py @@ -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 diff --git a/pvlib/spa.py b/pvlib/spa.py index c7dac9fb17..b6a2962d8d 100644 --- a/pvlib/spa.py +++ b/pvlib/spa.py @@ -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: diff --git a/pvlib/tmy.py b/pvlib/tmy.py index be70caa633..9e5d1678de 100644 --- a/pvlib/tmy.py +++ b/pvlib/tmy.py @@ -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 diff --git a/pvlib/tools.py b/pvlib/tools.py index 90b188b007..b1637a2fb7 100644 --- a/pvlib/tools.py +++ b/pvlib/tools.py @@ -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 diff --git a/pvlib/tracking.py b/pvlib/tracking.py index 033b578084..0c49f17c2d 100644 --- a/pvlib/tracking.py +++ b/pvlib/tracking.py @@ -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. @@ -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. @@ -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.