Пример #1
0
def demo():
    cs = crystal.symmetry(
        unit_cell = "40, 50, 60, 90, 90, 90",
        space_group_symbol = "Hall: P 1")

    sg_explorer = pointgroup_tools.space_group_graph_from_cell_and_sg(
        cs.unit_cell(), cs.space_group(), 3.0)

    for sg, cell in sg_explorer.return_likely_sg_and_cell():
        print '%20s' % sg.build_derived_point_group().type( \
            ).universal_hermann_mauguin_symbol(), \
              '%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f' % cell.parameters()
Пример #2
0
    def group_xds_results(self, show_details=True):
        self.groups = map(lambda g: list(g), nx.connected_components(self.G))
        self.groups.sort(key=lambda x:-len(x))
        self.grouped_dirs = []
        self.reference_symmetries = []

        for i, sg in enumerate(self.groups):
            self.reference_symmetries.append([])
            avg_cell = uctbx.unit_cell(self._average_p1_cell(sg))
            print >>self.out, "[%2d]"%(i+1), len(sg), "members:"
            print >>self.out, " Averaged P1 Cell=", " ".join(map(lambda x:"%.2f"%x, avg_cell.parameters()))
            print >>self.out, " Members=", sg
            if show_details:
                # by explore_metric_symmetry
                print >>self.out, " Possible symmetries:"
                sg_explorer = pointgroup_tools.space_group_graph_from_cell_and_sg(avg_cell,  sgtbx.space_group_info("P1").group(), max_delta=10)
                tmp = []
                for obj in sg_explorer.pg_graph.graph.node_objects.values():
                    pg = obj.allowed_xtal_syms[0][0].space_group().build_derived_reflection_intensity_group(True).info()
                    cbop = obj.allowed_xtal_syms[0][1]
                    trans_cell = avg_cell.change_basis(cbop)

                    # Transform to best cell
                    fbc = crystal.find_best_cell(crystal.symmetry(trans_cell, space_group_info=pg,
                                                                  assert_is_compatible_unit_cell=False))
                    cbop = fbc.cb_op() * cbop
                    trans_cell = trans_cell.change_basis(fbc.cb_op())
                    #print "debug:: op-to-best-cell=", fbc.cb_op()

                    # If beta<90 in monoclinic system, force it to have beta>90
                    if pg.group().crystal_system() == "Monoclinic" and trans_cell.parameters()[4] < 90:
                        op = sgtbx.change_of_basis_op("-h,-k,l")
                        cbop = op * cbop
                        trans_cell = trans_cell.change_basis(op)

                    self.reference_symmetries[i].append((pg, trans_cell))
                    tmp.append(["   %-10s %s %s" % (pg, " ".join(map(lambda x:"%6.2f"%x, trans_cell.parameters())), cbop), pg.type().number()])
                for t in sorted(tmp, key=lambda x:x[1]):
                    print >> self.out, t[0]
                
                self.reference_symmetries[i].sort(key=lambda x:x[0].type().number())

                # by pointless results
                sgs = map(lambda x: self.symms[x].space_group(), sg)
                sgs_set = set(sgs)
                print >>self.out, " Space group and frequency in processed results:"
                for s in sorted(sgs_set, key=lambda x:x.type().number()):
                    print >>self.out, "   %-10s: %4d files" % (s.info(), sgs.count(s))
                print >>self.out, ""

            dirs = map(lambda x: self.dirs[x], sg)
            self.grouped_dirs.append(dirs)
