Ejemplo n.º 1
0
  def __init__(self, experiments, profile_fitter, reflections, num_folds):
    '''
    Create the integration report

    :param experiments: The experiment list
    :param profile_model: The profile model
    :param reflections: The reflection table

    '''
    from collections import OrderedDict

    # Initialise the report class
    super(ProfileValidationReport, self).__init__()

    # Create the table
    table = Table()

    # Set the title
    table.name = 'validation.summary'
    table.title = 'Summary of profile validation '

    # Add the columns
    table.cols.append(('id', 'ID'))
    table.cols.append(('subsample', 'Sub-sample'))
    table.cols.append(('n_valid', '# validated'))
    table.cols.append(('cc', '<CC>'))
    table.cols.append(('nrmsd', '<NRMSD>'))

    # Split the reflections
    reflection_tables = reflections.split_by_experiment_id()
    assert len(reflection_tables) == len(experiments)
    assert len(profile_fitter) == num_folds

    # Create the summary for each profile model
    for i in range(len(reflection_tables)):
      reflection_table = reflection_tables[i]
      reflection_table = reflection_table.select(
        reflection_table.get_flags(
          reflection_table.flags.integrated_prf))
      index = reflection_table['profile.index']
      cc = reflection_table['profile.correlation']
      nrmsd = reflection_table['profile.rmsd']
      for j in range(num_folds):
        mask = index == j
        num_validated = mask.count(True)
        if num_validated == 0:
          mean_cc = 0
          mean_nrmsd = 0
        else:
          mean_cc = flex.mean(cc.select(mask))
          mean_nrmsd = flex.mean(nrmsd.select(mask))
        table.rows.append([
          '%d'   % i,
          '%d'   % j,
          '%d'   % num_validated,
          '%.2f' % mean_cc,
          '%.2f' % mean_nrmsd])

    # Add the table
    self.add_table(table)
Ejemplo n.º 2
0
    def __init__(self, experiments, profile_fitter, reflections, num_folds):
        """
        Create the integration report

        :param experiments: The experiment list
        :param profile_model: The profile model
        :param reflections: The reflection table
        """
        # Initialise the report class
        super().__init__()

        # Create the table
        table = Table()

        # Set the title
        table.name = "validation.summary"
        table.title = "Summary of profile validation "

        # Add the columns
        table.cols.append(("id", "ID"))
        table.cols.append(("subsample", "Sub-sample"))
        table.cols.append(("n_valid", "# validated"))
        table.cols.append(("cc", "<CC>"))
        table.cols.append(("nrmsd", "<NRMSD>"))

        # Split the reflections
        reflection_tables = reflections.split_by_experiment_id()
        assert len(reflection_tables) == len(experiments)
        assert len(profile_fitter) == num_folds

        # Create the summary for each profile model
        for i in range(len(reflection_tables)):
            reflection_table = reflection_tables[i]
            reflection_table = reflection_table.select(
                reflection_table.get_flags(reflection_table.flags.integrated_prf)
            )
            index = reflection_table["profile.index"]
            cc = reflection_table["profile.correlation"]
            nrmsd = reflection_table["profile.rmsd"]
            for j in range(num_folds):
                mask = index == j
                num_validated = mask.count(True)
                if num_validated == 0:
                    mean_cc = 0
                    mean_nrmsd = 0
                else:
                    mean_cc = flex.mean(cc.select(mask))
                    mean_nrmsd = flex.mean(nrmsd.select(mask))
                table.rows.append(
                    [
                        "%d" % i,
                        "%d" % j,
                        "%d" % num_validated,
                        f"{mean_cc:.2f}",
                        f"{mean_nrmsd:.2f}",
                    ]
                )

        # Add the table
        self.add_table(table)
Ejemplo n.º 3
0
    def __init__(self, experiments, reference, reflections):
        '''
    Create the integration report

    :param experiments: The experiment list
    :param reference: The reference profiles
    :param reflections: The reflection table

    '''
        from collections import OrderedDict

        # Initialise the report class
        super(ProfileModelReport, self).__init__()

        # Create the table
        table = Table()

        # Set the title
        table.name = 'profile.summary'
        table.title = 'Summary of profile model'

        # Add the columns
        table.cols.append(('id', 'ID'))
        table.cols.append(('profile', 'Profile'))
        table.cols.append(('created', 'Created'))
        table.cols.append(('x', 'X (px)'))
        table.cols.append(('y', 'Y (px)'))
        table.cols.append(('z', 'Z (im)'))
        table.cols.append(('n_reflections', '# reflections'))

        # Create the summary for each profile model
        for i in range(len(reference)):
            model = reference[i]
            for j in range(len(model)):
                table.rows.append([
                    '%d' % i,
                    '%d' % j,
                    '%s' % True,
                    '%.2f' % model.sampler().coord(j)[0],
                    '%.2f' % model.sampler().coord(j)[1],
                    '%.2f' % model.sampler().coord(j)[2],
                    '%d' % model.n_reflections(j)
                ])

        # Add the table
        self.add_table(table)

        # Add the profiles
        for i in range(len(fitter)):
            model = fitter[i]
            for j in range(len(model)):
                if model.valid(j):
                    array = Array()
                    array.name = 'profile.model.%d.%d' % (i, j)
                    array.title = 'Profile model (id: %d, profile: %d)' % (i,
                                                                           j)
                    array.data = model.data(j)
                    self.add_array(array)
Ejemplo n.º 4
0
    def __init__(self, experiments, reference, reflections):
        """
        Create the integration report

        :param experiments: The experiment list
        :param reference: The reference profiles
        :param reflections: The reflection table

        """
        from collections import OrderedDict

        # Initialise the report class
        super(ProfileModelReport, self).__init__()

        # Create the table
        table = Table()

        # Set the title
        table.name = "profile.summary"
        table.title = "Summary of profile model"

        # Add the columns
        table.cols.append(("id", "ID"))
        table.cols.append(("profile", "Profile"))
        table.cols.append(("created", "Created"))
        table.cols.append(("x", "X (px)"))
        table.cols.append(("y", "Y (px)"))
        table.cols.append(("z", "Z (im)"))
        table.cols.append(("n_reflections", "# reflections"))

        # Create the summary for each profile model
        for i in range(len(reference)):
            model = reference[i]
            for j in range(len(model)):
                table.rows.append([
                    "%d" % i,
                    "%d" % j,
                    "%s" % True,
                    "%.2f" % model.sampler().coord(j)[0],
                    "%.2f" % model.sampler().coord(j)[1],
                    "%.2f" % model.sampler().coord(j)[2],
                    "%d" % model.n_reflections(j),
                ])

        # Add the table
        self.add_table(table)

        # Add the profiles
        for i in range(len(fitter)):
            model = fitter[i]
            for j in range(len(model)):
                if model.valid(j):
                    array = Array()
                    array.name = "profile.model.%d.%d" % (i, j)
                    array.title = "Profile model (id: %d, profile: %d)" % (i,
                                                                           j)
                    array.data = model.data(j)
                    self.add_array(array)
Ejemplo n.º 5
0
    def __init__(self, experiments, fitter, reflections):
        """
        Create the integration report

        :param experiments: The experiment list
        :param profile_model: The profile model
        :param reflections: The reflection table
        """
        # Initialise the report class
        super().__init__()

        # Create the table
        table = Table()

        # Set the title
        table.name = "profile.summary"
        table.title = "Summary of profile model"

        # Add the columns
        table.cols.append(("id", "ID"))
        table.cols.append(("profile", "Profile"))
        table.cols.append(("created", "Created"))
        table.cols.append(("x", "X (px)"))
        table.cols.append(("y", "Y (px)"))
        table.cols.append(("z", "Z (im)"))
        table.cols.append(("n_reflections", "# reflections"))

        # Create the summary for each profile model
        for i in range(len(fitter)):
            model = fitter[i]
            for j in range(len(model)):
                table.rows.append(
                    [
                        "%d" % i,
                        "%d" % j,
                        f"{model.valid(j)}",
                        f"{model.coord(j)[0]:.2f}",
                        f"{model.coord(j)[1]:.2f}",
                        f"{model.coord(j)[2]:.2f}",
                        "%d" % model.n_reflections(j),
                    ]
                )

        # Add the table
        self.add_table(table)

        # Add the profiles
        for i in range(len(fitter)):
            model = fitter[i]
            for j in range(len(model)):
                if model.valid(j):
                    array = Array()
                    array.name = "profile.model.%d.%d" % (i, j)
                    array.title = "Profile model (id: %d, profile: %d)" % (i, j)
                    array.data = model.data(j)
                    self.add_array(array)
