Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
parser-cpmd
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nomad-lab
parser-cpmd
Commits
9e3c8a36
Commit
9e3c8a36
authored
9 years ago
by
Lauri Himanen
Browse files
Options
Downloads
Patches
Plain Diff
Removed the use of the pytz module, created own timezone class.
parent
4f8676f1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
parser/parser-cpmd/cpmdparser/versions/cpmd41/mainparser.py
+17
-4
17 additions, 4 deletions
parser/parser-cpmd/cpmdparser/versions/cpmd41/mainparser.py
with
17 additions
and
4 deletions
parser/parser-cpmd/cpmdparser/versions/cpmd41/mainparser.py
+
17
−
4
View file @
9e3c8a36
...
...
@@ -7,8 +7,6 @@ from .commonparser import CPMDCommonParser
from
.inputparser
import
CPMDInputParser
import
re
import
logging
import
time
import
pytz
import
datetime
import
numpy
as
np
logger
=
logging
.
getLogger
(
"
nomad
"
)
...
...
@@ -308,6 +306,21 @@ class CPMDMainParser(MainHierarchicalParser):
#=======================================================================
# misc. functions
def
timestamp_from_string
(
self
,
timestring
):
class
UTCtzinfo
(
datetime
.
tzinfo
):
"""
Class that represents the UTC timezone.
"""
ZERO
=
datetime
.
timedelta
(
0
)
def
utcoffset
(
self
,
dt
):
return
UTCtzinfo
.
ZERO
def
tzname
(
self
,
dt
):
return
"
UTC
"
def
dst
(
self
,
dt
):
return
UTCtzinfo
.
ZERO
"""
Returns the seconds since epoch for the given date and the wall
clock seconds for the given wall clock time. Assumes UTC timezone.
"""
...
...
@@ -316,8 +329,8 @@ class CPMDMainParser(MainHierarchicalParser):
year
,
month
,
day
=
[
int
(
x
)
for
x
in
date
.
split
(
"
-
"
)]
hour
,
minute
,
second
,
msec
=
[
float
(
x
)
for
x
in
re
.
split
(
"
[:.]
"
,
clock_time
)]
date_obj
=
datetime
.
datetime
(
year
,
month
,
day
,
tzinfo
=
pytz
.
utc
)
date_timestamp
=
(
date_obj
-
datetime
.
datetime
(
1970
,
1
,
1
,
tzinfo
=
pytz
.
utc
)).
total_seconds
()
date_obj
=
datetime
.
datetime
(
year
,
month
,
day
,
tzinfo
=
UTCtzinfo
()
)
date_timestamp
=
(
date_obj
-
datetime
.
datetime
(
1970
,
1
,
1
,
tzinfo
=
UTCtzinfo
()
)).
total_seconds
()
wall_time
=
hour
*
3600
+
minute
*
60
+
second
+
0.001
*
msec
return
date_timestamp
,
wall_time
...
...
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