def tst_sg_tools():
    unit_cell = uctbx.unit_cell('40, 50, 60, 90.0, 90.0, 90.0')
    mi = flex.miller_index(((2, 4, 6), (2, 4, 8)))
    xs = crystal.symmetry(unit_cell, "P 1 1 21")
    ms = miller.set(xs, mi)

    tmp_choice = pt.space_group_graph_from_cell_and_sg(unit_cell,
                                                       xs.space_group())

    xs1 = crystal.symmetry(
        uctbx.unit_cell('40.00 60.00 50.00 90.00 90.00 90.00'), 'P 1 21 1')

    xs2 = crystal.symmetry(
        uctbx.unit_cell('40.00 50.00 60.00 90.00 90.00 90.00'), 'P 2 2 21')

    xs3 = crystal.symmetry(
        uctbx.unit_cell('40.00 60.00 50.00 90.00 90.00 90.00'), 'P 21 21 2')

    xs4 = crystal.symmetry(
        uctbx.unit_cell('50.00 60.00 40.00 90.00 90.00 90.00'), 'P 21 21 2')

    xs5 = crystal.symmetry(
        uctbx.unit_cell('40.00 50.00 60.00 90.00 90.00 90.00'), 'P 21 21 21')

    p222_dict = {
        str(xs2.unit_cell().parameters()) + " " + str(xs2.space_group_info()):
        None,
        str(xs3.unit_cell().parameters()) + " " + str(xs3.space_group_info()):
        None,
        str(xs4.unit_cell().parameters()) + " " + str(xs4.space_group_info()):
        None,
        str(xs5.unit_cell().parameters()) + " " + str(xs5.space_group_info()):
        None
    }

    p112 = tmp_choice.pg_graph.graph.node_objects['P 1 1 2'].allowed_xtal_syms
    # check the cell parameters
    assert approx_equal(p112[0][0].unit_cell().parameters(),
                        xs1.unit_cell().parameters())
    # check the sg
    assert p112[0][0].space_group() == xs1.space_group()
    # check the change of basis operator
    assert approx_equal(
        xs.change_basis(p112[0][1]).unit_cell().parameters(),
        xs1.unit_cell().parameters())

    p222 = tmp_choice.pg_graph.graph.node_objects['P 2 2 2'].allowed_xtal_syms

    for xs in p222:
        comp_string = (str(xs[0].unit_cell().parameters()) + " " +
                       str(xs[0].space_group_info()))
        assert p222_dict.has_key(comp_string)
def tst_sg_tools():
  unit_cell = uctbx.unit_cell('40, 50, 60, 90.0, 90.0, 90.0')
  mi = flex.miller_index(((2,4,6), (2,4,8)))
  xs = crystal.symmetry(unit_cell, "P 1 1 21")
  ms = miller.set(xs, mi)

  tmp_choice = pt.space_group_graph_from_cell_and_sg(unit_cell,
                                                     xs.space_group())

  xs1=crystal.symmetry(uctbx.unit_cell('40.00 60.00 50.00 90.00 90.00 90.00'),
                       'P 1 21 1')

  xs2=crystal.symmetry(uctbx.unit_cell('40.00 50.00 60.00 90.00 90.00 90.00'),
                       'P 2 2 21')

  xs3=crystal.symmetry(uctbx.unit_cell('40.00 60.00 50.00 90.00 90.00 90.00'),
                       'P 21 21 2')

  xs4=crystal.symmetry(uctbx.unit_cell('50.00 60.00 40.00 90.00 90.00 90.00'),
                       'P 21 21 2')

  xs5=crystal.symmetry(uctbx.unit_cell('40.00 50.00 60.00 90.00 90.00 90.00'),
                       'P 21 21 21')

  p222_dict = { str( xs2.unit_cell().parameters())
                + " " + str( xs2.space_group_info() ): None,
                str( xs3.unit_cell().parameters())
                + " " + str( xs3.space_group_info() ):None,
                str( xs4.unit_cell().parameters())
                + " " + str( xs4.space_group_info() ):None,
                str( xs5.unit_cell().parameters())
                + " " + str( xs5.space_group_info() ):None
                }


  p112 = tmp_choice.pg_graph.graph.node_objects['P 1 1 2'].allowed_xtal_syms
  # check the cell parameters
  assert approx_equal(p112[0][0].unit_cell().parameters(),
                      xs1.unit_cell().parameters())
  # check the sg
  assert p112[0][0].space_group() == xs1.space_group()
  # check the change of basis operator
  assert approx_equal(xs.change_basis(p112[0][1]).unit_cell().parameters(),
                      xs1.unit_cell().parameters())

  p222 = tmp_choice.pg_graph.graph.node_objects['P 2 2 2'].allowed_xtal_syms

  for xs in p222:
    comp_string = (str(xs[0].unit_cell().parameters())
                   + " " + str(xs[0].space_group_info()))
    assert p222_dict.has_key(comp_string)
