def compute_map(self):
   density_modification.density_modification.compute_map(self)
   if self.model_map_coeffs is not None:
     model_coeffs, dm_coeffs = self.model_map_coeffs.common_sets(self.map_coeffs)
     fft_map = model_coeffs.fft_map(
       resolution_factor=self.params.grid_resolution_factor).apply_sigma_scaling()
     dm_map = dm_coeffs.fft_map(
       resolution_factor=self.params.grid_resolution_factor).apply_sigma_scaling()
     print
     corr = flex.linear_correlation(
       fft_map.real_map_unpadded().as_1d(), dm_map.real_map_unpadded().as_1d())
     print "dm/model correlation:"
     corr.show_summary()
     self.correlation_coeffs.append(corr.coefficient())
     self.mean_phase_errors.append(flex.mean(phase_error(
       flex.arg(model_coeffs.data()),
       flex.arg(dm_coeffs.data())))/density_modification.pi_180)
 def compute_map(self):
     density_modification.density_modification.compute_map(self)
     if self.model_map_coeffs is not None:
         model_coeffs, dm_coeffs = self.model_map_coeffs.common_sets(
             self.map_coeffs)
         fft_map = model_coeffs.fft_map(
             resolution_factor=self.params.grid_resolution_factor
         ).apply_sigma_scaling()
         dm_map = dm_coeffs.fft_map(
             resolution_factor=self.params.grid_resolution_factor
         ).apply_sigma_scaling()
         print()
         corr = flex.linear_correlation(fft_map.real_map_unpadded().as_1d(),
                                        dm_map.real_map_unpadded().as_1d())
         print("dm/model correlation:")
         corr.show_summary()
         self.correlation_coeffs.append(corr.coefficient())
         self.mean_phase_errors.append(
             flex.mean(
                 phase_error(flex.arg(model_coeffs.data()),
                             flex.arg(dm_coeffs.data()))) /
             density_modification.pi_180)
示例#3
0
 def compute_map_coefficients(self):
     f_obs = self.f_obs_complete.select(
         self.f_obs_complete.d_spacings().data() >= self.d_min)
     f_calc = f_obs.structure_factors_from_map(self.map, use_sg=True)
     f_obs_active = f_obs.select_indices(self.active_indices)
     minimized = relative_scaling.ls_rel_scale_driver(
         f_obs_active,
         f_calc.as_amplitude_array().select_indices(self.active_indices),
         use_intensities=False,
         use_weights=False)
     #minimized.show()
     f_calc = f_calc.customized_copy(data=f_calc.data()\
                                     * math.exp(-minimized.p_scale)\
                                     * adptbx.debye_waller_factor_u_star(
                                       f_calc.indices(), minimized.u_star))
     f_calc_active = f_calc.common_set(f_obs_active)
     matched_indices = f_obs.match_indices(self.f_obs_active)
     lone_indices_selection = matched_indices.single_selection(0)
     from mmtbx.max_lik import maxlik
     alpha_beta_est = maxlik.alpha_beta_est_manager(
         f_obs=f_obs_active,
         f_calc=f_calc_active,
         free_reflections_per_bin=140,
         flags=flex.bool(f_obs_active.size()),
         interpolation=True,
         epsilons=f_obs_active.epsilons().data().as_double())
     alpha, beta = alpha_beta_est.alpha_beta_for_each_reflection(
         f_obs=self.f_obs_complete.select(
             self.f_obs_complete.d_spacings().data() >= self.d_min))
     f_obs.data().copy_selected(lone_indices_selection.iselection(),
                                flex.abs(f_calc.data()))
     t = maxlik.fo_fc_alpha_over_eps_beta(f_obs=f_obs,
                                          f_model=f_calc,
                                          alpha=alpha,
                                          beta=beta)
     hl_coeff = flex.hendrickson_lattman(
         t * flex.cos(f_calc.phases().data()),
         t * flex.sin(f_calc.phases().data()))
     dd = alpha.data()
     #
     hl_array = f_calc.array(
         data=self.hl_coeffs_start.common_set(f_calc).data() + hl_coeff)
     self.compute_phase_source(hl_array)
     fom = flex.abs(self.phase_source.data())
     mFo = hl_array.array(data=f_obs.data() * self.phase_source.data())
     DFc = hl_array.array(data=dd *
                          f_calc.as_amplitude_array().phase_transfer(
                              self.phase_source).data())
     centric_flags = f_obs.centric_flags().data()
     acentric_flags = ~centric_flags
     fo_scale = flex.double(centric_flags.size())
     fc_scale = flex.double(centric_flags.size())
     fo_scale.set_selected(acentric_flags, 2)
     fo_scale.set_selected(centric_flags, 1)
     fc_scale.set_selected(acentric_flags, 1)
     fc_scale.set_selected(centric_flags, 0)
     fo_scale.set_selected(lone_indices_selection, 0)
     fc_scale.set_selected(lone_indices_selection, -1)
     self.map_coeffs = hl_array.array(data=mFo.data() * fo_scale -
                                      DFc.data() * fc_scale)
     self.fom = hl_array.array(data=fom)
     self.hl_coeffs = hl_array
     # statistics
     self.r1_factor = f_obs_active.r1_factor(f_calc_active)
     fom = fom.select(matched_indices.pair_selection(0))
     self.r1_factor_fom = flex.sum(
       fom * flex.abs(f_obs_active.data() - f_calc_active.as_amplitude_array().data())) \
         / flex.sum(fom * f_obs_active.data())
     phase_source, phase_source_previous = self.phase_source.common_sets(
         self.phase_source_previous)
     self.mean_delta_phi = phase_error(
         flex.arg(phase_source.data()),
         flex.arg(phase_source_previous.data()))
     phase_source, phase_source_initial = self.phase_source.common_sets(
         self.phase_source_initial)
     self.mean_delta_phi_initial = phase_error(
         flex.arg(phase_source.data()),
         flex.arg(phase_source_initial.data()))
     self.mean_fom = flex.mean(fom)
     fom = f_obs_active.array(data=fom)
     if fom.data().size() < 1000:  # 2013-12-14 was hard-wired at 1000 tt
         reflections_per_bin = fom.data().size()
     else:
         reflections_per_bin = 1000
     fom.setup_binner(reflections_per_bin=reflections_per_bin)
     self.mean_fom_binned = fom.mean(use_binning=True)
示例#4
0
 def compute_map_coefficients(self):
   f_obs = self.f_obs_complete.select(self.f_obs_complete.d_spacings().data() >= self.d_min)
   f_calc = f_obs.structure_factors_from_map(self.map, use_sg=True)
   f_obs_active = f_obs.select_indices(self.active_indices)
   minimized = relative_scaling.ls_rel_scale_driver(
     f_obs_active,
     f_calc.as_amplitude_array().select_indices(self.active_indices),
     use_intensities=False,
     use_weights=False)
   #minimized.show()
   f_calc = f_calc.customized_copy(data=f_calc.data()\
                                   * math.exp(-minimized.p_scale)\
                                   * adptbx.debye_waller_factor_u_star(
                                     f_calc.indices(), minimized.u_star))
   f_calc_active = f_calc.common_set(f_obs_active)
   matched_indices = f_obs.match_indices(self.f_obs_active)
   lone_indices_selection = matched_indices.single_selection(0)
   from mmtbx.max_lik import maxlik
   alpha_beta_est = maxlik.alpha_beta_est_manager(
     f_obs=f_obs_active,
     f_calc=f_calc_active,
     free_reflections_per_bin=140,
     flags=flex.bool(f_obs_active.size()),
     interpolation=True,
     epsilons=f_obs_active.epsilons().data().as_double())
   alpha, beta = alpha_beta_est.alpha_beta_for_each_reflection(
     f_obs=self.f_obs_complete.select(self.f_obs_complete.d_spacings().data() >= self.d_min))
   f_obs.data().copy_selected(
     lone_indices_selection.iselection(), flex.abs(f_calc.data()))
   t = maxlik.fo_fc_alpha_over_eps_beta(
     f_obs=f_obs,
     f_model=f_calc,
     alpha=alpha,
     beta=beta)
   hl_coeff = flex.hendrickson_lattman(
     t * flex.cos(f_calc.phases().data()),
     t * flex.sin(f_calc.phases().data()))
   dd = alpha.data()
   #
   hl_array = f_calc.array(
     data=self.hl_coeffs_start.common_set(f_calc).data()+hl_coeff)
   self.compute_phase_source(hl_array)
   fom = flex.abs(self.phase_source.data())
   mFo = hl_array.array(data=f_obs.data()*self.phase_source.data())
   DFc = hl_array.array(data=dd*f_calc.as_amplitude_array().phase_transfer(
       self.phase_source).data())
   centric_flags = f_obs.centric_flags().data()
   acentric_flags = ~centric_flags
   fo_scale = flex.double(centric_flags.size())
   fc_scale = flex.double(centric_flags.size())
   fo_scale.set_selected(acentric_flags, 2)
   fo_scale.set_selected(centric_flags, 1)
   fc_scale.set_selected(acentric_flags, 1)
   fc_scale.set_selected(centric_flags, 0)
   fo_scale.set_selected(lone_indices_selection, 0)
   fc_scale.set_selected(lone_indices_selection, -1)
   self.map_coeffs = hl_array.array(
     data=mFo.data()*fo_scale - DFc.data()*fc_scale)
   self.fom = hl_array.array(data=fom)
   self.hl_coeffs = hl_array
   # statistics
   self.r1_factor = f_obs_active.r1_factor(f_calc_active)
   fom = fom.select(matched_indices.pair_selection(0))
   self.r1_factor_fom = flex.sum(
     fom * flex.abs(f_obs_active.data() - f_calc_active.as_amplitude_array().data())) \
       / flex.sum(fom * f_obs_active.data())
   phase_source, phase_source_previous = self.phase_source.common_sets(
     self.phase_source_previous)
   self.mean_delta_phi = phase_error(
     flex.arg(phase_source.data()), flex.arg(phase_source_previous.data()))
   phase_source, phase_source_initial = self.phase_source.common_sets(
     self.phase_source_initial)
   self.mean_delta_phi_initial = phase_error(
     flex.arg(phase_source.data()), flex.arg(phase_source_initial.data()))
   self.mean_fom = flex.mean(fom)
   fom = f_obs_active.array(data=fom)
   if fom.data().size()<1000: # 2013-12-14 was hard-wired at 1000 tt
     reflections_per_bin=fom.data().size()
   else:
     reflections_per_bin=1000
   fom.setup_binner(reflections_per_bin=reflections_per_bin)
   self.mean_fom_binned = fom.mean(use_binning=True)