Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SOHViewer
Manage
Activity
Members
Labels
Plan
Issues
14
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
5
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
244ac453
Commit
244ac453
authored
1 year ago
by
Lan Dam
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into i145_jerk_dps_click_not_show_info
parents
87d308a4
af926184
No related branches found
No related tags found
1 merge request
!165
Fix SOH info not show for bottom of Jerk/DPS and display all info lines for the case data point clicked matches more than one SOH lines.
Pipeline
#2972
passed with stage
in 3 minutes and 17 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
sohstationviewer/database/extract_data.py
+30
-11
30 additions, 11 deletions
sohstationviewer/database/extract_data.py
sohstationviewer/database/soh.db
+0
-0
0 additions, 0 deletions
sohstationviewer/database/soh.db
tests/database/test_extract_data.py
+38
-8
38 additions, 8 deletions
tests/database/test_extract_data.py
with
68 additions
and
19 deletions
sohstationviewer/database/extract_data.py
+
30
−
11
View file @
244ac453
...
...
@@ -18,18 +18,10 @@ def get_chan_plot_info(org_chan_id: str, data_type: str,
:return info of channel read from DB which is used for plotting
"""
chan
=
org_chan_id
if
org_chan_id
.
startswith
(
'
EX
'
):
chan
=
'
EX?
'
if
org_chan_id
.
startswith
(
'
VM
'
):
chan
=
'
VM?
'
if
org_chan_id
.
startswith
(
'
MassPos
'
):
chan
=
'
MassPos?
'
chan
=
convert_actual_channel_to_db_channel_w_question_mark
(
chan
)
if
org_chan_id
.
startswith
(
'
DS
'
):
chan
=
'
SEISMIC
'
if
org_chan_id
.
startswith
(
'
Event DS
'
):
chan
=
'
Event DS?
'
if
org_chan_id
.
startswith
(
'
Disk Usage
'
):
chan
=
'
Disk Usage?
'
if
dbConf
[
'
seisRE
'
].
match
(
chan
):
chan
=
'
SEISMIC
'
# The valueColors for each color mode is stored in a separate column.
...
...
@@ -74,7 +66,16 @@ def get_chan_plot_info(org_chan_id: str, data_type: str,
return
chan_db_info
[
0
]
def
get_convert_factor
(
chan_id
,
data_type
):
def
get_convert_factor
(
chan_id
:
str
,
data_type
:
str
)
->
float
:
"""
Get the convert factor to convert data from count (value read from file)
to actual value to display.
:param chan_id: actual channel name read from file
:param data_type: type of data in data set
:return: converting factor
"""
chan_id
=
convert_actual_channel_to_db_channel_w_question_mark
(
chan_id
)
sql
=
f
"
SELECT convertFactor FROM Channels WHERE channel=
'
{
chan_id
}
'
"
\
f
"
AND dataType=
'
{
data_type
}
'"
ret
=
execute_db
(
sql
)
...
...
@@ -84,6 +85,24 @@ def get_convert_factor(chan_id, data_type):
return
None
def
convert_actual_channel_to_db_channel_w_question_mark
(
chan_id
:
str
)
->
str
:
"""
The digit in channel end with a digit is represented with the question
mark
'
?
'
in DB. This function change the real channel name to DB
channel name with
'
?
'
.
:param chan_id: real channel name
:return chan_id: channel name with
'
?
'
at the end if available
"""
sql
=
"
SELECT * FROM Channels WHERE channel like
'
%?
'"
ret
=
execute_db
(
sql
)
question_channels
=
[
c
[
0
][:
-
1
]
for
c
in
ret
]
if
any
(
chan_id
.
startswith
(
x
)
for
x
in
question_channels
):
if
chan_id
[
-
1
].
isdigit
():
# to prevent the case prefix similar to prefix of channel w/o ?
chan_id
=
chan_id
[:
-
1
]
+
'
?
'
return
chan_id
def
get_seismic_chan_label
(
chan_id
):
"""
Get label for chan_id in which data stream can use chan_id for label while
...
...
This diff is collapsed.
Click to expand it.
sohstationviewer/database/soh.db
+
0
−
0
View file @
244ac453
No preview for this file type
This diff is collapsed.
Click to expand it.
tests/database/test_extract_data.py
+
38
−
8
View file @
244ac453
...
...
@@ -6,11 +6,13 @@ from sohstationviewer.database.extract_data import (
get_signature_channels
,
get_color_def
,
get_color_ranges
,
convert_actual_channel_to_db_channel_w_question_mark
,
get_convert_factor
)
class
Test
ExtractData
(
unittest
.
TestCase
):
def
test_
get_chan_plot_info_
good_soh_channel_and_data_type
(
self
):
class
Test
GetChanPlotInfo
(
unittest
.
TestCase
):
def
test_good_soh_channel_and_data_type
(
self
):
"""
Test basic functionality of get_chan_plot_info - channel and data type
combination exists in database table `Channels`
...
...
@@ -27,7 +29,7 @@ class TestExtractData(unittest.TestCase):
self
.
assertDictEqual
(
get_chan_plot_info
(
'
SOH/Data Def
'
,
'
RT130
'
),
expected_result
)
def
test_
get_chan_plot_info_
masspos_channel
(
self
):
def
test_masspos_channel
(
self
):
with
self
.
subTest
(
"
Mass position
'
VM
'"
):
expected_result
=
{
'
channel
'
:
'
VM1
'
,
'
plotType
'
:
'
linesMasspos
'
,
...
...
@@ -54,7 +56,7 @@ class TestExtractData(unittest.TestCase):
self
.
assertDictEqual
(
get_chan_plot_info
(
'
MassPos1
'
,
'
RT130
'
),
expected_result
)
def
test_
get_chan_plot_info_
seismic_channel
(
self
):
def
test_seismic_channel
(
self
):
with
self
.
subTest
(
"
RT130 Seismic
"
):
expected_result
=
{
'
channel
'
:
'
DS2
'
,
'
plotType
'
:
'
linesSRate
'
,
...
...
@@ -81,7 +83,7 @@ class TestExtractData(unittest.TestCase):
self
.
assertDictEqual
(
get_chan_plot_info
(
'
LHE
'
,
'
Q330
'
),
expected_result
)
def
test_
get_chan_plot_info_
data_type_is_unknown
(
self
):
def
test_data_type_is_unknown
(
self
):
"""
Test basic functionality of get_chan_plot_info - data type is the
string
'
Unknown
'
.
...
...
@@ -113,7 +115,7 @@ class TestExtractData(unittest.TestCase):
get_chan_plot_info
(
'
LCE
'
,
'
Unknown
'
),
expected_result
)
def
test_
get_chan_plot_info_
bad_channel_or_data_type
(
self
):
def
test_bad_channel_or_data_type
(
self
):
"""
Test basic functionality of get_chan_plot_info - channel and data type
combination does not exist in database table Channels and data type is
...
...
@@ -159,7 +161,9 @@ class TestExtractData(unittest.TestCase):
self
.
assertDictEqual
(
get_chan_plot_info
(
'
SOH/Data Def
'
,
'
Q330
'
),
expected_result
)
def
test_get_seismic_chan_label_good_channel_id
(
self
):
class
TestGetSeismicChanLabel
(
unittest
.
TestCase
):
def
test_good_channel_id
(
self
):
"""
Test basic functionality of get_seismic_chan_label - channel ID ends
in one of the keys in conf.dbSettings.dbConf[
'
seisLabel
'
] or
...
...
@@ -174,7 +178,7 @@ class TestExtractData(unittest.TestCase):
self
.
assertEqual
(
get_seismic_chan_label
(
'
DS-TEST-CHANNEL
'
),
'
DS-TEST-CHANNEL
'
)
def
test_
get_chan_label_
bad_channel_id
(
self
):
def
test_bad_channel_id
(
self
):
"""
Test basic functionality of get_seismic_chan_label - channel ID does
not end in one of the keys in conf.dbSettings.dbConf[
'
seisLabel
'
]
...
...
@@ -182,16 +186,22 @@ class TestExtractData(unittest.TestCase):
"""
self
.
assertRaises
(
IndexError
,
get_seismic_chan_label
,
''
)
class
TestGetSignatureChannels
(
unittest
.
TestCase
):
def
test_get_signature_channels
(
self
):
"""
Test basic functionality of get_signature_channels
"""
self
.
assertIsInstance
(
get_signature_channels
(),
dict
)
class
TestGetColorDef
(
unittest
.
TestCase
):
def
test_get_color_def
(
self
):
"""
Test basic functionality of get_color_def
"""
colors
=
get_color_def
()
expected_colors
=
[
'
K
'
,
'
U
'
,
'
C
'
,
'
G
'
,
'
Y
'
,
'
R
'
,
'
M
'
,
'
E
'
]
self
.
assertListEqual
(
colors
,
expected_colors
)
class
TestGetColorRanges
(
unittest
.
TestCase
):
def
test_get_color_ranges
(
self
):
"""
Test basic functionality of get_color_ranges
"""
names
,
all_counts
,
all_display_strings
=
get_color_ranges
()
...
...
@@ -212,3 +222,23 @@ class TestExtractData(unittest.TestCase):
# Check that each list of strings to display have enough items
for
display_strings
in
all_display_strings
:
self
.
assertEqual
(
len
(
display_strings
),
num_color_def
+
1
)
class
TestConvertActualChannelToDBChannelWQuestionMark
(
unittest
.
TestCase
):
def
test_question_channel
(
self
):
ret
=
convert_actual_channel_to_db_channel_w_question_mark
(
'
VM1
'
)
self
.
assertEqual
(
ret
,
'
VM?
'
)
def
test_non_question_channel
(
self
):
ret
=
convert_actual_channel_to_db_channel_w_question_mark
(
'
VCO
'
)
self
.
assertEqual
(
ret
,
'
VCO
'
)
class
TestGetConvertFactor
(
unittest
.
TestCase
):
def
test_question_channel
(
self
):
ret
=
get_convert_factor
(
'
VM1
'
,
'
Centaur
'
)
self
.
assertEqual
(
ret
,
10
**
(
-
6
))
def
test_non_question_channel
(
self
):
ret
=
get_convert_factor
(
'
VEP
'
,
'
Q330
'
)
self
.
assertEqual
(
ret
,
0.15
)
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