Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
X
xsocs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
22
Issues
22
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kmap
xsocs
Commits
c6a7dcc7
Commit
c6a7dcc7
authored
Jan 18, 2017
by
Damien Naudet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Preparing the multiple gaussians fit.
parent
edce4b3e
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
320 additions
and
302 deletions
+320
-302
kmap/gui/process/FitWidget.py
kmap/gui/process/FitWidget.py
+74
-20
kmap/gui/project/ProjectNodes.py
kmap/gui/project/ProjectNodes.py
+1
-1
kmap/gui/view/FitView.py
kmap/gui/view/FitView.py
+10
-10
kmap/gui/view/fitview/DropPlotWidget.py
kmap/gui/view/fitview/DropPlotWidget.py
+2
-2
kmap/gui/view/fitview/FitModel.py
kmap/gui/view/fitview/FitModel.py
+7
-8
kmap/io/FitH5.py
kmap/io/FitH5.py
+226
-261
No files found.
kmap/gui/process/FitWidget.py
View file @
c6a7dcc7
...
...
@@ -33,7 +33,7 @@ from collections import OrderedDict
from
silx.gui
import
qt
as
Qt
from
...io.QSpaceH5
import
QSpaceH5
from
...io.FitH5
import
FitH5Writer
from
...io.FitH5
import
FitH5Writer
,
FitH5QAxis
from
..widgets.Containers
import
GroupBox
from
..widgets.Input
import
StyledLineEdit
from
..widgets.FileChooser
import
FileChooser
...
...
@@ -181,34 +181,88 @@ class FitWidget(Qt.QDialog):
results
=
peak_fit
(
self
.
__qspaceFile
,
fit_type
=
self
.
__fitType
,
roiIndices
=
self
.
__roiIndices
)
with
FitH5Writer
(
self
.
__selectedFile
,
mode
=
'w'
)
as
fitH5
:
entry
=
results
.
fit_name
process
=
results
.
fit_name
entry
=
results
.
entry
fitH5
.
create_entry
(
entry
)
fitH5
.
create_process
(
entry
,
process
)
fitH5
.
set_scan_x
(
entry
,
results
.
sample_x
)
fitH5
.
set_scan_y
(
entry
,
results
.
sample_y
)
fitH5
.
set_status
(
entry
,
process
,
results
.
status
)
fitH5
.
set_qx
(
entry
,
results
.
q_x
)
fitH5
.
set_qy
(
entry
,
results
.
q_y
)
fitH5
.
set_qz
(
entry
,
results
.
q_z
)
for
resName
,
data
in
results
.
q_x_results
.
items
():
fitH5
.
set_qx_result
(
entry
,
process
,
resName
,
data
)
for
resName
,
data
in
results
.
q_y_results
.
items
():
fitH5
.
set_qy_result
(
entry
,
process
,
resName
,
data
)
for
resName
,
data
in
results
.
q_z_results
.
items
():
fitH5
.
set_qz_result
(
entry
,
process
,
resName
,
data
)
processes
=
results
.
processes
()
for
process
in
processes
:
fitH5
.
create_process
(
entry
,
process
)
for
param
in
results
.
params
(
process
):
xresult
=
results
.
results
(
process
,
param
,
results
.
QX_AXIS
)
yresult
=
results
.
results
(
process
,
param
,
results
.
QY_AXIS
)
zresult
=
results
.
results
(
process
,
param
,
results
.
QZ_AXIS
)
xstatus
=
results
.
qx_status
(
process
)
ystatus
=
results
.
qy_status
(
process
)
zstatus
=
results
.
qz_status
(
process
)
fitH5
.
set_qx_result
(
entry
,
process
,
param
,
xresult
)
fitH5
.
set_qy_result
(
entry
,
process
,
param
,
yresult
)
fitH5
.
set_qz_result
(
entry
,
process
,
param
,
zresult
)
fitH5
.
set_status
(
entry
,
process
,
FitH5QAxis
.
qx_axis
,
xstatus
)
fitH5
.
set_status
(
entry
,
process
,
FitH5QAxis
.
qy_axis
,
ystatus
)
fitH5
.
set_status
(
entry
,
process
,
FitH5QAxis
.
qz_axis
,
zstatus
)
# with FitH5Writer(self.__selectedFile, mode='w') as fitH5:
# entry = results.fit_name
# process = results.fit_name
# fitH5.create_entry(entry)
# fitH5.create_process(entry, process)
#
# fitH5.set_scan_x(entry, results.sample_x)
# fitH5.set_scan_y(entry, results.sample_y)
# fitH5.set_status(entry, process, results.status)
# fitH5.set_qx(entry, results.q_x)
# fitH5.set_qy(entry, results.q_y)
# fitH5.set_qz(entry, results.q_z)
#
# for resName, data in results.q_x_results.items():
# fitH5.set_qx_result(entry,
# process,
# resName,
# data)
# for resName, data in results.q_y_results.items():
# fitH5.set_qy_result(entry,
# process,
# resName,
# data)
# for resName, data in results.q_z_results.items():
# fitH5.set_qz_result(entry,
# process,
# resName,
# data)
self
.
__fitFile
=
self
.
__selectedFile
self
.
_setStatus
(
FitWidget
.
StatusCompleted
)
...
...
kmap/gui/project/ProjectNodes.py
View file @
c6a7dcc7
...
...
@@ -153,7 +153,7 @@ class FitButton(EditorMixin, Qt.QWidget):
dialog
.
selectFile
(
os
.
path
.
join
(
workdir
,
itemBasename
))
if
dialog
.
exec_
():
csvPath
=
dialog
.
selectedFiles
()[
0
]
fitItem
.
fitH5
.
export_
txt
(
csvPath
)
fitItem
.
fitH5
.
export_
csv
(
fitItem
.
fitH5
.
entries
()[
0
],
csvPath
)
@
H5NodeClassDef
(
'FitGroup'
,
...
...
kmap/gui/view/FitView.py
View file @
c6a7dcc7
...
...
@@ -36,7 +36,7 @@ from silx.gui import qt as Qt
from
kmap.gui.project.XsocsH5Factory
import
h5NodeToProjectItem
from
kmap.gui.widgets.Containers
import
GroupBox
from
kmap.io.FitH5
import
FitH5
from
kmap.io.FitH5
import
FitH5
,
FitH5QAxis
from
..widgets.XsocsPlot2D
import
XsocsPlot2D
from
kmap.gui.model.TreeView
import
TreeView
...
...
@@ -218,7 +218,7 @@ class FitView(Qt.QMainWindow):
if
processes
:
process
=
processes
[
0
]
if
process
==
'
LeastSq
'
:
if
process
==
'
gaussian
'
:
_initLeastSq
(
self
.
__plots
,
fitH5
.
filename
,
entry
,
process
)
elif
process
==
'Centroid'
:
_initCentroid
(
self
.
__plots
,
fitH5
.
filename
,
entry
,
process
)
...
...
@@ -269,7 +269,7 @@ class FitView(Qt.QMainWindow):
# TODO : refactor
process
=
self
.
__process
if
process
==
'
LeastSq
'
:
if
process
==
'
gaussian
'
:
_plotLeastSq
(
self
.
__fitPlots
,
xIdx
,
fitH5
,
entry
,
process
,
...
...
@@ -319,7 +319,7 @@ def _plotLeastSq(plots, index, fitH5,
xFitQY
=
fitH5
.
get_qy
(
entry
)
xFitQZ
=
fitH5
.
get_qz
(
entry
)
heights
=
fitH5
.
get_result
(
entry
,
process
,
'
height
'
)
heights
=
fitH5
.
get_result
(
entry
,
process
,
'
intensity
'
)
positions
=
fitH5
.
get_result
(
entry
,
process
,
'position'
)
widths
=
fitH5
.
get_result
(
entry
,
process
,
'width'
)
...
...
@@ -408,17 +408,17 @@ def _initLeastSq(plots, fitH5Name, entry, process):
qApp
.
processEvents
()
plots
[
0
].
plotFitResult
(
fitH5Name
,
entry
,
process
,
'position'
,
FitH5
.
qx_axis
)
'position'
,
FitH5
QAxis
.
qx_axis
)
qApp
.
processEvents
()
plots
[
1
].
plotFitResult
(
fitH5Name
,
entry
,
process
,
'position'
,
FitH5
.
qy_axis
)
'position'
,
FitH5
QAxis
.
qy_axis
)
qApp
.
processEvents
()
plots
[
2
].
plotFitResult
(
fitH5Name
,
entry
,
process
,
'position'
,
FitH5
.
qz_axis
)
'position'
,
FitH5
QAxis
.
qz_axis
)
def
_initCentroid
(
plots
,
fitH5Name
,
entry
,
process
):
...
...
@@ -435,13 +435,13 @@ def _initCentroid(plots, fitH5Name, entry, process):
qApp
=
Qt
.
qApp
# plots[0].setVisible(True)
qApp
.
processEvents
()
plots
[
0
].
plotFitResult
(
fitH5Name
,
entry
,
process
,
'position'
,
FitH5
.
qx_axis
)
plots
[
0
].
plotFitResult
(
fitH5Name
,
entry
,
process
,
'position'
,
FitH5
QAxis
.
qx_axis
)
# plots[1].setVisible(True)
qApp
.
processEvents
()
plots
[
1
].
plotFitResult
(
fitH5Name
,
entry
,
process
,
'position'
,
FitH5
.
qy_axis
)
plots
[
1
].
plotFitResult
(
fitH5Name
,
entry
,
process
,
'position'
,
FitH5
QAxis
.
qy_axis
)
# plots[2].setVisible(True)
qApp
.
processEvents
()
plots
[
2
].
plotFitResult
(
fitH5Name
,
entry
,
process
,
'position'
,
FitH5
.
qz_axis
)
plots
[
2
].
plotFitResult
(
fitH5Name
,
entry
,
process
,
'position'
,
FitH5
QAxis
.
qz_axis
)
if
__name__
==
'__main__'
:
...
...
kmap/gui/view/fitview/DropPlotWidget.py
View file @
c6a7dcc7
...
...
@@ -31,7 +31,7 @@ __date__ = "15/09/2016"
from
silx.gui
import
qt
as
Qt
from
kmap.io.FitH5
import
FitH5
from
kmap.io.FitH5
import
FitH5
,
FitH5QAxis
from
...widgets.XsocsPlot2D
import
XsocsPlot2D
...
...
@@ -81,7 +81,7 @@ class DropPlotWidget(XsocsPlot2D):
scan_y
=
h5f
.
scan_y
(
entry
)
self
.
__legend
=
self
.
setPlotData
(
scan_x
,
scan_y
,
data
)
self
.
setGraphTitle
(
result
+
'/'
+
FitH5
.
axis_names
[
q_axis
])
self
.
setGraphTitle
(
result
+
'/'
+
FitH5
QAxis
.
axis_names
[
q_axis
])
if
__name__
==
'__main__'
:
...
...
kmap/gui/view/fitview/FitModel.py
View file @
c6a7dcc7
...
...
@@ -29,7 +29,6 @@ __authors__ = ["D. Naudet"]
__license__
=
"MIT"
__date__
=
"01/01/2017"
import
numpy
as
np
from
silx.gui
import
qt
as
Qt
...
...
@@ -38,7 +37,7 @@ from kmap.gui.model.Model import Model, RootNode
from
kmap.gui.project.Hdf5Nodes
import
H5File
from
kmap.gui.model.ModelDef
import
ModelRoles
from
kmap.io.FitH5
import
FitH5
from
kmap.io.FitH5
import
FitH5
,
FitH5QAxis
from
...widgets.XsocsPlot2D
import
XsocsPlot2D
from
...project.Hdf5Nodes
import
H5Base
,
H5NodeClassDef
...
...
@@ -111,16 +110,16 @@ class FitProcessNode(FitEntryNode):
"""
Node linked to a process group in a FitH5 file.
"""
process
=
property
(
lambda
self
:
self
.
h5Path
.
split
(
'/'
)[
1
])
process
=
property
(
lambda
self
:
self
.
h5Path
.
lstrip
(
'/'
).
split
(
'/'
)[
1
])
def
_loadChildren
(
self
):
base
=
self
.
h5Path
.
rstrip
(
'/'
)
entry
=
self
.
entry
process
=
self
.
process
children
=
[]
print
'PATH'
,
self
.
h5Path
,
self
.
entry
,
self
.
process
with
FitH5
(
self
.
h5File
,
mode
=
'r'
)
as
h5f
:
results
=
h5f
.
result
s
(
entry
,
process
)
results
=
h5f
.
get_result_name
s
(
entry
,
process
)
for
result
in
results
:
child
=
FitResultNode
(
self
.
h5File
,
base
+
'/'
+
result
)
children
.
append
(
child
)
...
...
@@ -203,11 +202,11 @@ class FitModel(Model):
return
super
(
Model
,
self
).
mimeData
(
indexes
)
if
index
.
column
()
==
1
:
q_axis
=
FitH5
.
qx_axis
q_axis
=
FitH5
QAxis
.
qx_axis
elif
index
.
column
()
==
2
:
q_axis
=
FitH5
.
qy_axis
q_axis
=
FitH5
QAxis
.
qy_axis
elif
index
.
column
()
==
3
:
q_axis
=
FitH5
.
qz_axis
q_axis
=
FitH5
QAxis
.
qz_axis
else
:
raise
ValueError
(
'Unexpected column.'
)
...
...
kmap/io/FitH5.py
View file @
c6a7dcc7
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment