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
25ca8b31
Commit
25ca8b31
authored
Nov 19, 2018
by
Thomas Vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
share QSpace projection to axes code
parent
ada8073e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
38 deletions
+29
-38
xsocs/gui/process/FitWidget.py
xsocs/gui/process/FitWidget.py
+3
-7
xsocs/gui/view/FitView.py
xsocs/gui/view/FitView.py
+2
-7
xsocs/process/fit/peak_fit.py
xsocs/process/fit/peak_fit.py
+1
-24
xsocs/util/__init__.py
xsocs/util/__init__.py
+23
-0
No files found.
xsocs/gui/process/FitWidget.py
View file @
25ca8b31
...
...
@@ -34,7 +34,7 @@ import logging
from
silx.gui
import
qt
as
Qt
from
...io.QSpaceH5
import
QSpaceH5
from
...util
import
bin_centers_to_range_step
from
...util
import
bin_centers_to_range_step
,
project
from
..widgets.Containers
import
GroupBox
from
..widgets.RoiAxisWidget
import
RoiAxisWidget
...
...
@@ -196,13 +196,9 @@ class FitWidget(Qt.QWidget):
:param int index: QSpace index
"""
qspace
=
self
.
__qspaceH5
.
qspace_slice
(
index
)
dim2_sum
=
qspace
.
sum
(
axis
=
0
).
sum
(
axis
=
0
)
cube_sum_dim2
=
qspace
.
sum
(
axis
=
2
)
dim1_sum
=
cube_sum_dim2
.
sum
(
axis
=
0
)
dim0_sum
=
cube_sum_dim2
.
sum
(
axis
=
1
)
projections
=
project
(
self
.
__qspaceH5
.
qspace_slice
(
index
))
for
profile
,
slider
in
zip
(
(
dim0_sum
,
dim1_sum
,
dim2_sum
)
,
for
profile
,
slider
in
zip
(
projections
,
self
.
roiWidget
().
sliders
()):
slider
.
setGroovePixmapFromProfile
(
profile
,
colormap
=
'jet'
)
...
...
xsocs/gui/view/FitView.py
View file @
25ca8b31
...
...
@@ -47,6 +47,7 @@ from .fitview.DropPlotWidget import DropPlotWidget
from
.fitview.Plotter
import
GaussianPlotter
,
CentroidPlotter
from
...process.fit.peak_fit
import
background_estimation
,
BackgroundTypes
from
...util
import
project
_logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -270,17 +271,11 @@ class FitView(Qt.QMainWindow):
with
self
.
__qspaceH5
:
cube
=
self
.
__qspaceH5
.
qspace_slice
(
xIdx
)
histo
=
self
.
__qspaceH5
.
histo
mask
=
np
.
where
(
histo
>
0
)
weights
=
histo
[
mask
]
cube
[
mask
]
/=
weights
xAcqQX
=
self
.
__qspaceH5
.
qx
xAcqQY
=
self
.
__qspaceH5
.
qy
xAcqQZ
=
self
.
__qspaceH5
.
qz
yAcqQZ
=
cube
.
sum
(
axis
=
0
).
sum
(
axis
=
0
)
cube_sum_z
=
cube
.
sum
(
axis
=
2
)
yAcqQY
=
cube_sum_z
.
sum
(
axis
=
0
)
yAcqQX
=
cube_sum_z
.
sum
(
axis
=
1
)
yAcqQX
,
yAcqQY
,
yAcqQZ
=
project
(
cube
,
histo
)
# Get plotter
if
entry
==
'Gaussian'
:
...
...
xsocs/process/fit/peak_fit.py
View file @
25ca8b31
...
...
@@ -36,7 +36,6 @@ import ctypes
import
multiprocessing
from
threading
import
Thread
import
multiprocessing.sharedctypes
as
mp_sharedctypes
import
warnings
import
numpy
as
np
from
scipy.optimize
import
leastsq
...
...
@@ -46,7 +45,7 @@ from silx.math.fit import snip1d
from
...
import
config
from
...io
import
QSpaceH5
from
...io.FitH5
import
BackgroundTypes
from
...util
import
gaussian
from
...util
import
gaussian
,
project
from
.fitresults
import
FitResult
...
...
@@ -317,28 +316,6 @@ def _fit_process(index,
return
result
def
project
(
data
,
hits
=
None
):
"""Sum data along each axis
:param numpy.ndarray data: 3D histogram
:param Union[numpy.ndarray,None] hits:
Number of bin count of the histogram or None to ignore
:return: Projections on each axis of the dataset
:rtype: List[numpy.ndarray]
"""
if
hits
is
not
None
:
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
'ignore'
,
RuntimeWarning
)
data
/=
hits
data
[
hits
<=
0
]
=
0
dim2_sum
=
data
.
sum
(
axis
=
0
).
sum
(
axis
=
0
)
data_sum_dim2
=
data
.
sum
(
axis
=
2
)
dim1_sum
=
data_sum_dim2
.
sum
(
axis
=
0
)
dim0_sum
=
data_sum_dim2
.
sum
(
axis
=
1
)
return
dim0_sum
,
dim1_sum
,
dim2_sum
# Center of mass
def
centroid
(
axis
,
signal
):
...
...
xsocs/util/__init__.py
View file @
25ca8b31
...
...
@@ -32,6 +32,7 @@ __date__ = "01/03/2016"
import
sys
import
warnings
import
numpy
...
...
@@ -72,3 +73,25 @@ def gaussian(x, area, center, sigma):
"""
return
(
area
*
(
1.
/
(
_SQRT_2_PI
*
sigma
))
*
numpy
.
exp
(
-
0.5
*
((
x
-
center
)
/
sigma
)
**
2
))
def
project
(
data
,
hits
=
None
):
"""Sum data along each axis
:param numpy.ndarray data: 3D histogram
:param Union[numpy.ndarray,None] hits:
Number of bin count of the histogram or None to ignore
:return: Projections on each axis of the dataset
:rtype: List[numpy.ndarray]
"""
if
hits
is
not
None
:
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
'ignore'
,
RuntimeWarning
)
data
/=
hits
data
[
hits
<=
0
]
=
0
dim2_sum
=
data
.
sum
(
axis
=
0
).
sum
(
axis
=
0
)
data_sum_dim2
=
data
.
sum
(
axis
=
2
)
dim1_sum
=
data_sum_dim2
.
sum
(
axis
=
0
)
dim0_sum
=
data_sum_dim2
.
sum
(
axis
=
1
)
return
dim0_sum
,
dim1_sum
,
dim2_sum
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