Beispiel #1
0
def test_plot_outliers():
    """Test outlier plot, for standard and null data."""
    data = {
        "x": [1.0, 2.0],
        "y": [0.0, 1.0],
        "z": [1.0, 1.0],
        "image_size": [100, 200]
    }
    d = plot_outliers(data)
    assert "outliers_vs_z" in d
    assert "outlier_xy_positions" in d

    data = {"x": [], "y": [], "z": [], "image_size": [100, 200]}
    d = plot_outliers(data)
    assert "outliers_vs_z" in d
    assert "outlier_xy_positions" in d
Beispiel #2
0
def make_outlier_plots(reflection_tables, experiments):
    """Make outlier plots for the HTML report."""
    data = {}
    for j, (table, expt) in enumerate(zip(reflection_tables, experiments)):
        outliers = table.get_flags(table.flags.outlier_in_scaling)
        x, y, z = table["xyzobs.px.value"].select(outliers).parts()
        if expt.scan:
            zrange = [
                i / expt.scan.get_oscillation()[1]
                for i in expt.scan.get_oscillation_range()
            ]
        else:
            zrange = [0, 0]
        data[j] = {
            "x": list(x),
            "y": list(y),
            "z": list(z),
            "image_size": expt.detector[0].get_image_size(),
            "z_range": zrange,
        }
    d = OrderedDict()
    for key in sorted(data):
        outlier_plots = plot_outliers(data[key])
        for plot in outlier_plots.values():
            if plot:  # may be null if no outliers
                plot["layout"]["title"] += f" (dataset {key})"
        d["outlier_plot_" + str(key)] = outlier_plots["outlier_xy_positions"]
        d["outlier_plot_z" + str(key)] = outlier_plots["outliers_vs_z"]
    graphs = {"outlier_plots": d}
    return graphs
Beispiel #3
0
 def make_plots(self):
     """Generate plot data of outliers on the detector and vs z."""
     d = OrderedDict()
     for key in sorted(self.data):
         outlier_plots = plot_outliers(self.data[key])
         for plot in outlier_plots.values():
             if plot:  # may be null if no outliers
                 plot["layout"]["title"] += " (dataset %s)" % key
         d["outlier_plot_" + str(key)] = outlier_plots["outlier_xy_positions"]
         d["outlier_plot_z" + str(key)] = outlier_plots["outliers_vs_z"]
     graphs = {"outlier_plots": d}
     return graphs