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
e5b61b9d
Commit
e5b61b9d
authored
1 month ago
by
Erin (Josh) Rigler
Browse files
Options
Downloads
Patches
Plain Diff
RawInputClient Update:
- handle intervals other than 1s and 1m properly
parent
2702d9f4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!386
Overhaul EdgeFactory and MiniSeedFactory for Edge data migration
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
geomagio/edge/RawInputClient.py
+31
-10
31 additions, 10 deletions
geomagio/edge/RawInputClient.py
with
31 additions
and
10 deletions
geomagio/edge/RawInputClient.py
+
31
−
10
View file @
e5b61b9d
...
...
@@ -14,13 +14,16 @@ from time import sleep
"""
MAXINPUTSIZE: Edge uses a short for the data count, so the max input size
for a single data packet to edge is 32767
for a single data packet to edge is *supposed* to be 32767. However, this
was never tested thoroughly until we added support for 10Hz data, when
it was quickly discovered that setting this value caused Edge to hang.
Therefore, MAXINPUTSIZE was reduced to 10_000, which seems to work well.
HOURSECONDS: The number of seconds in an hour. Used as an arbitrary size
for sending seconds data.
DAYMINUTES: The numbers of minutes in a day. Used as the size for sending
minute data, since Edge stores by the day.
"""
MAXINPUTSIZE
=
32767
MAXINPUTSIZE
=
10_000
HOURSECONDS
=
3600
DAYMINUTES
=
1440
...
...
@@ -161,7 +164,7 @@ class RawInputClient:
PARAMETERS
----------
interval: {
'
day
'
,
'
hour
'
,
'
minute
'
,
'
second
'
}
interval: {
'
day
'
,
'
hour
'
,
'
minute
'
,
'
second
'
,
'
tenhertz
'
}
data interval.
trace: obspy.core.trace
...
...
@@ -174,7 +177,11 @@ class RawInputClient:
totalsamps
=
len
(
trace
.
data
)
starttime
=
trace
.
stats
.
starttime
if
interval
==
"
second
"
:
if
interval
==
"
tenhertz
"
:
nsamp
=
MAXINPUTSIZE
timeoffset
=
1
/
10.0
samplerate
=
10.0
elif
interval
==
"
second
"
:
nsamp
=
HOURSECONDS
timeoffset
=
1
samplerate
=
1.0
...
...
@@ -360,7 +367,7 @@ class RawInputClient:
secs
,
usecs
,
self
.
sequence
,
*
samples
*
samples
,
)
return
buf
...
...
@@ -377,16 +384,30 @@ class RawInputClient:
tuple: (ratemantissa, ratedivosor)
ratemantissa: int
ratedivosor: int
NOTE that `ratemantissa` and `ratedivisor` map directly to the SEED
standard
'
s
"
sample rate factor
"
and
"
sample rate multiplier
"
, which
are stored in a miniseed block
'
s fixed data header as 2-byte words;
earlier versions of this method did not handle sample rates lower
than 1/second properly (they did handle 1/minute as a special-case);
"""
if
rate
>
0.9999
:
# sample rates greater or equal to 1/second
# (this will not handle >327 Hz, but for consistency
# with earlier versions, we leave it unchanged)
ratemantissa
=
int
(
rate
*
100
+
0.001
)
ratedivisor
=
-
100
elif
rate
*
60.0
-
1.0
<
0.00000001
:
# one minute data
ratemantissa
=
-
60
ratedivisor
=
1
elif
rate
*
21600
>
1.0001
:
# sample periods between 1 second and 6 hours
# (this should handle 1-minute data identically to
# earlier versions)
ratemantissa
=
-
int
(
1
/
rate
+
0.001
)
ratedivisor
=
-
1
else
:
ratemantissa
=
int
(
rate
*
10000.0
+
0.001
)
ratedivisor
=
-
10000
# sample periods 6 hours and longer
# (this will not handle periods longer than ~22 years)
ratemantissa
=
-
int
(
1
/
rate
/
21600
)
ratedivisor
=
-
21600
return
(
ratemantissa
,
ratedivisor
)
...
...
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