Example #1
0
def plot_amplitude_for_energy_dependence(db_conn, query, exp_dir, envir, title, preplot=None):
    hanle_curve_fits = db_conn.spin_optics.hanle_curve_fits
    fits = field_dataframe(
        hanle_curve_fits.find(query),
        ["probe_energy", "sample_temperature", "amplitude", "inv_hwhm", "probe_background", "offset", "pump_intensity"],
    )
    print(fits)
    fig, ax = plt.subplots()

    ax2 = None
    if preplot:
        ax2 = preplot(fig, ax)

    # TODO: make other plot functions match axis use and preplot
    ax.plot(fits["probe_energy"], fits["amplitude_0"], "^r", label="g = 0.33")
    ax.plot(fits["probe_energy"], fits["amplitude_1"], "ok", label="g = 2.7")
    ax.axhline(y=0, color="grey", linewidth=1)
    ax.set_yticklabels(ax.get_yticks() / 1e-6)
    ax.set_xlabel("Energy (eV)")
    ax.set_ylabel("Faraday Rotation ($\mu rad$)")
    plt.title(title)

    if ax2:
        lines, labels = ax.get_legend_handles_labels()
        lines2, labels2 = ax2.get_legend_handles_labels()
        ax2.legend(lines + lines2, labels + labels2, loc=0)
    else:
        ax.legend()

    plt.savefig(os.path.join(exp_dir, envir["eid"] + " amplitude vs. energy.pdf"))
Example #2
0
def plot_lifetime_for_power_dependence(db_conn, query, exp_dir, envir, title):
    hanle_curve_fits = db_conn.spin_optics.hanle_curve_fits
    query_vars = [
        "probe_energy",
        "sample_temperature",
        "amplitude",
        "inv_hwhm",
        "probe_background",
        "offset",
        "pump_intensity",
    ]
    fits = field_dataframe(hanle_curve_fits.find(query), query_vars)
    print(fits)
    fig, ax = plt.subplots()
    plt.plot(fits["pump_intensity"], hanle_lifetime_gauss_in_sec(fits["inv_hwhm_0"], g=0.33), "^r", label="g = 0.33")
    plt.plot(fits["pump_intensity"], hanle_lifetime_gauss_in_sec(fits["inv_hwhm_1"], g=2.7), "ok", label="g = 2.7")

    ax.set_yticklabels(ax.get_yticks() / 1e-9)
    ax.set_xticklabels(ax.get_xticks() / 1e-3)
    plt.xlabel("Pump Intensity (milliwatts)")
    plt.ylabel("Lifetime (ns)")
    plt.title(title)
    plt.legend()
    plt.savefig(os.path.join(exp_dir, envir["eid"] + " lifetime vs. pump power.pdf"))

    fits["lifetime_0_0.33 (sec)"] = hanle_lifetime_gauss_in_sec(fits["inv_hwhm_0"], g=0.33)
    fits["lifetime_1_2.7 (sec)"] = hanle_lifetime_gauss_in_sec(fits["inv_hwhm_1"], g=2.7)
    fits.columns = dimension_column_labels(fits.columns, db_conn)

    fits.to_csv(os.path.join(exp_dir, envir["eid"] + " data vs. pump power.csv"))
Example #3
0
def plot_amplitude_for_power_dependence(db_conn, query, exp_dir, envir, title):
    hanle_curve_fits = db_conn.spin_optics.hanle_curve_fits
    fits = field_dataframe(
        hanle_curve_fits.find(query),
        ["probe_energy", "sample_temperature", "amplitude", "inv_hwhm", "probe_background", "offset", "pump_intensity"],
    )
    print(fits)
    fig, ax = plt.subplots()
    plt.plot(fits["pump_intensity"], fits["amplitude_0"], "^r", label="g = 0.33")
    plt.plot(fits["pump_intensity"], fits["amplitude_1"], "ok", label="g = 2.7")

    ax.set_yticklabels(ax.get_yticks() / 1e-6)
    ax.set_xticklabels(ax.get_xticks() / 1e-3)
    plt.xlabel("Pump Intensity (milliwatts)")
    plt.ylabel("Amplitude ($\mu rad$)")
    plt.title(title)
    plt.legend()
    plt.savefig(os.path.join(exp_dir, envir["eid"] + " amplitude vs. pump power.pdf"))