Exemplo n.º 1
0
    def add_line_to_table(idx):
      x = sort_radii[idx]
      if self.tilecounts[x] < 3:
        radial = (0,0)
        tangential = (0,0)
        rmean,tmean,rsigma,tsigma=(0,0,1,1)
      else:
        radial,tangential,rmean,tmean,rsigma,tsigma = get_radial_tangential_vectors(self,x,
          self.post_mean_cv[x],
          self.correction_vector_x, self.correction_vector_y,
          self.model_calcx-self.refined_cntr_x,
          self.model_calcy-self.refined_cntr_y)

      table_data.append(  [
        format_value("%3d",   x),
        format_value("%7.2f", self.radii[x]),
        format_value("%6d",  self.tilecounts[x]),
        format_value("%5.2f", self.asymmetric_tile_rmsd[x]),
        format_value("%5.2f", self.tile_rmsd[x]),
        format_value("%5.2f", self.post_mean_cv[x][0]),
        format_value("%5.2f", self.post_mean_cv[x][1]),
        format_value("%5.2f", matrix.col(self.post_mean_cv[x]).length()),
        format_value("%6.2f", wtaveg[x]),
        format_value("%6.2f", rsigma),
        format_value("%6.2f", tsigma),
        format_value("%5.2f", self.tile_translations.x[2*x]),
        format_value("%5.2f", self.tile_translations.x[2*x+1]),
        "",
        format_value("%5.2f", self.tile_rotations.x[x])
      ])