Ejemplo n.º 6
0
  def __init__(self, experiments, fitter, reflections):
    '''
    Create the integration report

    :param experiments: The experiment list
    :param profile_model: The profile model
    :param reflections: The reflection table

    '''
    from collections import OrderedDict

    # Initialise the report class
    super(ProfileModelReport, self).__init__()

    # Create the table
    table = Table()

    # Set the title
    table.name = 'profile.summary'
    table.title = 'Summary of profile model'

    # Add the columns
    table.cols.append(('id', 'ID'))
    table.cols.append(('profile', 'Profile'))
    table.cols.append(('created', 'Created'))
    table.cols.append(('x', 'X (px)'))
    table.cols.append(('y', 'Y (px)'))
    table.cols.append(('z', 'Z (im)'))
    table.cols.append(('n_reflections', '# reflections'))

    # Create the summary for each profile model
    for i in range(len(fitter)):
      model = fitter[i]
      for j in range(len(model)):
        table.rows.append([
          '%d'   % i,
          '%d'   % j,
          '%s'   % model.valid(j),
          '%.2f' % model.coord(j)[0],
          '%.2f' % model.coord(j)[1],
          '%.2f' % model.coord(j)[2],
          '%d'   % model.n_reflections(j)])

    # Add the table
    self.add_table(table)

    # Add the profiles
    for i in range(len(fitter)):
      model = fitter[i]
      for j in range(len(model)):
        if model.valid(j):
          array = Array()
          array.name = 'profile.model.%d.%d' % (i, j)
          array.title = 'Profile model (id: %d, profile: %d)' % (i, j)
          array.data = model.data(j)
          self.add_array(array)
