Skip to content
Snippets Groups Projects
Commit e5b61b9d authored by Erin (Josh) Rigler's avatar Erin (Josh) Rigler
Browse files

RawInputClient Update:

- handle intervals other than 1s and 1m properly
parent 2702d9f4
No related branches found
No related tags found
1 merge request!386Overhaul EdgeFactory and MiniSeedFactory for Edge data migration
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment