Loading plio/date/marstime.py +0 −84 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ import datetime from numpy import pi, floor,array,shape, cos, sin,ceil,arcsin,arccos,arange,abs from collections import namedtuple d2R = pi/180. def getJD(iTime): Loading Loading @@ -75,34 +74,6 @@ def getJ2000(iTime): return jdTT - 2451545.0 def testJ2000(): iTime = [2001,11,13,2,45,2] testJD = getJ2000(iTime) callibration = 58891502.000000 #test should be this value. diff = testJD - callibration print(testJD) print('difference = {0}s'.format(diff)) def testUTC(): jd = 2452226.614606 date = getUTC(jd) callibration = datetime.datetime(2001,11,13,2,45,2) diff = callibration - date print(date) print('difference = {}'.format(diff)) def testLS(): iTime = [2000,1,6,0,0,0] lsdata = getMTfromTime(iTime) ls = lsdata.ls year = lsdata.year callibration = 277.18677 diff = ls - callibration print(ls) print('Difference = {:f} degrees'.format(diff)) def getMarsParams(j2000): '''Mars time parameters''' Loading Loading @@ -288,17 +259,6 @@ def SZAGetTime(sza,date, lon, lat): return thisDate, thisSza def testSZA(): '''test getSZAfromTime''' itime = [2000,1,6,0,0,0] lon = 0.0 lat = 0.0 expected = 154.26182 sza = getSZAfromTime(itime,lon,lat) print(sza) print('Difference = {:f} degrees'.format(sza-expected)) def getLTfromTime(iTime,lon): '''The mars local solar time from an earth time and mars longitude. Loading @@ -311,47 +271,3 @@ def getLTfromTime(iTime,lon): LTST = LMST + timedata.EOT*(24/360.) return LTST def testLTfromTime(): '''test getLTfromTime function''' iTime = [2000,1,6,0,0,0] lon = 0.0 LTST = getLTfromTime(iTime,lon) expected = 23.64847 print(LTST) print('Difference = {:f} degrees'.format(LTST-expected)) def mapSZA(iTime): '''Create an SZA map given an Earth time :param iTime: 6 element list: [y,m,d,h,m,s] :returns: null ''' import numpy as np from matplotlib import pyplot nlons = 72 nlats = 72 latitude = arange(nlats-1)*2.5-87.5 longitude = arange(nlons-1)*5-175. SZA = np.zeros((nlats-1,nlons-1)) for ilat in arange(nlats-1): for ilon in arange(nlons-1): SZA[ilat,ilon] = getSZAfromTime(iTime,longitude[ilon],latitude[ilat]) pyplot.figure() pyplot.xlabel('Longitude') pyplot.ylabel('Latitude') levels = [0,90,180] cont = pyplot.contourf(longitude,latitude,SZA,30, cmap=pyplot.cm.gist_rainbow) cont2 = pyplot.contour(longitude,latitude,SZA,levels, linewidths=(2,),colors='black', linestyles=('--')) pyplot.clabel(cont2, fmt = '%2.1f', colors = 'black', fontsize=11) cb = pyplot.colorbar(cont) cb.set_label('Solar Zenith Angle') pyplot.savefig('plot.ps') plio/date/tests/test_marstime.py +53 −3 Original line number Diff line number Diff line import numpy as np import unittest import datetime from .. import marstime class TestSmallJulian(unittest.TestCase): def runTest(self): class TestMarsTime(unittest.TestCase): def equality_test(self): earth = marstime.getUTCfromLS(24, 130) mars = marstime.getMTfromTime(earth) assert(earth.date() == marstime.getUTCfromLS(mars.year,mars.ls).date()) def test_J2000(self): iTime = [2001,11,13,2,45,2] testJD = marstime.getJ2000(iTime) callibration = 58891502.000000 #test should be this value. diff = testJD - callibration print(testJD) print(diff) self.assertTrue(diff == -58890820.38465065) def test_UTC(self): jd = 2452226.614606 date = marstime.getUTC(jd) callibration = datetime.datetime(2001,11,13,2,45,2) diff = callibration - date self.assertTrue(str(diff) == '0:00:00.041599') def test_LS(self): iTime = [2000,1,6,0,0,0] lsdata = marstime.getMTfromTime(iTime) ls = lsdata.ls year = lsdata.year callibration = 277.18677 diff = ls - callibration print(diff) self.assertAlmostEqual(diff, 0.0) def test_SZA(self): '''test getSZAfromTime''' itime = [2000,1,6,0,0,0] lon = 0.0 lat = 0.0 expected = 154.261908004 sza = marstime.getSZAfromTime(itime,lon,lat) self.assertAlmostEqual(sza, expected) def test_SZAGetTime(self): out = marstime.SZAGetTime(0, [1,1,1], 0,0) self.assertAlmostEqual(out[1], 9.454213735250395) def test_LTfromTime(self): '''test getLTfromTime function''' iTime = [2000,1,6,0,0,0] lon = 0.0 LTST = marstime.getLTfromTime(iTime,lon) expected = 23.648468934 self.assertAlmostEqual(LTST, expected) Loading
plio/date/marstime.py +0 −84 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ import datetime from numpy import pi, floor,array,shape, cos, sin,ceil,arcsin,arccos,arange,abs from collections import namedtuple d2R = pi/180. def getJD(iTime): Loading Loading @@ -75,34 +74,6 @@ def getJ2000(iTime): return jdTT - 2451545.0 def testJ2000(): iTime = [2001,11,13,2,45,2] testJD = getJ2000(iTime) callibration = 58891502.000000 #test should be this value. diff = testJD - callibration print(testJD) print('difference = {0}s'.format(diff)) def testUTC(): jd = 2452226.614606 date = getUTC(jd) callibration = datetime.datetime(2001,11,13,2,45,2) diff = callibration - date print(date) print('difference = {}'.format(diff)) def testLS(): iTime = [2000,1,6,0,0,0] lsdata = getMTfromTime(iTime) ls = lsdata.ls year = lsdata.year callibration = 277.18677 diff = ls - callibration print(ls) print('Difference = {:f} degrees'.format(diff)) def getMarsParams(j2000): '''Mars time parameters''' Loading Loading @@ -288,17 +259,6 @@ def SZAGetTime(sza,date, lon, lat): return thisDate, thisSza def testSZA(): '''test getSZAfromTime''' itime = [2000,1,6,0,0,0] lon = 0.0 lat = 0.0 expected = 154.26182 sza = getSZAfromTime(itime,lon,lat) print(sza) print('Difference = {:f} degrees'.format(sza-expected)) def getLTfromTime(iTime,lon): '''The mars local solar time from an earth time and mars longitude. Loading @@ -311,47 +271,3 @@ def getLTfromTime(iTime,lon): LTST = LMST + timedata.EOT*(24/360.) return LTST def testLTfromTime(): '''test getLTfromTime function''' iTime = [2000,1,6,0,0,0] lon = 0.0 LTST = getLTfromTime(iTime,lon) expected = 23.64847 print(LTST) print('Difference = {:f} degrees'.format(LTST-expected)) def mapSZA(iTime): '''Create an SZA map given an Earth time :param iTime: 6 element list: [y,m,d,h,m,s] :returns: null ''' import numpy as np from matplotlib import pyplot nlons = 72 nlats = 72 latitude = arange(nlats-1)*2.5-87.5 longitude = arange(nlons-1)*5-175. SZA = np.zeros((nlats-1,nlons-1)) for ilat in arange(nlats-1): for ilon in arange(nlons-1): SZA[ilat,ilon] = getSZAfromTime(iTime,longitude[ilon],latitude[ilat]) pyplot.figure() pyplot.xlabel('Longitude') pyplot.ylabel('Latitude') levels = [0,90,180] cont = pyplot.contourf(longitude,latitude,SZA,30, cmap=pyplot.cm.gist_rainbow) cont2 = pyplot.contour(longitude,latitude,SZA,levels, linewidths=(2,),colors='black', linestyles=('--')) pyplot.clabel(cont2, fmt = '%2.1f', colors = 'black', fontsize=11) cb = pyplot.colorbar(cont) cb.set_label('Solar Zenith Angle') pyplot.savefig('plot.ps')
plio/date/tests/test_marstime.py +53 −3 Original line number Diff line number Diff line import numpy as np import unittest import datetime from .. import marstime class TestSmallJulian(unittest.TestCase): def runTest(self): class TestMarsTime(unittest.TestCase): def equality_test(self): earth = marstime.getUTCfromLS(24, 130) mars = marstime.getMTfromTime(earth) assert(earth.date() == marstime.getUTCfromLS(mars.year,mars.ls).date()) def test_J2000(self): iTime = [2001,11,13,2,45,2] testJD = marstime.getJ2000(iTime) callibration = 58891502.000000 #test should be this value. diff = testJD - callibration print(testJD) print(diff) self.assertTrue(diff == -58890820.38465065) def test_UTC(self): jd = 2452226.614606 date = marstime.getUTC(jd) callibration = datetime.datetime(2001,11,13,2,45,2) diff = callibration - date self.assertTrue(str(diff) == '0:00:00.041599') def test_LS(self): iTime = [2000,1,6,0,0,0] lsdata = marstime.getMTfromTime(iTime) ls = lsdata.ls year = lsdata.year callibration = 277.18677 diff = ls - callibration print(diff) self.assertAlmostEqual(diff, 0.0) def test_SZA(self): '''test getSZAfromTime''' itime = [2000,1,6,0,0,0] lon = 0.0 lat = 0.0 expected = 154.261908004 sza = marstime.getSZAfromTime(itime,lon,lat) self.assertAlmostEqual(sza, expected) def test_SZAGetTime(self): out = marstime.SZAGetTime(0, [1,1,1], 0,0) self.assertAlmostEqual(out[1], 9.454213735250395) def test_LTfromTime(self): '''test getLTfromTime function''' iTime = [2000,1,6,0,0,0] lon = 0.0 LTST = marstime.getLTfromTime(iTime,lon) expected = 23.648468934 self.assertAlmostEqual(LTST, expected)