[Python-modules-commits] [python-pysolar] 23/42: After run of 2to3

Wolfgang Borgert debacle at moszumanska.debian.org
Fri Oct 3 23:37:03 UTC 2014


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to tag 0.6
in repository python-pysolar.

commit 10dc22061042c8cd633faea121636fa93603da29
Author: Robin Wilson <robin at rtwilson.com>
Date:   Sat Apr 19 03:53:10 2014 +0100

    After run of 2to3
---
 Pysolar/__init__.py   |  2 +-
 Pysolar/constants.py  |  3 ++-
 Pysolar/elevation.py  |  6 +++---
 Pysolar/query_usno.py | 38 +++++++++++++++++++-------------------
 Pysolar/radiation.py  |  2 +-
 Pysolar/simulate.py   |  8 ++++----
 Pysolar/solar.py      |  8 ++++----
 Pysolar/testsolar.py  |  8 ++++----
 Pysolar/util.py       |  2 +-
 9 files changed, 39 insertions(+), 38 deletions(-)

diff --git a/Pysolar/__init__.py b/Pysolar/__init__.py
index 276ca2c..d018838 100644
--- a/Pysolar/__init__.py
+++ b/Pysolar/__init__.py
@@ -1 +1 @@
-from solar import *
+from .solar import *
diff --git a/Pysolar/constants.py b/Pysolar/constants.py
index 49c1f25..1bd0034 100644
--- a/Pysolar/constants.py
+++ b/Pysolar/constants.py
@@ -40,7 +40,8 @@ See also ftp://ftp.imcce.fr/pub/ephem/planets/vsop87/VSOP87D.ear
 
 """
 
-def buildPolyFit((a, b, c, d)): 
+def buildPolyFit(xxx_todo_changeme): 
+    (a, b, c, d) = xxx_todo_changeme
     return (lambda x: a + b * x + c * x ** 2 + (x ** 3) / d)
 
 def buildPolyDict():
diff --git a/Pysolar/elevation.py b/Pysolar/elevation.py
index 16a0709..9eea89a 100644
--- a/Pysolar/elevation.py
+++ b/Pysolar/elevation.py
@@ -36,7 +36,7 @@ def GetPressureWithElevation(h, Ps=101325.00, Ts=288.15, Tl=-0.0065, Hb=0.0, R=8
 	#M= Molar mass of Earth's atmosphere = 0.0289644 kg/mol
 	#P=Ps*(Ts/((Ts+Tl)*(h-Hb)))^((g*M)/(R*Tl))
 	#returns pressure in pascals
-	if h>11000.0: print"WARNING: Elevation used exceeds the recommended maximum elevation for this function (11,000m)"
+	if h>11000.0: print("WARNING: Elevation used exceeds the recommended maximum elevation for this function (11,000m)")
 	theDenominator = Ts+(Tl*(h-Hb))
 	theExponent=(g*M)/(R*Tl)
 	return Ps*(Ts/theDenominator)**theExponent
@@ -51,12 +51,12 @@ def GetTemperatureWithElevation(h, Ts=288.15, Tl=-0.0065):
 	return Ts+(h*Tl)
 
 def ElevationTest():
-	print "Elevation(m) Pressure(Pa) Temperature(K)"
+	print("Elevation(m) Pressure(Pa) Temperature(K)")
 	h=0
 	for i in range(11):
 		P=GetPressureWithElevation(h)
 		T=GetTemperatureWithElevation(h)
-		print "%i %i %i" % (h, P, T)
+		print("%i %i %i" % (h, P, T))
 		h=h+1000
 
 
diff --git a/Pysolar/query_usno.py b/Pysolar/query_usno.py
index 2906268..bd9f506 100644
--- a/Pysolar/query_usno.py
+++ b/Pysolar/query_usno.py
@@ -20,7 +20,7 @@
 """Tool for requesting data from US Naval Observatory
 
 """
-import datetime, random, time, urllib, urllib2
+import datetime, random, time, urllib.request, urllib.parse, urllib.error, urllib.request, urllib.error, urllib.parse
 import Pysolar as solar
 
 class Ephemeris:
@@ -50,16 +50,16 @@ class EphemerisComparison:
 def RequestEphemerisData(datum):
 	data = EncodeRequest(datum.latitude, datum.longitude, datum.timestamp, datum.elevation)
 	url = 'http://aa.usno.navy.mil/cgi-bin/aa_topocentric2.pl'
-	req = urllib2.Request(url, data)
-	response = urllib2.urlopen(req)
+	req = urllib.request.Request(url, data)
+	response = urllib.request.urlopen(req)
 
 	lines = response.readlines()
 	response.close()
 	#print lines
 	#print lines[21] # should not we do some try catch here?
 	result = lines[21]
-	tokens = filter(lambda x: x not in ' ', result.split(' '))
-	print 'Tokens: \n', tokens
+	tokens = [x for x in result.split(' ') if x not in ' ']
+	print('Tokens: \n', tokens)
 
 	usno_alt = float(tokens[4]) + float(tokens[5])/60.0 + float(tokens[6])/3600.0
 	usno_az = float(tokens[7]) + float(tokens[8])/60.0 + float(tokens[9])/3600.0
@@ -121,7 +121,7 @@ def EncodeRequest(latitude, longitude, timestamp, elevation):
 	
 	params['hh1'] = str(elevation) # height above sea level in meters
 	params['ZZZ'] = 'END'
-	data = urllib.urlencode(params)
+	data = urllib.parse.urlencode(params)
 	return data
 
 def GatherRandomEphemeris():
@@ -136,7 +136,7 @@ def GatherRandomEphemeris():
 	WriteEphemerisDatumToFile(d, 'usno_data.txt')
 
 def PrintEphemerisDatum(datum):
-	print datum.timestamp, datum.latitude, datum.longitude, datum.elevation, datum.azimuth, datum.altitude
+	print(datum.timestamp, datum.latitude, datum.longitude, datum.elevation, datum.azimuth, datum.altitude)
 
 def ReadEphemeridesLog(logname):
 	data = []
@@ -181,19 +181,19 @@ if __name__ == '__main__':
 	az_errors = np.array([c.az_error for c in comps])
 	alt_errors = np.array([c.alt_error for c in comps])
 
-	print '---------------------'
-	print 'Azimuth stats'
-	print 'Mean error: ' + str(np.mean(az_errors))
-	print 'Std dev: ' + str(np.std(az_errors))
-	print 'Min error: ' + str(stats.tmin(az_errors, None))
-	print 'Max error: ' + str(stats.tmax(az_errors, None))
+	print('---------------------')
+	print('Azimuth stats')
+	print('Mean error: ' + str(np.mean(az_errors)))
+	print('Std dev: ' + str(np.std(az_errors)))
+	print('Min error: ' + str(stats.tmin(az_errors, None)))
+	print('Max error: ' + str(stats.tmax(az_errors, None)))
 
-	print '----------------------'
-	print 'Altitude stats'
+	print('----------------------')
+	print('Altitude stats')
 	
-	print 'Mean error: ' + str(np.mean(alt_errors))
-	print 'Std dev: '+ str(np.std(alt_errors))
-	print 'Min error: ' + str(stats.tmin(alt_errors, None))
-	print 'Max error: ' + str(stats.tmax(alt_errors, None))
+	print('Mean error: ' + str(np.mean(alt_errors)))
+	print('Std dev: '+ str(np.std(alt_errors)))
+	print('Min error: ' + str(stats.tmin(alt_errors, None)))
+	print('Max error: ' + str(stats.tmax(alt_errors, None)))
 
 	WriteComparisonsToCSV(comps, 'pysolar_v_usno.csv')
diff --git a/Pysolar/radiation.py b/Pysolar/radiation.py
index b9616e0..862a352 100644
--- a/Pysolar/radiation.py
+++ b/Pysolar/radiation.py
@@ -20,7 +20,7 @@
 """Calculate different kinds of radiation components via default values
 
 """
-import solar
+from . import solar
 import math
 
 def GetAirMassRatio(altitude_deg):
diff --git a/Pysolar/simulate.py b/Pysolar/simulate.py
index d6e85af..8e068a0 100644
--- a/Pysolar/simulate.py
+++ b/Pysolar/simulate.py
@@ -21,8 +21,8 @@
 
 """
 import datetime
