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
c897348b
Commit
c897348b
authored
10 years ago
by
Hal Simpson
Browse files
Options
Downloads
Patches
Plain Diff
updated per comments in git
parent
25d8edab
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
bin/geomag.py
+12
-70
12 additions, 70 deletions
bin/geomag.py
geomagio/Algorithm.py
+5
-4
5 additions, 4 deletions
geomagio/Algorithm.py
geomagio/Controller.py
+2
-5
2 additions, 5 deletions
geomagio/Controller.py
geomagio/XYZAlgorithm.py
+2
-21
2 additions, 21 deletions
geomagio/XYZAlgorithm.py
with
21 additions
and
100 deletions
bin/geomag.py
+
12
−
70
View file @
c897348b
...
@@ -25,66 +25,12 @@ def main():
...
@@ -25,66 +25,12 @@ def main():
Inputs
Inputs
------
------
--input: string
see --help from commandline.
the type of data for input
currently either iaga or edge.
Notes
--output: string
-----
the type of data for ouput
parses command line options using argparse, then calls the controller
currently either iaga or edge.
with instantiated I/O factories, and algorithm(s)
--starttime: string
formatted as a obspy.core.UTCDateTime object
the starttime for data input/output
--endtime: string
formatted as a obspy.core.UTCDateTime object
the endtime for data input/output
--observatory:string
--channels: array_like
list of channels
--type: string
data type
--invterval: string
data interval.
--algorithm: string
name of an algorithm to use.
--xyz-informat: string
The input format/coordinate system of the input file.
geo: geographic coordinate system (xyzf)
mag: magnetic north coordinate system (hdzf)
obs: observatory coordinate system (hezf)
obsd: observatory coordinate system (hdzf)
--xyz-outformat: string
The ouput format/coordinate system of the output file.
geo: geographic coordinate system (xyzf)
mag: magnetic north coordinate system (hdzf)
obs: observatory coordinate system (hezf or hdzf)
--input_iaga_magweb: boolean
indicates to use http://magweb.cr.usgs.gov/data/magnetometer/ as the
source of iaga2002 files.
--input_iaga_url: string
url of iaga2002 files to use as the data source.
--input-iaga-urltemplate: string
template for the subdirectories that files are found in.
example: %(OBS)s/%(interval)s%(type)s/
--input-iaga-filetemplate: string
template for the file name
example: %(obs)s%(ymd)s%(t)s%(i)s.%(i)s
--input-iaga-file: string
the filename of the Iaga2002 file to be read from
--input-iaga-stdin: boolean
indicates the file will be coming from stdin
--output_iaga_file: string
the filename of a new Iaga2002 file to be read to
--output-iaga-url: string
url of directory to write output files in.
--output-iaga-urltemplate: string
template for the subdirectories that files are to be written in.
example: %(OBS)s/%(interval)s%(type)s/
--output-iaga-filetemplate: string
template for the file name
example: %(obs)s%(ymd)s%(t)s%(i)s.%(i)s
--output-iaga-stdout: boolen
indicates output will go to stdout
"""
"""
args
=
parse_args
()
args
=
parse_args
()
...
@@ -101,16 +47,12 @@ def main():
...
@@ -101,16 +47,12 @@ def main():
observatory
=
args
.
observatory
,
observatory
=
args
.
observatory
,
type
=
args
.
type
,
type
=
args
.
type
,
interval
=
args
.
interval
)
interval
=
args
.
interval
)
elif
args
.
input_iaga_file
is
not
None
:
elif
args
.
input_iaga_file
is
not
None
or
args
.
input_iaga_stdin
:
iagaFile
=
open
(
args
.
input_iaga_file
,
'
r
'
).
read
()
if
args
.
input_iaga_file
is
not
None
:
inputfactory
=
iaga2002
.
StreamIAGA2002Factory
(
iagaFile
=
open
(
args
.
input_iaga_file
,
'
r
'
).
read
()
stream
=
iagaFile
,
else
:
observatory
=
args
.
observatory
,
print
>>
sys
.
stderr
,
"
Iaga Input waiting for data from stdin
"
type
=
args
.
type
,
iagaFile
=
sys
.
stdin
.
read
()
interval
=
args
.
interval
)
elif
args
.
input_iaga_stdin
:
print
>>
sys
.
stderr
,
"
Iaga Input waiting for data from stdin
"
iagaFile
=
sys
.
stdin
.
read
()
inputfactory
=
iaga2002
.
StreamIAGA2002Factory
(
inputfactory
=
iaga2002
.
StreamIAGA2002Factory
(
stream
=
iagaFile
,
stream
=
iagaFile
,
observatory
=
args
.
observatory
,
observatory
=
args
.
observatory
,
...
...
This diff is collapsed.
Click to expand it.
geomagio/Algorithm.py
+
5
−
4
View file @
c897348b
...
@@ -14,8 +14,9 @@ class Algorithm(object):
...
@@ -14,8 +14,9 @@ class Algorithm(object):
An algorithm processes a stream of timeseries to produce new timeseries.
An algorithm processes a stream of timeseries to produce new timeseries.
"""
"""
def
__init__
(
self
,
channels
=
None
):
def
__init__
(
self
,
inchannels
=
None
,
outchannels
=
None
):
self
.
_channels
=
channels
self
.
_inchannels
=
inchannels
self
.
_outchannels
=
outchannels
pass
pass
def
process
(
self
,
stream
):
def
process
(
self
,
stream
):
...
@@ -41,7 +42,7 @@ class Algorithm(object):
...
@@ -41,7 +42,7 @@ class Algorithm(object):
array_like
array_like
list of channels the algorithm needs to operate.
list of channels the algorithm needs to operate.
"""
"""
return
self
.
_channels
return
self
.
_
in
channels
def
get_output_channels
(
self
):
def
get_output_channels
(
self
):
"""
Get output channels
"""
Get output channels
...
@@ -51,4 +52,4 @@ class Algorithm(object):
...
@@ -51,4 +52,4 @@ class Algorithm(object):
array_like
array_like
list of channels the algorithm will be returning.
list of channels the algorithm will be returning.
"""
"""
return
self
.
_channels
return
self
.
_
out
channels
This diff is collapsed.
Click to expand it.
geomagio/Controller.py
+
2
−
5
View file @
c897348b
...
@@ -13,7 +13,7 @@ class Controller(object):
...
@@ -13,7 +13,7 @@ class Controller(object):
algorithm: the algorithm(s) that will take procees the timeseries data
algorithm: the algorithm(s) that will take procees the timeseries data
"""
"""
def
__init__
(
self
,
inputFactory
,
outputFactory
,
algorithm
=
None
):
def
__init__
(
self
,
inputFactory
,
outputFactory
,
algorithm
):
self
.
_inputFactory
=
inputFactory
self
.
_inputFactory
=
inputFactory
self
.
_algorithm
=
algorithm
self
.
_algorithm
=
algorithm
self
.
_outputFactory
=
outputFactory
self
.
_outputFactory
=
outputFactory
...
@@ -31,9 +31,6 @@ class Controller(object):
...
@@ -31,9 +31,6 @@ class Controller(object):
input_channels
=
self
.
_algorithm
.
get_input_channels
()
input_channels
=
self
.
_algorithm
.
get_input_channels
()
timeseries
=
self
.
_inputFactory
.
get_timeseries
(
starttime
,
endtime
,
timeseries
=
self
.
_inputFactory
.
get_timeseries
(
starttime
,
endtime
,
channels
=
input_channels
)
channels
=
input_channels
)
if
self
.
_algorithm
is
not
None
:
processed
=
self
.
_algorithm
.
process
(
timeseries
)
processed
=
self
.
_algorithm
.
process
(
timeseries
)
else
:
processed
=
timeseries
output_channels
=
self
.
_algorithm
.
get_output_channels
()
output_channels
=
self
.
_algorithm
.
get_output_channels
()
self
.
_outputFactory
.
put_timeseries
(
processed
,
channels
=
output_channels
)
self
.
_outputFactory
.
put_timeseries
(
processed
,
channels
=
output_channels
)
This diff is collapsed.
Click to expand it.
geomagio/XYZAlgorithm.py
+
2
−
21
View file @
c897348b
...
@@ -33,7 +33,8 @@ class XYZAlgorithm(Algorithm):
...
@@ -33,7 +33,8 @@ class XYZAlgorithm(Algorithm):
"""
"""
def
__init__
(
self
,
informat
=
None
,
outformat
=
None
):
def
__init__
(
self
,
informat
=
None
,
outformat
=
None
):
Algorithm
.
__init__
(
self
)
Algorithm
.
__init__
(
self
,
inchannels
=
CHANNELS
[
self
.
informat
],
outchannels
=
CHANNELS
[
self
.
outformat
])
self
.
informat
=
informat
self
.
informat
=
informat
self
.
outformat
=
outformat
self
.
outformat
=
outformat
...
@@ -54,26 +55,6 @@ class XYZAlgorithm(Algorithm):
...
@@ -54,26 +55,6 @@ class XYZAlgorithm(Algorithm):
return
False
return
False
return
True
return
True
def
get_input_channels
(
self
):
"""
Get input channels
Returns
-------
array_like
list of channels the algorithm needs to operate.
"""
return
CHANNELS
[
self
.
informat
]
def
get_output_channels
(
self
):
"""
Get output channels
Returns
-------
array_like
list of channels the algorithm will be returning.
"""
return
CHANNELS
[
self
.
outformat
]
def
process
(
self
,
timeseries
):
def
process
(
self
,
timeseries
):
"""
converts a timeseries stream into a different coordinate system
"""
converts a timeseries stream into a different coordinate system
...
...
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