Ejemplo n.º 7
0
    def __init__(self, experiments, reflections):
        '''
    Create the integration report

    :param experiments: The experiment list
    :param reflections: The reflection table

    '''
        from collections import OrderedDict

        # Initialise the report class
        super(IntegrationReport, self).__init__()

        # Split the tables by experiment id
        tables = reflections.split_by_experiment_id()
        assert (len(tables) == len(experiments))

        # Initialise the dictionary
        report_list = []

        # Generate an integration report for each experiment
        for i, (expr, data) in enumerate(zip(experiments, tables)):
            report_list.append(generate_integration_report(expr, data))

        # Construct the per image table
        table = Table()
        table.name = 'integration.image.summary'
        table.title = "Summary vs image number"
        table.cols.append(('id', 'ID'))
        table.cols.append(('image', 'Image'))
        table.cols.append(('n_full', '# full'))
        table.cols.append(('n_part', '# part'))
        table.cols.append(('n_over', '# over'))
        table.cols.append(('n_ice', '# ice'))
        table.cols.append(('n_sum', '# sum'))
        table.cols.append(('n_prf', '# prf'))
        table.cols.append(('ibg', 'Ibg'))
        table.cols.append(('ios_sum', 'I/sigI\n (sum)'))
        table.cols.append(('ios_prf', 'I/sigI\n (prf)'))
        table.cols.append(('cc_prf', 'CC prf'))
        table.cols.append(('rmsd_xy', 'RMSD XY'))
        for j, report in enumerate(report_list):
            report = report['image']
            for i in range(len(report['bins']) - 1):
                table.rows.append([
                    '%d' % j,
                    '%d' % report['bins'][i],
                    '%d' % report['n_full'][i],
                    '%d' % report['n_partial'][i],
                    '%d' % report['n_overload'][i],
                    '%d' % report['n_ice'][i],
                    '%d' % report['n_summed'][i],
                    '%d' % report['n_fitted'][i],
                    '%.2f' % report['mean_background'][i],
                    '%.2f' % report['ios_sum'][i],
                    '%.2f' % report['ios_prf'][i],
                    '%.2f' % report['cc_prf'][i],
                    '%.2f' % report['rmsd_xy'][i]
                ])
        self.add_table(table)

        # Construct the per resolution table
        table = Table()
        table.name = 'integration.resolution.summary'
        table.title = "Summary vs resolution"
        table.cols.append(('id', 'ID'))
        table.cols.append(('dmin', 'd min'))
        table.cols.append(('n_full', '# full'))
        table.cols.append(('n_part', '# part'))
        table.cols.append(('n_over', '# over'))
        table.cols.append(('n_ice', '# ice'))
        table.cols.append(('n_sum', '# sum'))
        table.cols.append(('n_prf', '# prf'))
        table.cols.append(('ibg', 'Ibg'))
        table.cols.append(('ios_sum', 'I/sigI\n (sum)'))
        table.cols.append(('ios_prf', 'I/sigI\n (prf)'))
        table.cols.append(('cc_prf', 'CC prf'))
        table.cols.append(('rmsd_xy', 'RMSD XY'))
        for j, report in enumerate(report_list):
            report = report['resolution']
            for i in range(len(report['bins']) - 1):
                table.rows.append([
                    '%d' % j,
                    '%.2f' % report['bins'][i],
                    '%d' % report['n_full'][i],
                    '%d' % report['n_partial'][i],
                    '%d' % report['n_overload'][i],
                    '%d' % report['n_ice'][i],
                    '%d' % report['n_summed'][i],
                    '%d' % report['n_fitted'][i],
                    '%.2f' % report['mean_background'][i],
                    '%.2f' % report['ios_sum'][i],
                    '%.2f' % report['ios_prf'][i],
                    '%.2f' % report['cc_prf'][i],
                    '%.2f' % report['rmsd_xy'][i]
                ])
        self.add_table(table)

        # Create the overall table
        for j, report in enumerate(report_list):
            report = report['summary']
            summary = report['overall']
            high = report['high']
            low = report['low']

            table = Table()
            table.name = 'integration.overall.summary'
            table.title = "Summary for experiment %d" % j
            table.cols.append(('item', 'Item'))
            table.cols.append(('overall', 'Overall'))
            table.cols.append(('low', 'Low'))
            table.cols.append(('high', 'High'))
            desc_fmt_key = [
                ("dmin", '%.2f', 'dmin'), ('dmax', '%.2f', 'dmax'),
                ("number fully recorded", '%d', "n_full"),
                ("number partially recorded", '%d', "n_partial"),
                ("number with invalid background pixels", '%d',
                 "n_invalid_bg"),
                ("number with invalid foreground pixels", '%d',
                 "n_invalid_fg"),
                ("number with overloaded pixels", '%d', "n_overload"),
                ("number in powder rings", '%d', "n_ice"),
                ("number processed with summation", '%d', "n_summed"),
                ("number processed with profile fitting", '%d', "n_fitted"),
                ("number failed in background modelling", '%d',
                 "n_failed_background"),
                ("number failed in summation", '%d', "n_failed_summation"),
                ("number failed in profile fitting", '%d', "n_failed_fitting"),
                ("ibg", '%.2f', "mean_background"),
                ("i/sigi (summation)", '%.2f', "ios_sum"),
                ("i/sigi (profile fitting)", '%.2f', "ios_prf"),
                ("cc prf", '%.2f', "cc_prf"),
                ("cc_pearson sum/prf", '%.2f', "cc_pearson_sum_prf"),
                ("cc_spearman sum/prf", '%.2f', "cc_spearman_sum_prf")
            ]
            for desc, fmt, key in desc_fmt_key:
                table.rows.append([
                    desc, fmt % summary[key], fmt % low[key], fmt % high[key]
                ])
            self.add_table(table)
