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
67a3ea16
"git@code.usgs.gov:water/dataRetrieval.git" did not exist on "1378d0740896e4180b7f3d9d853ccd4c7478eda5"
Commit
67a3ea16
authored
9 years ago
by
Eddie McWhirter
Browse files
Options
Downloads
Patches
Plain Diff
Add a PCDCPFactory test.
parent
717ae201
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
geomagio/pcdcp/PCDCPFactory.py
+5
-0
5 additions, 0 deletions
geomagio/pcdcp/PCDCPFactory.py
geomagio/pcdcp/PCDCPFactory_test.py
+17
-15
17 additions, 15 deletions
geomagio/pcdcp/PCDCPFactory_test.py
geomagio/pcdcp/PCDCPWriter.py
+1
-0
1 addition, 0 deletions
geomagio/pcdcp/PCDCPWriter.py
with
23 additions
and
15 deletions
geomagio/pcdcp/PCDCPFactory.py
+
5
−
0
View file @
67a3ea16
...
@@ -104,14 +104,18 @@ class PCDCPFactory(TimeseriesFactory):
...
@@ -104,14 +104,18 @@ class PCDCPFactory(TimeseriesFactory):
interval
=
interval
or
self
.
interval
interval
=
interval
or
self
.
interval
days
=
self
.
_get_days
(
starttime
,
endtime
)
days
=
self
.
_get_days
(
starttime
,
endtime
)
timeseries
=
obspy
.
core
.
Stream
()
timeseries
=
obspy
.
core
.
Stream
()
for
day
in
days
:
for
day
in
days
:
url
=
self
.
_get_url
(
observatory
,
day
,
type
,
interval
)
url
=
self
.
_get_url
(
observatory
,
day
,
type
,
interval
)
pcdcpFile
=
read_url
(
url
)
pcdcpFile
=
read_url
(
url
)
timeseries
+=
self
.
parse_string
(
pcdcpFile
)
timeseries
+=
self
.
parse_string
(
pcdcpFile
)
# merge channel traces for multiple days
# merge channel traces for multiple days
timeseries
.
merge
()
timeseries
.
merge
()
# trim to requested start/end time
# trim to requested start/end time
timeseries
.
trim
(
starttime
,
endtime
)
timeseries
.
trim
(
starttime
,
endtime
)
return
timeseries
return
timeseries
def
parse_string
(
self
,
pcdcpString
):
def
parse_string
(
self
,
pcdcpString
):
...
@@ -165,6 +169,7 @@ class PCDCPFactory(TimeseriesFactory):
...
@@ -165,6 +169,7 @@ class PCDCPFactory(TimeseriesFactory):
data
[
channel
])
data
[
channel
])
stream
+=
obspy
.
core
.
Trace
(
data
[
channel
],
stats
)
stream
+=
obspy
.
core
.
Trace
(
data
[
channel
],
stats
)
return
stream
return
stream
def
_get_url
(
self
,
observatory
,
date
,
type
=
'
variation
'
,
interval
=
'
minute
'
):
def
_get_url
(
self
,
observatory
,
date
,
type
=
'
variation
'
,
interval
=
'
minute
'
):
...
...
This diff is collapsed.
Click to expand it.
geomagio/pcdcp/PCDCPFactory_test.py
+
17
−
15
View file @
67a3ea16
...
@@ -5,21 +5,23 @@ from obspy.core.utcdatetime import UTCDateTime
...
@@ -5,21 +5,23 @@ from obspy.core.utcdatetime import UTCDateTime
from
nose.tools
import
assert_equals
from
nose.tools
import
assert_equals
def
test_
_get_days
():
def
test_
parse_string
():
"""
geomagio.pcdcp.PCDCPFactory_test.test_
_get_days
()
"""
geomagio.pcdcp.PCDCPFactory_test.test_
parse_string
()
Call the _get_days method with starttime and endtime separated by more
Send a PCDCP file string in to parse_string to make sure a well formed
than one day.
stream is created with proper values.
Verify it returns all days between the given starttime and endtime.
"""
"""
starttime
=
UTCDateTime
(
'
2014-01-01
'
)
pcdcpString
=
"
BOU 2015 001 01-Jan-15 HEZF 0.01nT File Version 2.00
\n
"
endtime
=
UTCDateTime
(
'
2014-01-07
'
)
+
"
0000 2086167 -5707 4745737 5237768
\n
"
+
"
0001 2086190 -5664 4745737 5237777
\n
"
+
"
0002 2086213 -5638 4745741 5237787
\n
"
+
"
0003 2086239 -5632 4745739 5237796
\n
"
+
"
0004 2086198 -5626 4745743 5237786
\n
"
assert_equals
(
PCDCPFactory
(
''
).
_get_days
(
starttime
,
endtime
),
[
stream
=
PCDCPFactory
().
parse_string
(
pcdcpString
)
UTCDateTime
(
'
2014-01-01
'
),
UTCDateTime
(
'
2014-01-02
'
),
assert_equals
(
type
(
stream
),
obspy
.
core
.
stream
.
Stream
)
UTCDateTime
(
'
2014-01-03
'
),
assert_equals
(
stream
[
0
].
stats
.
network
,
'
NT
'
)
UTCDateTime
(
'
2014-01-04
'
),
assert_equals
(
stream
[
0
].
stats
.
station
,
'
BOU
'
)
UTCDateTime
(
'
2014-01-05
'
),
assert_equals
(
stream
[
0
].
stats
.
starttime
,
UTCDateTime
(
'
2014-01-06
'
),
UTCDateTime
(
'
2015-01-01T00:00:00.000000Z
'
))
UTCDateTime
(
'
2014-01-07
'
)])
This diff is collapsed.
Click to expand it.
geomagio/pcdcp/PCDCPWriter.py
+
1
−
0
View file @
67a3ea16
...
@@ -70,6 +70,7 @@ class PCDCPWriter(object):
...
@@ -70,6 +70,7 @@ class PCDCPWriter(object):
A string formatted to be the data lines in a PCDCP file.
A string formatted to be the data lines in a PCDCP file.
"""
"""
buf
=
[]
buf
=
[]
if
timeseries
.
select
(
channel
=
'
D
'
):
if
timeseries
.
select
(
channel
=
'
D
'
):
d
=
timeseries
.
select
(
channel
=
'
D
'
)
d
=
timeseries
.
select
(
channel
=
'
D
'
)
d
[
0
].
data
=
ChannelConverter
.
get_minutes_from_radians
(
d
[
0
].
data
)
d
[
0
].
data
=
ChannelConverter
.
get_minutes_from_radians
(
d
[
0
].
data
)
...
...
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