import logging log = logging.getLogger(__name__) import os import collections import numpy as np from . import azav from . import dataReduction from . import utils from . import storage from . import filters default_extension = ".npz" def _conv(x): try: x = float(x) except: x = np.nan return x def _readDiagnostic(fname,retry=3): ntry = 0 while ntry 0: data.data = filters.removeZingers(data.data,threshold=zingerFilter) #data.save(storageFile); it does not save err ? # idx = utils.findSlice(data.q,qlims) # n = np.nanmean(data.data[:,idx],axis=1) # data.norm_range = qlims # data.norm = n # n = utils.reshapeToBroadcast(n,data.data) # data.data_norm = data.data/n data.save(storageFile) return data def doFolder_dataRed(azavStorage,monitor=None,funcForAveraging=np.nanmean, qlims=None,outStorageFile='auto',reference='min'): """ azavStorage if a DataStorage instance or the filename to read """ if isinstance(azavStorage,storage.DataStorage): data = azavStorage folder = azavStorage.folder elif os.path.isfile(azavStorage): folder = os.path.dirname(azavStorage) data = storage.DataStorage(azavStorage) else: # assume is just a folder name folder = azavStorage azavStorage = folder + "/pyfai_1d" + default_extension data = storage.DataStorage(azavStorage) #assert data.q.shape[0] == data.data.shape[1] == data.err.shape[1] if qlims is not None: idx = (data.q>qlims[0]) & (data.q