Ejemplo n.º 8
0
    def __init__(self, experiments, reflections):
        """
        Create the integration report

        :param experiments: The experiment list
        :param reflections: The reflection table
        """
        # Initialise the report class
        super(IntegrationReport, self).__init__()

        # Split the tables by experiment id
        tables = reflections.split_by_experiment_id()
        assert len(tables) == len(experiments)

        # Initialise the dictionary
        report_list = []

        # Generate an integration report for each experiment
        for i, (expr, data) in enumerate(zip(experiments, tables)):
            report_list.append(generate_integration_report(expr, data))

        # Construct the per image table
        table = Table()
        table.name = "integration.image.summary"
        table.title = "Summary vs image number"
        table.cols.append(("id", "ID"))
        table.cols.append(("image", "Image"))
        table.cols.append(("n_full", "# full"))
        table.cols.append(("n_part", "# part"))
        table.cols.append(("n_over", "# over"))
        table.cols.append(("n_ice", "# ice"))
        table.cols.append(("n_sum", "# sum"))
        table.cols.append(("n_prf", "# prf"))
        table.cols.append(("ibg", "Ibg"))
        table.cols.append(("ios_sum", "I/sigI\n (sum)"))
        table.cols.append(("ios_prf", "I/sigI\n (prf)"))
        table.cols.append(("cc_prf", "CC prf"))
        table.cols.append(("rmsd_xy", "RMSD XY"))
        for j, report in enumerate(report_list):
            report = report["image"]
            for i in range(len(report["bins"]) - 1):
                table.rows.append([
                    "%d" % j,
                    "%d" % (report["bins"][i] + 1),
                    "%d" % report["n_full"][i],
                    "%d" % report["n_partial"][i],
                    "%d" % report["n_overload"][i],
                    "%d" % report["n_ice"][i],
                    "%d" % report["n_summed"][i],
                    "%d" % report["n_fitted"][i],
                    "%.2f" % report["mean_background"][i],
                    "%.2f" % report["ios_sum"][i],
                    "%.2f" % report["ios_prf"][i],
                    "%.2f" % report["cc_prf"][i],
                    "%.2f" % report["rmsd_xy"][i],
                ])
        self.add_table(table)

        # Construct the per resolution table
        table = Table()
        table.name = "integration.resolution.summary"
        table.title = "Summary vs resolution"
        table.cols.append(("id", "ID"))
        table.cols.append(("dmin", "d min"))
        table.cols.append(("n_full", "# full"))
        table.cols.append(("n_part", "# part"))
        table.cols.append(("n_over", "# over"))
        table.cols.append(("n_ice", "# ice"))
        table.cols.append(("n_sum", "# sum"))
        table.cols.append(("n_prf", "# prf"))
        table.cols.append(("ibg", "Ibg"))
        table.cols.append(("ios_sum", "I/sigI\n (sum)"))
        table.cols.append(("ios_prf", "I/sigI\n (prf)"))
        table.cols.append(("cc_prf", "CC prf"))
        table.cols.append(("rmsd_xy", "RMSD XY"))
        for j, report in enumerate(report_list):
            report = report["resolution"]
            for i in range(len(report["bins"]) - 1):
                table.rows.append([
                    "%d" % j,
                    "%.2f" % report["bins"][i],
                    "%d" % report["n_full"][i],
                    "%d" % report["n_partial"][i],
                    "%d" % report["n_overload"][i],
                    "%d" % report["n_ice"][i],
                    "%d" % report["n_summed"][i],
                    "%d" % report["n_fitted"][i],
                    "%.2f" % report["mean_background"][i],
                    "%.2f" % report["ios_sum"][i],
                    "%.2f" % report["ios_prf"][i],
                    "%.2f" % report["cc_prf"][i],
                    "%.2f" % report["rmsd_xy"][i],
                ])
        self.add_table(table)

        # Create the overall table
        for j, report in enumerate(report_list):
            report = report["summary"]
            summary = report["overall"]
            high = report["high"]
            low = report["low"]

            table = Table()
            table.name = "integration.overall.summary"
            table.title = "Summary for experiment %d" % j
            table.cols.append(("item", "Item"))
            table.cols.append(("overall", "Overall"))
            table.cols.append(("low", "Low"))
            table.cols.append(("high", "High"))
            desc_fmt_key = [
                ("dmin", "%.2f", "dmin"),
                ("dmax", "%.2f", "dmax"),
                ("number fully recorded", "%d", "n_full"),
                ("number partially recorded", "%d", "n_partial"),
                ("number with invalid background pixels", "%d",
                 "n_invalid_bg"),
                ("number with invalid foreground pixels", "%d",
                 "n_invalid_fg"),
                ("number with overloaded pixels", "%d", "n_overload"),
                ("number in powder rings", "%d", "n_ice"),
                ("number processed with summation", "%d", "n_summed"),
                ("number processed with profile fitting", "%d", "n_fitted"),
                ("number failed in background modelling", "%d",
                 "n_failed_background"),
                ("number failed in summation", "%d", "n_failed_summation"),
                ("number failed in profile fitting", "%d", "n_failed_fitting"),
                ("ibg", "%.2f", "mean_background"),
                ("i/sigi (summation)", "%.2f", "ios_sum"),
                ("i/sigi (profile fitting)", "%.2f", "ios_prf"),
                ("cc prf", "%.2f", "cc_prf"),
                ("cc_pearson sum/prf", "%.2f", "cc_pearson_sum_prf"),
                ("cc_spearman sum/prf", "%.2f", "cc_spearman_sum_prf"),
            ]
            for desc, fmt, key in desc_fmt_key:
                table.rows.append([
                    desc, fmt % summary[key], fmt % low[key], fmt % high[key]
                ])
            self.add_table(table)
