def resolution_plots_and_stats(self): self.merging_stats = merging_statistics.dataset_statistics( self.intensities, n_bins=self.params.resolution_bins, cc_one_half_significance_level=self.params. cc_half_significance_level, eliminate_sys_absent=self.params.eliminate_sys_absent, use_internal_variance=self.params.use_internal_variance, assert_is_not_unique_set_under_symmetry=False, ) intensities_anom = self.intensities.as_anomalous_array() intensities_anom = intensities_anom.map_to_asu().customized_copy( info=self.intensities.info()) self.merging_stats_anom = merging_statistics.dataset_statistics( intensities_anom, n_bins=self.params.resolution_bins, anomalous=True, cc_one_half_significance_level=self.params. cc_half_significance_level, eliminate_sys_absent=self.params.eliminate_sys_absent, use_internal_variance=self.params.use_internal_variance, assert_is_not_unique_set_under_symmetry=False, ) is_centric = self.intensities.space_group().is_centric() plotter = ResolutionPlotsAndStats(self.merging_stats, self.merging_stats_anom, is_centric) d = OrderedDict() d.update(plotter.cc_one_half_plot(method=self.params.cc_half_method)) d.update(plotter.i_over_sig_i_plot()) d.update(plotter.completeness_plot()) d.update(plotter.multiplicity_vs_resolution_plot()) overall_stats = plotter.overall_statistics_table( self.params.cc_half_method) merging_stats = plotter.merging_statistics_table( self.params.cc_half_method) return overall_stats, merging_stats, d
def test_ResolutionPlotsAndStats(iobs): i_obs_anom = iobs.as_anomalous_array() iobs_anom = i_obs_anom.map_to_asu().customized_copy(info=iobs.info()) n_bins = 2 result = dataset_statistics(iobs, assert_is_not_unique_set_under_symmetry=False, n_bins=n_bins) anom_result = dataset_statistics( iobs_anom, assert_is_not_unique_set_under_symmetry=False, anomalous=True, n_bins=n_bins, ) plotter = ResolutionPlotsAndStats(result, anom_result) assert plotter.d_star_sq_ticktext == [ "1.26", "1.19", "1.13", "1.08", "1.04" ] assert plotter.d_star_sq_tickvals == pytest.approx( [0.6319, 0.7055, 0.7792, 0.8528, 0.9264], 1e-4) tables = plotter.statistics_tables() assert len(tables) == 2 # overall and per resolution # test plots individually d = plotter.cc_one_half_plot() assert len(d["cc_one_half"]["data"]) == 4 assert all(len(x["x"]) == n_bins for x in d["cc_one_half"]["data"]) d = plotter.i_over_sig_i_plot() assert len(d["i_over_sig_i"]["data"]) == 1 assert len(d["i_over_sig_i"]["data"][0]["y"]) == n_bins d = plotter.r_pim_plot() assert len(d["r_pim"]["data"]) == 1 assert len(d["r_pim"]["data"][0]["y"]) == n_bins d = plotter.completeness_plot() assert len(d["completeness"]["data"]) == 2 assert len(d["completeness"]["data"][0]["y"]) == n_bins d = plotter.multiplicity_vs_resolution_plot() assert len(d["multiplicity_vs_resolution"]["data"]) == 2 assert len(d["multiplicity_vs_resolution"]["data"][0]["y"]) == n_bins # now try centric options and sigma tau for cc_one_half plotter = ResolutionPlotsAndStats(result, anom_result, is_centric=True) d = plotter.cc_one_half_plot(method="sigma_tau") assert len(d["cc_one_half"]["data"]) == 4 assert all(len(x["x"]) == n_bins for x in d["cc_one_half"]["data"][:2]) assert d["cc_one_half"]["data"][2] == {} # no anomalous plots assert d["cc_one_half"]["data"][3] == {} # no anomalous plots d = plotter.completeness_plot() assert len(d["completeness"]["data"]) == 2 assert len(d["completeness"]["data"][0]["y"]) == n_bins assert d["completeness"]["data"][1] == {} d = plotter.multiplicity_vs_resolution_plot() assert len(d["multiplicity_vs_resolution"]["data"]) == 2 assert len(d["multiplicity_vs_resolution"]["data"][0]["y"]) == n_bins assert d["multiplicity_vs_resolution"]["data"][1] == {} plots = plotter.make_all_plots() assert list(plots.keys()) == [ "cc_one_half", "i_over_sig_i", "completeness", "multiplicity_vs_resolution", "r_pim", ] for plot in plots.values(): assert plot["layout"]["xaxis"][ "ticktext"] == plotter.d_star_sq_ticktext assert plot["layout"]["xaxis"][ "tickvals"] == plotter.d_star_sq_tickvals
def test_ResolutionPlotsAndStats(iobs): i_obs_anom = iobs.as_anomalous_array() iobs_anom = i_obs_anom.map_to_asu().customized_copy(info=iobs.info()) n_bins = 2 result = dataset_statistics( iobs, assert_is_not_unique_set_under_symmetry=False, n_bins=n_bins ) anom_result = dataset_statistics( iobs_anom, assert_is_not_unique_set_under_symmetry=False, anomalous=True, n_bins=n_bins, ) plotter = ResolutionPlotsAndStats(result, anom_result) assert plotter.d_star_sq_ticktext == ["1.74", "1.53", "1.38", "1.27", "1.18"] assert plotter.d_star_sq_tickvals == pytest.approx( [ 0.32984033277048164, 0.42706274943714834, 0.524285166103815, 0.6215075827704818, 0.7187299994371485, ], 1e-4, ) tables = plotter.statistics_tables() assert len(tables) == 2 # overall and per resolution # test plots individually d = plotter.cc_one_half_plot() assert len(d["cc_one_half"]["data"]) == 6 assert all(len(x["x"]) == n_bins for x in d["cc_one_half"]["data"][:4]) d["cc_one_half"]["data"][0]["x"] == [ 0.5 * (uctbx.d_as_d_star_sq(b.d_max) + uctbx.d_as_d_star_sq(b.d_min)) for b in result.bins ] d = plotter.i_over_sig_i_plot() assert len(d["i_over_sig_i"]["data"]) == 1 assert len(d["i_over_sig_i"]["data"][0]["y"]) == n_bins d = plotter.r_pim_plot() assert len(d["r_pim"]["data"]) == 1 assert len(d["r_pim"]["data"][0]["y"]) == n_bins d = plotter.completeness_plot() assert len(d["completeness"]["data"]) == 2 assert len(d["completeness"]["data"][0]["y"]) == n_bins d = plotter.multiplicity_vs_resolution_plot() assert len(d["multiplicity_vs_resolution"]["data"]) == 2 assert len(d["multiplicity_vs_resolution"]["data"][0]["y"]) == n_bins # now try centric options and sigma tau for cc_one_half plotter = ResolutionPlotsAndStats(result, anom_result, is_centric=True) d = plotter.cc_one_half_plot(method="sigma_tau") assert len(d["cc_one_half"]["data"]) == 6 assert all(len(x["x"]) == n_bins for x in d["cc_one_half"]["data"][:2]) assert d["cc_one_half"]["data"][2] == {} # no anomalous plots assert d["cc_one_half"]["data"][3] == {} # no anomalous plots assert d["cc_one_half"]["data"][4] == {} # no cc_fit assert d["cc_one_half"]["data"][5] == {} # no d_min d = plotter.completeness_plot() assert len(d["completeness"]["data"]) == 2 assert len(d["completeness"]["data"][0]["y"]) == n_bins assert d["completeness"]["data"][1] == {} d = plotter.multiplicity_vs_resolution_plot() assert len(d["multiplicity_vs_resolution"]["data"]) == 2 assert len(d["multiplicity_vs_resolution"]["data"][0]["y"]) == n_bins assert d["multiplicity_vs_resolution"]["data"][1] == {} plots = plotter.make_all_plots() assert list(plots.keys()) == [ "cc_one_half", "i_over_sig_i", "completeness", "multiplicity_vs_resolution", "r_pim", ] for plot in plots.values(): assert plot["layout"]["xaxis"]["ticktext"] == plotter.d_star_sq_ticktext assert plot["layout"]["xaxis"]["tickvals"] == plotter.d_star_sq_tickvals