Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Shakemap
shakyground2
Commits
d5528c2e
Commit
d5528c2e
authored
May 27, 2021
by
g-weatherill
Browse files
Another fix to the datetime isoformat
parent
ce87885f
Pipeline
#23464
passed with stage
in 11 minutes and 22 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
shakyground2/earthquake.py
View file @
d5528c2e
...
...
@@ -214,7 +214,7 @@ class Earthquake(object):
)
# Time is not necessarily in ISO format, so fix this for use with datetime object
hh
,
mm
,
ss
=
event
[
"time"
].
split
(
":"
)
ss
=
"
{:2.6f}"
.
format
(
float
(
ss
.
replace
(
"Z"
,
""
))
)
ss
=
"
%09.6f"
%
float
(
ss
.
replace
(
"Z"
,
""
))
event_time
=
":"
.
join
([
hh
,
mm
,
ss
])
d_t
=
datetime
.
datetime
.
fromisoformat
(
" "
.
join
([
event
[
"date"
],
event_time
]))
# If the event has a focal mechanism then parse this into the correct format
...
...
tests/earthquake_test.py
View file @
d5528c2e
...
...
@@ -208,3 +208,16 @@ class EarthquakeTestCase(unittest.TestCase):
ns_distance
=
Point
(
0.0
,
bbox
[
1
],
0.0
).
distance
(
Point
(
0.0
,
bbox
[
3
],
0.0
))
self
.
assertAlmostEqual
(
max_dist
,
ew_distance
,
5
)
self
.
assertAlmostEqual
(
max_dist
,
ns_distance
,
5
)
def
test_from_quakeml
(
self
):
# Verifies that the earthquake object can be built from different GEOFON events
event_id_set
=
[
"gfz2021kdvq"
,
"gfz2021keus"
,
"gfz2021kduj"
]
target_string_set
=
[
"gfz2021kdvq 2021-05-25 09:41:17.200000 (29.35200E, -1.74600N, 10.00 km) M 4.39"
,
"gfz2021keus 2021-05-25 22:21:36.400000 (122.49800E, 24.83200N, 10.00 km) M 4.56"
,
"gfz2021kduj 2021-05-25 09:03:03.393825 (29.48394E, -1.78596N, 10.00 km) M 4.59"
,
]
results
=
[]
for
event_id
in
event_id_set
:
results
.
append
(
str
(
Earthquake
.
from_quakeml
(
event_id
)))
self
.
assertListEqual
(
results
,
target_string_set
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment