예제 #1
0
def summary():
    long_data = LB51_get_cal_data.get_long_pulse_data()
    short_data = LB51_get_cal_data.get_short_pulse_data()
    binned_603 = LB51_get_cal_data.bin_burst_data(long_data["603"]["total"],
                                                  603)
    binned_99 = LB51_get_cal_data.bin_burst_data(short_data["99"]["total"], 99)
    short_summary_data = [short_data["359"]]
    short_summary_data.extend(binned_99)
    long_summary_data = [long_data["641"]]
    long_summary_data.extend(binned_603)
    f, axs = plt.subplots(
        2,
        2,
        sharex=True,
        sharey="row",
        figsize=(3.37, 5),
        gridspec_kw={"height_ratios": [2, 6]},
    )
    spectra_series_plot(axs[1, 0], short_summary_data)
    spectra_series_plot(axs[1, 1], long_summary_data)
    emission_axs = linear_plots([axs[0, 0], axs[0, 1]],
                                short_data["359"]["sum_intact"])
    format_summary_plot(f, axs, emission_axs)
    plt.savefig("plots/2021_06_13_summary.eps", dpi=600)
    plt.savefig("plots/2021_06_13_summary.png", dpi=600)
예제 #2
0
파일: quant.py 프로젝트: dhigley6/LB51
def run_quant_ana():
    """Calculate stim. strength of expt. data"""
    short_data = LB51_get_cal_data.get_short_pulse_data()
    long_data = LB51_get_cal_data.get_long_pulse_data()
    short_run_sets_list = ["99", "290", "359", "388"]
    short_fluences = []
    short_stim_strengths = []
    for run_set in short_run_sets_list:
        fluence = short_data[run_set]["sum_intact"]["fluence"]
        # if run_set == "99":
        # fluence = 1898
        stim_strength = get_stim_efficiency(short_data[run_set])
        short_fluences.append(fluence)
        short_stim_strengths.append(stim_strength)
    long_run_sets_list = ["641", "554", "603"]
    long_fluences = []
    long_stim_strengths = []
    for run_set in long_run_sets_list:
        fluence = long_data[run_set]["sum_intact"]["fluence"]
        stim_strength = get_stim_efficiency(long_data[run_set])
        long_fluences.append(fluence)
        long_stim_strengths.append(stim_strength)
    quant_data = {
        "short_fluences": np.array(short_fluences),
        "long_fluences": np.array(long_fluences),
        "short_efficiencies": 100 * np.array(short_stim_strengths),
        "long_efficiencies": 100 * np.array(long_stim_strengths),
    }
    _save_quant_data(quant_data)
예제 #3
0
def load_data():
    long_data = LB51_get_cal_data.get_long_pulse_data()
    short_data = LB51_get_cal_data.get_short_pulse_data()
    binned_603 = LB51_get_cal_data.bin_burst_data(long_data["603"]["total"],
                                                  603)
    binned_99 = LB51_get_cal_data.bin_burst_data(short_data["99"]["total"], 99)
    data_sets = {
        "short_pulse_low_fluence": short_data["359"]["sum_intact"],
        "short_pulse_high_fluence_low_photon_energy":
        binned_99[0]["sum_intact"],
        "short_pulse_high_fluence_high_photon_energy":
        binned_99[0]["sum_intact"],
        "long_pulse_low_fluence": long_data["641"]["sum_intact"],
        "long_pulse_high_fluence_low_photon_energy":
        binned_603[0]["sum_intact"],
        "long_pulse_high_fluence_high_photon_energy":
        binned_603[1]["sum_intact"],
    }
    return data_sets