def do_pointgroup_tricks(input_uc,
                         input_ls,
                         max_delta,
                         out=None):
  if out is None:
    out = sys.stdout

  sg_explorer = pgt.space_group_graph_from_cell_and_sg(
      input_uc,
      input_ls,
      max_delta)


  print >> out, "A summary of the constructed point group graph object is given below"
  print >> out, "===================================================================="
  print >> out
  print >> out, "----------------------"
  print >> out, "Input crystal symmetry"
  print >> out, "----------------------"
  print >> out, "Unit cell: ", input_uc.parameters()
  print >> out, "Unit cell volume: ", input_uc.volume()
  print >> out, "Space group: ", sgtbx.space_group_info( group=input_ls )
  print >> out
  print >> out
  print >> out, "--------------------------"
  print >> out, "Lattice symmetry deduction"
  print >> out, "--------------------------"
  print >> out, "Niggli cell: ", sg_explorer.xs_prim_set.unit_cell().parameters()
  print >> out, "Niggli cell volume: ", sg_explorer.xs_prim_set.unit_cell().volume()
  print >> out, "Niggli transformed input symmetry: ", sg_explorer.xs_prim_set.space_group_info()
  print >> out, "Symmetry of Niggli cell: ", sgtbx.space_group_info( group = sg_explorer.pg_high )
  print >> out
  print >> out
  print >> out, "All pointgroups that are both a subgroup of the lattice symmetry and"
  print >> out, "a supergroup of the Niggli transformed input symmetry wil now be listed,"
  print >> out, "as well as their minimal supergroups/maximal subgroups and symmetry"
  print >> out, "operators that generate them."
  print >> out, "For each pointgroup, a list of compatible spacegroups will be listed."
  print >> out, "Care is taken that there are no systematic absence violation with the "
  print >> out, "provided input spacegroup."
  print >> out
  out.flush()

  sg_explorer.show(out=out)

  # return the object
  return sg_explorer
def do_pointgroup_tricks(input_uc,
                         input_ls,
                         max_delta,
                         out=None):
  if out is None:
    out = sys.stdout

  sg_explorer = pgt.space_group_graph_from_cell_and_sg(
      input_uc,
      input_ls,
      max_delta)


  print("A summary of the constructed point group graph object is given below", file=out)
  print("====================================================================", file=out)
  print(file=out)
  print("----------------------", file=out)
  print("Input crystal symmetry", file=out)
  print("----------------------", file=out)
  print("Unit cell: ", input_uc.parameters(), file=out)
  print("Unit cell volume: ", input_uc.volume(), file=out)
  print("Space group: ", sgtbx.space_group_info( group=input_ls ), file=out)
  print(file=out)
  print(file=out)
  print("--------------------------", file=out)
  print("Lattice symmetry deduction", file=out)
  print("--------------------------", file=out)
  print("Niggli cell: ", sg_explorer.xs_prim_set.unit_cell().parameters(), file=out)
  print("Niggli cell volume: ", sg_explorer.xs_prim_set.unit_cell().volume(), file=out)
  print("Niggli transformed input symmetry: ", sg_explorer.xs_prim_set.space_group_info(), file=out)
  print("Symmetry of Niggli cell: ", sgtbx.space_group_info( group = sg_explorer.pg_high ), file=out)
  print(file=out)
  print(file=out)
  print("All pointgroups that are both a subgroup of the lattice symmetry and", file=out)
  print("a supergroup of the Niggli transformed input symmetry wil now be listed,", file=out)
  print("as well as their minimal supergroups/maximal subgroups and symmetry", file=out)
  print("operators that generate them.", file=out)
  print("For each pointgroup, a list of compatible spacegroups will be listed.", file=out)
  print("Care is taken that there are no systematic absence violation with the ", file=out)
  print("provided input spacegroup.", file=out)
  print(file=out)
  out.flush()

  sg_explorer.show(out=out)

  # return the object
  return sg_explorer
