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
9030c3f9
Commit
9030c3f9
authored
5 years ago
by
JOSSOUD Olivier
Browse files
Options
Downloads
Patches
Plain Diff
Use config file to set a default data directory.
parent
04b377db
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
config/settings.ini
+3
-0
3 additions, 0 deletions
config/settings.ini
src/config.py
+31
-0
31 additions, 0 deletions
src/config.py
src/main.py
+7
-1
7 additions, 1 deletion
src/main.py
src/uim/conductcalibuim.py
+5
-2
5 additions, 2 deletions
src/uim/conductcalibuim.py
src/utils.py
+10
-0
10 additions, 0 deletions
src/utils.py
with
56 additions
and
3 deletions
config/settings.ini
0 → 100644
+
3
−
0
View file @
9030c3f9
[DATA_SOURCE]
# Absolute path of the base directory where the data files produced by the CFA are be stored.
absolute_root_dir
=
/homel/ojossoud/_temp/data_cfa
This diff is collapsed.
Click to expand it.
src/config.py
0 → 100644
+
31
−
0
View file @
9030c3f9
from
configobj
import
ConfigObj
import
utils
import
threading
class
Config
:
def
__init__
(
self
,
filename
):
self
.
full_filename
=
"
../config/
"
+
filename
self
.
config_parser
=
ConfigObj
(
self
.
full_filename
)
self
.
file_access_lock
=
threading
.
Lock
()
def
write
(
self
,
instrument
,
key
,
value
):
self
.
file_access_lock
.
acquire
()
self
.
config_parser
.
reload
()
self
.
config_parser
[
instrument
][
key
]
=
str
(
value
)
self
.
config_parser
.
write
()
self
.
file_access_lock
.
release
()
def
read
(
self
,
instrument
,
key
):
self
.
file_access_lock
.
acquire
()
self
.
config_parser
.
reload
()
try
:
value
=
self
.
config_parser
[
instrument
][
key
]
except
:
self
.
file_access_lock
.
release
()
raise
self
.
file_access_lock
.
release
()
value
=
utils
.
convert_to_numeric
(
value
)
return
value
This diff is collapsed.
Click to expand it.
src/main.py
+
7
−
1
View file @
9030c3f9
...
@@ -3,12 +3,18 @@ import sys
...
@@ -3,12 +3,18 @@ import sys
from
PyQt5.QtWidgets
import
QApplication
from
PyQt5.QtWidgets
import
QApplication
from
PyQt5.QtCore
import
QThread
from
PyQt5.QtCore
import
QThread
from
config
import
Config
from
gui.mainwindow
import
MainWindow
from
gui.mainwindow
import
MainWindow
from
dataprovider.conductcalibprovider
import
ConductCalibProvider
from
dataprovider.conductcalibprovider
import
ConductCalibProvider
from
uim.conductcalibuim
import
ConductCalibUim
from
uim.conductcalibuim
import
ConductCalibUim
########################################################################################################################
# CONFIG
########################################################################################################################
config
=
Config
(
"
settings.ini
"
)
########################################################################################################################
########################################################################################################################
# WINDOWS
# WINDOWS
...
@@ -27,7 +33,7 @@ conduct_prvd = ConductCalibProvider()
...
@@ -27,7 +33,7 @@ conduct_prvd = ConductCalibProvider()
# GUI MANAGERS
# GUI MANAGERS
########################################################################################################################
########################################################################################################################
conductcalib_uim
=
ConductCalibUim
(
conduct_prvd
,
main_window_ui
)
conductcalib_uim
=
ConductCalibUim
(
conduct_prvd
,
main_window_ui
,
config
)
########################################################################################################################
########################################################################################################################
# LAUNCH APPLICATION
# LAUNCH APPLICATION
...
...
This diff is collapsed.
Click to expand it.
src/uim/conductcalibuim.py
+
5
−
2
View file @
9030c3f9
...
@@ -5,6 +5,7 @@ import pandas as pd
...
@@ -5,6 +5,7 @@ import pandas as pd
import
numpy
as
np
import
numpy
as
np
import
utils
import
utils
from
config
import
Config
from
dataprovider.conductcalibprovider
import
ConductCalibProvider
from
dataprovider.conductcalibprovider
import
ConductCalibProvider
from
dataprovider.conductcalibprovider
import
CalibRun
from
dataprovider.conductcalibprovider
import
CalibRun
from
gui.uimainwindow
import
Ui_MainWindow
from
gui.uimainwindow
import
Ui_MainWindow
...
@@ -27,9 +28,10 @@ class ConductCalibUim:
...
@@ -27,9 +28,10 @@ class ConductCalibUim:
VALIDAUTO_COL
=
5
VALIDAUTO_COL
=
5
VALIDMANUAL_COL
=
6
VALIDMANUAL_COL
=
6
def
__init__
(
self
,
conduct_prvd
:
ConductCalibProvider
,
main_ui
:
Ui_MainWindow
):
def
__init__
(
self
,
conduct_prvd
:
ConductCalibProvider
,
main_ui
:
Ui_MainWindow
,
config
:
Config
):
self
.
main_ui
=
main_ui
self
.
main_ui
=
main_ui
self
.
conduct_prvd
=
conduct_prvd
self
.
conduct_prvd
=
conduct_prvd
self
.
config
=
config
self
.
current_calib_run
=
None
self
.
current_calib_run
=
None
self
.
current_channel
=
int
(
self
.
main_ui
.
conduct_combobox_channel
.
currentText
())
self
.
current_channel
=
int
(
self
.
main_ui
.
conduct_combobox_channel
.
currentText
())
...
@@ -50,7 +52,8 @@ class ConductCalibUim:
...
@@ -50,7 +52,8 @@ class ConductCalibUim:
self
.
main_ui
.
conduct_tablewidget_run
.
cellClicked
.
connect
(
self
.
highlight_step
)
self
.
main_ui
.
conduct_tablewidget_run
.
cellClicked
.
connect
(
self
.
highlight_step
)
def
load_data
(
self
):
def
load_data
(
self
):
directory
=
QFileDialog
.
getExistingDirectory
()
directory
=
QFileDialog
.
getExistingDirectory
(
directory
=
self
.
config
.
read
(
"
DATA_SOURCE
"
,
"
absolute_root_dir
"
)
+
"
/conduct_calib
"
)
# If user cancels directory selection, do nothing.
# If user cancels directory selection, do nothing.
if
directory
==
""
:
if
directory
==
""
:
...
...
This diff is collapsed.
Click to expand it.
src/utils.py
+
10
−
0
View file @
9030c3f9
...
@@ -2,6 +2,7 @@ import pyqtgraph as pg
...
@@ -2,6 +2,7 @@ import pyqtgraph as pg
import
datetime
import
datetime
import
pandas
as
pd
import
pandas
as
pd
import
numpy
as
np
import
numpy
as
np
import
re
from
PyQt5.QtWidgets
import
QTableWidget
from
PyQt5.QtWidgets
import
QTableWidget
from
PyQt5.QtGui
import
QColor
from
PyQt5.QtGui
import
QColor
...
@@ -16,6 +17,15 @@ def datetime64_to_epoch_ms(datetimes_list: np.ndarray) -> list:
...
@@ -16,6 +17,15 @@ def datetime64_to_epoch_ms(datetimes_list: np.ndarray) -> list:
return
[
float
(
instant
)
/
1e9
for
instant
in
datetimes_list
]
return
[
float
(
instant
)
/
1e9
for
instant
in
datetimes_list
]
def
convert_to_numeric
(
str_value
:
str
):
"""
Convert a string to float (if there is a
"
.
"
in the string) or to integer, if possible.
"""
if
re
.
match
(
"
^-?\d+\.\d+$
"
,
str_value
):
return
float
(
str_value
)
elif
re
.
match
(
"
^-?\d+$
"
,
str_value
):
return
int
(
str_value
)
else
:
return
str_value
####################################################################
####################################################################
# Graphics
# Graphics
...
...
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