Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
geomag-algorithms
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
ghsc
National Geomagnetism Program
geomag-algorithms
Commits
a214cf3b
Commit
a214cf3b
authored
9 years ago
by
Hal Simpson
Browse files
Options
Downloads
Patches
Plain Diff
Moved gap routines to utilities file.
parent
809fa4af
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
geomagio/TimeseriesFactory.py
+1
-47
1 addition, 47 deletions
geomagio/TimeseriesFactory.py
with
1 addition
and
47 deletions
geomagio/TimeseriesFactory.py
+
1
−
47
View file @
a214cf3b
"""
Abstract Timeseries Factory Interface.
"""
"""
Abstract Timeseries Factory Interface.
"""
import
numpy.ma
as
ma
import
numpy.ma
as
ma
import
obspy
import
obspy
import
numpy
class
TimeseriesFactory
(
object
):
class
TimeseriesFactory
(
object
):
"""
Base class for timeseries factories.
"""
Base class for timeseries factories.
...
@@ -95,50 +96,3 @@ class TimeseriesFactory(object):
...
@@ -95,50 +96,3 @@ class TimeseriesFactory(object):
if any errors occur.
if any errors occur.
"""
"""
raise
NotImplementedError
(
'"
put_timeseries
"
not implemented
'
)
raise
NotImplementedError
(
'"
put_timeseries
"
not implemented
'
)
def
create_gap_stream
(
self
,
timeseries
,
channels
):
gap_stream
=
obspy
.
core
.
Stream
()
for
channel
in
channels
:
for
trace
in
timeseries
.
select
(
channel
=
channel
):
trace
.
data
=
ma
.
masked_invalid
(
trace
.
data
)
for
data
in
trace
.
split
():
gap_stream
+=
data
# gaps are returned from getGaps from the point before, to the
# point after, so remove that point to get the gap.
gaps
=
gap_stream
.
getGaps
()
for
gap
in
gaps
:
gap
[
4
]
=
gap
[
4
]
+
60
gap
[
5
]
=
gap
[
5
]
-
60
# sync gaps across channels
full_gaps
=
[]
gap_cnt
=
len
(
gaps
)
for
i
in
range
(
0
,
gap_cnt
):
gap
=
gaps
[
i
]
if
self
.
_contained_in_gap
(
gap
,
full_gaps
):
continue
starttime
=
gap
[
4
]
endtime
=
gap
[
5
]
for
x
in
range
(
i
+
1
,
gap_cnt
):
nxtgap
=
gaps
[
x
]
if
((
nxtgap
[
4
]
>=
starttime
and
nxtgap
[
4
]
<=
endtime
)
or
(
nxtgap
[
5
]
>=
starttime
and
nxtgap
[
5
]
<=
endtime
)):
if
nxtgap
[
4
]
<
starttime
:
starttime
=
nxtgap
[
4
]
if
nxtgap
[
5
]
>
endtime
:
endtime
=
nxtgap
[
5
]
full_gaps
.
append
([
starttime
,
endtime
])
return
(
full_gaps
,
gaps
)
def
_contained_in_gap
(
self
,
gap
,
gaps
):
starttime
=
gap
[
4
]
endtime
=
gap
[
5
]
for
gap
in
gaps
:
if
starttime
>=
gap
[
0
]
and
endtime
<=
gap
[
1
]:
return
True
return
False
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