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

This pull request addresses issue #2221 #2239

Merged
merged 7 commits into from
Aug 19, 2024
Merged
33 changes: 30 additions & 3 deletions src/pyFAI/average.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import numpy
import fabio
import weakref
import os
from scipy import ndimage
from scipy.interpolate import interp1d
from scipy.optimize import fmin
Expand Down Expand Up @@ -559,10 +560,36 @@ def write_reduction(self, algorithm, data):
filter_parameters = algorithm.get_parameters()
for name, value in filter_parameters.items():
header[name] = str(value)
image = self._fabio_class.__class__(data=data, header=header)

if not self._dry_run:
image.write(file_name)
logger.info("Wrote %s", file_name)
dim = len(data.shape)

try:
image = self._fabio_class.__class__(data=data, header=header)
image.write(f"{file_name}")
logger.info("Wrote %s", file_name)

except:
if dim == 3:
image = self._fabio_class.__class__(data=data[0], header=header)
if hasattr(image, 'append_frame'):
for i in range(1, data.shape[0]):
image.append_frame(data=data[i])
image.write(f"{file_name}")
logger.info("Wrote %s", file_name)

else:
base_name, ext = os.path.splitext(file_name)
image.write(f"{base_name}_channel_0{ext}")
logger.info("Wrote %s", file_name)
for i in range(1, data.shape[0]):
image = self._fabio_class.__class__(data=data[i], header=header)
file_name=f"{base_name}_channel_{i}{ext}"
image.write(file_name)
logger.info("Wrote %s", file_name)

if self._dry_run:
image = self._fabio_class.__class__(data=data, header=header)
self._fabio_images[algorithm] = image

def get_fabio_image(self, algorithm):
Expand Down
Loading