def show_process_info(out):
  print >> out, "\\/"*39
  introspection.virtual_memory_info().show_if_available(out=out, show_max=True)
  xray.structure_factors.global_counters.show(out=out)
  print >> out, format_cpu_times()
  print >> out, "/\\"*39
  out.flush()
Exemple #2
0
def show_process_info(out):
    print >> out, "\\/" * 39
    introspection.virtual_memory_info().show_if_available(out=out,
                                                          show_max=True)
    xray.structure_factors.global_counters.show(out=out)
    print >> out, format_cpu_times()
    print >> out, "/\\" * 39
    out.flush()
Exemple #3
0
 def __init__(self, manager, xray_structure, miller_set, algorithm="fft"):
     scattering_type_registry = xray_structure.scattering_type_registry()
     if (len(scattering_type_registry.unassigned_types()) > 0):
         self.show_unknown_scatterers(registry=scattering_type_registry)
     time_all = user_plus_sys_time()
     managed_calculation_base.__init__(self,
                                       manager,
                                       xray_structure,
                                       miller_set,
                                       algorithm="fft")
     assert miller_set.d_min() > manager.d_min() * (1 - 1e-6)
     manager.setup_fft()  # before timing
     time_sampling = user_plus_sys_time()
     sampled_density = ext.sampled_model_density(
         unit_cell=xray_structure.unit_cell(),
         scatterers=xray_structure.scatterers(),
         scattering_type_registry=scattering_type_registry,
         fft_n_real=manager.rfft().n_real(),
         fft_m_real=manager.rfft().m_real(),
         u_base=manager.u_base(),
         wing_cutoff=manager.wing_cutoff(),
         exp_table_one_over_step_size=manager.exp_table_one_over_step_size(
         ),
         force_complex=manager.force_complex(),
         sampled_density_must_be_positive=manager.
         sampled_density_must_be_positive(),
         tolerance_positive_definite=manager.tolerance_positive_definite())
     time_sampling = time_sampling.elapsed()
     time_fft = user_plus_sys_time()
     if (not sampled_density.anomalous_flag()):
         sf_map = manager.rfft().forward(sampled_density.real_map())
         collect_conj = True
     else:
         sf_map = manager.cfft().backward(sampled_density.complex_map())
         collect_conj = False
     time_fft = time_fft.elapsed()
     time_from_map = user_plus_sys_time()
     self._f_calc_data = maptbx.structure_factors.from_map(
         space_group=miller_set.space_group(),
         anomalous_flag=sampled_density.anomalous_flag(),
         miller_indices=miller_set.indices(),
         complex_map=sf_map,
         conjugate_flag=collect_conj).data()
     time_from_map = time_from_map.elapsed()
     time_apply_u_extra = user_plus_sys_time()
     sampled_density.eliminate_u_extra_and_normalize(
         miller_set.indices(), self._f_calc_data)
     time_apply_u_extra = time_apply_u_extra.elapsed()
     introspection.virtual_memory_info().update_max()
     manager.estimate_time_fft.register(
         n_scatterers=xray_structure.scatterers().size(),
         n_miller_indices=miller_set.indices().size(),
         time_sampling=time_sampling,
         time_fft=time_fft,
         time_from_or_to_map=time_from_map,
         time_apply_u_extra=time_apply_u_extra)
     global_counters.from_scatterers_fft.process(time_all.elapsed())
Exemple #4
0
def show_vm_info(msg):
  print msg
  from libtbx import introspection
  introspection.virtual_memory_info().show(prefix="  ", show_max=True)
  global _show_vm_info_time
  t = time.time()
  print "  time since previous: %.2f seconds" % (t-_show_vm_info_time)
  _show_vm_info_time = t
  print
  sys.stdout.flush()