Пример #7
0
    def group_xds_results(self, out, show_details=True):
        print >> out, "Making groups from %d results\n" % len(
            self.p1cells)  # Show total and failed!!

        self.groups = map(lambda g: list(g), nx.connected_components(self.G))
        self.groups.sort(key=lambda x: -len(x))
        self.grouped_dirs = []
        self.reference_symmetries = []

        #details_str = "group file a b c al be ga\n"
        #ofs_debug = open("cell_debug.dat", "w")
        #ofs_debug.write("group xdsdir a b c al be ga\n")

        for i, keys in enumerate(self.groups):
            self.reference_symmetries.append([])
            avg_cell = uctbx.unit_cell(self._average_p1_cell(keys))
            print >> out, "[%2d]" % (i + 1), len(keys), "members:"
            print >> out, " Averaged P1 Cell=", " ".join(
                map(lambda x: "%.2f" % x, avg_cell.parameters()))

            #from yamtbx.util.xtal import format_unit_cell
            #for xd, uc in zip(map(lambda k:self.dirs[k], keys), self._transformed_cells(keys)):
            #    ofs_debug.write("%3d %s %s\n" % (i, xd, format_unit_cell(uc)))

            #print >>out, " Members=", keys
            if show_details:
                # by explore_metric_symmetry
                sg_explorer = pointgroup_tools.space_group_graph_from_cell_and_sg(
                    avg_cell,
                    sgtbx.space_group_info("P1").group(),
                    max_delta=10)
                tmp = []
                for obj in sg_explorer.pg_graph.graph.node_objects.values():
                    pg = obj.allowed_xtal_syms[0][0].space_group(
                    ).build_derived_reflection_intensity_group(True).info()
                    cbop = obj.allowed_xtal_syms[0][1]
                    trans_cell = avg_cell.change_basis(cbop)

                    if pg.group() == sgtbx.space_group_info("I2").group():
                        print >> out, "Warning!! I2 cell was given."  # this should not happen..

                    # Transform to best cell
                    fbc = crystal.find_best_cell(
                        crystal.symmetry(trans_cell,
                                         space_group_info=pg,
                                         assert_is_compatible_unit_cell=False),
                        best_monoclinic_beta=False
                    )  # If True, C2 may result in I2..
                    cbop = fbc.cb_op() * cbop
                    trans_cell = trans_cell.change_basis(fbc.cb_op())
                    #print "debug:: op-to-best-cell=", fbc.cb_op()

                    # If beta<90 in monoclinic system, force it to have beta>90
                    if pg.group().crystal_system(
                    ) == "Monoclinic" and trans_cell.parameters()[4] < 90:
                        op = sgtbx.change_of_basis_op("-h,-k,l")
                        cbop = op * cbop
                        trans_cell = trans_cell.change_basis(op)

                    tmp.append([0, pg, trans_cell, cbop, pg.type().number()])

                # Calculate frequency
                for pgnum in set(map(lambda x: x[-1], tmp)):
                    sel = filter(lambda x: tmp[x][-1] == pgnum,
                                 xrange(len(tmp)))
                    pgg = tmp[sel[0]][1].group()

                    if len(sel) == 1:
                        freq = len(
                            filter(
                                lambda x: self.symms[x].space_group().
                                build_derived_reflection_intensity_group(
                                    True) == pgg, keys))
                        tmp[sel[0]][0] = freq
                    else:
                        trans_cells = map(
                            lambda x: numpy.array(tmp[x][2].parameters()), sel)

                        for key in keys:
                            if self.symms[key].space_group(
                            ).build_derived_reflection_intensity_group(
                                    True) != pgg:
                                continue
                            cell = numpy.array(
                                self.symms[key].unit_cell().parameters())
                            celldiffs = map(lambda tc: sum(abs(tc - cell)),
                                            trans_cells)
                            min_key = celldiffs.index(min(celldiffs))
                            tmp[sel[min_key]][0] += 1

                print >> out, " Possible symmetries:"
                print >> out, "   freq symmetry     a      b      c     alpha  beta   gamma reindex"
                for freq, pg, trans_cell, cbop, pgnum in sorted(
                        tmp, key=lambda x: x[-1]):
                    print >> out, "   %4d %-10s %s %s" % (freq, pg, " ".join(
                        map(lambda x: "%6.2f" % x,
                            trans_cell.parameters())), cbop)
                    self.reference_symmetries[i].append((pg, trans_cell, freq))
                print >> out, ""

            dirs = map(lambda x: self.dirs[x], keys)
            self.grouped_dirs.append(dirs)
def test_extensively( this_chunk ):
  n_chunks = 1
  i_chunk = int(this_chunk)

  assert i_chunk <= n_chunks
  for i_sg, sg in enumerate(sgtbx.space_group_symbol_iterator()):
    if i_sg % n_chunks != i_chunk:
      continue

    buffer = StringIO()

    group = sgtbx.space_group(sg.hall())

    #if group != sgtbx.space_group_info( symbol = 'I 21 21 21' ).group() :
    #  continue

    unit_cell =sgtbx.space_group_info(group=group).any_compatible_unit_cell(
      volume=57*57*76)

    xs_in = crystal.symmetry(unit_cell=unit_cell, space_group=group)
    xs_in = xs_in.best_cell()

    # Just make sure we have the 'best cell' to start out with

    xs_minimum = xs_in.change_basis(xs_in.change_of_basis_op_to_niggli_cell())

    sg_min = xs_minimum.space_group()
    sg_min_info = sgtbx.space_group_info(group = sg_min)
    sg_min_to_ref = sg_min_info.change_of_basis_op_to_reference_setting()
    sg_in_to_min = xs_in.change_of_basis_op_to_niggli_cell()

    xs_ref = xs_minimum.change_basis(sg_min_to_ref)
    best_cell_finder = fbc(xs_ref.unit_cell(),
                           xs_ref.space_group())
    xs_ref = best_cell_finder.return_best_xs()

    xs_lattice_pg = sgtbx.lattice_symmetry.group(
      xs_minimum.unit_cell(),
      max_delta=5.0)
    sg_in_ref_setting = sg_min.change_basis(sg_min_to_ref)

    # -----------
    queue = []
    if sg_in_ref_setting.is_chiral():
      print "Testing : ",\
            sgtbx.space_group_info(group=group),\
            "( or ", sgtbx.space_group_info(group=sg_in_ref_setting),\
            " in reference setting)"
      for s in sg_min:
        new_sg = sgtbx.space_group()
        new_sg.expand_smx(s)
        if new_sg in queue:
          continue
        else:
          queue.append(new_sg)
        xs_cheat = crystal.symmetry(xs_minimum.unit_cell(),
                                    space_group=new_sg)
        #print
        #print "Using symop", s

        xs_cheat_min = xs_cheat.change_basis(
          xs_cheat.change_of_basis_op_to_niggli_cell() )

        #print "This results in space group: ", xs_cheat.space_group_info()

        sg_clues = pt.space_group_graph_from_cell_and_sg(
          xs_cheat_min.unit_cell(),
          xs_cheat_min.space_group() )

        #sg_clues.show()

        found_it = False
        #print
        #print " --- Spacegroups consistent with input parameters ---"
        for sg_and_uc in sg_clues.return_likely_sg_and_cell():
          check_sg = False
          check_uc = False
          xs = crystal.symmetry(sg_and_uc[1], space_group=sg_and_uc[0])
          if approx_equal(
            sg_and_uc[1].parameters(),
            xs_ref.unit_cell().parameters(),
            eps=0.001,
            out=buffer):
            if sg_and_uc[0] == sg_in_ref_setting:
              found_it = True

          #print sgtbx.space_group_info( group=sg_and_uc[0] ), \
          #      sg_and_uc[1].parameters()
        if not found_it:
          print "FAILURE: ", sg.hall()
          assert found_it
