def make_merging_stats_plots(script): """Make merging stats plots for HTML report""" d = { "scaling_tables": ([], []), "resolution_plots": {}, "batch_plots": {}, "misc_plots": {}, "anom_plots": {}, "image_range_tables": [], } ( batches, rvb, isigivb, svb, batch_data, ) = reflection_tables_to_batch_dependent_properties( # pylint: disable=unbalanced-tuple-unpacking script.reflections, script.experiments, script.scaled_miller_array, ) bm = batch_manager(batches, batch_data) image_range_tables = make_image_range_table(script.experiments, bm) if script.merging_statistics_result: stats = script.merging_statistics_result anom_stats = script.anom_merging_statistics_result is_centric = script.scaled_miller_array.space_group().is_centric() # Now calculate batch data plotter = ResolutionPlotsAndStats(stats, anom_stats, is_centric) d["resolution_plots"].update(plotter.make_all_plots()) d["scaling_tables"] = plotter.statistics_tables() d["batch_plots"].update(scale_rmerge_vs_batch_plot(bm, rvb, svb)) d["batch_plots"].update(i_over_sig_i_vs_batch_plot(bm, isigivb)) plotter = IntensityStatisticsPlots( script.scaled_miller_array, run_xtriage_analysis=False ) d["resolution_plots"].update(plotter.generate_resolution_dependent_plots()) if d["resolution_plots"]["cc_one_half"]["data"][2]: cc_anom = d["resolution_plots"]["cc_one_half"]["data"][2]["y"] significance = d["resolution_plots"]["cc_one_half"]["data"][3]["y"] sig = flex.double(cc_anom) > flex.double(significance) max_anom = 0 for i, v in enumerate(sig): if v: max_anom = i else: break d_min = uctbx.d_star_sq_as_d(plotter.binner.limits())[max_anom + 1] else: d_min = 0.0 d["misc_plots"].update(plotter.generate_miscellanous_plots()) intensities_anom = script.scaled_miller_array.as_anomalous_array() intensities_anom = intensities_anom.map_to_asu().customized_copy( info=script.scaled_miller_array.info() ) anom_plotter = AnomalousPlotter(intensities_anom, strong_cutoff=d_min) d["anom_plots"].update(anom_plotter.make_plots()) d["image_range_tables"] = [image_range_tables] return d
def make_plots(self): """Generate tables of overall and resolution-binned merging statistics.""" d = { "scaling_tables": ([], []), "resolution_plots": OrderedDict(), "batch_plots": OrderedDict(), "misc_plots": OrderedDict(), "anom_plots": OrderedDict(), "image_range_tables": [], } if "statistics" in self.data: plotter = ResolutionPlotsAndStats( self.data["statistics"], self.data["anomalous_statistics"], is_centric=self.data["is_centric"], ) d["resolution_plots"].update(plotter.make_all_plots()) d["scaling_tables"] = plotter.statistics_tables() d["batch_plots"].update( scale_rmerge_vs_batch_plot( self.data["bm"], self.data["r_merge_vs_batch"], self.data["scale_vs_batch"], )) d["batch_plots"].update( i_over_sig_i_vs_batch_plot(self.data["bm"], self.data["isigivsbatch"])) plotter = IntensityStatisticsPlots( self.data["scaled_miller_array"], run_xtriage_analysis=False) d["resolution_plots"].update( plotter.generate_resolution_dependent_plots()) if d["resolution_plots"]["cc_one_half"]["data"][2]: cc_anom = d["resolution_plots"]["cc_one_half"]["data"][2]["y"] significance = d["resolution_plots"]["cc_one_half"]["data"][3][ "y"] sig = flex.double(cc_anom) > flex.double(significance) max_anom = 0 for i, v in enumerate(sig): if v: max_anom = i else: break d_min = uctbx.d_star_sq_as_d( plotter.binner.limits())[max_anom + 1] else: d_min = 0.0 d["misc_plots"].update(plotter.generate_miscellanous_plots()) intensities_anom = self.data[ "scaled_miller_array"].as_anomalous_array() intensities_anom = intensities_anom.map_to_asu().customized_copy( info=self.data["scaled_miller_array"].info()) anom_plotter = AnomalousPlotter(intensities_anom, strong_cutoff=d_min) d["anom_plots"].update(anom_plotter.make_plots()) d["image_range_tables"] = self.data["image_range_tables"] return d