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
d02b77e6
Commit
d02b77e6
authored
9 years ago
by
Jeremy M Fee
Browse files
Options
Downloads
Patches
Plain Diff
Validate requested output channels, and raise more meaningful exception
parent
9d0c6ec4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
geomagio/edge/EdgeFactory.py
+3
-4
3 additions, 4 deletions
geomagio/edge/EdgeFactory.py
geomagio/iaga2002/IAGA2002Writer.py
+6
-1
6 additions, 1 deletion
geomagio/iaga2002/IAGA2002Writer.py
geomagio/pcdcp/PCDCPWriter.py
+7
-1
7 additions, 1 deletion
geomagio/pcdcp/PCDCPWriter.py
with
16 additions
and
6 deletions
geomagio/edge/EdgeFactory.py
+
3
−
4
View file @
d02b77e6
...
@@ -17,7 +17,7 @@ import obspy.core
...
@@ -17,7 +17,7 @@ import obspy.core
from
datetime
import
datetime
from
datetime
import
datetime
from
obspy
import
earthworm
from
obspy
import
earthworm
from
obspy.core
import
UTCDateTime
from
obspy.core
import
UTCDateTime
from
..
import
ChannelConverter
from
..
import
ChannelConverter
,
TimeseriesUtility
from
..TimeseriesFactory
import
TimeseriesFactory
from
..TimeseriesFactory
import
TimeseriesFactory
from
..TimeseriesFactoryException
import
TimeseriesFactoryException
from
..TimeseriesFactoryException
import
TimeseriesFactoryException
from
..ObservatoryMetadata
import
ObservatoryMetadata
from
..ObservatoryMetadata
import
ObservatoryMetadata
...
@@ -183,12 +183,11 @@ class EdgeFactory(TimeseriesFactory):
...
@@ -183,12 +183,11 @@ class EdgeFactory(TimeseriesFactory):
if
(
starttime
is
None
or
endtime
is
None
):
if
(
starttime
is
None
or
endtime
is
None
):
starttime
,
endtime
=
self
.
_get_stream_start_end_times
(
timeseries
)
starttime
,
endtime
=
self
.
_get_stream_start_end_times
(
timeseries
)
for
channel
in
channels
:
for
channel
in
channels
:
if
timeseries
.
select
(
channel
=
channel
).
count
()
==
0
:
if
timeseries
.
select
(
channel
=
channel
).
count
()
==
0
:
raise
TimeseriesFactoryException
(
raise
TimeseriesFactoryException
(
'
Missing channel
"
%s
"
for output
'
%
channel
)
'
Missing channel
"
%s
"
for output
, available
channel
s %s
'
%
(
channel
,
str
(
TimeseriesUtility
.
get_channels
(
timeseries
))))
for
channel
in
channels
:
for
channel
in
channels
:
self
.
_put_channel
(
timeseries
,
observatory
,
channel
,
type
,
self
.
_put_channel
(
timeseries
,
observatory
,
channel
,
type
,
interval
,
starttime
,
endtime
)
interval
,
starttime
,
endtime
)
...
...
This diff is collapsed.
Click to expand it.
geomagio/iaga2002/IAGA2002Writer.py
+
6
−
1
View file @
d02b77e6
...
@@ -3,7 +3,7 @@ from cStringIO import StringIO
...
@@ -3,7 +3,7 @@ from cStringIO import StringIO
from
datetime
import
datetime
from
datetime
import
datetime
import
numpy
import
numpy
import
textwrap
import
textwrap
from
..
import
ChannelConverter
from
..
import
ChannelConverter
,
TimeseriesUtility
from
..TimeseriesFactoryException
import
TimeseriesFactoryException
from
..TimeseriesFactoryException
import
TimeseriesFactoryException
from
..Util
import
create_empty_trace
from
..Util
import
create_empty_trace
import
IAGA2002Parser
import
IAGA2002Parser
...
@@ -30,6 +30,11 @@ class IAGA2002Writer(object):
...
@@ -30,6 +30,11 @@ class IAGA2002Writer(object):
channels: array_like
channels: array_like
channels to be written from timeseries object
channels to be written from timeseries object
"""
"""
for
channel
in
channels
:
if
timeseries
.
select
(
channel
=
channel
).
count
()
==
0
:
raise
TimeseriesFactoryException
(
'
Missing channel
"
%s
"
for output, available channels %s
'
%
(
channel
,
str
(
TimeseriesUtility
.
get_channels
(
timeseries
))))
stats
=
timeseries
[
0
].
stats
stats
=
timeseries
[
0
].
stats
if
len
(
channels
)
!=
4
:
if
len
(
channels
)
!=
4
:
self
.
_pad_to_four_channels
(
timeseries
,
channels
)
self
.
_pad_to_four_channels
(
timeseries
,
channels
)
...
...
This diff is collapsed.
Click to expand it.
geomagio/pcdcp/PCDCPWriter.py
+
7
−
1
View file @
d02b77e6
...
@@ -3,7 +3,8 @@ import numpy
...
@@ -3,7 +3,8 @@ import numpy
import
PCDCPParser
import
PCDCPParser
from
cStringIO
import
StringIO
from
cStringIO
import
StringIO
from
datetime
import
datetime
from
datetime
import
datetime
from
geomagio
import
ChannelConverter
from
..
import
ChannelConverter
,
TimeseriesUtility
from
..TimeseriesFactoryException
import
TimeseriesFactoryException
from
obspy.core
import
Stream
from
obspy.core
import
Stream
...
@@ -26,6 +27,11 @@ class PCDCPWriter(object):
...
@@ -26,6 +27,11 @@ class PCDCPWriter(object):
channels : array_like
channels : array_like
Channels to be written from timeseries object.
Channels to be written from timeseries object.
"""
"""
for
channel
in
channels
:
if
timeseries
.
select
(
channel
=
channel
).
count
()
==
0
:
raise
TimeseriesFactoryException
(
'
Missing channel
"
%s
"
for output, available channels %s
'
%
(
channel
,
str
(
TimeseriesUtility
.
get_channels
(
timeseries
))))
stats
=
timeseries
[
0
].
stats
stats
=
timeseries
[
0
].
stats
out
.
write
(
self
.
_format_header
(
stats
))
out
.
write
(
self
.
_format_header
(
stats
))
out
.
write
(
self
.
_format_data
(
timeseries
,
channels
))
out
.
write
(
self
.
_format_data
(
timeseries
,
channels
))
...
...
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