def __call__(self): """ Do the processing. :return: The processed data """ # Set the job index job.index = self.index # Get the start time start_time = time() # Check all reflections have same imageset and get it exp_id = list(set(self.reflections["id"])) imageset = self.experiments[exp_id[0]].imageset for i in exp_id[1:]: assert (self.experiments[i].imageset == imageset ), "Task can only handle 1 imageset" # Get the sub imageset frame00, frame01 = self.frames try: frame10, frame11 = imageset.get_array_range() except Exception: frame10, frame11 = (0, len(imageset)) try: assert frame00 < frame01 assert frame10 < frame11 assert frame00 >= frame10 assert frame01 <= frame11 index0 = frame00 - frame10 index1 = index0 + (frame01 - frame00) assert index0 < index1 assert index0 >= 0 assert index1 <= len(imageset) imageset = imageset[index0:index1] except Exception: raise RuntimeError("Programmer Error: bad array range") try: frame0, frame1 = imageset.get_array_range() except Exception: frame0, frame1 = (0, len(imageset)) # Initialise the dataset image_volume = MultiPanelImageVolume() for panel in self.experiments[0].detector: image_volume.add( ImageVolume(frame0, frame1, panel.get_image_size()[1], panel.get_image_size()[0])) # Read all the images into a block of data read_time = 0.0 for i in range(len(imageset)): st = time() image = imageset.get_corrected_data(i) mask = imageset.get_mask(i) if self.params.integration.lookup.mask is not None: assert len(mask) == len( self.params.lookup.mask ), "Mask/Image are incorrect size %d %d" % ( len(mask), len(self.params.integration.lookup.mask), ) mask = tuple(m1 & m2 for m1, m2 in zip( self.params.integration.lookup.mask, mask)) image_volume.set_image(frame0 + i, make_image(image, mask)) read_time += time() - st del image del mask # Process the data st = time() data = self.executor.process(image_volume, self.experiments, self.reflections) process_time = time() - st # Set the result values return dials.algorithms.integration.Result( index=self.index, reflections=self.reflections, read_time=read_time, process_time=process_time, total_time=time() - start_time, extract_time=0, data=data, )
def __call__(self): ''' Do the processing. :return: The processed data ''' from dials.model.data import make_image from dials.model.data import MultiPanelImageVolume from dials.model.data import ImageVolume from dials.algorithms.integration.processor import job from time import time # Set the job index job.index = self.index # Get the start time start_time = time() # Check all reflections have same imageset and get it exp_id = list(set(self.reflections['id'])) imageset = self.experiments[exp_id[0]].imageset for i in exp_id[1:]: assert self.experiments[i].imageset == imageset, "Task can only handle 1 imageset" # Get the sub imageset frame00, frame01 = self.frames try: frame10, frame11 = imageset.get_array_range() except Exception: frame10, frame11 = (0, len(imageset)) try: assert frame00 < frame01 assert frame10 < frame11 assert frame00 >= frame10 assert frame01 <= frame11 index0 = frame00 - frame10 index1 = index0 + (frame01 - frame00) assert index0 < index1 assert index0 >= 0 assert index1 <= len(imageset) imageset = imageset[index0:index1] except Exception: raise RuntimeError('Programmer Error: bad array range') try: frame0, frame1 = imageset.get_array_range() except Exception: frame0, frame1 = (0, len(imageset)) # Initialise the dataset image_volume = MultiPanelImageVolume() for panel in self.experiments[0].detector: image_volume.add(ImageVolume( frame0, frame1, panel.get_image_size()[1], panel.get_image_size()[0])) # Read all the images into a block of data read_time = 0.0 for i in range(len(imageset)): st = time() image = imageset.get_corrected_data(i) mask = imageset.get_mask(i) if self.params.integration.lookup.mask is not None: assert len(mask) == len(self.params.lookup.mask), \ "Mask/Image are incorrect size %d %d" % ( len(mask), len(self.params.integration.lookup.mask)) mask = tuple(m1 & m2 for m1, m2 in zip(self.params.integration.lookup.mask, mask)) image_volume.set_image(frame0 + i, make_image(image, mask)) read_time += time() - st del image del mask # Process the data st = time() data = self.executor.process( image_volume, self.experiments, self.reflections) process_time = time() - st # Set the result values result = Result(self.index, self.reflections) result.read_time = read_time result.process_time = process_time result.total_time = time() - start_time result.data = data return result