예제 #4
0
def save_markus_data():
    long_data = LB51_get_cal_data.get_long_pulse_data()
    short_data = LB51_get_cal_data.get_short_pulse_data()
    binned_603 = LB51_get_cal_data.bin_burst_data(long_data["603"]["total"],
                                                  603)
    binned_99 = LB51_get_cal_data.bin_burst_data(short_data["99"]["total"], 99)
    data_sets_to_save = {
        "short_pulse_low_fluence": short_data["359"]["sum_intact"],
        "short_pulse_high_fluence_low_photon_energy":
        binned_99[0]["sum_intact"],
        "short_pulse_high_fluence_high_photon_energy":
        binned_99[0]["sum_intact"],
        "long_pulse_low_fluence": long_data["641"]["sum_intact"],
        "long_pulse_high_fluence_low_photon_energy":
        binned_603[0]["sum_intact"],
        "long_pulse_high_fluence_high_photon_energy":
        binned_603[1]["sum_intact"],
    }
    with open("markus_data.pickle", "wb") as f:
        pickle.dump(data_sets_to_save, f)
    make_test_figure(data_sets_to_save)
예제 #5
0
def overview_plot():
    """Make plots summarizing the obtained data"""

    def individual_shots_plot(ax, data, shots_to_plot):
        phot = data["sum_intact"]["phot"]
        for ind, shot in enumerate(shots_to_plot):
            sam_spec = data["blown"]["sam_spec"][shot]
            no_sam_spec = data["blown"]["no_sam_spec"][shot]
            norm_sam_spec = sam_spec / np.amax(sam_spec) / 1.5
            norm_no_sam_spec = no_sam_spec * NO_SAM / np.amax(sam_spec) / 1.5
            if ind == 0:
                sam_label = "Top"
                no_sam_label = "Bot."
            else:
                sam_label = "_nolegend_"
                no_sam_label = "_nolegend_"
            ax.plot(phot, norm_sam_spec + ind, "r", label=sam_label)
            ax.plot(phot, norm_no_sam_spec + ind, "k--", label=no_sam_label)
            if ind == 0:
                ax.legend(loc="best")

    def summed_spectra_plot(ax, data):
        phot = data["sum_intact"]["phot"]
        norm = np.amax(data["sum_intact"]["no_sam_spec"])
        sam_spec = data["sum_intact"]["sam_spec"] / norm
        no_sam_spec = data["sum_intact"]["no_sam_spec"] / norm
        exc_spec = data["sum_intact"]["exc_sam_spec"] / norm
        ssrl_trans = np.exp(-1 * data["sum_intact"]["ssrl_absorption"])
        lin_sam_spec = no_sam_spec * ssrl_trans
        ax.plot(phot, no_sam_spec * NO_SAM, "k--", label="Ref.")
        ax.plot(phot, sam_spec, "k", label="Sam.")
        ax.plot(phot, lin_sam_spec, "k:", label="Linear Sam.")
        ax.fill_between(
            phot,
            lin_sam_spec,
            sam_spec,
            where=(exc_spec > 0),
            facecolor="b",
            edgecolor="w",
        )
        ax.fill_between(
            phot,
            lin_sam_spec,
            sam_spec,
            where=(exc_spec < 0),
            facecolor="r",
            edgecolor="w",
        )

    def nonlinear_spectra_plot(ax, data):
        phot = data["sum_intact"]["phot"]
        norm = np.amax(data["sum_intact"]["no_sam_spec"])
        no_sam_spec = data["sum_intact"]["no_sam_spec"] / norm
        exc_spec = data["sum_intact"]["exc_sam_spec"] / norm
        ax.plot(phot, exc_spec * 5, color="k", label="5 X Diff.")
        ax.plot(phot, no_sam_spec, "k--", label="Ref.")
        ax.fill_between(
            phot,
            np.zeros_like(phot),
            exc_spec * 5,
            where=(exc_spec > 0),
            facecolor="b",
            edgecolor="w",
        )
        ax.fill_between(
            phot,
            np.zeros_like(phot),
            exc_spec * 5,
            where=(exc_spec < 0),
            facecolor="r",
            edgecolor="w",
        )

    def xas_plot(ax, low_data, high_data, threshold=0.15):
        high_phot = high_data["sum_intact"]["phot"]
        high_threshold = threshold * np.amax(high_data["sum_intact"]["no_sam_spec"])
        high_in_range = high_data["sum_intact"]["no_sam_spec"] > high_threshold
        ax.plot(
            high_phot[high_in_range],
            high_data["sum_intact"]["abs"][high_in_range],
            color="tab:orange",
            label="1335\nmJ/cm$^2$",
        )
        low_phot = low_data["sum_intact"]["phot"]
        low_threshold = threshold * np.amax(low_data["sum_intact"]["no_sam_spec"])
        low_in_range = low_data["sum_intact"]["no_sam_spec"] > low_threshold
        ax.plot(
            low_phot[low_in_range],
            low_data["sum_intact"]["abs"][low_in_range],
            "g",
            label="12\nmJ/cm$^2$",
        )
        ax.plot(
            low_phot, low_data["sum_intact"]["ssrl_absorption"], "k--", label="Sync."
        )

    short_data = LB51_get_cal_data.get_short_pulse_data()
    long_data = LB51_get_cal_data.get_long_pulse_data()
    f, axs = plt.subplots(2, 2, figsize=(3.37, 4))
    shots_to_plot = [
        20,
        23,
        26,
    ]  # last shots on some samples (blown up) after the first few
    individual_shots_plot(axs[0, 0], long_data["603"], shots_to_plot)
    summed_spectra_plot(axs[1, 0], short_data["99"])
    nonlinear_spectra_plot(axs[0, 1], short_data["99"])
    xas_plot(axs[1, 1], short_data["359"], short_data["99"])
    format_data_overview_plot(f, axs)
    plt.savefig("plots/2021_01_04_overview_for_setup.eps", dpi=600)
    plt.savefig("plots/2021_01_04_overview_for_setup.png", dpi=600)
예제 #6
0
def overview_plot():
    """Make plots summarizing the obtained data"""
    def individual_shots_plot(ax, data, shots_to_plot):
        phot = data["sum_intact"]["phot"]
        for ind, shot in enumerate(shots_to_plot):
            sam_spec = data["intact"]["sam_spec"][shot]
            no_sam_spec = data["intact"]["no_sam_spec"][shot]
            norm_sam_spec = sam_spec / np.amax(sam_spec) / 4
            norm_no_sam_spec = no_sam_spec * NO_SAM / np.amax(sam_spec) / 4
            if ind == 0:
                sam_label = "Co/Pd"
                no_sam_label = "Ref."
            else:
                sam_label = "_nolegend_"
                no_sam_label = "_nolegend_"
            ax.plot(phot, norm_sam_spec + ind, "k", label=sam_label)
            ax.plot(phot, norm_no_sam_spec + ind, "k--", label=no_sam_label)
            if ind == 0:
                ax.legend(loc="best")

    def summed_spectra_plot(ax, data):
        phot = data["sum_intact"]["phot"]
        norm = np.amax(data["sum_intact"]["no_sam_spec"])
        sam_spec = data["sum_intact"]["sam_spec"] / norm
        no_sam_spec = data["sum_intact"]["no_sam_spec"] / norm
        exc_spec = data["sum_intact"]["exc_sam_spec"] / norm
        ssrl_trans = np.exp(-1 * data["sum_intact"]["ssrl_absorption"])
        lin_sam_spec = no_sam_spec * ssrl_trans
        ax.plot(phot, no_sam_spec * NO_SAM, "k--", label="Ref.")
        ax.plot(phot, sam_spec, "k", label="Co/Pd")
        ax.plot(phot, lin_sam_spec, "k:", label="Linear Co/Pd")
        ax.fill_between(
            phot,
            lin_sam_spec,
            sam_spec,
            where=(exc_spec > 0),
            facecolor="b",
            edgecolor="w",
        )
        ax.fill_between(
            phot,
            lin_sam_spec,
            sam_spec,
            where=(exc_spec < 0),
            facecolor="r",
            edgecolor="w",
        )

    def nonlinear_spectra_plot(ax, data):
        phot = data["sum_intact"]["phot"]
        norm = np.amax(data["sum_intact"]["no_sam_spec"])
        no_sam_spec = data["sum_intact"]["no_sam_spec"] / norm
        exc_spec = data["sum_intact"]["exc_sam_spec"] / norm
        ax.plot(phot, exc_spec * 5, color="k", label="5 X Diff.")
        ax.plot(phot, no_sam_spec, "k--", label="Ref.")
        ax.fill_between(
            phot,
            np.zeros_like(phot),
            exc_spec * 5,
            where=(exc_spec > 0),
            facecolor="b",
            edgecolor="w",
        )
        ax.fill_between(
            phot,
            np.zeros_like(phot),
            exc_spec * 5,
            where=(exc_spec < 0),
            facecolor="r",
            edgecolor="w",
        )

    def xas_plot(ax, low_data, high_data, threshold=0.15):
        high_phot = high_data["sum_intact"]["phot"]
        high_threshold = threshold * np.amax(
            high_data["sum_intact"]["no_sam_spec"])
        high_in_range = high_data["sum_intact"]["no_sam_spec"] > high_threshold
        ax.plot(
            high_phot[high_in_range],
            high_data["sum_intact"]["abs"][high_in_range],
            color="tab:orange",
            label="1335\nmJ/cm$^2$",
        )
        low_phot = low_data["sum_intact"]["phot"]
        low_threshold = threshold * np.amax(
            low_data["sum_intact"]["no_sam_spec"])
        low_in_range = low_data["sum_intact"]["no_sam_spec"] > low_threshold
        ax.plot(
            low_phot[low_in_range],
            low_data["sum_intact"]["abs"][low_in_range],
            "g",
            label="12\nmJ/cm$^2$",
        )
        ax.plot(low_phot,
                low_data["sum_intact"]["ssrl_absorption"],
                "k--",
                label="Sync.")

    short_data = LB51_get_cal_data.get_short_pulse_data()
    f, axs = plt.subplots(2, 2, sharex=True, figsize=(3.37, 4))
    shots_to_plot = [3, 4,
                     5]  # Three consecutive pulses, not at beginning or end
    individual_shots_plot(axs[0, 0], short_data["99"], shots_to_plot)
    summed_spectra_plot(axs[1, 0], short_data["99"])
    nonlinear_spectra_plot(axs[0, 1], short_data["99"])
    xas_plot(axs[1, 1], short_data["359"], short_data["99"])
    format_data_overview_plot(f, axs)
    plt.savefig("plots/2021_06_20_overview.eps", dpi=600)
    plt.savefig("plots/2021_06_20_overview.png", dpi=600)
예제 #7
0
파일: quant_stim.py 프로젝트: dhigley6/LB51
"""Quantifying experimentally measured stimulated RIXS strength
"""

import numpy as np
import pickle
import matplotlib.pyplot as plt
from scipy.stats import percentileofscore

from LB51 import LB51_get_cal_data

MEASURED_STIM_FILE = "data/proc/stim_efficiency.pickle"

SHORT_DATA = LB51_get_cal_data.get_short_pulse_data()
LONG_DATA = LB51_get_cal_data.get_long_pulse_data()

SHORT_RUN_SETS_LIST = ["99", "290", "359", "388"]
SHORT_RUN_SETS_LIST = [
    "99",
    "290",
    "359",
]  # remove run set 388 since that one has very limited data
LONG_RUN_SETS_LIST = ["641", "603"]
SSRL_ABSORPTION_COPD = SHORT_DATA["99"]["sum_intact"]["ssrl_absorption"]

OFFSET_REFERENCE = {
    "99": SHORT_DATA["99"],
    "290": SHORT_DATA["99"],
    "359": SHORT_DATA["99"],
    "388": SHORT_DATA["99"],
    "603": LONG_DATA["603"],
    "641": LONG_DATA["603"],