Exemplo n.º 2
0
 def print_table(self):
  from libtbx import table_utils
  from libtbx.str_utils import format_value

  table_header = ["Tile","Dist","Nobs","aRmsd","Rmsd","delx","dely","disp","rotdeg","Rsigma","Tsigma"]
  table_data = []
  table_data.append(table_header)
  sort_radii = flex.sort_permutation(flex.double(self.radii))
  tile_rmsds = flex.double()
  radial_sigmas = flex.double(len(self.tiles) // 4)
  tangen_sigmas = flex.double(len(self.tiles) // 4)
  for idx in range(len(self.tiles) // 4):
    x = sort_radii[idx]
    if self.tilecounts[x] < 3:
      wtaveg = 0.0
      radial = (0,0)
      tangential = (0,0)
      rmean,tmean,rsigma,tsigma=(0,0,1,1)
    else:
      wtaveg = self.weighted_average_angle_deg_from_tile(x)
      radial,tangential,rmean,tmean,rsigma,tsigma = get_radial_tangential_vectors(self,x)

    radial_sigmas[x]=rsigma
    tangen_sigmas[x]=tsigma
    table_data.append(  [
      format_value("%3d",   x),
      format_value("%7.2f", self.radii[x]),
      format_value("%6d",  self.tilecounts[x]),
      format_value("%5.2f", self.asymmetric_tile_rmsd[x]),
      format_value("%5.2f", self.tile_rmsd[x]),
      format_value("%5.2f", self.mean_cv[x][0]),
      format_value("%5.2f", self.mean_cv[x][1]),
      format_value("%5.2f", matrix.col(self.mean_cv[x]).length()),
      format_value("%6.2f", wtaveg),
      format_value("%6.2f", rsigma),
      format_value("%6.2f", tsigma),
    ])
  table_data.append([""]*len(table_header))
  rstats = flex.mean_and_variance(radial_sigmas,self.tilecounts.as_double())
  tstats = flex.mean_and_variance(tangen_sigmas,self.tilecounts.as_double())
  table_data.append(  [
      format_value("%3s",   "ALL"),
      format_value("%s", ""),
      format_value("%6d",  self.overall_N),
      format_value("%5.2f", math.sqrt(flex.mean(self.delrsq))),
      format_value("%5.2f", self.overall_rmsd),
      format_value("%5.2f", self.overall_cv[0]),
      format_value("%5.2f", self.overall_cv[1]),
      format_value("%5.2f", flex.mean(flex.double([matrix.col(cv).length() for cv in self.mean_cv]))),
      format_value("%s", ""),
      format_value("%6.2f", rstats.mean()),
      format_value("%6.2f", tstats.mean()),
    ])

  print
  print table_utils.format(table_data,has_header=1,justify='center',delim=" ")
Exemplo n.º 3
0
 def print_table(self):
  from libtbx import table_utils
  from libtbx.str_utils import format_value

  table_header = ["Tile","Dist","Nobs","aRmsd","Rmsd","delx","dely","disp","rotdeg","Rsigma","Tsigma"]
  table_data = []
  table_data.append(table_header)
  sort_radii = flex.sort_permutation(flex.double(self.radii))
  tile_rmsds = flex.double()
  radial_sigmas = flex.double(len(self.tiles) // 4)
  tangen_sigmas = flex.double(len(self.tiles) // 4)
  for idx in range(len(self.tiles) // 4):
    x = sort_radii[idx]
    if self.tilecounts[x] < 3:
      wtaveg = 0.0
      radial = (0,0)
      tangential = (0,0)
      rmean,tmean,rsigma,tsigma=(0,0,1,1)
    else:
      wtaveg = self.weighted_average_angle_deg_from_tile(x)
      radial,tangential,rmean,tmean,rsigma,tsigma = get_radial_tangential_vectors(self,x)

    radial_sigmas[x]=rsigma
    tangen_sigmas[x]=tsigma
    table_data.append(  [
      format_value("%3d",   x),
      format_value("%7.2f", self.radii[x]),
      format_value("%6d",  self.tilecounts[x]),
      format_value("%5.2f", self.asymmetric_tile_rmsd[x]),
      format_value("%5.2f", self.tile_rmsd[x]),
      format_value("%5.2f", self.mean_cv[x][0]),
      format_value("%5.2f", self.mean_cv[x][1]),
      format_value("%5.2f", matrix.col(self.mean_cv[x]).length()),
      format_value("%6.2f", wtaveg),
      format_value("%6.2f", rsigma),
      format_value("%6.2f", tsigma),
    ])
  table_data.append([""]*len(table_header))
  rstats = flex.mean_and_variance(radial_sigmas,self.tilecounts.as_double())
  tstats = flex.mean_and_variance(tangen_sigmas,self.tilecounts.as_double())
  table_data.append(  [
      format_value("%3s",   "ALL"),
      format_value("%s", ""),
      format_value("%6d",  self.overall_N),
      format_value("%5.2f", math.sqrt(flex.mean(self.delrsq))),
      format_value("%5.2f", self.overall_rmsd),
      format_value("%5.2f", self.overall_cv[0]),
      format_value("%5.2f", self.overall_cv[1]),
      format_value("%5.2f", flex.mean(flex.double([matrix.col(cv).length() for cv in self.mean_cv]))),
      format_value("%s", ""),
      format_value("%6.2f", rstats.mean()),
      format_value("%6.2f", tstats.mean()),
    ])

  print
  print table_utils.format(table_data,has_header=1,justify='center',delim=" ")
Exemplo n.º 4
0
  def print_table(self):
    from libtbx import table_utils
    from libtbx.str_utils import format_value
    table_header = ["Tile","Dist","Nobs","aRmsd","Rmsd","delx","dely","disp","rotdeg",
                    "Rsigma","Tsigma","Transx","Transy","DelRot","Rotdeg"]
    table_data = []
    table_data.append(table_header)
    sort_radii = flex.sort_permutation(flex.double(self.radii))
    tile_rmsds = flex.double()
    radial_sigmas = flex.double(len(self.tiles) // 4)
    tangen_sigmas = flex.double(len(self.tiles) // 4)

    wtaveg = [0.]*(len(self.tiles) // 4)
    for x in range(len(self.tiles) // 4):
      if self.tilecounts[x] >= 3:
        wtaveg[x] = self.weighted_average_angle_deg_from_tile(x, self.post_mean_cv[x], self.correction_vector_x,
          self.correction_vector_y)

    for idx in range(len(self.tiles) // 4):
      x = sort_radii[idx]
      if self.tilecounts[x] < 3:
        radial = (0,0)
        tangential = (0,0)
        rmean,tmean,rsigma,tsigma=(0,0,1,1)
      else:
        radial,tangential,rmean,tmean,rsigma,tsigma = get_radial_tangential_vectors(self,x,
          self.post_mean_cv[x],
          self.correction_vector_x, self.correction_vector_y,
          self.model_calcx-self.refined_cntr_x,
          self.model_calcy-self.refined_cntr_y)

      # paired rotations of two ASICS on the same sensor
      if x%2==0:
        # previous method: delrot = "%5.2f"%(wtaveg[x]-wtaveg[x+1])
        delrot = "%5.2f"%(self.tile_rotations.x[x] - self.tile_rotations.x[1+x])
      else:
        delrot = ""

      radial_sigmas[x]=rsigma
      tangen_sigmas[x]=tsigma
      table_data.append(  [
        format_value("%3d",   x),
        format_value("%7.2f", self.radii[x]),
        format_value("%6d",  self.tilecounts[x]),
        format_value("%5.2f", self.asymmetric_tile_rmsd[x]),
        format_value("%5.2f", self.tile_rmsd[x]),
        format_value("%5.2f", self.post_mean_cv[x][0]),
        format_value("%5.2f", self.post_mean_cv[x][1]),
        format_value("%5.2f", matrix.col(self.post_mean_cv[x]).length()),
        format_value("%6.2f", wtaveg[x]),
        format_value("%6.2f", rsigma),
        format_value("%6.2f", tsigma),
        format_value("%5.2f", self.tile_translations.x[2*x]),
        format_value("%5.2f", self.tile_translations.x[2*x+1]),
        copy.copy(delrot),
        format_value("%5.2f", self.tile_rotations.x[x])
      ])
    table_data.append([""]*len(table_header))
    rstats = flex.mean_and_variance(radial_sigmas,self.tilecounts.as_double())
    tstats = flex.mean_and_variance(tangen_sigmas,self.tilecounts.as_double())
    table_data.append(  [
        format_value("%3s",   "ALL"),
        format_value("%s", ""),
        format_value("%6d",  self.overall_N),
        format_value("%5.2f", math.sqrt(flex.mean(self.delrsq))),
        format_value("%5.2f", self.overall_rmsd),
        format_value("%5.2f", self.overall_cv[0]),
        format_value("%5.2f", self.overall_cv[1]),
        format_value("%5.2f", flex.mean(flex.double([cv.length() for cv in self.post_mean_cv]))),
        format_value("%s", ""),
        format_value("%6.2f", rstats.mean()),
        format_value("%6.2f", tstats.mean()),
        format_value("%s", ""),
        format_value("%s", ""),
        #root mean squared difference in same-sensor (adjacent)-ASIC rotations, weighted by minimum # of observations on either ASIC of the sensor
        format_value("%5.2f", math.sqrt(
           flex.sum(
             flex.double([
               (min([self.tilecounts[2*isen],self.tilecounts[2*isen+1]])) *
                    (self.tile_rotations.x[2*isen] - self.tile_rotations.x[1+2*isen])**2
               for isen in xrange(len(self.tiles) // 8)]
             )
           )/
           flex.sum(
             flex.double(
               [(min([self.tilecounts[2*isen],self.tilecounts[2*isen+1]])) for isen in xrange(len(self.tiles) // 8)]
             )
           )
        )),
        format_value("%s", ""),
    ])

    print
    print table_utils.format(table_data,has_header=1,justify='center',delim=" ")
Exemplo n.º 5
0
def run_correction_vector_plot(working_phil):

    L = lines(working_phil)
    for line in L.vectors():
        pass  # pull out the information, lines class does all the work

    close_x = flex.double()
    close_y = flex.double()
    far_x = flex.double()
    far_y = flex.double()
    master_coords = L.master_coords
    master_cv = L.master_cv
    master_tiles = L.master_tiles
    for idx in range(0, len(master_coords), 10):
        if matrix.col(
                master_cv[idx]).length() < L.tile_rmsd[master_tiles[idx]]:
            pass
            #close_x.append(master_coords[idx][0])
            #close_y.append(master_coords[idx][1])
        else:
            far_x.append(master_coords[idx][0])
            far_y.append(master_coords[idx][1])
            close_x.append(master_coords[idx][0] + master_cv[idx][0])
            close_y.append(master_coords[idx][1] + master_cv[idx][1])
    if working_phil.show_plots is True:
        from matplotlib import pyplot as plt
        plt.plot(close_x, close_y, "r.")
        plt.plot(far_x, far_y, "g.")
        plt.axes().set_aspect("equal")
        plt.show()

    sort_radii = flex.sort_permutation(flex.double(L.radii))
    tile_rmsds = flex.double()
    radial_sigmas = flex.double(64)
    tangen_sigmas = flex.double(64)
    for idx in range(64):
        x = sort_radii[idx]
        print(
            "Tile %2d: radius %7.2f, %6d observations, delx %5.2f  dely %5.2f, rmsd = %5.2f"
            % (x, L.radii[x], L.tilecounts[x], L.mean_cv[x][0],
               L.mean_cv[x][1], L.tile_rmsd[x]),
            end=' ')
        if L.tilecounts[x] < 3:
            print()
            radial = (0, 0)
            tangential = (0, 0)
            rmean, tmean, rsigma, tsigma = (0, 0, 1, 1)
        else:
            wtaveg = L.weighted_average_angle_deg_from_tile(x)
            print("Tile rotation %6.2f deg" % wtaveg, end=' ')
            radial, tangential, rmean, tmean, rsigma, tsigma = get_radial_tangential_vectors(
                L, x)
            print("%6.2f %6.2f" % (rsigma, tsigma))
        radial_sigmas[x] = rsigma
        tangen_sigmas[x] = tsigma
    rstats = flex.mean_and_variance(radial_sigmas, L.tilecounts.as_double())
    tstats = flex.mean_and_variance(tangen_sigmas, L.tilecounts.as_double())

    print(
        "\nOverall                 %8d observations, delx %5.2f  dely %5.2f, rmsd = %5.2f"
        % (L.overall_N, L.overall_cv[0], L.overall_cv[1], L.overall_rmsd))
    print("Average tile rmsd %5.2f" % flex.mean(flex.double(L.tile_rmsd)))
    print("Average tile displacement %5.2f" %
          (flex.mean(flex.double([matrix.col(cv).length()
                                  for cv in L.mean_cv]))))
    print("Weighted average radial sigma %6.2f" % rstats.mean())
    print("Weighted average tangential sigma %6.2f" % tstats.mean())

    if working_phil.show_plots is True:
        plt.plot([(L.tiles[4 * x + 0] + L.tiles[4 * x + 2]) / 2.
                  for x in range(64)],
                 [(L.tiles[4 * x + 1] + L.tiles[4 * x + 3]) / 2.
                  for x in range(64)], "go")
        for x in range(64):
            plt.text(10 + (L.tiles[4 * x + 0] + L.tiles[4 * x + 2]) / 2.,
                     10 + (L.tiles[4 * x + 1] + L.tiles[4 * x + 3]) / 2.,
                     "%d" % x)
        plt.show()

        for idx in range(64):
            x = sort_radii[idx]
            print(
                "Tile %2d: radius %7.2f, %6d observations, delx %5.2f  dely %5.2f, rmsd = %5.2f"
                % (x, L.radii[x], L.tilecounts[x], L.mean_cv[x][0],
                   L.mean_cv[x][1], L.tile_rmsd[x]),
                end=' ')
            if L.tilecounts[x] < 3:
                print()
                radial = (0, 0)
                tangential = (0, 0)
                rmean, tmean, rsigma, tsigma = (0, 0, 1, 1)
            else:
                wtaveg = L.weighted_average_angle_deg_from_tile(x)
                print("Tile rotation %6.2f deg" % wtaveg, end=' ')
                radial, tangential, rmean, tmean, rsigma, tsigma = get_radial_tangential_vectors(
                    L, x)
                print("%6.2f %6.2f" % (rsigma, tsigma))

            if working_phil.colormap:
                from pylab import imshow, axes, colorbar, show
                import numpy

                xcv, ycv = get_correction_vector_xy(L, x)
                _min = min(min(xcv), min(ycv))
                _max = max(max(xcv), max(ycv))

                hist, xedges, yedges = numpy.histogram2d(xcv,
                                                         ycv,
                                                         bins=40,
                                                         range=[[_min, _max],
                                                                [_min, _max]])
                extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]

                imshow(hist.T,
                       extent=extent,
                       interpolation='nearest',
                       origin='lower')
                from matplotlib.patches import Ellipse
                ell = Ellipse(xy=(L.mean_cv[x][0], L.mean_cv[x][1]),
                              width=2. * rsigma,
                              height=2. * tsigma,
                              angle=math.atan2(-(radial[1]), -(radial[0])) *
                              180. / math.pi,
                              edgecolor="y",
                              linewidth=2,
                              fill=False,
                              zorder=100)
                axes().add_artist(ell)
                colorbar()
                show()

            else:
                from matplotlib import pyplot as plt
                xcv, ycv = get_correction_vector_xy(L, x)
                if len(xcv) == 0 or len(ycv) == 0: continue
                plt.plot(xcv, ycv, "r.")
                plt.plot([L.mean_cv[x][0]], [L.mean_cv[x][1]], "go")
                plt.plot([L.mean_cv[x][0] + radial[0]],
                         [L.mean_cv[x][1] + radial[1]], "yo")
                plt.plot([L.mean_cv[x][0] + tangential[0]],
                         [L.mean_cv[x][1] + tangential[1]], "bo")
                from matplotlib.patches import Ellipse
                ell = Ellipse(xy=(L.mean_cv[x][0], L.mean_cv[x][1]),
                              width=2. * rsigma,
                              height=2. * tsigma,
                              angle=math.atan2(-(radial[1]), -(radial[0])) *
                              180. / math.pi,
                              edgecolor="y",
                              linewidth=2,
                              fill=False,
                              zorder=100)
                plt.axes().add_artist(ell)
                plt.axes().set_aspect("equal")
                _min = min(min(xcv), min(ycv))
                _max = max(max(xcv), max(ycv))
                plt.axes().set_xlim(_min, _max)
                plt.axes().set_ylim(_min, _max)
                plt.show()
Exemplo n.º 6
0
    def print_table(self):
        from libtbx import table_utils
        from libtbx.str_utils import format_value

        table_header = [
            "Tile",
            "Dist",
            "Nobs",
            "aRmsd",
            "Rmsd",
            "delx",
            "dely",
            "disp",
            "rotdeg",
            "Rsigma",
            "Tsigma",
            "Transx",
            "Transy",
            "DelRot",
        ]
        table_data = []
        table_data.append(table_header)
        sort_radii = flex.sort_permutation(flex.double(self.radii))
        tile_rmsds = flex.double()
        radial_sigmas = flex.double(64)
        tangen_sigmas = flex.double(64)

        wtaveg = [0.0] * 64
        for x in xrange(64):
            if self.tilecounts[x] >= 3:
                wtaveg[x] = self.weighted_average_angle_deg_from_tile(
                    x, self.post_mean_cv[x], self.correction_vector_x, self.correction_vector_y
                )

        for idx in xrange(64):
            x = sort_radii[idx]
            if self.tilecounts[x] < 3:
                radial = (0, 0)
                tangential = (0, 0)
                rmean, tmean, rsigma, tsigma = (0, 0, 1, 1)
            else:
                radial, tangential, rmean, tmean, rsigma, tsigma = get_radial_tangential_vectors(self, x)

            # paired rotations of two ASICS on the same sensor
            if x % 2 == 0:
                delrot = "%5.2f" % (wtaveg[x] - wtaveg[x + 1])
            else:
                delrot = ""

            radial_sigmas[x] = rsigma
            tangen_sigmas[x] = tsigma
            table_data.append(
                [
                    format_value("%3d", x),
                    format_value("%7.2f", self.radii[x]),
                    format_value("%6d", self.tilecounts[x]),
                    format_value("%5.2f", self.asymmetric_tile_rmsd[x]),
                    format_value("%5.2f", self.tile_rmsd[x]),
                    format_value("%5.2f", self.post_mean_cv[x][0]),
                    format_value("%5.2f", self.post_mean_cv[x][1]),
                    format_value("%5.2f", matrix.col(self.post_mean_cv[x]).length()),
                    format_value("%6.2f", wtaveg[x]),
                    format_value("%6.2f", rsigma),
                    format_value("%6.2f", tsigma),
                    format_value("%5.2f", self.x[2 * x]),
                    format_value("%5.2f", self.x[2 * x + 1]),
                    copy.copy(delrot),
                ]
            )
        table_data.append([""] * len(table_header))
        rstats = flex.mean_and_variance(radial_sigmas, self.tilecounts.as_double())
        tstats = flex.mean_and_variance(tangen_sigmas, self.tilecounts.as_double())
        table_data.append(
            [
                format_value("%3s", "ALL"),
                format_value("%s", ""),
                format_value("%6d", self.overall_N),
                format_value("%5.2f", math.sqrt(flex.mean(self.delrsq))),
                format_value("%5.2f", self.overall_rmsd),
                format_value("%5.2f", self.overall_cv[0]),
                format_value("%5.2f", self.overall_cv[1]),
                format_value("%5.2f", flex.mean(flex.double([cv.length() for cv in self.post_mean_cv]))),
                format_value("%s", ""),
                format_value("%6.2f", rstats.mean()),
                format_value("%6.2f", tstats.mean()),
                format_value("%s", ""),
                format_value("%s", ""),
                format_value("%s", ""),
            ]
        )

        print
        print table_utils.format(table_data, has_header=1, justify="center", delim=" ")
Exemplo n.º 7
0
  def print_table(self):
    from libtbx import table_utils
    from libtbx.str_utils import format_value
    table_header = ["Tile","Dist","Nobs","aRmsd","Rmsd","delx","dely","disp","rotdeg",
                    "Rsigma","Tsigma","Transx","Transy","DelRot"]
    table_data = []
    table_data.append(table_header)
    sort_radii = flex.sort_permutation(flex.double(self.radii))
    tile_rmsds = flex.double()
    radial_sigmas = flex.double(64)
    tangen_sigmas = flex.double(64)

    wtaveg = [0.]*64
    for x in range(64):
      if self.tilecounts[x] >= 3:
        wtaveg[x] = self.weighted_average_angle_deg_from_tile(x, self.post_mean_cv[x], self.correction_vector_x,
          self.correction_vector_y)

    for idx in range(64):
      x = sort_radii[idx]
      if self.tilecounts[x] < 3:
        radial = (0,0)
        tangential = (0,0)
        rmean,tmean,rsigma,tsigma=(0,0,1,1)
      else:
        radial,tangential,rmean,tmean,rsigma,tsigma = get_radial_tangential_vectors(self,x)

      # paired rotations of two ASICS on the same sensor
      if x%2==0:
        delrot = "%5.2f"%(wtaveg[x]-wtaveg[x+1])
      else:
        delrot = ""

      radial_sigmas[x]=rsigma
      tangen_sigmas[x]=tsigma
      table_data.append(  [
        format_value("%3d",   x),
        format_value("%7.2f", self.radii[x]),
        format_value("%6d",  self.tilecounts[x]),
        format_value("%5.2f", self.asymmetric_tile_rmsd[x]),
        format_value("%5.2f", self.tile_rmsd[x]),
        format_value("%5.2f", self.post_mean_cv[x][0]),
        format_value("%5.2f", self.post_mean_cv[x][1]),
        format_value("%5.2f", matrix.col(self.post_mean_cv[x]).length()),
        format_value("%6.2f", wtaveg[x]),
        format_value("%6.2f", rsigma),
        format_value("%6.2f", tsigma),
        format_value("%5.2f", self.x[2*x]),
        format_value("%5.2f", self.x[2*x+1]),
        copy.copy(delrot)
      ])
    table_data.append([""]*len(table_header))
    rstats = flex.mean_and_variance(radial_sigmas,self.tilecounts.as_double())
    tstats = flex.mean_and_variance(tangen_sigmas,self.tilecounts.as_double())
    table_data.append(  [
        format_value("%3s",   "ALL"),
        format_value("%s", ""),
        format_value("%6d",  self.overall_N),
        format_value("%5.2f", math.sqrt(flex.mean(self.delrsq))),
        format_value("%5.2f", self.overall_rmsd),
        format_value("%5.2f", self.overall_cv[0]),
        format_value("%5.2f", self.overall_cv[1]),
        format_value("%5.2f", flex.mean(flex.double([cv.length() for cv in self.post_mean_cv]))),
        format_value("%s", ""),
        format_value("%6.2f", rstats.mean()),
        format_value("%6.2f", tstats.mean()),
        format_value("%s", ""),
        format_value("%s", ""),
        format_value("%s", ""),
      ])

    print()
    print(table_utils.format(table_data,has_header=1,justify='center',delim=" "))
def run_correction_vector_plot(working_phil):

  L = lines(working_phil)
  for line in L.vectors():
    pass # pull out the information, lines class does all the work

  close_x = flex.double()
  close_y = flex.double()
  far_x = flex.double()
  far_y = flex.double()
  master_coords = L.master_coords
  master_cv = L.master_cv
  master_tiles = L.master_tiles
  for idx in xrange(0,len(master_coords),10):
    if matrix.col(master_cv[idx]).length() < L.tile_rmsd[ master_tiles[idx] ]:
      pass
      #close_x.append(master_coords[idx][0])
      #close_y.append(master_coords[idx][1])
    else:
      far_x.append(master_coords[idx][0])
      far_y.append(master_coords[idx][1])
      close_x.append(master_coords[idx][0]+master_cv[idx][0])
      close_y.append(master_coords[idx][1]+master_cv[idx][1])
  if working_phil.show_plots is True:
    from matplotlib import pyplot as plt
    plt.plot(close_x,close_y,"r.")
    plt.plot(far_x,far_y,"g.")
    plt.axes().set_aspect("equal")
    plt.show()


  sort_radii = flex.sort_permutation(flex.double(L.radii))
  tile_rmsds = flex.double()
  radial_sigmas = flex.double(64)
  tangen_sigmas = flex.double(64)
  for idx in xrange(64):
    x = sort_radii[idx]
    print "Tile %2d: radius %7.2f, %6d observations, delx %5.2f  dely %5.2f, rmsd = %5.2f"%(
      x, L.radii[x], L.tilecounts[x], L.mean_cv[x][0], L.mean_cv[x][1],
      L.tile_rmsd[x]
        ),
    if L.tilecounts[x] < 3:
      print
      radial = (0,0)
      tangential = (0,0)
      rmean,tmean,rsigma,tsigma=(0,0,1,1)
    else:
      wtaveg = L.weighted_average_angle_deg_from_tile(x)
      print "Tile rotation %6.2f deg"%wtaveg,
      radial,tangential,rmean,tmean,rsigma,tsigma = get_radial_tangential_vectors(L,x)
      print "%6.2f %6.2f"%(rsigma,tsigma)
    radial_sigmas[x]=rsigma
    tangen_sigmas[x]=tsigma
  rstats = flex.mean_and_variance(radial_sigmas,L.tilecounts.as_double())
  tstats = flex.mean_and_variance(tangen_sigmas,L.tilecounts.as_double())

  print "\nOverall                 %8d observations, delx %5.2f  dely %5.2f, rmsd = %5.2f"%(
      L.overall_N, L.overall_cv[0], L.overall_cv[1], L.overall_rmsd)
  print "Average tile rmsd %5.2f"%flex.mean(flex.double(L.tile_rmsd))
  print "Average tile displacement %5.2f"%(flex.mean(
    flex.double([matrix.col(cv).length() for cv in L.mean_cv])))
  print "Weighted average radial sigma %6.2f"%rstats.mean()
  print "Weighted average tangential sigma %6.2f"%tstats.mean()

  if working_phil.show_plots is True:
    plt.plot([(L.tiles[4*x+0]+L.tiles[4*x+2])/2. for x in xrange(64)],[(L.tiles[4*x+1]+L.tiles[4*x+3])/2. for x in xrange(64)],"go")
    for x in xrange(64):
      plt.text(10+(L.tiles[4*x+0]+L.tiles[4*x+2])/2.,10+(L.tiles[4*x+1]+L.tiles[4*x+3])/2.,"%d"%x)
    plt.show()

    for idx in xrange(64):
      x = sort_radii[idx]
      print "Tile %2d: radius %7.2f, %6d observations, delx %5.2f  dely %5.2f, rmsd = %5.2f"%(
        x, L.radii[x], L.tilecounts[x], L.mean_cv[x][0], L.mean_cv[x][1],
        L.tile_rmsd[x]
        ),
      if L.tilecounts[x] < 3:
        print
        radial = (0,0)
        tangential = (0,0)
        rmean,tmean,rsigma,tsigma=(0,0,1,1)
      else:
        wtaveg = L.weighted_average_angle_deg_from_tile(x)
        print "Tile rotation %6.2f deg"%wtaveg,
        radial,tangential,rmean,tmean,rsigma,tsigma = get_radial_tangential_vectors(L,x)
        print "%6.2f %6.2f"%(rsigma,tsigma)

      if working_phil.colormap:
        from pylab import imshow, axes, colorbar, show
        import numpy

        xcv,ycv = get_correction_vector_xy(L,x)
        _min = min(min(xcv),min(ycv))
        _max = max(max(xcv),max(ycv))

        hist,xedges,yedges = numpy.histogram2d(xcv,ycv,bins=40,range=[[_min,_max],[_min,_max]])
        extent = [xedges[0], xedges[-1], yedges[0], yedges[-1] ]

        imshow(hist.T,extent=extent,interpolation='nearest',origin='lower')
        from matplotlib.patches import Ellipse
        ell = Ellipse(xy=(L.mean_cv[x][0],L.mean_cv[x][1]),
                      width=2.*rsigma, height=2.*tsigma,
                      angle=math.atan2(-(radial[1]),-(radial[0]))*180./math.pi,
                      edgecolor="y", linewidth=2, fill=False, zorder=100)
        axes().add_artist(ell)
        colorbar()
        show()

      else:
        from matplotlib import pyplot as plt
        xcv,ycv = get_correction_vector_xy(L,x)
        if len(xcv)==0 or len(ycv)==0: continue
        plt.plot(xcv,ycv,"r.")
        plt.plot([L.mean_cv[x][0]],[L.mean_cv[x][1]],"go")
        plt.plot([L.mean_cv[x][0]+radial[0]],[L.mean_cv[x][1]+radial[1]],"yo")
        plt.plot([L.mean_cv[x][0]+tangential[0]],[L.mean_cv[x][1]+tangential[1]],"bo")
        from matplotlib.patches import Ellipse
        ell = Ellipse(xy=(L.mean_cv[x][0],L.mean_cv[x][1]),
                      width=2.*rsigma, height=2.*tsigma,
                      angle=math.atan2(-(radial[1]),-(radial[0]))*180./math.pi,
                      edgecolor="y", linewidth=2, fill=False, zorder=100)
        plt.axes().add_artist(ell)
        plt.axes().set_aspect("equal")
        _min = min(min(xcv),min(ycv))
        _max = max(max(xcv),max(ycv))
        plt.axes().set_xlim(_min,_max)
        plt.axes().set_ylim(_min,_max)
        plt.show()