def show_vm_info(msg):
  print msg
  from libtbx import introspection
  introspection.virtual_memory_info().show(prefix="  ", show_max=True)
  global _show_vm_info_time
  t = time.time()
  print "  time since previous: %.2f seconds" % (t-_show_vm_info_time)
  _show_vm_info_time = t
  print
  sys.stdout.flush()
 def __init__(self, manager,
                    xray_structure,
                    miller_set,
                    algorithm="fft"):
   time_all = user_plus_sys_time()
   managed_calculation_base.__init__(self,
     manager, xray_structure, miller_set, algorithm="fft")
   assert miller_set.d_min() > manager.d_min() * (1-1e-6)
   manager.setup_fft() # before timing
   time_sampling = user_plus_sys_time()
   sampled_density = ext.sampled_model_density(
     unit_cell=xray_structure.unit_cell(),
     scatterers=xray_structure.scatterers(),
     scattering_type_registry=xray_structure.scattering_type_registry(),
     fft_n_real=manager.rfft().n_real(),
     fft_m_real=manager.rfft().m_real(),
     u_base=manager.u_base(),
     wing_cutoff=manager.wing_cutoff(),
     exp_table_one_over_step_size=manager.exp_table_one_over_step_size(),
     force_complex=manager.force_complex(),
     sampled_density_must_be_positive=
       manager.sampled_density_must_be_positive(),
     tolerance_positive_definite=manager.tolerance_positive_definite())
   time_sampling = time_sampling.elapsed()
   time_fft = user_plus_sys_time()
   if (not sampled_density.anomalous_flag()):
     sf_map = manager.rfft().forward(sampled_density.real_map())
     collect_conj = True
   else:
     sf_map = manager.cfft().backward(sampled_density.complex_map())
     collect_conj = False
   time_fft = time_fft.elapsed()
   time_from_map = user_plus_sys_time()
   self._f_calc_data = maptbx.structure_factors.from_map(
     space_group=miller_set.space_group(),
     anomalous_flag=sampled_density.anomalous_flag(),
     miller_indices=miller_set.indices(),
     complex_map=sf_map,
     conjugate_flag=collect_conj).data()
   time_from_map = time_from_map.elapsed()
   time_apply_u_extra = user_plus_sys_time()
   sampled_density.eliminate_u_extra_and_normalize(
     miller_set.indices(),
     self._f_calc_data)
   time_apply_u_extra = time_apply_u_extra.elapsed()
   introspection.virtual_memory_info().update_max()
   manager.estimate_time_fft.register(
     n_scatterers=xray_structure.scatterers().size(),
     n_miller_indices=miller_set.indices().size(),
     time_sampling=time_sampling,
     time_fft=time_fft,
     time_from_or_to_map=time_from_map,
     time_apply_u_extra=time_apply_u_extra)
   global_counters.from_scatterers_fft.process(time_all.elapsed())
Exemple #7
0
 def __init__(self, manager, xray_structure, u_iso_refinable_params,
              miller_set, d_target_d_f_calc, n_parameters):
     time_all = time_apply_u_extra = user_plus_sys_time()
     gradients_base.__init__(self,
                             manager,
                             xray_structure,
                             miller_set,
                             algorithm="fft")
     self._d_target_d_f_calc = d_target_d_f_calc
     manager.setup_fft()  # before timing
     time_apply_u_extra = user_plus_sys_time()
     self._results = ext.fast_gradients(
         unit_cell=xray_structure.unit_cell(),
         scatterers=xray_structure.scatterers(),
         scattering_type_registry=xray_structure.scattering_type_registry(),
         u_base=manager.u_base(),
         wing_cutoff=manager.wing_cutoff(),
         exp_table_one_over_step_size=manager.exp_table_one_over_step_size(
         ),
         tolerance_positive_definite=manager.tolerance_positive_definite())
     coeff = self._gradient_map_coeff()
     time_apply_u_extra = time_apply_u_extra.elapsed()
     time_from_or_to_map = user_plus_sys_time()
     coeff_map = self._gradient_map_coeff_to_map(coeff)
     time_from_or_to_map = time_from_or_to_map.elapsed()
     time_fft = user_plus_sys_time()
     if (not coeff.anomalous_flag()):
         gradient_map = manager.rfft().backward(coeff_map.complex_map())
     else:
         gradient_map = manager.cfft().backward(coeff_map.complex_map())
     time_fft = time_fft.elapsed()
     time_sampling = user_plus_sys_time()
     self._results.sampling(
         scatterers=xray_structure.scatterers(),
         u_iso_refinable_params=u_iso_refinable_params,
         scattering_type_registry=xray_structure.scattering_type_registry(),
         site_symmetry_table=xray_structure.site_symmetry_table(),
         ft_d_target_d_f_calc=gradient_map,
         n_parameters=n_parameters,
         sampled_density_must_be_positive=manager.
         sampled_density_must_be_positive())
     time_sampling = time_sampling.elapsed()
     introspection.virtual_memory_info().update_max()
     manager.estimate_time_fft.register(
         n_scatterers=xray_structure.scatterers().size(),
         n_miller_indices=miller_set.indices().size(),
         time_sampling=time_sampling,
         time_fft=time_fft,
         time_from_or_to_map=time_from_or_to_map,
         time_apply_u_extra=time_apply_u_extra)
     self.d_target_d_site_frac_was_used = False
     self.d_target_d_u_star_was_used = False
     global_counters.gradients_fft.process(time_all.elapsed())
 def __init__(self, manager,
                    xray_structure,
                    u_iso_refinable_params,
                    miller_set,
                    d_target_d_f_calc,
                    n_parameters):
   time_all = time_apply_u_extra = user_plus_sys_time()
   gradients_base.__init__(self,
     manager, xray_structure, miller_set, algorithm="fft")
   self._d_target_d_f_calc = d_target_d_f_calc
   manager.setup_fft() # before timing
   time_apply_u_extra = user_plus_sys_time()
   self._results = ext.fast_gradients(
     unit_cell=xray_structure.unit_cell(),
     scatterers=xray_structure.scatterers(),
     scattering_type_registry=xray_structure.scattering_type_registry(),
     u_base=manager.u_base(),
     wing_cutoff=manager.wing_cutoff(),
     exp_table_one_over_step_size=manager.exp_table_one_over_step_size(),
     tolerance_positive_definite=manager.tolerance_positive_definite())
   coeff = self._gradient_map_coeff()
   time_apply_u_extra = time_apply_u_extra.elapsed()
   time_from_or_to_map = user_plus_sys_time()
   coeff_map = self._gradient_map_coeff_to_map(coeff)
   time_from_or_to_map = time_from_or_to_map.elapsed()
   time_fft = user_plus_sys_time()
   if (not coeff.anomalous_flag()):
     gradient_map = manager.rfft().backward(coeff_map.complex_map())
   else:
     gradient_map = manager.cfft().backward(coeff_map.complex_map())
   time_fft = time_fft.elapsed()
   time_sampling = user_plus_sys_time()
   self._results.sampling(
     scatterers=xray_structure.scatterers(),
     u_iso_refinable_params=u_iso_refinable_params,
     scattering_type_registry=xray_structure.scattering_type_registry(),
     site_symmetry_table=xray_structure.site_symmetry_table(),
     ft_d_target_d_f_calc=gradient_map,
     n_parameters=n_parameters,
     sampled_density_must_be_positive=
       manager.sampled_density_must_be_positive())
   time_sampling = time_sampling.elapsed()
   introspection.virtual_memory_info().update_max()
   manager.estimate_time_fft.register(
     n_scatterers=xray_structure.scatterers().size(),
     n_miller_indices=miller_set.indices().size(),
     time_sampling=time_sampling,
     time_fft=time_fft,
     time_from_or_to_map=time_from_or_to_map,
     time_apply_u_extra=time_apply_u_extra)
   self.d_target_d_site_frac_was_used = False
   self.d_target_d_u_star_was_used = False
   global_counters.gradients_fft.process(time_all.elapsed())
Exemple #9
0
def run(args):
    assert len(args) == 0
    import_modules()
    import time
    t_start = time.time()
    from libtbx import introspection
    import os
    import sysconfig
    print "After script imports:"
    print "  wall clock time: %.2f" % (time.time() - t_start)
    print
    mb = 1024 * 1024
    lib = os.path.join(
        os.environ[
            "LIBTBX_BUILD"],  # intentionally not using libtbx.env for speed
        "lib")
    ext_so = []
    for node in os.listdir(lib):
        pylibext = sysconfig.get_config_vars("SO")[0]
        if (node.endswith("_ext" + pylibext)):
            ext_so.append(node.split(".")[0])
    ext_so.sort(cmp_so)
    print "Before importing extensions:"
    vmi = introspection.virtual_memory_info()
    vmi.show(prefix="  ")
    prev_vms = vmi.get_bytes('VmSize:')
    prev_rss = vmi.get_bytes('VmRSS:')
    print "  wall clock time: %.2f" % (time.time() - t_start)
    print
    for so in ext_so:
        t0 = time.time()
        exec("import %s" % so)
        vmi = introspection.virtual_memory_info()
        vms = vmi.get_bytes('VmSize:')
        rss = vmi.get_bytes('VmRSS:')
        if (vms is not None):  # won't work on Mac
            print "%.2f %3.0f %3.0f %s" % (time.time() - t0,
                                           (vms - prev_vms) / mb,
                                           (rss - prev_rss) / mb, so)
        else:
            assert (sys.platform in ["darwin", "win32"])
            print "%.2f %s" % (time.time() - t0, so)
        prev_vms = vms
        prev_rss = rss
    print
    print "After importing all extensions:"
    introspection.virtual_memory_info().show(prefix="  ")
    print "  wall clock time: %.2f" % (time.time() - t_start)
    print
def run(args):
  assert len(args) == 0
  import_modules()
  import time
  t_start = time.time()
  from libtbx import introspection
  import os
  import sysconfig
  print "After script imports:"
  print "  wall clock time: %.2f" % (time.time() - t_start)
  print
  mb = 1024 * 1024
  lib = os.path.join(
    os.environ["LIBTBX_BUILD"], # intentionally not using libtbx.env for speed
    "lib")
  ext_so = []
  for node in os.listdir(lib):
    pylibext = sysconfig.get_config_vars("SO")[0]
    if (node.endswith("_ext" + pylibext)):
      ext_so.append(node.split(".")[0])
  ext_so.sort(cmp_so)
  print "Before importing extensions:"
  vmi = introspection.virtual_memory_info()
  vmi.show(prefix="  ")
  prev_vms = vmi.get_bytes('VmSize:')
  prev_rss = vmi.get_bytes('VmRSS:')
  print "  wall clock time: %.2f" % (time.time() - t_start)
  print
  for so in ext_so:
    t0 = time.time()
    exec("import %s" % so)
    vmi = introspection.virtual_memory_info()
    vms = vmi.get_bytes('VmSize:')
    rss = vmi.get_bytes('VmRSS:')
    if (vms is not None) : # won't work on Mac
      print "%.2f %3.0f %3.0f %s" % (
        time.time()-t0, (vms-prev_vms)/mb, (rss-prev_rss)/mb, so)
    else :
      assert (sys.platform in ["darwin", "win32"])
      print "%.2f %s" % (time.time()-t0, so)
    prev_vms = vms
    prev_rss = rss
  print
  print "After importing all extensions:"
  introspection.virtual_memory_info().show(prefix="  ")
  print "  wall clock time: %.2f" % (time.time() - t_start)
  print
Exemple #11
0
 def call(self, f, msg):
     t0 = time.time()
     f()
     sa = size_as_string_with_commas(introspection.virtual_memory_info().
                                     current_max_sizes().virtual_memory)
     if (self.show):
         delta = time.time() - t0
         self.time_cumulative += delta
         print "%6.2f %8.2f %15s:" % (delta, self.time_cumulative, sa), msg
         sys.stdout.flush()
Exemple #12
0
 def call(self, func, prefix):
   t0 = time.time()
   result = func()
   sa=size_as_string_with_commas(
     introspection.virtual_memory_info().current_max_sizes().virtual_memory)
   if(self.params.show_time):
     delta = time.time()-t0
     self.time_cumulative += delta
     print("%6.2f %8.2f %15s:"%(delta, self.time_cumulative, sa), prefix)
     sys.stdout.flush()
   return result
Exemple #13
0
def run(args):
    assert len(args) == 0
    import time
    t_start = time.time()
    from libtbx import introspection
    import os
    print "After script imports:"
    print "  wall clock time: %.2f" % (time.time() - t_start)
    print
    mb = 1024 * 1024
    lib = os.path.join(
        os.environ[
            "LIBTBX_BUILD"],  # intentionally not using libtbx.env for speed
        "lib")
    ext_so = []
    for node in os.listdir(lib):
        if (node.endswith("_ext.so")):
            ext_so.append(node[:-3])
    ext_so.sort(cmp_so)
    print "Before importing extensios:"
    vmi = introspection.virtual_memory_info()
    vmi.show(prefix="  ")
    prev_vms = vmi.get_bytes('VmSize:')
    prev_rss = vmi.get_bytes('VmRSS:')
    print "  wall clock time: %.2f" % (time.time() - t_start)
    print
    for so in ext_so:
        t0 = time.time()
        exec("import %s" % so)
        vmi = introspection.virtual_memory_info()
        vms = vmi.get_bytes('VmSize:')
        rss = vmi.get_bytes('VmRSS:')
        print "%.2f %3.0f %3.0f %s" % (time.time() - t0, (vms - prev_vms) / mb,
                                       (rss - prev_rss) / mb, so)
        prev_vms = vms
        prev_rss = rss
    print
    print "After importing all extensios:"
    introspection.virtual_memory_info().show(prefix="  ")
    print "  wall clock time: %.2f" % (time.time() - t_start)
    print
Exemple #14
0
def run(args):
  assert len(args) == 0
  import time
  t_start = time.time()
  from libtbx import introspection
  import os
  print "After script imports:"
  print "  wall clock time: %.2f" % (time.time() - t_start)
  print
  mb = 1024 * 1024
  lib = os.path.join(
    os.environ["LIBTBX_BUILD"], # intentionally not using libtbx.env for speed
    "lib")
  ext_so = []
  for node in os.listdir(lib):
    if (node.endswith("_ext.so")):
      ext_so.append(node[:-3])
  ext_so.sort(cmp_so)
  print "Before importing extensios:"
  vmi = introspection.virtual_memory_info()
  vmi.show(prefix="  ")
  prev_vms = vmi.get_bytes('VmSize:')
  prev_rss = vmi.get_bytes('VmRSS:')
  print "  wall clock time: %.2f" % (time.time() - t_start)
  print
  for so in ext_so:
    t0 = time.time()
    exec("import %s" % so)
    vmi = introspection.virtual_memory_info()
    vms = vmi.get_bytes('VmSize:')
    rss = vmi.get_bytes('VmRSS:')
    print "%.2f %3.0f %3.0f %s" % (
      time.time()-t0, (vms-prev_vms)/mb, (rss-prev_rss)/mb, so)
    prev_vms = vms
    prev_rss = rss
  print
  print "After importing all extensios:"
  introspection.virtual_memory_info().show(prefix="  ")
  print "  wall clock time: %.2f" % (time.time() - t_start)
  print
 def __init__(self,
       xray_structure,
       ignore_zero_occupancy_atoms,
       solvent_radius,
       shrink_truncation_radius,
       ignore_hydrogen_atoms=True,
       gridding_n_real=None,
       grid_step=None,
       atom_radii=None):
    global number_of_mask_calculations
    number_of_mask_calculations += 1
    assert [gridding_n_real, grid_step].count(None) == 1
    self.xray_structure = xray_structure
    if (gridding_n_real is None):
      gridding_n_real = maptbx.crystal_gridding(
        unit_cell=xray_structure.unit_cell(),
        step=grid_step).n_real()
    if(atom_radii is None):
      atom_radii = vdw_radii_from_xray_structure(xray_structure =
        self.xray_structure)
    sites_frac = xray_structure.sites_frac()
    self.n_atoms_excluded = 0
    selection = flex.bool(xray_structure.scatterers().size(), True)
    if(ignore_zero_occupancy_atoms):
      selection &= xray_structure.scatterers().extract_occupancies() > 0
    if(ignore_hydrogen_atoms):
      selection &= (~xray_structure.hd_selection())
    sites_frac = sites_frac.select(selection)
    atom_radii = atom_radii.select(selection)
    self.n_atoms_excluded = selection.count(False)
    around_atoms.__init__(self,
      unit_cell           = xray_structure.unit_cell(),
      space_group_order_z = xray_structure.space_group().order_z(),
      sites_frac          = sites_frac,
      atom_radii          = atom_radii,
      gridding_n_real     = gridding_n_real,
      solvent_radius      = solvent_radius,
      shrink_truncation_radius = shrink_truncation_radius)
    introspection.virtual_memory_info().update_max()
