Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
XRD
darfix
Commits
760f1d7c
Commit
760f1d7c
authored
Aug 05, 2021
by
Julia Garriga Ferrer
Browse files
[gui][grainplot] Use dicttonx to save data into nexus file
parent
2b0c0c4f
Pipeline
#52153
passed with stage
in 6 minutes and 9 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
darfix/gui/grainPlotWidget.py
View file @
760f1d7c
...
...
@@ -26,7 +26,7 @@
__authors__
=
[
"J. Garriga"
]
__license__
=
"MIT"
__date__
=
"0
7
/0
6
/2021"
__date__
=
"0
5
/0
8
/2021"
from
matplotlib.colors
import
hsv_to_rgb
import
numpy
...
...
@@ -37,10 +37,10 @@ from silx.gui.plot import Plot2D
from
silx.image.marchingsquares
import
find_contours
from
silx.math.medianfilter
import
medfilt2d
from
silx.utils.enum
import
Enum
as
_Enum
from
silx.io.dictdump
import
dicttonx
import
darfix
from
.operationThread
import
OperationThread
from
darfix.io.utils
import
write_maps
class
Method
(
_Enum
):
...
...
@@ -200,6 +200,7 @@ class GrainPlotWidget(qt.QMainWindow):
colors
=
self
.
_curvesColormap
.
applyToData
(
levels
)
xdim
=
self
.
dataset
.
dims
.
get
(
1
)
ydim
=
self
.
dataset
.
dims
.
get
(
0
)
self
.
_curves
=
[]
for
ipolygon
,
polygon
in
enumerate
(
polygons
):
# iso contours
for
icontour
,
contour
in
enumerate
(
polygon
):
...
...
@@ -216,6 +217,7 @@ class GrainPlotWidget(qt.QMainWindow):
x
-=
xcenter
ycenter
=
(
ydim
.
unique_values
[
-
1
]
-
ydim
.
unique_values
[
0
])
/
2
y
-=
ycenter
self
.
_curves
.
append
((
x
,
y
,
colors
[
ipolygon
]))
legend
=
"custom-polygon-%d"
%
icontour
*
(
ipolygon
+
1
)
self
.
_contoursPlot
.
addCurve
(
x
=
x
,
y
=
y
,
linestyle
=
"-"
,
linewidth
=
2.0
,
legend
=
legend
,
resetzoom
=
False
,
...
...
@@ -282,16 +284,37 @@ class GrainPlotWidget(qt.QMainWindow):
"""
Loads the file from a FileDialog.
"""
list_of_maps
=
{}
for
axis
,
dim
in
self
.
dataset
.
dims
:
list_of_maps
[
dim
.
name
]
=
{
Method
.
COM
.
name
:
self
.
_moments
[
axis
][
0
],
Method
.
FWHM
.
name
:
self
.
_moments
[
axis
][
1
],
Method
.
SKEWNESS
.
name
:
self
.
_moments
[
axis
][
2
],
Method
.
KURTOSIS
.
name
:
self
.
_moments
[
axis
][
3
]
if
self
.
dataset
.
dims
.
ndim
>
1
:
nx
=
{
"entry"
:
{
"data"
:
{
">"
+
Method
.
MOSAICITY
.
name
:
"../maps/"
+
Method
.
MOSAICITY
.
name
,
"@signal"
:
Method
.
MOSAICITY
.
name
,
"@NX_class"
:
"NXdata"
},
"maps"
:
{
Method
.
ORI_DIST
.
name
:
self
.
ori_dist
,
Method
.
MOSAICITY
.
name
:
hsv_to_rgb
(
self
.
_computeMosaicity
()),
Method
.
MOSAICITY
.
name
+
"@interpretation"
:
"rgba-image"
,
"@NX_class"
:
"NXcollection"
},
"@NX_class"
:
"NXentry"
,
"@default"
:
"data"
,
},
"@NX_class"
:
"NXroot"
,
"@default"
:
"entry"
}
list_of_maps
[
Method
.
MOSAICITY
.
name
]
=
hsv_to_rgb
(
self
.
_computeMosaicity
())
for
axis
,
dim
in
self
.
dataset
.
dims
:
nx
[
"entry"
][
"maps"
].
update
(
{
Method
.
COM
.
name
:
self
.
_moments
[
axis
][
0
],
Method
.
FWHM
.
name
:
self
.
_moments
[
axis
][
1
],
Method
.
SKEWNESS
.
name
:
self
.
_moments
[
axis
][
2
],
Method
.
KURTOSIS
.
name
:
self
.
_moments
[
axis
][
3
]
}
)
fileDialog
=
qt
.
QFileDialog
()
...
...
@@ -300,4 +323,4 @@ class GrainPlotWidget(qt.QMainWindow):
fileDialog
.
setOption
(
fileDialog
.
DontUseNativeDialog
)
fileDialog
.
setDefaultSuffix
(
".h5"
)
if
fileDialog
.
exec_
():
write_maps
(
fileDialog
.
selectedFiles
()[
0
]
,
list_of_maps
,
Method
.
MOSAICITY
.
name
,
'entry'
,
1
)
dicttonx
(
nx
,
fileDialog
.
selectedFiles
()[
0
])
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment