Commit 77c4738a authored by Julia Garriga Ferrer's avatar Julia Garriga Ferrer
Browse files

[gui][grainplot] Add case for one dimension datasets

parent 760f1d7c
Pipeline #52156 passed with stage
in 3 minutes and 16 seconds
......@@ -92,7 +92,7 @@ class GrainPlotWidget(qt.QMainWindow):
self._levelsWidget.setLayout(levelsLayout)
self._mosaicityPlot = Plot2D(parent=self)
self._exportButton = qt.QPushButton("Export")
self._exportButton.clicked.connect(self._saveMaps)
self._exportButton.clicked.connect(self.exportMaps)
layout.addWidget(self._methodCB)
layout.addWidget(self._levelsWidget)
layout.addWidget(self._plotWidget)
......@@ -280,12 +280,12 @@ class GrainPlotWidget(qt.QMainWindow):
return medfilt2d(img)
def _saveMaps(self):
def exportMaps(self):
"""
Loads the file from a FileDialog.
"""
if self.dataset.dims.ndim > 1:
if self.dataset and self.dataset.dims.ndim > 1:
nx = {
"entry": {
"data": {
......@@ -306,15 +306,37 @@ class GrainPlotWidget(qt.QMainWindow):
"@default": "entry"
}
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]
}
)
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]
}
)
else:
nx = {
"entry": {
"data": {
">" + Method.COM.name: "../maps/" + Method.COM.name,
"@signal": Method.COM.name,
"@NX_class": "NXdata"
},
"maps": {
Method.COM.name: self._moments[0][0],
Method.FWHM.name: self._moments[0][1],
Method.SKEWNESS.name: self._moments[0][2],
Method.KURTOSIS.name: self._moments[0][3],
"@NX_class": "NXcollection"
},
"@NX_class": "NXentry",
"@default": "data",
},
"@NX_class": "NXroot",
"@default": "entry"
}
fileDialog = qt.QFileDialog()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment