Пример #1
0
def compute(miller_array, step_scale=0.0005):
    miller_array.show_comprehensive_summary(prefix="  ")
    step = miller_array.d_min() * step_scale
    #
    ma_p1 = miller_array.expand_to_p1()
    #
    n_h = {}
    n_k = {}
    n_l = {}
    indices = ma_p1.indices()
    for ind in indices:
        h, k, l = ind
        n_h.setdefault(h, flex.int()).append(1)
        n_k.setdefault(k, flex.int()).append(1)
        n_l.setdefault(l, flex.int()).append(1)

    def count(d):
        for k in d.keys():
            d[k] = d[k].size()
        return d

    n_h = count(n_h)
    n_k = count(n_k)
    n_l = count(n_l)
    # resolutions along axes
    a, b, c = miller_array.unit_cell().parameters()[:3]
    x, rho_x = one_d_image_along_axis(n=n_h, step=step, uc_length=a)
    y, rho_y = one_d_image_along_axis(n=n_k, step=step, uc_length=b)
    z, rho_z = one_d_image_along_axis(n=n_l, step=step, uc_length=c)
    # 2nd derivatives
    r2x = second_derivatives(rho=rho_x, delta=step)
    r2y = second_derivatives(rho=rho_y, delta=step)
    r2z = second_derivatives(rho=rho_z, delta=step)
    # effective resolution along axes
    d_eff_a = compute_d_eff(r=x, rho_2nd=r2x)
    d_eff_b = compute_d_eff(r=y, rho_2nd=r2y)
    d_eff_c = compute_d_eff(r=z, rho_2nd=r2z)
    print("  Effective resolution along axes a,b,c: %6.3f %6.3f %6.3f" %
          (d_eff_a, d_eff_b, d_eff_c))
    # all directions
    l = 0.8 * min(d_eff_a / 2.5, d_eff_b / 2.5, d_eff_c / 2.5)
    r = 1.2 * max(d_eff_a / 2.5, d_eff_b / 2.5, d_eff_c / 2.5)
    us = regular_grid_on_unit_sphere.rosca(m=9, hemisphere=True)
    d_effs = flex.double()
    o = maptbx.ft_analytical_1d_point_scatterer_at_origin(N=100000)
    for i, u in enumerate(us):
        o.compute(miller_indices=indices,
                  step=step,
                  left=l,
                  right=r,
                  u_frac=miller_array.unit_cell().fractionalize(u))
        dist, rho_ = o.distances(), o.rho()
        rho2 = second_derivatives(rho=rho_, delta=step)
        d_eff = compute_d_eff(r=dist, rho_2nd=rho2)
        d_effs.append(d_eff)
    print("  Effective resolution (min,max): %8.3f%8.3f" %
          (flex.min(d_effs), flex.max(d_effs)))
def compute(miller_array, step_scale=0.0005):
  miller_array.show_comprehensive_summary(prefix="  ")
  step = miller_array.d_min()*step_scale
  #
  ma_p1 = miller_array.expand_to_p1()
  #
  n_h = {}
  n_k = {}
  n_l = {}
  indices = ma_p1.indices()
  for ind in indices:
    h,k,l = ind
    n_h.setdefault(h, flex.int()).append(1)
    n_k.setdefault(k, flex.int()).append(1)
    n_l.setdefault(l, flex.int()).append(1)
  def count(d):
    for k in d.keys():
      d[k] = d[k].size()
    return d
  n_h = count(n_h)
  n_k = count(n_k)
  n_l = count(n_l)
  # resolutions along axes
  a,b,c = miller_array.unit_cell().parameters()[:3]
  x, rho_x = one_d_image_along_axis(n=n_h, step=step, uc_length=a)
  y, rho_y = one_d_image_along_axis(n=n_k, step=step, uc_length=b)
  z, rho_z = one_d_image_along_axis(n=n_l, step=step, uc_length=c)
  # 2nd derivatives
  r2x = second_derivatives(rho=rho_x, delta=step)
  r2y = second_derivatives(rho=rho_y, delta=step)
  r2z = second_derivatives(rho=rho_z, delta=step)
  # effective resolution along axes
  d_eff_a = compute_d_eff(r=x, rho_2nd=r2x)
  d_eff_b = compute_d_eff(r=y, rho_2nd=r2y)
  d_eff_c = compute_d_eff(r=z, rho_2nd=r2z)
  print "  Effective resolution along axes a,b,c: %6.3f %6.3f %6.3f"%(
    d_eff_a, d_eff_b, d_eff_c)
  # all directions
  l = 0.8 * min(d_eff_a/2.5, d_eff_b/2.5, d_eff_c/2.5)
  r = 1.2 * max(d_eff_a/2.5, d_eff_b/2.5, d_eff_c/2.5)
  us = regular_grid_on_unit_sphere.rosca(m=9, hemisphere=True)
  d_effs = flex.double()
  o = maptbx.ft_analytical_1d_point_scatterer_at_origin(N=100000)
  for i, u in enumerate(us):
    o.compute(
      miller_indices=indices,
      step=step,
      left=l,
      right=r,
      u_frac=miller_array.unit_cell().fractionalize(u))
    dist, rho_ = o.distances(), o.rho()
    rho2 = second_derivatives(rho=rho_, delta=step)
    d_eff = compute_d_eff(r=dist, rho_2nd=rho2)
    d_effs.append(d_eff)
  print "  Effective resolution (min,max): %8.3f%8.3f"%(
    flex.min(d_effs), flex.max(d_effs))
def run():
  r = regular_grid_on_unit_sphere.rosca(m=9, hemisphere=False)
  assert r.size() == 649
  r = regular_grid_on_unit_sphere.rosca(m=9, hemisphere=True)
  assert r.size() == 361
def run():
  r = regular_grid_on_unit_sphere.rosca(m=9, hemisphere=False)
  assert r.size() == 649
  r = regular_grid_on_unit_sphere.rosca(m=9, hemisphere=True)
  assert r.size() == 361