[Python-modules-commits] [python-pysolar] 10/18: julian.py: fixed omission of microseconds testsolar.py: increased precision of tests Please enter the commit message for your changes.

Wolfgang Borgert debacle at moszumanska.debian.org
Fri Oct 3 23:36:09 UTC 2014


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

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

commit 89fa0d190dacb5c73f13e6a042bc88ad4cfd5156
Author: Brandon Stafford <brandon at pingswept.org>
Date:   Wed May 21 20:12:23 2008 -0400

    julian.py: fixed omission of microseconds
    testsolar.py: increased precision of tests
    Please enter the commit message for your changes.
---
 julian.py    | 14 +++++++-------
 testsolar.py |  4 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/julian.py b/julian.py
index 208c097..02758ec 100644
--- a/julian.py
+++ b/julian.py
@@ -28,13 +28,13 @@ def GetJulianDay(utc_datetime):	# based on NREL/TP-560-34302 by Andreas and Reda
 								# does not accept years before 0 because of bounds check on Python's datetime.year field
 	year = utc_datetime.year
 	month = utc_datetime.month
-	if(month <= 2):		# shift to accomodate leap years?
-		year = year - 1
-		month = month + 12
-	day = utc_datetime.day + (((utc_datetime.hour * 3600.0) + (utc_datetime.minute * 60.0) + utc_datetime.second) / 86400.0)
-	gregorian_offset = 2 - math.floor(year / 100) + math.floor(math.floor(year / 100) / 4)
-	julian_day = math.floor(365.25*(year + 4716)) + math.floor(30.6001 *(month + 1)) + day - 1524.5
-	if (julian_day <= 2299160):
+	if(month <= 2.0):		# shift to accomodate leap years?
+		year = year - 1.0
+		month = month + 12.0
+	day = utc_datetime.day + (((utc_datetime.hour * 3600.0) + (utc_datetime.minute * 60.0) + utc_datetime.second + utc_datetime.microsecond) / 86400.0)
+	gregorian_offset = 2.0 - (year // 100.0) + ((year // 100.0) // 4.0)
+	julian_day = math.floor(365.25 * (year + 4716.0)) + math.floor(30.6001 * (month + 1.0)) + day - 1524.5
+	if (julian_day <= 2299160.0):
 		return julian_day # before October 5, 1852
 	else:
 		return julian_day + gregorian_offset # after October 5, 1852
diff --git a/testsolar.py b/testsolar.py
index e4db0de..894078b 100644
--- a/testsolar.py
+++ b/testsolar.py
@@ -77,7 +77,7 @@ class testSolar(unittest.TestCase):
 		self.assertAlmostEqual(0.0037927819922933584, self.jme, 12) # value not validated
 
 	def testGetGeocentricLongitude(self):
-		self.assertAlmostEqual(204.0182635175, self.geocentric_longitude, 4) # value from Reda and Andreas (2005)
+		self.assertAlmostEqual(204.0182635175, self.geocentric_longitude, 10) # value from Reda and Andreas (2005)
 
 	def testGetGeocentricLatitude(self):
 		self.assertAlmostEqual(0.0001011219, self.geocentric_latitude, 9) # value from Reda and Andreas (2005)
@@ -96,7 +96,7 @@ class testSolar(unittest.TestCase):
 		self.assertAlmostEqual(-0.0057113603, self.aberration_correction, 9) # value not validated
 
 	def testGetApparentSunLongitude(self):
-		self.assertAlmostEqual(204.0085537528, self.apparent_sun_longitude, 4) # value from Reda and Andreas (2005)
+		self.assertAlmostEqual(204.0085537528, self.apparent_sun_longitude, 10) # value from Reda and Andreas (2005)
 
 	def testGetApparentSiderealTime(self):
 		self.assertAlmostEqual(318.5119, self.apparent_sidereal_time, 2) # value derived from Reda and Andreas (2005)

-- 
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