def get_available_detectors(): detector_classes = set() detector_names = [] for key, item in ALL_DETECTORS.items(): detector_classes.add(item) for detector in detector_classes: if len(detector.aliases) > 0: detector_names.append(detector.aliases[0]) else: detector_names.append(detector().__class__.__name__) sorted_indices = sorted(range(len(detector_names)), key=detector_names.__getitem__) detector_names_sorted = [detector_names[i] for i in sorted_indices] detector_classes_sorted = [ list(detector_classes)[i] for i in sorted_indices ] base_class_index = detector_names_sorted.index('Detector') del detector_names_sorted[base_class_index] del detector_classes_sorted[base_class_index] return detector_names_sorted, detector_classes_sorted
def test_detector_instanciate(self): """ this method try to instantiate all the detectors """ for k, v in ALL_DETECTORS.items(): logger.debug(k) v()
def guess_detector_by_shape(shape): # for every detector known to pyFAI for name, detector in sorted(ALL_DETECTORS.items()): # if a shape limit is set if hasattr(detector, 'MAX_SHAPE'): if detector.MAX_SHAPE == shape: return detector() if hasattr(detector, 'BINNED_PIXEL_SIZE'): for binning in detector.BINNED_PIXEL_SIZE.keys(): if shape == tuple(np.array(detector.MAX_SHAPE) / binning): # possibly needs to be reversed [::-1] detector = detector() detector.set_binning(binning) return detector return None