Example #1
0
def find_filtermode(fname):
    """
    Derive enum value from string found in filename.
    For downward compatibility, search for both patterns (e.g. '0filter' and
    'nofilter').
    """
    from constants import FILTER_MODES
    names = ["nofilter", "prefilter", "postfilter"]
    for enumval, name in zip(sorted(FILTER_MODES.keys()), names):
        if "{}filter".format(enumval) in fname or name in fname:
            return enumval
    raise KeyError("Filter mode could not be deduced from filename!")
            )

    frames = [239, 359, 479, 599, 719, 999]
    fluxes = [
            #5e5, # omitted because gradient is too irregular
            5e6, 2e7, 5e7, 5e8]
    ylim, suffix, legendfm, loc = input_files[fname]
    """
    fig, axes = plt.subplots(1, 3, True, True)
    axes[0].set_ylabel("Edge sharpness")
    axes[1].set_xlabel("Frames")
    for ax, title in zip(axes, ["unfiltered", "prefiltered", "postfiltered"]):
        ax.set_title(title)
    """

    for fm, name in FILTER_MODES.items():
        fig, ax = plt.subplots(1, 1)
        #ax = axes[fm] # current subplot axis.
        fm_selection = fmode == fm
        for fl in fluxes:
            fl_selection = flux[fm_selection] == fl
            frms_sorting = np.argsort(frms[fm_selection][fl_selection])

            flux_str = mant_exp_from_int(fl)[2]
            ax.errorbar(
                    frms[fm_selection][fl_selection][frms_sorting],
                    sharpness[fm_selection][fl_selection][frms_sorting],
                    yerr=uncertainty[fm_selection][fl_selection][frms_sorting],
                    fmt=".-",
                    label=flux_str,
                    markersize=1.0