Exemplo n.º 1
0
def plot_hanle_fits_for_power_dependence(
    data, envir, curve_loader, fit_plot_filename, db_conn, constrain_background=False
):
    exp_dir = exp_dir_from_env(envir)
    fit_plots_dir = os.path.join(exp_dir, "fit_plots")
    if not os.path.exists(fit_plots_dir):
        os.makedirs(fit_plots_dir)

    for s, w, pup in zip(data.Timestamp.values, data.W.values, data.PuP):
        curve = curve_loader(s)
        result = hanle_fit_for_data(curve, db_conn)
        if result is not None:
            plot_hanle_curve(curve, result)
            # title(hanle_curve_title_from_stored(curve_id))
            plt.savefig(os.path.join(fit_plots_dir, fit_plot_filename(s, w)))

            plt.close()
Exemplo n.º 2
0
def plot_hanle_fits_for_energy_dependence(
    data, envir, curve_loader, fit_plot_filename, db_conn, constrain_background=False, **kwargs
):
    exp_dir = exp_dir_from_env(envir)
    fit_plots_dir = os.path.join(exp_dir, "fit_plots")
    if not os.path.exists(fit_plots_dir):
        os.makedirs(fit_plots_dir)

    for s, w, pp, z, bg in zip(data.Timestamp.values, data.W.values, data.PP, data.Z.values, data.BG.values):
        curve = curve_loader(s)
        result = hanle_fit_for_data(curve, db_conn)
        if result is not None:
            plot_hanle_curve(curve, result, **kwargs)
            # title(hanle_curve_title_from_stored(curve_id))
            if not constrain_background:
                plt.savefig(os.path.join(fit_plots_dir, fit_plot_filename(s, w)))
            else:
                if not os.path.exists(os.path.join(fit_plots_dir, "constrained_bg")):
                    os.path.makedirs(os.path.join(fit_plots_dir, "constrained_bg"))
                plt.savefig(os.path.exists(os.path.join(fit_plots_dir, "constrained_bg", "%04d.pdf" % s)))
            plt.close()