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
09aa375c
Commit
09aa375c
authored
9 years ago
by
Eddie McWhirter
Browse files
Options
Downloads
Patches
Plain Diff
Clean up comments and code in PCDCPWriter.
parent
099be8ff
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
geomagio/pcdcp/PCDCPWriter.py
+31
-24
31 additions, 24 deletions
geomagio/pcdcp/PCDCPWriter.py
with
31 additions
and
24 deletions
geomagio/pcdcp/PCDCPWriter.py
+
31
−
24
View file @
09aa375c
...
...
@@ -26,30 +26,29 @@ class PCDCPWriter(object):
Channels to be written from timeseries object.
"""
stats
=
timeseries
[
0
].
stats
out
.
write
(
self
.
_format_header
(
stats
,
channels
))
out
.
write
(
self
.
_format_header
(
stats
))
out
.
write
(
self
.
_format_data
(
timeseries
,
channels
))
def
_format_header
(
self
,
name
,
value
):
def
_format_header
(
self
,
stats
):
"""
format headers for PCDCP file
Parameters
----------
name : str
the name to be written
value : str
the value to written.
stats : List
An object with the header values to be written.
Returns
-------
str
a
string formatted to be a single header line in a PCDCP file
A
string formatted to be a single header line in a PCDCP file
.
"""
buf
=
[]
observatory
=
name
.
station
year
=
str
(
name
.
starttime
.
year
)
yearday
=
str
(
name
.
starttime
.
julday
).
zfill
(
3
)
date
=
name
.
starttime
.
strftime
(
"
%d-%b-%y
"
)
space
=
'
'
observatory
=
stats
.
station
year
=
str
(
stats
.
starttime
.
year
)
yearday
=
str
(
stats
.
starttime
.
julday
).
zfill
(
3
)
date
=
stats
.
starttime
.
strftime
(
"
%d-%b-%y
"
)
buf
.
append
(
observatory
+
'
'
+
year
+
'
'
+
yearday
+
'
'
+
date
+
'
HEZF 0.01nT File Version 2.00
\n
'
)
...
...
@@ -60,10 +59,15 @@ class PCDCPWriter(object):
Parameters
----------
timeseries : obspy.core.Stream
stream containing traces with channel listed in channels
channels : sequence
list and order of channel values to output.
timeseries : obspy.core.Stream
Stream containing traces with channel listed in channels
channels : sequence
List and order of channel values to output.
Returns
-------
str
A string formatted to be the data lines in a PCDCP file.
"""
buf
=
[]
if
timeseries
.
select
(
channel
=
'
D
'
):
...
...
@@ -86,11 +90,11 @@ class PCDCPWriter(object):
Parameters
----------
time : datetime
t
imestamp for values
values : sequence
l
ist and order of channel values to output.
i
f value is NaN, self.empty_value is output in its place.
time : datetime
T
imestamp for values
.
values : sequence
L
ist and order of channel values to output.
I
f value is NaN, self.empty_value is output in its place.
Returns
-------
...
...
@@ -99,8 +103,8 @@ class PCDCPWriter(object):
"""
tt
=
time
.
timetuple
()
totalMinutes
=
int
(
tt
.
tm_hour
*
60
+
tt
.
tm_min
)
return
'
{0:0>4d}
'
\
'
{2: >8d} {3: >8d} {4: >8d} {5: >8d}
\n
'
.
format
(
return
'
{0:0>4d}
{2: >8d} {3: >8d} {4: >8d} {5: >8d}
\n
'
.
format
(
totalMinutes
,
int
(
time
.
microsecond
/
1000
),
*
[
self
.
empty_value
if
numpy
.
isnan
(
val
)
else
int
(
round
(
val
*
100
))
for
val
in
values
])
...
...
@@ -113,7 +117,10 @@ class PCDCPWriter(object):
Parameters
----------
timeseries : obspy.core.Stream
timeseries : obspy.core.Stream
Stream containing traces with channel listed in channels
channels : sequence
List and order of channel values to output.
Returns
-------
...
...
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