Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[XRF] Do not attempt to save as ASCII the derivatives. #1061

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading