コード例 #1
0
    def run(self):
        ''' Parse the options. '''
        # Parse the command line arguments
        params, options = self.parser.parse_args(show_diff_phil=True)
        self.params = params

        total = 0
        for ewrap, rwrap in zip(params.input.experiments,
                                params.input.reflections):
            experiments = ewrap.data
            reflections = rwrap.data
            if params.repredict_input_reflections:
                from dials.algorithms.refinement.prediction.managed_predictors import ExperimentsPredictorFactory
                ref_predictor = ExperimentsPredictorFactory.from_experiments(
                    experiments, force_stills=experiments.all_stills())
                reflections = ref_predictor(reflections)
            reflections = setup_stats(experiments, reflections)
            for expt_id, expt in enumerate(experiments):
                refls = reflections.select(reflections['id'] == expt_id)
                if len(refls) == 0: continue
                trumpet_plot(expt, refls)

                total += 1
                if params.max_plots and total >= params.max_plots:
                    break
            if params.max_plots and total >= params.max_plots:
                break
        plt.show()
コード例 #2
0
        def plotit(reflections, experiments):
            """
      Make the plots for a set of reflections and experiments.
      """
            detector = experiments.detectors()[0]
            beam = experiments.beams()[
                0]  # only used to compute resolution of 2theta
            reflections = reflections.select(
                reflections['intensity.sum.variance'] > 0)

            # Setup up deltaXY and two theta bins
            reflections['difference_vector_norms'] = (
                reflections['xyzcal.mm'] -
                reflections['xyzobs.mm.value']).norms()
            reflections = setup_stats(
                detector, experiments, reflections,
                two_theta_only=True)  # add two theta to reflection table
            sorted_two_theta = flex.sorted(reflections['two_theta_obs'])
            bin_low = [
                sorted_two_theta[int((len(sorted_two_theta) / n_bins) * i)]
                for i in range(n_bins)
            ]
            bin_high = [bin_low[i + 1] for i in range(n_bins - 1)]
            bin_high.append(sorted_two_theta[-1] + arbitrary_padding)

            x_centers = flex.double()
            n_refls = flex.int()
            rmsds = flex.double()
            p25r = flex.double()
            p50r = flex.double()
            p75r = flex.double()
            p25i = flex.double()
            p50i = flex.double()
            p75i = flex.double()
            print("# 2theta Res N dXY IsigI")

            # Compute stats for each bin
            for i in range(n_bins):
                refls = reflections.select(
                    (reflections['two_theta_obs'] >= bin_low[i])
                    & (reflections['two_theta_obs'] < bin_high[i]))
                # Only compute deltaXY stats on reflections with I/sigI at least 5
                i_sigi = refls['intensity.sum.value'] / flex.sqrt(
                    refls['intensity.sum.variance'])
                refls = refls.select(i_sigi >= 5)
                n = len(refls)
                if n < 10: continue
                min_r, q1_r, med_r, q3_r, max_r = five_number_summary(
                    1000 * refls['difference_vector_norms'])

                n_refls.append(n)

                rmsds_ = 1000 * math.sqrt(
                    flex.sum_sq(refls['difference_vector_norms']) / n)

                min_i, q1_i, med_i, q3_i, max_i = five_number_summary(i_sigi)
                p25i.append(q1_i)
                p50i.append(med_i)
                p75i.append(q3_i)
                # x_center
                c = ((bin_high[i] - bin_low[i]) / 2) + bin_low[i]
                # resolution
                d = beam.get_wavelength() / (2 * math.sin(math.pi * c /
                                                          (2 * 180)))
                x_centers.append(c)
                rmsds.append(rmsds_)
                print("%d % 5.1f % 5.1f % 8d %.1f %.1f" %
                      (i, c, d, n, med_r, med_i))
                p25r.append(q1_r)
                p50r.append(med_r)
                p75r.append(q3_r)

            # After binning, plot the results
            for plot in figures:
                ax1 = figures[plot]['ax1']
                ax2 = figures[plot]['ax2']
                if plot == 'isigi':
                    line, = ax1.plot(x_centers.as_numpy_array(),
                                     p50i.as_numpy_array(), '-')
                    line.set_label('Median')
                    ax1.fill_between(x_centers.as_numpy_array(),
                                     p25i.as_numpy_array(),
                                     p75i.as_numpy_array(),
                                     interpolate=True,
                                     alpha=0.50,
                                     color=line.get_color())
                    line, = ax2.plot(x_centers.as_numpy_array(),
                                     n_refls.as_numpy_array(),
                                     '-',
                                     color=line.get_color())
                    line.set_label('Median')
                elif plot == 'deltaXY':
                    line, = ax1.plot(x_centers.as_numpy_array(),
                                     p50r.as_numpy_array(), '-')
                    line.set_label('Median')
                    ax1.fill_between(x_centers.as_numpy_array(),
                                     p25r.as_numpy_array(),
                                     p75r.as_numpy_array(),
                                     interpolate=True,
                                     alpha=0.50,
                                     color=line.get_color())
                    line, = ax2.plot(x_centers.as_numpy_array(),
                                     n_refls.as_numpy_array(),
                                     '-',
                                     color=line.get_color())
                    line.set_label('Median')
                ax1.legend()
                ax2.legend()