def test_extensively(this_chunk):
    n_chunks = 1
    i_chunk = int(this_chunk)

    assert i_chunk <= n_chunks
    for i_sg, sg in enumerate(sgtbx.space_group_symbol_iterator()):
        if i_sg % n_chunks != i_chunk:
            continue

        buffer = StringIO()

        group = sgtbx.space_group(sg.hall())

        #if group != sgtbx.space_group_info( symbol = 'I 21 21 21' ).group():
        #  continue

        unit_cell = sgtbx.space_group_info(
            group=group).any_compatible_unit_cell(volume=57 * 57 * 76)

        xs_in = crystal.symmetry(unit_cell=unit_cell, space_group=group)
        xs_in = xs_in.best_cell()

        # Just make sure we have the 'best cell' to start out with

        xs_minimum = xs_in.change_basis(
            xs_in.change_of_basis_op_to_niggli_cell())

        sg_min = xs_minimum.space_group()
        sg_min_info = sgtbx.space_group_info(group=sg_min)
        sg_min_to_ref = sg_min_info.change_of_basis_op_to_reference_setting()
        sg_in_to_min = xs_in.change_of_basis_op_to_niggli_cell()

        xs_ref = xs_minimum.change_basis(sg_min_to_ref)
        best_cell_finder = fbc(xs_ref.unit_cell(), xs_ref.space_group())
        xs_ref = best_cell_finder.return_best_xs()

        xs_lattice_pg = sgtbx.lattice_symmetry.group(xs_minimum.unit_cell(),
                                                     max_delta=5.0)
        sg_in_ref_setting = sg_min.change_basis(sg_min_to_ref)

        # -----------
        queue = []
        if sg_in_ref_setting.is_chiral():
            print "Testing : ",\
                  sgtbx.space_group_info(group=group),\
                  "( or ", sgtbx.space_group_info(group=sg_in_ref_setting),\
                  " in reference setting)"
            for s in sg_min:
                new_sg = sgtbx.space_group()
                new_sg.expand_smx(s)
                if new_sg in queue:
                    continue
                else:
                    queue.append(new_sg)
                xs_cheat = crystal.symmetry(xs_minimum.unit_cell(),
                                            space_group=new_sg)
                #print
                #print "Using symop", s

                xs_cheat_min = xs_cheat.change_basis(
                    xs_cheat.change_of_basis_op_to_niggli_cell())

                #print "This results in space group: ", xs_cheat.space_group_info()

                sg_clues = pt.space_group_graph_from_cell_and_sg(
                    xs_cheat_min.unit_cell(), xs_cheat_min.space_group())

                #sg_clues.show()

                found_it = False
                #print
                #print " --- Spacegroups consistent with input parameters ---"
                for sg_and_uc in sg_clues.return_likely_sg_and_cell():
                    check_sg = False
                    check_uc = False
                    xs = crystal.symmetry(sg_and_uc[1],
                                          space_group=sg_and_uc[0])
                    if approx_equal(sg_and_uc[1].parameters(),
                                    xs_ref.unit_cell().parameters(),
                                    eps=0.001,
                                    out=buffer):
                        if sg_and_uc[0] == sg_in_ref_setting:
                            found_it = True

                    #print sgtbx.space_group_info( group=sg_and_uc[0] ), \
                    #      sg_and_uc[1].parameters()
                if not found_it:
                    print "FAILURE: ", sg.hall()
                    assert found_it
    def group_xds_results(self, show_details=True):
        self.groups = map(lambda g: list(g), nx.connected_components(self.G))
        self.groups.sort(key=lambda x:-len(x))
        self.grouped_dirs = []
        self.reference_symmetries = []

        for i, sg in enumerate(self.groups):
            self.reference_symmetries.append([])
            avg_cell = uctbx.unit_cell(self._average_p1_cell(sg))
            print >>self.out, "[%2d]"%(i+1), len(sg), "members:"
            print >>self.out, " Averaged P1 Cell=", " ".join(map(lambda x:"%.2f"%x, avg_cell.parameters()))
            print >>self.out, " Members=", sg
            if show_details:
                # by explore_metric_symmetry
                sg_explorer = pointgroup_tools.space_group_graph_from_cell_and_sg(avg_cell,  sgtbx.space_group_info("P1").group(), max_delta=10)
                tmp = []
                for obj in sg_explorer.pg_graph.graph.node_objects.values():
                    pg = obj.allowed_xtal_syms[0][0].space_group().build_derived_reflection_intensity_group(True).info()
                    cbop = obj.allowed_xtal_syms[0][1]
                    trans_cell = avg_cell.change_basis(cbop)

                    if pg.group() == sgtbx.space_group_info("I2").group():
                        print >>self.out, "Warning!! I2 cell was given." # Not sure if this happens..

                    # Transform to best cell
                    fbc = crystal.find_best_cell(crystal.symmetry(trans_cell, space_group_info=pg,
                                                                  assert_is_compatible_unit_cell=False),
                                                 best_monoclinic_beta=False) # If True, C2 may result in I2..
                    cbop = fbc.cb_op() * cbop
                    trans_cell = trans_cell.change_basis(fbc.cb_op())
                    #print "debug:: op-to-best-cell=", fbc.cb_op()

                    # If beta<90 in monoclinic system, force it to have beta>90
                    if pg.group().crystal_system() == "Monoclinic" and trans_cell.parameters()[4] < 90:
                        op = sgtbx.change_of_basis_op("-h,-k,l")
                        cbop = op * cbop
                        trans_cell = trans_cell.change_basis(op)

                    tmp.append([0, pg, trans_cell, cbop, pg.type().number()])

                # Calculate frequency
                for pgnum in set(map(lambda x: x[-1], tmp)):
                    sel = filter(lambda x: tmp[x][-1]==pgnum, xrange(len(tmp)))
                    pgg = tmp[sel[0]][1].group()

                    if len(sel) == 1:
                        freq = len(filter(lambda x: self.symms[x].space_group().build_derived_reflection_intensity_group(True) == pgg, sg))
                        tmp[sel[0]][0] = freq
                    else:
                        trans_cells = map(lambda x: numpy.array(tmp[x][2].parameters()), sel)
                        
                        for idx in sg:
                            if self.symms[idx].space_group().build_derived_reflection_intensity_group(True) != pgg: continue
                            cell = numpy.array(self.symms[idx].unit_cell().parameters())
                            celldiffs = map(lambda tc: sum(abs(tc-cell)), trans_cells)
                            min_idx = celldiffs.index(min(celldiffs))
                            tmp[sel[min_idx]][0] += 1

                print >>self.out, " Possible symmetries:"
                print >>self.out, "   freq symmetry     a      b      c     alpha  beta   gamma reindex"
                for freq, pg, trans_cell, cbop, pgnum in sorted(tmp, key=lambda x:x[-1]):
                    print >> self.out, "   %4d %-10s %s %s" % (freq, pg, " ".join(map(lambda x:"%6.2f"%x, trans_cell.parameters())), cbop)
                    self.reference_symmetries[i].append((pg, trans_cell, freq))

            dirs = map(lambda x: self.dirs[x], sg)
            self.grouped_dirs.append(dirs)