Skip to content

Commit 32051dd

Browse files
committed
fix + bug. add more comments. remove more floats
1 parent 06fd22d commit 32051dd

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pvlib/solarposition.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ def ephemeris(time, location, pressure=101325, temperature=12):
271271
# Most comments in this function are from PVLIB_MATLAB or from
272272
# pvlib-python's attempt to understand and fix problems with the
273273
# algorithm. The comments are *not* based on the reference material.
274+
# This helps a little bit:
275+
# http://www.cv.nrao.edu/~rfisher/Ephemerides/times.html
274276

275277
pvl_logger.warning('Using solarposition.ephemeris is discouraged. '
276278
'solarposition.pyephem and solarposition.spa are '
@@ -301,15 +303,14 @@ def ephemeris(time, location, pressure=101325, temperature=12):
301303

302304
# strip out the day of the year and calculate the decimal hour
303305
DayOfYear = time_utc.dayofyear
304-
DecHours = (time_utc.hour + time_utc.minute/60. + time_utc.second/3600.
306+
DecHours = (time_utc.hour + time_utc.minute/60. + time_utc.second/3600. +
305307
time_utc.microsecond/3600.e6)
306308

307309
UnivDate = DayOfYear
308310
UnivHr = DecHours
309311

310312
Yr = Year - 1900
311-
312-
YrBegin = 365 * Yr + np.floor((Yr - 1) / float(4)) - 0.5
313+
YrBegin = 365 * Yr + np.floor((Yr - 1) / 4.) - 0.5
313314

314315
Ezero = YrBegin + UnivDate
315316
T = Ezero / 36525.
@@ -318,7 +319,7 @@ def ephemeris(time, location, pressure=101325, temperature=12):
318319
GMST0 = 6 / 24. + 38 / 1440. + (
319320
45.836 + 8640184.542 * T + 0.0929 * T ** 2) / 86400.
320321
GMST0 = 360 * (GMST0 - np.floor(GMST0))
321-
GMSTi = np.mod(GMST0 + 360 * (1.0027379093 * UnivHr / float(24)), 360)
322+
GMSTi = np.mod(GMST0 + 360 * (1.0027379093 * UnivHr / 24.), 360)
322323

323324
LocAST = np.mod((360 + GMSTi - Longitude), 360)
324325
EpochDate = Ezero + UnivHr / 24.
@@ -357,7 +358,7 @@ def ephemeris(time, location, pressure=101325, temperature=12):
357358
# potential error in the following line
358359
SunEl = np.degrees(np.arcsin((np.cos(LatR) * (np.cos(DecR)) *
359360
(np.cos(HrAngleR)) + np.sin(LatR)*(np.sin(DecR)))))
360-
SolarTime = (180 + HrAngle) / float(15)
361+
SolarTime = (180 + HrAngle) / 15.
361362

362363
# replace with conditional array assignment
363364
Refract = []
@@ -375,7 +376,7 @@ def ephemeris(time, location, pressure=101325, temperature=12):
375376
else:
376377
Refract.append(0)
377378

378-
Refract = (np.array(Refract) * ((283 / float(273 + temperature))) *
379+
Refract = (np.array(Refract) * ((283 / (273. + temperature))) *
379380
pressure / 101325. / 3600.)
380381

381382
SunZen = 90 - SunEl

0 commit comments

Comments
 (0)