-import radiation
-import solar
+from . import radiation
+from . import solar
 from math import *
 
 def BuildTimeList(start_utc_datetime, end_utc_datetime, step_minutes):
@@ -31,7 +31,7 @@ def BuildTimeList(start_utc_datetime, end_utc_datetime, step_minutes):
 	time_list = []
 	span = end_utc_datetime - start_utc_datetime
 	dt = datetime.timedelta(seconds = step)
-	return map(lambda n: start_utc_datetime + dt * n, range((span.days * 86400 + span.seconds) / step))
+	return [start_utc_datetime + dt * n for n in range((span.days * 86400 + span.seconds) / step)]
 
 def CheckAgainstHorizon(power):
     (time, alt, az, radiation, shade) = power
@@ -58,7 +58,7 @@ def SimulateSpan(latitude_deg, longitude_deg, horizon, start_utc_datetime, end_u
 		solar.GetAzimuth(latitude_deg, longitude_deg, time, elevation)
 		) for time in time_list]	
 	power_list = [(time, alt, az, radiation.GetRadiationDirect(time, alt), horizon[int(az)]) for (time, alt, az) in angles_list]
-	return filter(CheckAgainstHorizon, power_list)
+	return list(filter(CheckAgainstHorizon, power_list))
 		
 #		xs = shade.GetXShade(width, 120, azimuth_deg)
 #		ys = shade.GetYShade(height, 120, altitude_deg)