Exemple #16
0
 def __init__(self,
              xray_structure,
              ignore_zero_occupancy_atoms,
              solvent_radius,
              shrink_truncation_radius,
              ignore_hydrogen_atoms=True,
              gridding_n_real=None,
              grid_step=None,
              atom_radii=None):
     global number_of_mask_calculations
     number_of_mask_calculations += 1
     assert [gridding_n_real, grid_step].count(None) == 1
     self.xray_structure = xray_structure
     if (gridding_n_real is None):
         gridding_n_real = maptbx.crystal_gridding(
             unit_cell=xray_structure.unit_cell(), step=grid_step).n_real()
     if (atom_radii is None):
         atom_radii = vdw_radii_from_xray_structure(
             xray_structure=self.xray_structure)
     sites_frac = xray_structure.sites_frac()
     self.n_atoms_excluded = 0
     selection = flex.bool(xray_structure.scatterers().size(), True)
     if (ignore_zero_occupancy_atoms):
         selection &= xray_structure.scatterers().extract_occupancies() > 0
     if (ignore_hydrogen_atoms):
         selection &= (~xray_structure.hd_selection())
     sites_frac = sites_frac.select(selection)
     atom_radii = atom_radii.select(selection)
     self.n_atoms_excluded = selection.count(False)
     around_atoms.__init__(
         self,
         unit_cell=xray_structure.unit_cell(),
         space_group_order_z=xray_structure.space_group().order_z(),
         sites_frac=sites_frac,
         atom_radii=atom_radii,
         gridding_n_real=gridding_n_real,
         solvent_radius=solvent_radius,
         shrink_truncation_radius=shrink_truncation_radius)
     introspection.virtual_memory_info().update_max()
Exemple #17
0
def show_process_info(out):
    print >> out, "\\/" * 39
    introspection.virtual_memory_info().show_if_available(out=out,
                                                          show_max=True)
    print >> out, "/\\" * 39
    out.flush()