Ejemplo n.º 9
0
    def run(self):
        """Run the script."""
        from dials.util.options import flatten_reflections, flatten_experiments

        # Parse the command line arguments
        params, options = self.parser.parse_args(show_diff_phil=True)

        # Show the help
        if len(params.input.reflections) != 1 and not len(
                params.input.experiments):
            self.parser.print_help()
            exit(0)

        from dials.util.options import flatten_reflections, flatten_experiments

        reflections = flatten_reflections(params.input.reflections)[0]
        experiments = flatten_experiments(params.input.experiments)

        assert len(experiments) == 1
        report = generate_integration_report(
            experiments[0],
            reflections,
            n_resolution_bins=params.n_resolution_bins,
            d_max=params.d_max,
            d_min=params.d_min,
        )

        # Construct the per resolution table
        from dials.util.report import Table

        table = Table()
        table.name = "integration.resolution.summary"
        table.title = "Summary vs resolution"
        table.cols.append(("d_max", "d_max"))
        table.cols.append(("d_mid", "d_mid"))
        table.cols.append(("d_min", "d_min"))
        table.cols.append(("n_full", "# full"))
        table.cols.append(("n_part", "# part"))
        table.cols.append(("n_over", "# over"))
        table.cols.append(("n_ice", "# ice"))
        table.cols.append(("n_sum", "# sum"))
        table.cols.append(("n_prf", "# prf"))
        table.cols.append(("ibg", "Ibg"))
        table.cols.append(("i_sum", "<I>\n (sum)"))
        table.cols.append(("ios_sum", "I/sigI\n (sum)"))
        table.cols.append(("ios_prf", "I/sigI\n (prf)"))
        table.cols.append(("cc_prf", "CC prf"))
        table.cols.append(("rmsd_xy", "RMSD XY"))

        # extract resolution report
        report = report["resolution"]
        report["d_mid"] = []
        for i in range(len(report["bins"]) - 1):
            report["d_mid"].append(
                (report["bins"][i + 1] + report["bins"][i]) / 2.0)
            table.rows.append([
                "%.2f" % report["bins"][i + 1],
                "%.2f" % report["d_mid"][i],
                "%.2f" % report["bins"][i],
                "%d" % report["n_full"][i],
                "%d" % report["n_partial"][i],
                "%d" % report["n_overload"][i],
                "%d" % report["n_ice"][i],
                "%d" % report["n_summed"][i],
                "%d" % report["n_fitted"][i],
                "%.4f" % report["mean_background"][i],
                "%.4f" % report["i_sum"][i],
                "%.4f" % report["ios_sum"][i],
                "%.4f" % report["ios_prf"][i],
                "%.4f" % report["cc_prf"][i],
                "%.4f" % report["rmsd_xy"][i],
            ])
        print(table.as_str())

        # plot mean background first
        # from matplotlib import pyplot
        # fig = pyplot.figure()
        # ax = fig.add_subplot(111)
        # ax.set_xlabel(r'resolution ($\AA$)')
        # ax.set_ylabel(r'$\langle I_b \rangle$')
        # d_mid = flex.double(report['d_mid'])
        # I_bg = flex.double(report['mean_background'][:-1])
        # dm2 = 1/flex.pow2(d_mid)
        # ax.plot(dm2, I_bg)
        # xticks = ax.get_xticks()
        # from math import sqrt
        # x_tick_labs = ["" if e <= 0.0 else "{:.2f}".format(sqrt(1./e))
        #               for e in xticks]
        # ax.set_xticklabels(x_tick_labs)
        #
        # pyplot.show()

        # try plot of log intensity and background
        templ = experiments[0].imageset.get_template()
        import os

        title = os.path.basename(templ)
        import matplotlib

        matplotlib.use("Agg")
        from matplotlib import pyplot

        fig = pyplot.figure()
        ax = fig.add_subplot(111)
        ax.set_xlabel(r"$d_{mid}$ ($\AA$)")
        ax.set_ylabel(r"$\langle Intensity \rangle$")
        d_mid = flex.double(report["d_mid"])
        I_bg = flex.double(report["mean_background"][:-1])
        I_sum = flex.double(report["i_sum"][:-1])
        dm2 = 1 / flex.pow2(d_mid)
        ax.plot(dm2, I_bg, label="Background")
        ax.plot(dm2, I_sum, label="Peak")
        ax.legend(loc="upper right")
        ax.set_title(title)
        ax.set_ylim(-2, 100)
        pyplot.minorticks_on()
        ax.grid(True, which="both")
        xticks = ax.get_xticks()
        from math import sqrt

        x_tick_labs = [
            "" if e <= 0.0 else "{:.2f}".format(sqrt(1.0 / e)) for e in xticks
        ]
        ax.set_xticklabels(x_tick_labs)

        pyplot.savefig("intensity_vs_resolution.png")
