Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Plio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aflab
astrogeology
Plio
Commits
95aacb31
Commit
95aacb31
authored
7 years ago
by
Kelvin Rodriguez
Browse files
Options
Downloads
Patches
Plain Diff
updated test
parent
01596787
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
plio/date/marstime.py
+0
-84
0 additions, 84 deletions
plio/date/marstime.py
plio/date/tests/test_marstime.py
+53
-3
53 additions, 3 deletions
plio/date/tests/test_marstime.py
with
53 additions
and
87 deletions
plio/date/marstime.py
+
0
−
84
View file @
95aacb31
...
@@ -16,7 +16,6 @@ import datetime
...
@@ -16,7 +16,6 @@ import datetime
from
numpy
import
pi
,
floor
,
array
,
shape
,
cos
,
sin
,
ceil
,
arcsin
,
arccos
,
arange
,
abs
from
numpy
import
pi
,
floor
,
array
,
shape
,
cos
,
sin
,
ceil
,
arcsin
,
arccos
,
arange
,
abs
from
collections
import
namedtuple
from
collections
import
namedtuple
d2R
=
pi
/
180.
d2R
=
pi
/
180.
def
getJD
(
iTime
):
def
getJD
(
iTime
):
...
@@ -75,34 +74,6 @@ def getJ2000(iTime):
...
@@ -75,34 +74,6 @@ def getJ2000(iTime):
return
jdTT
-
2451545.0
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
):
def
getMarsParams
(
j2000
):
'''
Mars time parameters
'''
'''
Mars time parameters
'''
...
@@ -288,17 +259,6 @@ def SZAGetTime(sza,date, lon, lat):
...
@@ -288,17 +259,6 @@ def SZAGetTime(sza,date, lon, lat):
return
thisDate
,
thisSza
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
):
def
getLTfromTime
(
iTime
,
lon
):
'''
The mars local solar time from an earth time and mars longitude.
'''
The mars local solar time from an earth time and mars longitude.
...
@@ -311,47 +271,3 @@ def getLTfromTime(iTime,lon):
...
@@ -311,47 +271,3 @@ def getLTfromTime(iTime,lon):
LTST
=
LMST
+
timedata
.
EOT
*
(
24
/
360.
)
LTST
=
LMST
+
timedata
.
EOT
*
(
24
/
360.
)
return
LTST
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
'
)
This diff is collapsed.
Click to expand it.
plio/date/tests/test_marstime.py
+
53
−
3
View file @
95aacb31
import
numpy
as
np
import
numpy
as
np
import
unittest
import
unittest
import
datetime
from
..
import
marstime
from
..
import
marstime
class
TestMarsTime
(
unittest
.
TestCase
):
class
TestSmallJulian
(
unittest
.
TestCase
):
def
equality_test
(
self
):
def
runTest
(
self
):
earth
=
marstime
.
getUTCfromLS
(
24
,
130
)
earth
=
marstime
.
getUTCfromLS
(
24
,
130
)
mars
=
marstime
.
getMTfromTime
(
earth
)
mars
=
marstime
.
getMTfromTime
(
earth
)
assert
(
earth
.
date
()
==
marstime
.
getUTCfromLS
(
mars
.
year
,
mars
.
ls
).
date
())
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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment