Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CFA Analysis
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
JOSSOUD Olivier
CFA Analysis
Commits
1a7b57df
Commit
1a7b57df
authored
5 years ago
by
JOSSOUD Olivier
Browse files
Options
Downloads
Patches
Plain Diff
Explo. Stabilisation time analysis window. Done.
parent
888d938a
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pyqt/stabwindow.ui
+4
-4
4 additions, 4 deletions
pyqt/stabwindow.ui
src/gui/uistabwindow.py
+2
-2
2 additions, 2 deletions
src/gui/uistabwindow.py
src/uim/explouim.py
+82
-10
82 additions, 10 deletions
src/uim/explouim.py
with
88 additions
and
16 deletions
pyqt/stabwindow.ui
+
4
−
4
View file @
1a7b57df
...
...
@@ -6,8 +6,8 @@
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
1
074
</width>
<height>
685
</height>
<width>
1
338
</width>
<height>
713
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
...
...
@@ -62,8 +62,8 @@
<rect>
<x>
10
</x>
<y>
50
</y>
<width>
87
1
</width>
<height>
6
2
1
</height>
<width>
132
1
</width>
<height>
6
5
1
</height>
</rect>
</property>
</widget>
...
...
This diff is collapsed.
Click to expand it.
src/gui/uistabwindow.py
+
2
−
2
View file @
1a7b57df
...
...
@@ -11,7 +11,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class
Ui_StabWindow
(
object
):
def
setupUi
(
self
,
StabWindow
):
StabWindow
.
setObjectName
(
"
StabWindow
"
)
StabWindow
.
resize
(
1
074
,
685
)
StabWindow
.
resize
(
1
338
,
713
)
self
.
horizontalLayoutWidget
=
QtWidgets
.
QWidget
(
StabWindow
)
self
.
horizontalLayoutWidget
.
setGeometry
(
QtCore
.
QRect
(
10
,
10
,
461
,
31
))
self
.
horizontalLayoutWidget
.
setObjectName
(
"
horizontalLayoutWidget
"
)
...
...
@@ -33,7 +33,7 @@ class Ui_StabWindow(object):
self
.
stab_combobox_variable
.
setObjectName
(
"
stab_combobox_variable
"
)
self
.
horizontalLayout
.
addWidget
(
self
.
stab_combobox_variable
)
self
.
stab_graphicsview
=
PlotWidget
(
StabWindow
)
self
.
stab_graphicsview
.
setGeometry
(
QtCore
.
QRect
(
10
,
50
,
87
1
,
6
2
1
))
self
.
stab_graphicsview
.
setGeometry
(
QtCore
.
QRect
(
10
,
50
,
132
1
,
6
5
1
))
self
.
stab_graphicsview
.
setObjectName
(
"
stab_graphicsview
"
)
self
.
retranslateUi
(
StabWindow
)
...
...
This diff is collapsed.
Click to expand it.
src/uim/explouim.py
+
82
−
10
View file @
1a7b57df
...
...
@@ -204,6 +204,8 @@ class ExploUim:
combobox
.
addItem
(
instrument_name
)
def
__update_variables_combobox__
(
self
,
combobox_text
:
str
,
combobox
:
QComboBox
):
if
combobox_text
==
""
:
return
# variables_combobox = self.main_ui.explo_tablewidget_variables.cellWidget(row, self.VARIABLE_COL)
variables_combobox
=
combobox
variables_combobox
.
clear
()
...
...
@@ -547,6 +549,7 @@ class ExploUim:
self
.
stab_plot_item
.
addItem
(
self
.
stab_step_curve
)
self
.
stab_window
.
ui
.
stab_graphicsview
.
setCentralItem
(
self
.
stab_plot_item
)
# Left
self
.
stab_region_left
=
pg
.
LinearRegionItem
(
brush
=
pg
.
mkBrush
(
color
=
[
0
,
0
,
255
,
40
]))
self
.
stab_region_left
.
setZValue
(
10
)
self
.
stab_plot_item
.
addItem
(
self
.
stab_region_left
,
ignoreBounds
=
True
)
...
...
@@ -555,6 +558,7 @@ class ExploUim:
self
.
stab_left_mean_line
=
pg
.
InfiniteLine
(
pen
=
pg
.
mkPen
(
color
=
[
0
,
0
,
255
]),
angle
=
0
)
self
.
stab_plot_item
.
addItem
(
self
.
stab_left_mean_line
)
# Right
self
.
stab_region_right
=
pg
.
LinearRegionItem
(
brush
=
pg
.
mkBrush
(
color
=
[
0
,
255
,
0
,
40
]))
self
.
stab_region_right
.
setZValue
(
10
)
self
.
stab_plot_item
.
addItem
(
self
.
stab_region_right
,
ignoreBounds
=
True
)
...
...
@@ -563,6 +567,22 @@ class ExploUim:
self
.
stab_right_mean_line
=
pg
.
InfiniteLine
(
pen
=
pg
.
mkPen
(
color
=
[
0
,
255
,
0
]),
angle
=
0
)
self
.
stab_plot_item
.
addItem
(
self
.
stab_right_mean_line
)
# High
self
.
stab_high_hline
=
pg
.
InfiniteLine
(
pen
=
pg
.
mkPen
(
color
=
[
255
,
0
,
0
],
style
=
Qt
.
DotLine
),
angle
=
0
)
self
.
stab_plot_item
.
addItem
(
self
.
stab_high_hline
)
self
.
stab_high_vline
=
pg
.
InfiniteLine
(
pen
=
pg
.
mkPen
(
color
=
[
255
,
0
,
0
],
style
=
Qt
.
DotLine
),
angle
=
90
)
self
.
stab_plot_item
.
addItem
(
self
.
stab_high_vline
)
# Low
self
.
stab_low_hline
=
pg
.
InfiniteLine
(
pen
=
pg
.
mkPen
(
color
=
[
255
,
0
,
0
],
style
=
Qt
.
DotLine
),
angle
=
0
)
self
.
stab_plot_item
.
addItem
(
self
.
stab_low_hline
)
self
.
stab_low_vline
=
pg
.
InfiniteLine
(
pen
=
pg
.
mkPen
(
color
=
[
255
,
0
,
0
],
style
=
Qt
.
DotLine
),
angle
=
90
)
self
.
stab_plot_item
.
addItem
(
self
.
stab_low_vline
)
# Time delta text
self
.
stab_time_text
=
pg
.
TextItem
(
anchor
=
(
0.5
,
1
))
self
.
stab_plot_item
.
addItem
(
self
.
stab_time_text
)
self
.
stab_timeseries
=
pd
.
DataFrame
()
def
__update_stab_plot__
(
self
,
var_combobox_text
:
str
):
...
...
@@ -575,7 +595,7 @@ class ExploUim:
# Get data
instrument_log
=
self
.
current_dataset
.
instlogs
[
self
.
stab_window
.
ui
.
stab_combobox_instrument
.
currentText
()]
variable_name
=
self
.
stab_window
.
ui
.
stab_combobox_variable
.
currentText
()
self
.
stab_timeseries
=
instrument_log
.
get_timeseries
(
variable_name
)
self
.
stab_timeseries
=
instrument_log
.
get_timeseries
(
variable_name
)
.
copy
()
# Set data to step curve
x_values
=
self
.
__get_timeseries_x_values__
(
self
.
stab_timeseries
)
...
...
@@ -583,34 +603,86 @@ class ExploUim:
y
=
self
.
__get_timeseries_y_values__
(
self
.
stab_timeseries
),
stepMode
=
True
)
# Convert data in a form more convenient for plot
self
.
stab_timeseries
[
"
datetime
"
]
=
utils
.
pd_time_to_epoch_ms
(
self
.
stab_timeseries
[
"
datetime
"
])
if
not
is_numeric_dtype
(
self
.
stab_timeseries
[
"
value
"
]):
self
.
stab_timeseries
[
"
value
"
]
=
self
.
stab_timeseries
[
"
value_int
"
]
# Get the main windows view box
main_range
=
self
.
plot_item
.
getViewBox
().
viewRange
()
# Place the 2 (right/left) regions
x_min
=
min
(
x_values
)
x_max
=
ma
x
(
x_values
)
x_min
=
m
a
in
_range
[
0
][
0
]
x_max
=
ma
in_range
[
0
][
1
]
x_1_third
=
x_min
+
((
x_max
-
x_min
)
/
3
)
x_2_third
=
x_min
+
2
*
((
x_max
-
x_min
)
/
3
)
self
.
stab_region_left
.
setRegion
([
x_min
,
x_1_third
])
self
.
stab_region_right
.
setRegion
([
x_2_third
,
x_max
])
# Re-calculate the position of the left/right means
self
.
__update_stab_mean__
(
self
.
stab_region_left
,
"
left
"
)
self
.
__update_stab_mean__
(
self
.
stab_region_right
,
"
right
"
)
# X range is the same as main window's plot X range
self
.
stab_plot_item
.
getViewBox
().
setRange
(
xRange
=
(
main_range
[
0
][
0
],
main_range
[
0
][
1
]),
yRange
=
(
main_range
[
1
][
0
],
main_range
[
1
][
1
]),
padding
=
0
)
def
__update_stab_mean__
(
self
,
region
:
pg
.
LinearRegionItem
,
side
:
str
):
df
=
self
.
stab_timeseries
.
copy
()
# Get the selected region's boundaries
xmin
=
region
.
getRegion
()[
0
]
xmax
=
region
.
getRegion
()[
1
]
df
[
"
datetime
"
]
=
utils
.
pd_time_to_epoch_ms
(
df
[
"
datetime
"
])
if
is_numeric_dtype
(
df
[
"
value
"
]):
x_value_var_name
=
"
value
"
else
:
x_value_var_name
=
"
value_int
"
mean
=
df
[(
df
[
"
datetime
"
]
>=
xmin
)
&
(
df
[
"
datetime
"
]
<=
xmax
)][
x_value_var_name
].
mean
()
# Compute x_value's average over the selected region.
mean
=
df
[(
df
[
"
datetime
"
]
>=
xmin
)
&
(
df
[
"
datetime
"
]
<=
xmax
)][
"
value
"
].
mean
()
if
math
.
isnan
(
mean
):
return
# Update global "mean" variable
setattr
(
self
,
"
stab_
"
+
side
+
"
_mean
"
,
mean
)
# Update 'mean' horizontal line position
line
=
getattr
(
self
,
"
stab_
"
+
side
+
"
_mean_line
"
)
line
.
setValue
(
mean
)
self
.
__compute_stab_delta__
()
def
__compute_stab_delta__
(
self
):
pass
# Left
left_mean
=
self
.
stab_left_mean
right_mean
=
self
.
stab_right_mean
high_y
=
max
(
left_mean
,
right_mean
)
low_y
=
min
(
left_mean
,
right_mean
)
ten_prct
=
(
high_y
-
low_y
)
*
0.1
high_minus_ten
=
high_y
-
ten_prct
low_plus_ten
=
low_y
+
ten_prct
# Find timeseries' value where crossing 'high_minus_ten' and 'low_plus_ten'
df
=
self
.
stab_timeseries
.
copy
()
# Keep only the data between both regions.
df
=
df
[(
df
[
"
datetime
"
]
>
self
.
stab_region_left
.
getRegion
()[
1
])
&
(
df
[
"
datetime
"
]
<
self
.
stab_region_right
.
getRegion
()[
0
])
&
(
df
[
"
value
"
]
<
high_minus_ten
)
&
(
df
[
"
value
"
]
>
low_plus_ten
)]
if
df
.
empty
:
return
high_datetime
=
df
.
loc
[
df
[
"
value
"
].
idxmax
()][
"
datetime
"
]
low_datetime
=
df
.
loc
[
df
[
"
value
"
].
idxmin
()][
"
datetime
"
]
# Plot lines
self
.
stab_high_hline
.
setValue
(
high_minus_ten
)
self
.
stab_low_hline
.
setValue
(
low_plus_ten
)
self
.
stab_high_vline
.
setValue
(
high_datetime
)
self
.
stab_low_vline
.
setValue
(
low_datetime
)
# Add text
time_delta
=
high_datetime
-
low_datetime
self
.
stab_time_text
.
setText
(
"
<--
"
+
"
{:.2f}
"
.
format
(
time_delta
)
+
"
s -->
"
)
self
.
stab_time_text
.
setPos
(
low_datetime
+
(
high_datetime
-
low_datetime
)
/
2
,
high_y
)
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