Ejemplo n.º 10
0
  def __init__(self, experiments, reflections):
    '''
    Create the integration report

    :param experiments: The experiment list
    :param reflections: The reflection table

    '''
    from collections import OrderedDict

    # Initialise the report class
    super(IntegrationReport, self).__init__()

    # Split the tables by experiment id
    tables = reflections.split_by_experiment_id()
    assert(len(tables) == len(experiments))

    # Initialise the dictionary
    report_list = []

    # Generate an integration report for each experiment
    for i, (expr, data) in enumerate(zip(experiments, tables)):
      report_list.append(generate_integration_report(expr, data))

    # Construct the per image table
    table = Table()
    table.name = 'integration.image.summary'
    table.title = "Summary vs image number"
    table.cols.append(('id', 'ID'))
    table.cols.append(('image', 'Image'))
    table.cols.append(('n_full', '# full'))
    table.cols.append(('n_part', '# part'))
    table.cols.append(('n_over', '# over'))
    table.cols.append(('n_ice', '# ice'))
    table.cols.append(('n_sum', '# sum'))
    table.cols.append(('n_prf', '# prf'))
    table.cols.append(('ibg', 'Ibg'))
    table.cols.append(('ios_sum', 'I/sigI\n (sum)'))
    table.cols.append(('ios_prf', 'I/sigI\n (prf)'))
    table.cols.append(('cc_prf', 'CC prf'))
    table.cols.append(('rmsd_xy', 'RMSD XY'))
    for j, report in enumerate(report_list):
      report = report['image']
      for i in range(len(report['bins'])-1):
        table.rows.append([
          '%d'   % j,
          '%d'   % report['bins'][i],
          '%d'   % report['n_full'][i],
          '%d'   % report['n_partial'][i],
          '%d'   % report['n_overload'][i],
          '%d'   % report['n_ice'][i],
          '%d'   % report['n_summed'][i],
          '%d'   % report['n_fitted'][i],
          '%.2f' % report['mean_background'][i],
          '%.2f' % report['ios_sum'][i],
          '%.2f' % report['ios_prf'][i],
          '%.2f' % report['cc_prf'][i],
          '%.2f' % report['rmsd_xy'][i]])
    self.add_table(table)

    # Construct the per resolution table
    table = Table()
    table.name = 'integration.resolution.summary'
    table.title = "Summary vs resolution"
    table.cols.append(('id', 'ID'))
    table.cols.append(('dmin', 'd min'))
    table.cols.append(('n_full', '# full'))
    table.cols.append(('n_part', '# part'))
    table.cols.append(('n_over', '# over'))
    table.cols.append(('n_ice', '# ice'))
    table.cols.append(('n_sum', '# sum'))
    table.cols.append(('n_prf', '# prf'))
    table.cols.append(('ibg', 'Ibg'))
    table.cols.append(('ios_sum', 'I/sigI\n (sum)'))
    table.cols.append(('ios_prf', 'I/sigI\n (prf)'))
    table.cols.append(('cc_prf', 'CC prf'))
    table.cols.append(('rmsd_xy', 'RMSD XY'))
    for j, report in enumerate(report_list):
      report = report['resolution']
      for i in range(len(report['bins'])-1):
        table.rows.append([
          '%d'   % j,
          '%.2f' % report['bins'][i],
          '%d'   % report['n_full'][i],
          '%d'   % report['n_partial'][i],
          '%d'   % report['n_overload'][i],
          '%d'   % report['n_ice'][i],
          '%d'   % report['n_summed'][i],
          '%d'   % report['n_fitted'][i],
          '%.2f' % report['mean_background'][i],
          '%.2f' % report['ios_sum'][i],
          '%.2f' % report['ios_prf'][i],
          '%.2f' % report['cc_prf'][i],
          '%.2f' % report['rmsd_xy'][i]])
    self.add_table(table)

    # Create the overall table
    for j, report in enumerate(report_list):
      report = report['summary']
      summary = report['overall']
      high = report['high']
      low = report['low']

      table = Table()
      table.name = 'integration.overall.summary'
      table.title = "Summary for experiment %d" % j
      table.cols.append(('item', 'Item'))
      table.cols.append(('overall', 'Overall'))
      table.cols.append(('low', 'Low'))
      table.cols.append(('high', 'High'))
      desc_fmt_key = [
        ("dmin",                                  '%.2f', 'dmin'),
        ('dmax',                                  '%.2f', 'dmax'),
        ("number fully recorded",                 '%d'  , "n_full"),
        ("number partially recorded",             '%d'  , "n_partial"),
        ("number with invalid background pixels", '%d'  , "n_invalid_bg"),
        ("number with invalid foreground pixels", '%d'  , "n_invalid_fg"),
        ("number with overloaded pixels",         '%d'  , "n_overload"),
        ("number in powder rings",                '%d'  , "n_ice"),
        ("number processed with summation",       '%d'  , "n_summed"),
        ("number processed with profile fitting", '%d'  , "n_fitted"),
        ("number failed in background modelling", '%d'  , "n_failed_background"),
        ("number failed in summation",            '%d'  , "n_failed_summation"),
        ("number failed in profile fitting",      '%d'  , "n_failed_fitting"),
        ("ibg",                                   '%.2f', "mean_background"),
        ("i/sigi (summation)",                    '%.2f', "ios_sum"),
        ("i/sigi (profile fitting)",              '%.2f', "ios_prf"),
        ("cc prf",                                '%.2f', "cc_prf"),
        ("cc_pearson sum/prf",                    '%.2f', "cc_pearson_sum_prf"),
        ("cc_spearman sum/prf",                   '%.2f', "cc_spearman_sum_prf")
      ]
      for desc, fmt, key in desc_fmt_key:
        table.rows.append([desc, fmt % summary[key], fmt % low[key], fmt % high[key]])
      self.add_table(table)