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..22658ee 100644 --- a/Pysolar/constants.py +++ b/Pysolar/constants.py @@ -40,7 +40,8 @@ """ -def buildPolyFit((a, b, c, d)): +def buildPolyFit(params): + (a, b, c, d) = params 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/radiation.py b/Pysolar/radiation.py index b9616e0..2cf4704 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 @@ """ 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 . -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 @@ import math import pytz from pytz import all_timezones -import solar +from . import solar # Some default constants diff --git a/setup.py b/setup.py index 97d6193..eaab3a0 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,9 @@ 'Topic :: Scientific/Engineering', 'Topic :: Scientific/Engineering :: Atmospheric Science', 'Topic :: Scientific/Engineering :: Mathematics', - 'Topic :: Software Development :: Libraries :: Python Modules'] + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 3'] setup(name='Pysolar',