def slice_callback_with_high_performance_http_data(self): BYU = self.object.read() linearintdata = flex.int_from_byte_str(BYU) provisional_size = linearintdata.size() assert provisional_size == self.size1 * self.size2 print("size assertion OK", provisional_size) linearintdata.reshape(flex.grid((self.size1, self.size2))) del self.object #once the data are copied, close the stream return linearintdata
def slice_callback_with_high_performance_http_data(self): BYU = self.object.read() linearintdata = flex.int_from_byte_str(BYU) provisional_size = linearintdata.size() assert provisional_size == self.size1*self.size2 print "size assertion OK",provisional_size linearintdata.reshape(flex.grid((self.size1,self.size2))) del self.object #once the data are copied, close the stream return linearintdata
def slice_callback_with_high_performance_http_data(self): BYU = self.object.read() linearintdata = flex.int_from_byte_str(BYU) provisional_size = linearintdata.size() if provisional_size == 480285: linearintdata.reshape(flex.grid((195, 2463))) elif provisional_size == 6224001: linearintdata.reshape(flex.grid((2527, 2463))) else: raise ImageException("wrong number of pixels for Pilatus image") del self.object #once the data are copied, close the stream return linearintdata
def slice_callback_with_high_performance_http_data(self): BYU = self.object.read() linearintdata = flex.int_from_byte_str(BYU) provisional_size = linearintdata.size() if provisional_size==480285: linearintdata.reshape(flex.grid((195,2463))) elif provisional_size==6224001: linearintdata.reshape(flex.grid((2527,2463))) else: raise ImageException("wrong number of pixels for Pilatus image") del self.object #once the data are copied, close the stream return linearintdata
def build_images(work_params, i_calc, reindexing_assistant): result = [] from create import add_noise from rstbx.simage import image_simple from cctbx.array_family import flex if (not work_params.apply_random_reindexing): i_calc_data_perms = [i_calc.data()] else: i_calc_data_perms = [i_calc.data().select(perm) for perm in reindexing_assistant.inv_perms] n_mdls = work_params.number_of_shots use_mp = (work_params.multiprocessing and n_mdls > 1) def build_one_image(i_img): mt = flex.mersenne_twister(seed=work_params.noise.random_seed+i_img) scale = int(work_params.signal_max*(0.1+0.9*mt.random_double())) crystal_rotation = mt.random_double_r3_rotation_matrix_arvo_1992() i_perm = mt.random_size_t() % len(i_calc_data_perms) image = image_simple( store_miller_index_i_seqs=True, store_spots=True, store_signals=True, set_pixels=True).compute( unit_cell=i_calc.unit_cell(), miller_indices=i_calc.indices(), spot_intensity_factors=i_calc_data_perms[i_perm], crystal_rotation_matrix=crystal_rotation, ewald_radius=1/work_params.wavelength, ewald_proximity=work_params.ewald_proximity, signal_max=scale, detector_distance=work_params.detector.distance, detector_size=work_params.detector.size, detector_pixels=work_params.detector.pixels, point_spread=work_params.point_spread, gaussian_falloff_scale=work_params.gaussian_falloff_scale) add_noise(work_params, pixels=image.pixels) if (not work_params.index_and_integrate): pixels = None else: pixels = image.pixels miller_index_i_seqs = image.miller_index_i_seqs if (use_mp): # to by-pass portable but slower pickling if (pixels is not None): assert pixels.is_0_based() assert not pixels.is_padded() assert pixels.all() == tuple(work_params.detector.pixels) pixels = pixels.copy_to_byte_str() miller_index_i_seqs = miller_index_i_seqs.copy_to_byte_str() return image_model( pixels=pixels, spot_positions=image.spots, spot_intensities=image.signals, unit_cell=i_calc.unit_cell(), crystal_rotation=crystal_rotation, miller_index_i_seqs=miller_index_i_seqs, scale=scale, i_perm=i_perm) if (not use_mp): for i_img in xrange(n_mdls): result.append(build_one_image(i_img)) else: from libtbx import easy_mp result = easy_mp.pool_map( fixed_func=build_one_image, args=range(n_mdls), chunksize=1, log=sys.stdout) for im in result: if (im is None): raise RuntimeError("Failure building image.") if (im.pixels is not None): im.pixels = flex.int_from_byte_str(im.pixels) im.pixels.reshape(flex.grid(work_params.detector.pixels)) im.miller_index_i_seqs = flex.size_t_from_byte_str( byte_str=im.miller_index_i_seqs) for im in result: im.make_backup() return image_models(miller_indices=i_calc.indices(), array=result)
def build_images(work_params, i_calc, reindexing_assistant): result = [] from .create import add_noise from rstbx.simage import image_simple from cctbx.array_family import flex if (not work_params.apply_random_reindexing): i_calc_data_perms = [i_calc.data()] else: i_calc_data_perms = [i_calc.data().select(perm) for perm in reindexing_assistant.inv_perms] n_mdls = work_params.number_of_shots use_mp = (work_params.multiprocessing and n_mdls > 1) def build_one_image(i_img): mt = flex.mersenne_twister(seed=work_params.noise.random_seed+i_img) scale = int(work_params.signal_max*(0.1+0.9*mt.random_double())) crystal_rotation = mt.random_double_r3_rotation_matrix_arvo_1992() i_perm = mt.random_size_t() % len(i_calc_data_perms) image = image_simple( store_miller_index_i_seqs=True, store_spots=True, store_signals=True, set_pixels=True).compute( unit_cell=i_calc.unit_cell(), miller_indices=i_calc.indices(), spot_intensity_factors=i_calc_data_perms[i_perm], crystal_rotation_matrix=crystal_rotation, ewald_radius=1/work_params.wavelength, ewald_proximity=work_params.ewald_proximity, signal_max=scale, detector_distance=work_params.detector.distance, detector_size=work_params.detector.size, detector_pixels=work_params.detector.pixels, point_spread=work_params.point_spread, gaussian_falloff_scale=work_params.gaussian_falloff_scale) add_noise(work_params, pixels=image.pixels) if (not work_params.index_and_integrate): pixels = None else: pixels = image.pixels miller_index_i_seqs = image.miller_index_i_seqs if (use_mp): # to by-pass portable but slower pickling if (pixels is not None): assert pixels.is_0_based() assert not pixels.is_padded() assert pixels.all() == tuple(work_params.detector.pixels) pixels = pixels.copy_to_byte_str() miller_index_i_seqs = miller_index_i_seqs.copy_to_byte_str() return image_model( pixels=pixels, spot_positions=image.spots, spot_intensities=image.signals, unit_cell=i_calc.unit_cell(), crystal_rotation=crystal_rotation, miller_index_i_seqs=miller_index_i_seqs, scale=scale, i_perm=i_perm) if (not use_mp): for i_img in xrange(n_mdls): result.append(build_one_image(i_img)) else: from libtbx import easy_mp result = easy_mp.pool_map( fixed_func=build_one_image, args=range(n_mdls), chunksize=1, log=sys.stdout) for im in result: if (im is None): raise RuntimeError("Failure building image.") if (im.pixels is not None): im.pixels = flex.int_from_byte_str(im.pixels) im.pixels.reshape(flex.grid(work_params.detector.pixels)) im.miller_index_i_seqs = flex.size_t_from_byte_str( byte_str=im.miller_index_i_seqs) for im in result: im.make_backup() return image_models(miller_indices=i_calc.indices(), array=result)