Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SOHViewer
Manage
Activity
Members
Labels
Plan
Issues
11
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Software Public
PASSOFT
SOHViewer
Commits
23fbceff
Commit
23fbceff
authored
1 year ago
by
Kien Le
Browse files
Options
Downloads
Patches
Plain Diff
Read ASCII files
parent
770b191b
No related branches found
No related tags found
1 merge request
!132
Fast MSEED read
Pipeline
#2582
passed with stage
in 2 minutes and 53 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sohstationviewer/model/mseed/read_mseed_experiment/mseed_reader.py
+32
-19
32 additions, 19 deletions
...nviewer/model/mseed/read_mseed_experiment/mseed_reader.py
with
32 additions
and
19 deletions
sohstationviewer/model/mseed/read_mseed_experiment/mseed_reader.py
+
32
−
19
View file @
23fbceff
...
@@ -250,25 +250,38 @@ class RecordReader:
...
@@ -250,25 +250,38 @@ class RecordReader:
encoding_format
=
self
.
header_unpacker
.
unpack
(
'
b
'
,
encoding_format
)[
0
]
encoding_format
=
self
.
header_unpacker
.
unpack
(
'
b
'
,
encoding_format
)[
0
]
encoding_format
=
EncodingFormat
(
encoding_format
)
encoding_format
=
EncodingFormat
(
encoding_format
)
# Currently, we are extracting only the first data point in each
if
encoding_format
==
EncodingFormat
.
ASCII
:
# record. The smallest possible amount of bytes we can extract while
# We want to read everything in the record if the encoding is
# guaranteeing that we get the first data point in the record is 8,
# ASCII.
# with Steim encodings and IEEE double precision float needing to use
record_length_exp
=
self
.
header_unpacker
.
unpack
(
# the whole buffer.
'
B
'
,
self
.
blockette_1000
.
record_length
buffer
=
self
.
file
.
read
(
8
)
)[
0
]
encoding_to_decoder
=
{
record_size
=
2
**
record_length_exp
EncodingFormat
.
ASCII
:
(
lambda
a1
,
a2
:
int
(
1
)),
# This name does not make much sense with what we are doing here,
EncodingFormat
.
INT_16_BIT
:
decode_int16
,
# but it will have to do for now.
EncodingFormat
.
INT_24_BIT
:
decode_int24
,
# The size of the record includes the header, so we have to account
EncodingFormat
.
INT_32_BIT
:
decode_int32
,
# for that when grabbing the data.
EncodingFormat
.
IEEE_FLOAT_32_BIT
:
decode_ieee_float
,
first_data_point
=
self
.
file
.
read
(
record_size
-
data_start
)
EncodingFormat
.
IEEE_FLOAT_64_BIT
:
decode_ieee_double
,
else
:
EncodingFormat
.
STEIM_1
:
decode_steim
,
EncodingFormat
.
STEIM_2
:
decode_steim
,
# Currently, we are extracting only the first data point in each
}
# record. The smallest possible amount of bytes we can extract
first_data_point
=
encoding_to_decoder
[
encoding_format
](
# while guaranteeing that we get the first data point in the
buffer
,
self
.
data_unpacker
# record is 8, with Steim encodings and IEEE double precision
)
# float needing to use the whole buffer.
buffer
=
self
.
file
.
read
(
8
)
encoding_to_decoder
=
{
EncodingFormat
.
INT_16_BIT
:
decode_int16
,
EncodingFormat
.
INT_24_BIT
:
decode_int24
,
EncodingFormat
.
INT_32_BIT
:
decode_int32
,
EncodingFormat
.
IEEE_FLOAT_32_BIT
:
decode_ieee_float
,
EncodingFormat
.
IEEE_FLOAT_64_BIT
:
decode_ieee_double
,
EncodingFormat
.
STEIM_1
:
decode_steim
,
EncodingFormat
.
STEIM_2
:
decode_steim
,
}
first_data_point
=
encoding_to_decoder
[
encoding_format
](
buffer
,
self
.
data_unpacker
)
# Seek back to the start of the record so we can call this method again
# Seek back to the start of the record so we can call this method again
# if needed.
# if needed.
self
.
file
.
seek
(
record_start
)
self
.
file
.
seek
(
record_start
)
...
...
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