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 update(self, scaling_script): if scaling_script.merging_statistics_result: self.data = { "statistics": scaling_script.merging_statistics_result, "anomalous_statistics": scaling_script.anom_merging_statistics_result, "is_centric": scaling_script.scaled_miller_array.space_group().is_centric(), } # Now calculate batch data ( batches, rvb, isigivb, svb, batch_data, ) = reflection_tables_to_batch_dependent_properties( # pylint: disable=unbalanced-tuple-unpacking scaling_script.reflections, scaling_script.experiments, scaling_script.scaled_miller_array, ) self.data[ "scaled_miller_array"] = scaling_script.scaled_miller_array self.data["bm"] = batch_manager(batches, batch_data) self.data["r_merge_vs_batch"] = rvb self.data["scale_vs_batch"] = svb self.data["isigivsbatch"] = isigivb self.data["image_range_tables"] = [ make_image_range_table(scaling_script.experiments, self.data["bm"]) ]
def batch_dependent_plots(self): binned_batches, rmerge, isigi, scalesvsbatch = batch_dependent_properties( self.batches, self.intensities, self.scales) batches = [{"id": b.id, "range": b.range} for b in self.params.batch] bm = batch_manager(binned_batches, batches) d = {} d.update(i_over_sig_i_vs_batch_plot(bm, isigi)) d.update(scale_rmerge_vs_batch_plot(bm, rmerge, scalesvsbatch)) return d
def batch_manager_fix(): """Make a batch manager fixture""" batch_params = [{ "id": 0, "range": [0, 10] }, { "id": 1, "range": [100, 110] }] batches = flex.int(itertools.chain(range(0, 10), range(100, 110))) return batch_manager(batches, batch_params)