Skip to content

Commit

Permalink
Merge pull request pingswept#11 from robintw/master
Browse files Browse the repository at this point in the history
Add Python 3 support. Thanks, Robin!
  • Loading branch information
pingswept committed Apr 19, 2014
2 parents 8d6a86f + 149a066 commit 86ae355
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Pysolar/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from solar import *
from .solar import *
3 changes: 2 additions & 1 deletion Pysolar/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
6 changes: 3 additions & 3 deletions Pysolar/elevation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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


2 changes: 1 addition & 1 deletion Pysolar/radiation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"""Calculate different kinds of radiation components via default values
"""
import solar
#from . import solar
import math

def GetAirMassRatio(altitude_deg):
Expand Down
8 changes: 4 additions & 4 deletions Pysolar/simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions Pysolar/solar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions Pysolar/testsolar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Pysolar/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import math
import pytz
from pytz import all_timezones
import solar
from . import solar

# Some default constants

Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 86ae355

Please sign in to comment.