Exemple #18
0
def run(args, log=sys.stdout):
    """phenix.mtriage:
  Given map file and optionally model and half-map files compute map statistics.

How to run:
  phenix.mtriage model_file_name=m.pdb map_file_name=m.map half_map_file_name_1=m1.map half_map_file_name_2=m2.map

Optional: model_file_name=, half_map_file_name_1=, half_map_file_name_2=

Feedback:
  [email protected]
  [email protected]
  """
    assert len(locals().keys()) == 2  # intentional
    print >> log, "-" * 79
    print >> log, run.__doc__
    print >> log, "-" * 79
    introspection.virtual_memory_info().show_if_available(
        out=null_out(), show_max=True)  # just to initialize something
    # Get inputs
    inputs = get_inputs(args=args, log=log, master_params=master_params)
    #
    task_obj = mmtbx.maps.mtriage.mtriage(map_inp=inputs.map_inp,
                                          map_inp_1=inputs.map_inp_1,
                                          map_inp_2=inputs.map_inp_2,
                                          pdb_inp=inputs.pdb_inp,
                                          params=inputs.params)
    results = task_obj.get_results()
    #
    # Map statistics
    #
    broadcast(m="Map statistics:", log=log)
    print >> log, "Map:"
    print >> log, "  origin:      ", results.counts.origin
    print >> log, "  last:        ", results.counts.last
    print >> log, "  focus:       ", results.counts.focus
    print >> log, "  all:         ", results.counts.all
    print >> log, "  min,max,mean:", results.counts.min_max_mean
    print >> log, "  d_min_corner:", "%7.3f" % results.counts.d_min_corner
    #
    print >> log, "Half-maps:"
    if (inputs.map_inp_1 is None):
        print >> log, "  Half-maps are not provided."
    #
    print >> log, "Histogram(s) of map values (masked):"
    show_histogram(map_histograms=results.histograms, log=log)
    # show results
    fv = format_value
    fs = "%8.2f"
    rm = results.masked
    ru = results.unmasked
    if ([rm, ru].count(None) == 0):
        print >> log, "Map resolution estimates:              masked unmasked"
        print >> log, "  using map alone (d99)            :", fv(
            fs, rm.d99), fv(fs, ru.d99)
        print >> log, "  using map alone (d9999)          :", fv(
            fs, rm.d9999), fv(fs, ru.d9999)
        print >> log, "  comparing with model (d_model)   :", fv(
            fs, rm.d_model), fv(fs, ru.d_model)
        print >> log, "    b_iso_overall                  :", fv(
            fs, rm.b_iso_overall), fv(fs, ru.b_iso_overall)
        print >> log, "  comparing with model (d_model_b0):", fv(
            fs, rm.d_model_b0), fv(fs, ru.d_model_b0)
        print >> log, "    b_iso_overall=0"
        print >> log, "  d_fsc_model:"
        print >> log, "    FSC(map,model map)=0           :", fv(
            fs, rm.d_fsc_model_0), fv(fs, ru.d_fsc_model_0)
        print >> log, "    FSC(map,model map)=0.143       :", fv(
            fs, rm.d_fsc_model_0143), fv(fs, ru.d_fsc_model_0143)
        print >> log, "    FSC(map,model map)=0.5         :", fv(
            fs, rm.d_fsc_model_05), fv(fs, ru.d_fsc_model_05)
        print >> log, "  d99 (half map 1)                 :", fv(
            fs, rm.d99_1), fv(fs, ru.d99_1)
        print >> log, "  d99 (half map 2)                 :", fv(
            fs, rm.d99_2), fv(fs, ru.d99_2)
        print >> log, "  FSC(half map 1,2)=0.143 (d_fsc)  :", fv(
            fs, rm.d_fsc), fv(fs, ru.d_fsc)
        print >> log
        #
        print >> log, "Radius used for mask smoothing:", format_value(
            "%6.2f", results.masked.radius_smooth)
        print >> log
    else:
        r = rm
        if (r is None): r = ru
        print >> log, "Map resolution estimates:              masked unmasked"
        print >> log, "  using map alone (d99)            :", fv(fs, r.d99)
        print >> log, "  using map alone (d9999)          :", fv(fs, r.d9999)
        print >> log, "  comparing with model (d_model)   :", fv(fs, r.d_model)
        print >> log, "    b_iso_overall                  :", fv(
            fs, r.b_iso_overall)
        print >> log, "  comparing with model (d_model_b0):", fv(
            fs, r.d_model_b0)
        print >> log, "    b_iso_overall=0"
        print >> log, "  d_fsc_model:"
        print >> log, "    FSC(map,model map)=0           :", fv(
            fs, r.d_fsc_model_0)
        print >> log, "    FSC(map,model map)=0.143       :", fv(
            fs, r.d_fsc_model_0143)
        print >> log, "    FSC(map,model map)=0.5         :", fv(
            fs, r.d_fsc_model_05)
        print >> log, "  d99 (half map 1)                 :", fv(fs, r.d99_1)
        print >> log, "  d99 (half map 2)                 :", fv(fs, r.d99_2)
        print >> log, "  FSC(half map 1,2)=0.143 (d_fsc)  :", fv(fs, r.d_fsc)
        print >> log
        #
        print >> log, "Radius used for mask smoothing:", format_value(
            "%s", str(r.radius_smooth))
        print >> log
    #
    for r in [(results.masked, "masked"), (results.unmasked, "unmasked")]:
        if (r[0] is None): continue
        # FSC_model curve
        if (r[0].fsc_curve_model is not None):
            file_name = "%s.%s.mtriage.log" % (
                inputs.params.fsc_model_plot_file_name_prefix, r[1])
            of = open(file_name, "w")
            for a, b in zip(r[0].fsc_curve_model.d_inv,
                            r[0].fsc_curve_model.fsc):
                print >> of, "%15.9f %15.9f" % (a, b)
            of.close()
            print >> log, "FSC(model map, map) is written to %s" % file_name
        # Mask
        if (inputs.params.write_mask_file and r[0].mask is not None):
            print >> log, "Mask is written to %s" % inputs.params.mask_file_name
            ccp4_map.write_ccp4_map(
                file_name=inputs.params.mask_file_name,
                unit_cell=inputs.crystal_symmetry.unit_cell(),
                space_group=inputs.crystal_symmetry.space_group(),
                map_data=r[0].mask,
                labels=flex.std_string(["mask"]))
        # FSC (half-maps) curve
        if (r[0].fsc_curve is not None):
            file_name = "%s.%s.mtriage.log" % (
                inputs.params.fsc_half_maps_file_name_prefix, r[1])
            of = open(file_name, "w")
            for a, b in zip(r[0].fsc_curve.fsc.d_inv, r[0].fsc_curve.fsc.fsc):
                print >> of, "%15.9f %15.9f" % (a, b)
            of.close()
            print >> log, "FSC(half map 1, half map 1) is written to %s" % file_name
    #
    return results  # required for GUI
#! /usr/bin/env phenix.python
import scitbx.array_family.flex
from libtbx.introspection import virtual_memory_info
from libtbx.utils import Sorry
from libtbx.utils import get_memory_from_string

kilobyte = 1024
megabyte = kilobyte * 1024
vmi = virtual_memory_info()
vms = vmi.virtual_memory_size()
maximum_memory = 8000 * megabyte

print vmi
print vms // megabyte
print float(vms) / maximum_memory * 100