def do_import(filename): logger.info("Loading %s" % os.path.basename(filename)) datablocks = DataBlockFactory.from_filenames([filename]) if len(datablocks) == 0: try: datablocks = DataBlockFactory.from_json_file(filename) except ValueError: raise Abort("Could not load %s" % filename) if len(datablocks) == 0: raise Abort("Could not load %s" % filename) if len(datablocks) > 1: raise Abort("Got multiple datablocks from file %s" % filename) # Ensure the indexer and downstream applications treat this as set of stills from dxtbx.imageset import ImageSet reset_sets = [] for imageset in datablocks[0].extract_imagesets(): imageset = ImageSet(imageset.data(), imageset.indices()) imageset.set_scan(None) imageset.set_goniometer(None) reset_sets.append(imageset) return DataBlockFactory.from_imageset(reset_sets)[0]
def tst_null_reader_imageset(self): from dxtbx.imageset import NullReader, ImageSet from dxtbx.model import Beam, Detector paths = ['hello_world.cbf'] # Create the null reader reader = NullReader(paths) # Create the imageset imageset = ImageSet(reader) # Try to get an item try: imageset[0] assert(False) except Exception: print 'OK' # Try to slice the imageset imageset2 = imageset[0:1] print 'OK' # Try some functions which should work assert(len(imageset) == 1) assert(imageset == imageset) assert(imageset.indices() == [0]) assert(imageset.is_valid()) print 'OK' # Try to get models (expect failure) try: imageset.get_image_models(0) assert(False) except Exception: print 'OK' # Get the image paths assert(imageset.paths() == paths) assert(imageset.get_path(0) == paths[0]) print 'OK' imageset.set_beam(Beam(), 0) imageset.set_detector(Detector(), 0) assert(isinstance(imageset.get_beam(0), Beam)) assert(isinstance(imageset.get_detector(0), Detector)) print 'OK'
def do_import(filename): logger.info("Loading %s"%os.path.basename(filename)) try: datablocks = DataBlockFactory.from_json_file(filename) except ValueError: datablocks = DataBlockFactory.from_filenames([filename]) if len(datablocks) == 0: raise Abort("Could not load %s"%filename) if len(datablocks) > 1: raise Abort("Got multiple datablocks from file %s"%filename) # Ensure the indexer and downstream applications treat this as set of stills from dxtbx.imageset import ImageSet reset_sets = [] for imageset in datablocks[0].extract_imagesets(): imageset = ImageSet(imageset.reader(), imageset.indices()) imageset._models = imageset._models imageset.set_scan(None) imageset.set_goniometer(None) reset_sets.append(imageset) return DataBlockFactory.from_imageset(reset_sets)[0]