diff --git a/Pysolar/solar.py b/Pysolar/solar.py
index 2235704..af38e90 100644
--- a/Pysolar/solar.py
+++ b/Pysolar/solar.py
@@ -24,9 +24,9 @@ This module contains the most important functions for calculation of the positio
 """
 import math
 import datetime
-import constants
-import julian
-import radiation
+from . import constants
+from . import julian
+from . import radiation
 
 #if __name__ == "__main__":
 def SolarTest():
@@ -40,7 +40,7 @@ def SolarTest():
 		azimuth_deg = GetAzimuth(latitude_deg, longitude_deg, d)
 		power = radiation.GetRadiationDirect(d, altitude_deg)
 		if (altitude_deg > 0):
-			print timestamp, "UTC", altitude_deg, azimuth_deg, power
+			print(timestamp, "UTC", altitude_deg, azimuth_deg, power)
 		d = d + thirty_minutes
 
 def EquationOfTime(day):
diff --git a/Pysolar/testsolar.py b/Pysolar/testsolar.py
index 073b884..e918c17 100644
--- a/Pysolar/testsolar.py
+++ b/Pysolar/testsolar.py
@@ -19,10 +19,10 @@
 #    You should have received a copy of the GNU General Public License along
 #    with Pysolar. If not, see <http://www.gnu.org/licenses/>.
 
-import solar
-import constants
-import julian
-import elevation
+from . import solar
+from . import constants
+from . import julian
+from . import elevation
 import datetime
 import unittest
 
diff --git a/Pysolar/util.py b/Pysolar/util.py
index 8598bb0..dd55e30 100644
--- a/Pysolar/util.py
+++ b/Pysolar/util.py
@@ -35,7 +35,7 @@ from datetime import timedelta
 import math
 import pytz
 from pytz import all_timezones
-import solar
+from . import solar
 
 # Some default constants
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-pysolar.git



More information about the Python-modules-commits mailing list