Skip to content

Commit

Permalink
Merge pull request #1061 from vasole/dat
Browse files Browse the repository at this point in the history
[XRF] Do not attempt to save as ASCII the derivatives.
  • Loading branch information
vasole authored Feb 9, 2024
2 parents 57815f4 + 68e5237 commit 361ed93
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions PyMca5/PyMcaIO/OutputBuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# The PyMca X-Ray Fluorescence Toolkit
#
# Copyright (c) 2019-2022 European Synchrotron Radiation Facility
# Copyright (c) 2019-2024 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF.
Expand Down Expand Up @@ -830,16 +830,35 @@ def _saveImages(self):
fileName,
labels=[title],
dtype=numpy.float32)
if self.csv or self.dat:
# only same shapes can be saved
goodIndices = []
for i in range(len(imageTitleLabels)):
if imageList[i].shape == imageList[0].shape:
goodIndices.append(i)
else:
txt = "Skip ASCII saving of badly shaped image {}".format(imageTitleLabels[i])
_logger.info(txt)
if len(goodIndices) == len((imageTitleLabels)):
goodImageList = imageList
goodImageTitleLabels = imageTitleLabels
else:
goodImageList = []
goodImageTitleLabels = []
for i in goodIndices:
goodImageList.append(imageList[i])
goodImageTitleLabels.append(imageTitleLabels[i])

if self.csv:
fileName = self.filename('.csv')
self._checkOverwrite(fileName)
ArraySave.save2DArrayListAsASCII(imageList, fileName, csv=True,
labels=imageTitleLabels)
ArraySave.save2DArrayListAsASCII(goodImageList, fileName, csv=True,
labels=goodImageTitleLabels)
if self.dat:
fileName = self.filename('.dat')
self._checkOverwrite(fileName)
ArraySave.save2DArrayListAsASCII(imageList, fileName, csv=False,
labels=imageTitleLabels)
ArraySave.save2DArrayListAsASCII(goodImageList, fileName, csv=False,
labels=goodImageTitleLabels)

if self.cfg and self._configurationkey in self:
fileName = self.filename('.cfg')
Expand Down

0 comments on commit 361ed93

Please sign in to comment.