Example #1
0
def plot_observable_correlations(results_table, base_pdf=None):

    for title, corrmat, labels, filename in observable_correlations(results_table, base_pdf):
        if base_pdf is not None:
            rlim = np.max(np.abs(corrmat))
        else:
            rlim = 1
        ranges = (-rlim, rlim)



        fig = plt.figure()
        plt.imshow(corrmat, cmap=plotutils.spectral_cm, vmin=ranges[0],
                   vmax=ranges[1], interpolation='none')
        plt.grid(False)
        if len(corrmat) < 20:
            ticks = np.arange(len(corrmat)), labels
            plt.xticks(*ticks, rotation=90)
            plt.yticks(*ticks)
        else:
            ...
            #empty = matplotlib.patches.Rectangle((0,0), 1, 1, fill=False,
            #                                     edgecolor='none',
            #                     visible=False)
            #plt.legend([empty]*len(corrmat), labels)

        plt.title(title)
        plt.tight_layout()
        plt.colorbar()

        yield (filename,) , fig
Example #2
0
def export_obscorrs(data_table, output_dir, prefix, base_pdf=None):
    import pandas as pd

    from smpdflib.corrutils import observable_correlations

    for title, corrmat, labels, filename in observable_correlations(data_table, base_pdf):
        name = prefix + "_" + normalize_name(title)
        filename = osp.join(output_dir, name + ".csv")
        pd.DataFrame(corrmat, index=labels, columns=labels).to_csv(filename, sep='\t')