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
151a1869
Commit
151a1869
authored
May 23, 2017
by
Damien Naudet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the MaxFitter.
parent
bcaa0ad2
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
593 additions
and
74 deletions
+593
-74
xsocs/examples/id01_peak.py
xsocs/examples/id01_peak.py
+2
-2
xsocs/fit/Centroid.py
xsocs/fit/Centroid.py
+54
-5
xsocs/fit/Gaussian.py
xsocs/fit/Gaussian.py
+61
-2
xsocs/fit/MaxFitter.py
xsocs/fit/MaxFitter.py
+121
-0
xsocs/fit/Plotter.py
xsocs/fit/Plotter.py
+0
-7
xsocs/fit/SilxFitter.py
xsocs/fit/SilxFitter.py
+62
-2
xsocs/fit/__init__.py
xsocs/fit/__init__.py
+4
-3
xsocs/gui/process/FitWidget.py
xsocs/gui/process/FitWidget.py
+3
-2
xsocs/gui/view/FitView.py
xsocs/gui/view/FitView.py
+3
-1
xsocs/gui/view/fitview/DropPlotWidget.py
xsocs/gui/view/fitview/DropPlotWidget.py
+2
-2
xsocs/gui/view/fitview/FitModel.py
xsocs/gui/view/fitview/FitModel.py
+10
-1
xsocs/gui/view/intensity/PlotModel.py
xsocs/gui/view/intensity/PlotModel.py
+3
-3
xsocs/gui/view/shift/ShiftView.py
xsocs/gui/view/shift/ShiftView.py
+0
-36
xsocs/gui/widgets/XsocsPlot2D.py
xsocs/gui/widgets/XsocsPlot2D.py
+1
-1
xsocs/process/fit/Fitter.py
xsocs/process/fit/Fitter.py
+25
-0
xsocs/process/fit/__init__.py
xsocs/process/fit/__init__.py
+28
-0
xsocs/process/fit/fitresults.py
xsocs/process/fit/fitresults.py
+1
-1
xsocs/process/fit/peak_fit.py
xsocs/process/fit/peak_fit.py
+9
-4
xsocs/process/fit/sharedresults.py
xsocs/process/fit/sharedresults.py
+202
-0
xsocs/process/setup.py
xsocs/process/setup.py
+1
-0
xsocs/process/test/test_fitter.py
xsocs/process/test/test_fitter.py
+1
-2
No files found.
xsocs/examples/id01_peak.py
View file @
151a1869
import
numpy
as
np
import
os
from
xsocs.process
import
peak_fit
import
numpy
as
np
from
xsocs.process.fit
import
peak_fit
# output directory (some temporary files will also be written there)
workdir
=
'/path/to/workdir/'
...
...
xsocs/fit/Centroid.py
View file @
151a1869
...
...
@@ -35,8 +35,10 @@ import numpy as np
from
.Plotter
import
Plotter
from
..process.Fitter
import
Fitter
from
..process.fitresults
import
FitStatus
from
..process.fit.Fitter
import
Fitter
from
..process.fit.fitresults
import
FitStatus
from
..process.fit.sharedresults
import
FitSharedResults
from
..process.fit.fitresults
import
FitResult
class
CentroidFitter
(
Fitter
):
...
...
@@ -82,12 +84,59 @@ class CentroidFitter(Fitter):
FitStatus
.
FAILED
)
class
CentroidPlotter
(
Plotter
):
class
CentroidResults
(
FitSharedResults
):
def
__init__
(
self
,
n_points
=
None
,
shared_results
=
None
,
shared_status
=
None
,
**
kwargs
):
super
(
CentroidResults
,
self
).
__init__
(
n_points
=
n_points
,
n_params
=
3
,
n_peaks
=
1
,
shared_results
=
shared_results
,
shared_status
=
shared_status
)
def
fit_results
(
self
,
*
args
,
**
kwargs
):
qx_results
=
self
.
_npy_qx_results
qy_results
=
self
.
_npy_qy_results
qz_results
=
self
.
_npy_qz_results
qx_status
=
self
.
_npy_qx_status
qy_status
=
self
.
_npy_qy_status
qz_status
=
self
.
_npy_qz_status
fit_name
=
'Centroid'
results
=
FitResult
(
fit_name
,
*
args
,
**
kwargs
)
results
.
add_qx_result
(
'centroid'
,
'I'
,
qx_results
[:,
0
].
ravel
())
results
.
add_qx_result
(
'centroid'
,
'COM'
,
qx_results
[:,
1
].
ravel
())
results
.
add_qx_result
(
'centroid'
,
'Max'
,
qx_results
[:,
2
].
ravel
())
results
.
set_qx_status
(
qx_status
)
results
.
add_qy_result
(
'centroid'
,
'I'
,
qy_results
[:,
0
].
ravel
())
results
.
add_qy_result
(
'centroid'
,
'COM'
,
qy_results
[:,
1
].
ravel
())
results
.
add_qy_result
(
'centroid'
,
'Max'
,
qy_results
[:,
2
].
ravel
())
results
.
set_qy_status
(
qy_status
)
results
.
add_qz_result
(
'centroid'
,
'I'
,
qz_results
[:,
0
].
ravel
())
results
.
add_qz_result
(
'centroid'
,
'COM'
,
qz_results
[:,
1
].
ravel
())
results
.
add_qz_result
(
'centroid'
,
'Max'
,
qz_results
[:,
2
].
ravel
())
results
.
set_qz_status
(
qz_status
)
return
results
class
CentroidPlotter
(
Plotter
):
def
plotFit
(
self
,
plot
,
x
,
peakParams
):
plot
.
setGraphTitle
(
'
QX
center of mass'
)
plot
.
setGraphTitle
(
'center of mass'
)
for
peakName
,
peak
in
peakParams
.
items
():
center
=
peak
.
get
(
'COM'
)
...
...
xsocs/fit/Gaussian.py
View file @
151a1869
...
...
@@ -37,8 +37,10 @@ from scipy.optimize import leastsq
from
.Plotter
import
Plotter
from
..process.Fitter
import
Fitter
from
..process.fitresults
import
FitStatus
from
..process.fit.Fitter
import
Fitter
from
..process.fit.fitresults
import
FitStatus
from
..process.fit.sharedresults
import
FitSharedResults
from
..process.fit.fitresults
import
FitResult
# Some constants
...
...
@@ -69,6 +71,63 @@ class GaussianFitter(Fitter):
self
.
_shared_results
.
set_qx_results
(
i_fit
,
x_fit
,
success_x
)
class
GaussianResults
(
FitSharedResults
):
def
__init__
(
self
,
n_points
=
None
,
n_peaks
=
1
,
shared_results
=
None
,
shared_status
=
None
):
super
(
GaussianResults
,
self
).
__init__
(
n_points
=
n_points
,
n_params
=
3
,
n_peaks
=
n_peaks
,
shared_results
=
shared_results
,
shared_status
=
shared_status
)
def
fit_results
(
self
,
*
args
,
**
kwargs
):
qx_results
=
self
.
_npy_qx_results
qy_results
=
self
.
_npy_qy_results
qz_results
=
self
.
_npy_qz_results
qx_status
=
self
.
_npy_qx_status
qy_status
=
self
.
_npy_qy_status
qz_status
=
self
.
_npy_qz_status
fit_name
=
'Gaussian'
results
=
FitResult
(
fit_name
,
*
args
,
**
kwargs
)
for
i_peak
in
range
(
self
.
_n_peaks
):
peak_name
=
'gauss_{0}'
.
format
(
i_peak
)
i_start
=
i_peak
*
3
results
.
add_qx_result
(
peak_name
,
'intensity'
,
qx_results
[:,
i_start
].
ravel
())
results
.
add_qx_result
(
peak_name
,
'position'
,
qx_results
[:,
i_start
+
1
].
ravel
())
results
.
add_qx_result
(
peak_name
,
'width'
,
qx_results
[:,
i_start
+
2
].
ravel
())
results
.
add_qy_result
(
peak_name
,
'intensity'
,
qy_results
[:,
i_start
].
ravel
())
results
.
add_qy_result
(
peak_name
,
'position'
,
qy_results
[:,
i_start
+
1
].
ravel
())
results
.
add_qy_result
(
peak_name
,
'width'
,
qy_results
[:,
i_start
+
2
].
ravel
())
results
.
add_qz_result
(
peak_name
,
'intensity'
,
qz_results
[:,
i_start
].
ravel
())
results
.
add_qz_result
(
peak_name
,
'position'
,
qz_results
[:,
i_start
+
1
].
ravel
())
results
.
add_qz_result
(
peak_name
,
'width'
,
qz_results
[:,
i_start
+
2
].
ravel
())
results
.
set_qy_status
(
qy_status
)
results
.
set_qx_status
(
qx_status
)
results
.
set_qz_status
(
qz_status
)
return
results
# 1d Gaussian func
# TODO : optimize
def
gaussian
(
x
,
a
,
c
,
s
):
...
...
xsocs/fit/MaxFitter.py
0 → 100644
View file @
151a1869
#!/usr/bin/python
# coding: utf8
# /*##########################################################################
#
# Copyright (c) 2015-2017 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# ###########################################################################*/
from
__future__
import
absolute_import
__authors__
=
[
"D. Naudet"
]
__date__
=
"01/01/2017"
__license__
=
"MIT"
from
.Plotter
import
Plotter
from
..process.fit.Fitter
import
Fitter
from
..process.fit.fitresults
import
FitStatus
from
..process.fit.sharedresults
import
FitSharedResults
from
..process.fit.fitresults
import
FitResult
class
MaxFitter
(
Fitter
):
"""
Fitter that returns the maximum and its position.
"""
def
fit
(
self
,
i_fit
,
i_cube
,
qx_profile
,
qy_profile
,
qz_profile
):
idx_max
=
qx_profile
.
argmax
()
self
.
_shared_results
.
set_qx_results
(
i_fit
,
[
qx_profile
[
idx_max
],
self
.
_qx
[
idx_max
]],
FitStatus
.
OK
)
idx_max
=
qy_profile
.
argmax
()
self
.
_shared_results
.
set_qy_results
(
i_fit
,
[
qy_profile
[
idx_max
],
self
.
_qy
[
idx_max
]],
FitStatus
.
OK
)
idx_max
=
qz_profile
.
argmax
()
self
.
_shared_results
.
set_qz_results
(
i_fit
,
[
qz_profile
[
idx_max
],
self
.
_qz
[
idx_max
]],
FitStatus
.
OK
)
class
MaxResults
(
FitSharedResults
):
def
__init__
(
self
,
n_points
=
None
,
shared_results
=
None
,
shared_status
=
None
):
super
(
MaxResults
,
self
).
__init__
(
n_points
=
n_points
,
n_params
=
2
,
n_peaks
=
1
,
shared_results
=
shared_results
,
shared_status
=
shared_status
)
def
fit_results
(
self
,
*
args
,
**
kwargs
):
qx_results
=
self
.
_npy_qx_results
qy_results
=
self
.
_npy_qy_results
qz_results
=
self
.
_npy_qz_results
qx_status
=
self
.
_npy_qx_status
qy_status
=
self
.
_npy_qy_status
qz_status
=
self
.
_npy_qz_status
fit_name
=
'Max'
results
=
FitResult
(
fit_name
,
*
args
,
**
kwargs
)
results
.
add_qx_result
(
'max'
,
'max'
,
qx_results
[:,
0
].
ravel
())
results
.
add_qx_result
(
'max'
,
'position'
,
qx_results
[:,
1
].
ravel
())
results
.
set_qx_status
(
qx_status
)
results
.
add_qy_result
(
'max'
,
'max'
,
qy_results
[:,
0
].
ravel
())
results
.
add_qy_result
(
'max'
,
'position'
,
qy_results
[:,
1
].
ravel
())
results
.
set_qy_status
(
qy_status
)
results
.
add_qz_result
(
'max'
,
'max'
,
qz_results
[:,
0
].
ravel
())
results
.
add_qz_result
(
'max'
,
'position'
,
qz_results
[:,
1
].
ravel
())
results
.
set_qz_status
(
qz_status
)
return
results
class
MaxPlotter
(
Plotter
):
def
plotFit
(
self
,
plot
,
x
,
peakParams
):
plot
.
setGraphTitle
(
'Maximum'
)
for
peakName
,
peak
in
peakParams
.
items
():
maximum
=
peak
.
get
(
'max'
)
position
=
peak
.
get
(
'position'
)
plot
.
addXMarker
(
position
,
legend
=
'max_position'
)
def
getPlotTitle
(
self
):
return
'Maximum'
if
__name__
==
'__main__'
:
pass
xsocs/fit/Plotter.py
View file @
151a1869
...
...
@@ -31,13 +31,6 @@ __date__ = "01/01/2017"
__license__
=
"MIT"
import
numpy
as
np
from
scipy.optimize
import
leastsq
from
..process.Fitter
import
Fitter
from
..process.fitresults
import
FitStatus
class
Plotter
(
object
):
def
__init__
(
self
):
super
(
Plotter
,
self
).
__init__
()
...
...
xsocs/fit/SilxFitter.py
View file @
151a1869
...
...
@@ -38,8 +38,10 @@ from silx.math.fit.fitmanager import FitManager
from
.Plotter
import
Plotter
from
..process.Fitter
import
Fitter
from
..process.fitresults
import
FitStatus
from
..process.fit.Fitter
import
Fitter
from
..process.fit.fitresults
import
FitStatus
from
..process.fit.sharedresults
import
FitSharedResults
from
..process.fit.fitresults
import
FitResult
class
SilxFitter
(
Fitter
):
...
...
@@ -148,6 +150,64 @@ class SilxFitter(Fitter):
FitStatus
.
FAILED
)
class
SilxResults
(
FitSharedResults
):
def
__init__
(
self
,
n_points
=
None
,
n_peaks
=
1
,
shared_results
=
None
,
shared_status
=
None
):
super
(
SilxResults
,
self
).
__init__
(
n_points
=
n_points
,
n_params
=
3
,
n_peaks
=
n_peaks
,
shared_results
=
shared_results
,
shared_status
=
shared_status
)
def
fit_results
(
self
,
*
args
,
**
kwargs
):
qx_results
=
self
.
_npy_qx_results
qy_results
=
self
.
_npy_qy_results
qz_results
=
self
.
_npy_qz_results
qx_status
=
self
.
_npy_qx_status
qy_status
=
self
.
_npy_qy_status
qz_status
=
self
.
_npy_qz_status
fit_name
=
'SilxFit'
results
=
FitResult
(
fit_name
,
*
args
,
**
kwargs
)
for
i_peak
in
range
(
self
.
_n_peaks
):
peak_name
=
'gauss_{0}'
.
format
(
i_peak
)
i_start
=
i_peak
*
3
results
.
add_qx_result
(
peak_name
,
'area'
,
qx_results
[:,
i_start
].
ravel
())
results
.
add_qx_result
(
peak_name
,
'position'
,
qx_results
[:,
i_start
+
1
].
ravel
())
results
.
add_qx_result
(
peak_name
,
'fwhm'
,
qx_results
[:,
i_start
+
2
].
ravel
())
results
.
add_qy_result
(
peak_name
,
'area'
,
qy_results
[:,
i_start
].
ravel
())
results
.
add_qy_result
(
peak_name
,
'position'
,
qy_results
[:,
i_start
+
1
].
ravel
())
results
.
add_qy_result
(
peak_name
,
'fwhm'
,
qy_results
[:,
i_start
+
2
].
ravel
())
results
.
add_qz_result
(
peak_name
,
'area'
,
qz_results
[:,
i_start
].
ravel
())
results
.
add_qz_result
(
peak_name
,
'position'
,
qz_results
[:,
i_start
+
1
].
ravel
())
results
.
add_qz_result
(
peak_name
,
'fwhm'
,
qz_results
[:,
i_start
+
2
].
ravel
())
results
.
set_qy_status
(
qy_status
)
results
.
set_qx_status
(
qx_status
)
results
.
set_qz_status
(
qz_status
)
return
results
class
SilxPlotter
(
Plotter
):
def
plotFit
(
self
,
plot
,
x
,
peakParams
):
for
peakName
,
peak
in
peakParams
.
items
():
...
...
xsocs/fit/__init__.py
View file @
151a1869
...
...
@@ -31,6 +31,7 @@ __date__ = "01/01/2017"
__license__
=
"MIT"
from
.Gaussian
import
GaussianFitter
,
GaussianPlotter
from
.Centroid
import
CentroidFitter
,
CentroidPlotter
from
.SilxFitter
import
SilxFitter
,
SilxPlotter
from
.Gaussian
import
GaussianFitter
,
GaussianResults
,
GaussianPlotter
from
.Centroid
import
CentroidFitter
,
CentroidResults
,
CentroidPlotter
from
.MaxFitter
import
MaxFitter
,
MaxResults
,
MaxPlotter
from
.SilxFitter
import
SilxFitter
,
SilxResults
,
SilxPlotter
xsocs/gui/process/FitWidget.py
View file @
151a1869
...
...
@@ -42,7 +42,7 @@ from ..widgets.Containers import GroupBox
from
..widgets.RoiAxisWidget
import
RoiAxisWidget
from
..widgets.Input
import
StyledLineEdit
from
...process.peak_fit
import
PeakFitter
,
FitTypes
from
...process.
fit.
peak_fit
import
PeakFitter
,
FitTypes
class
Roi3DSelectorWidget
(
Qt
.
QWidget
):
...
...
@@ -162,7 +162,8 @@ class FitWidget(Qt.QWidget):
"""
FitTypes
=
OrderedDict
([(
'Gaussian'
,
FitTypes
.
GAUSSIAN
),
(
'Centroid'
,
FitTypes
.
CENTROID
)])
\
(
'Centroid'
,
FitTypes
.
CENTROID
),
(
'Maximum'
,
FitTypes
.
MAX
)])
\
# ,
# ('Silx', FitTypes.SILX)])
...
...
xsocs/gui/view/FitView.py
View file @
151a1869
...
...
@@ -44,7 +44,7 @@ from ..project.QSpaceGroup import QSpaceItem
from
.fitview.FitModel
import
FitModel
,
FitH5Node
from
.fitview.DropPlotWidget
import
DropPlotWidget
from
...fit
import
GaussianPlotter
,
CentroidPlotter
,
SilxPlotter
from
...fit
import
GaussianPlotter
,
CentroidPlotter
,
SilxPlotter
,
MaxPlotter
class
FitView
(
Qt
.
QMainWindow
):
...
...
@@ -302,6 +302,8 @@ class FitView(Qt.QMainWindow):
plotterKlass
=
GaussianPlotter
elif
entry
==
'Centroid'
:
plotterKlass
=
CentroidPlotter
elif
entry
==
'Max'
:
plotterKlass
=
MaxPlotter
elif
entry
==
'SilxFit'
:
plotterKlass
=
SilxPlotter
...
...
xsocs/gui/view/fitview/DropPlotWidget.py
View file @
151a1869
...
...
@@ -33,8 +33,8 @@ import numpy as np
from
silx.gui
import
qt
as
Qt
from
xsocs
.io.FitH5
import
FitH5
,
FitH5QAxis
from
....process.fitresults
import
FitStatus
from
...
.io.FitH5
import
FitH5
,
FitH5QAxis
from
....process.fit
.fit
results
import
FitStatus
from
...widgets.XsocsPlot2D
import
XsocsPlot2D
...
...
xsocs/gui/view/fitview/FitModel.py
View file @
151a1869
...
...
@@ -43,7 +43,7 @@ from ...project.Hdf5Nodes import H5File
from
...project.Hdf5Nodes
import
H5Base
,
H5NodeClassDef
from
....io.FitH5
import
FitH5
,
FitH5QAxis
from
....process.fitresults
import
FitStatus
from
....process.fit
.fit
results
import
FitStatus
...
...
@@ -259,6 +259,15 @@ class FitResultNode(FitProcessNode):
legend
=
'__border'
,
z
=-
1
)
plot
.
setPlotData
(
x
,
y
,
data
)
# WARNING, DO NOT REMOVE
# for some reason the first thumbnail is empty if we dont call
# replot.
# ============
plot
.
replot
()
# ============
# WARNING END
pixmap
=
plot
.
toPixmap
()
self
.
_setDataInternal
(
1
,
pixmap
,
Qt
.
Qt
.
DecorationRole
)
qApp
.
processEvents
()
...
...
xsocs/gui/view/intensity/PlotModel.py
View file @
151a1869
...
...
@@ -33,9 +33,9 @@ __date__ = "01/11/2016"
from
silx.gui
import
qt
as
Qt
from
xsocs
.gui.model.Node
import
Node
from
xsocs
.gui.model.TreeView
import
TreeView
from
xsocs
.gui.model.Model
import
Model
,
ModelColumns
from
...
.gui.model.Node
import
Node
from
...
.gui.model.TreeView
import
TreeView
from
...
.gui.model.Model
import
Model
,
ModelColumns
class
CurveGroup
(
Node
):
...
...
xsocs/gui/view/shift/ShiftView.py
View file @
151a1869
...
...
@@ -222,42 +222,6 @@ class ShiftNode(Node):
centerY
=
origin
[
'y'
]
+
shiftY
plot
.
selectPoint
(
centerX
,
centerY
)
# shape = shiftSubject.getRoiSize()
# halfX = shape[0] / 2.
# halfY = shape[1] / 2.
# xBorder = np.array([centerX - halfX,
# centerX - halfX,
# centerX + halfX,
# centerX + halfX,
# centerX - halfX])
# yBorder = np.array([centerY - halfY,
# centerY + halfY,
# centerY + halfY,
# centerY - halfY,
# centerY - halfY])
#
# plot.addCurve(xBorder,
# yBorder,
# color='#f442eeaa',
# linestyle='-',
# linewidth=2,
# legend='__borders',
# z=-1)
#
# plot.addCurve(np.array([centerX, centerX]),
# np.array([centerY - halfY, centerY + halfY]),
# color='#f442eeaa',
# linestyle='-',
# linewidth=4,
# legend='__crosshairV')
#
# plot.addCurve(np.array([centerX - halfX, centerX + halfX]),
# np.array([centerY, centerY]),
# color='#f442eeaa',
# linestyle='-',
# linewidth=4,
# legend='__crosshairH')
plot
.
setPlotData
(
pos_0
,
pos_1
,
data
)
plot
.
replot
()
...
...
xsocs/gui/widgets/XsocsPlot2D.py
View file @
151a1869
...
...
@@ -43,7 +43,7 @@ from silx.io.utils import savetxt
from
silx.gui.icons
import
getQIcon
from
silx.gui.plot
import
PlotWindow
from
silx.math.histogram
import
Histogramnd
from
silx.gui.plot.
MPL
Colormap
import
viridis
from
silx.gui.plot.
matplotlib.
Colormap
import
viridis
from
..widgets.Containers
import
GroupBox
from
..widgets.RangeSlider
import
RangeSlider
...
...
xsocs/process/Fitter.py
→
xsocs/process/
fit/
Fitter.py
View file @
151a1869
...
...
@@ -32,6 +32,19 @@ __license__ = "MIT"
class
Fitter
(
object
):
qx
=
property
(
lambda
self
:
self
.
_qx
)
""" qx axis values """
qy
=
property
(
lambda
self
:
self
.
_qy
)
""" qy axis values """
qz
=
property
(
lambda
self
:
self
.
_qz
)
""" qz axis values """
shared_results
=
property
(
lambda
self
:
self
.
_shared_results
)
""" FitSharedResults instance use by this fitter """
def
__init__
(
self
,
qx
,
qy
,
qz
,
shared_results
):
super
(
Fitter
,
self
).
__init__
()
...
...
@@ -42,6 +55,18 @@ class Fitter(object):
self
.
_qz
=
qz
def
fit
(
self
,
i_fit
,
i_cube
,
qx_profile
,
qy_profile
,
qz_profile
):
"""
Performs the fit and stores the result in this instance's
FitSharedResult object.
:param i_fit: index of the fit result (in the FitH5 file). This
index is to be used when storing the result in the FitSharedResult
instance.
:param i_cube: index of the cube (in the QSpaceH5 file)
:param qx_profile: qx profile
:param qy_profile: qy profile
:param qz_profile: qz profile
:return:
"""
raise
NotImplementedError
(
'Not implemented.'
)
...
...
xsocs/process/fit/__init__.py
0 → 100644
View file @
151a1869
# coding: utf-8
# /*##########################################################################
#
# Copyright (c) 2015-2016 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# ###########################################################################*/
__authors__
=
[
"D. Naudet"
]
__license__
=
"MIT"
__date__
=
"01/05/2017"
xsocs/process/fitresults.py
→
xsocs/process/fit
/fit
results.py
View file @
151a1869
...
...
@@ -35,7 +35,7 @@ from collections import OrderedDict
import
numpy
as
np
from
..io.FitH5
import
FitH5Writer
,
FitH5QAxis
from
..
.
io.FitH5
import
FitH5Writer
,
FitH5QAxis
class
FitStatus
(
object
):
...
...
xsocs/process/peak_fit.py
→
xsocs/process/
fit/
peak_fit.py
View file @
151a1869
...
...
@@ -39,10 +39,12 @@ import multiprocessing.sharedctypes as mp_sharedctypes
import
numpy
as
np
# from silx.math import curve_fit
from
..io
import
QSpaceH5
from
..fit
import
GaussianFitter
,
CentroidFitter
,
SilxFitter
from
.sharedresults
import
(
FitTypes
,
GaussianResults
,
CentroidResults
,
SilxResults
)
from
...io
import
QSpaceH5
from
...fit
import
(
GaussianFitter
,
GaussianResults
,
CentroidFitter
,
CentroidResults
,
SilxFitter
,
SilxResults
,
MaxFitter
,
MaxResults
)
from
.sharedresults
import
FitTypes
disp_times
=
False
...
...
@@ -194,6 +196,9 @@ class PeakFitter(Thread):
elif
fit_type
==
FitTypes
.
CENTROID
:
fit_class
=
CentroidFitter
shared_results
=
CentroidResults
(
n_points
=
n_indices
)
elif
fit_type
==
FitTypes
.
MAX
:
fit_class
=
MaxFitter
shared_results
=
MaxResults
(
n_points
=
n_indices
)
elif
fit_type
==
FitTypes
.
SILX
:
fit_class
=
SilxFitter
n_peaks
=
n_peaks
if
n_peaks
>=
1
else
1
...
...
xsocs/process/sharedresults.py
→
xsocs/process/
fit/
sharedresults.py
View file @
151a1869
...
...
@@ -40,8 +40,8 @@ from .fitresults import FitResult
class
FitTypes
(
object
):
ALLOWED
=
range
(
3
)
GAUSSIAN
,
CENTROID
,
SILX
=
ALLOWED
ALLOWED
=
range
(
4
)