Exemplo n.º 1
0
def plot2d_summary(
    x,
    y,
    z,
    xlabel,
    ylabel,
    zlabel,
    title=None,
    append_to_filename="",
    pcm_kwargs={},
    rc_params={},
    **params,
):
    """Plot 2-dimensional data and save figure."""
    rcParams.update(rc_params)
    if any(len(a.shape) > 2 for a in (x, y, z)):
        logger.warning(
            f"Failed to plot {params['labber_filename']}: "
            f"data is more than 2D ({x.shape=} {y.shape=} {z.shape=})")
        return
    if len(set([x.shape[0], y.shape[0], z.shape[0]])) > 1:
        logger.warning(
            f"Truncating {params['labber_filename']} along first axis: "
            f"scan may have been interrupted ({x.shape=} {y.shape=} {z.shape=})."
        )
        n = min(x.shape[0], y.shape[0], z.shape[0])
        x, y, z = x[:n], y[:n], z[:n]
    min_z = np.min(z)
    try:
        fig = Figure()
        ax = fig.add_subplot()
        plot2d(
            x,
            y,
            z,
            xlabel=xlabel,
            ylabel=ylabel,
            zlabel=zlabel,
            title=title,
            ax=ax,
            **pcm_kwargs,
        )
    except Exception as e:
        logger.warning(
            f"Failed to plot data from {params['labber_filename']}: caught {repr(e)}"
        )
        return
    scan_id = flat_clfs(params)["scan"]
    stamp(ax, scan_id)
    fig.savefig(out_dir(params) / (scan_id + append_to_filename + ".png"),
                format="png")
Exemplo n.º 2
0
def reconstruct_current(name, obj):
    scan = name.split("/")[-1].split("::")[-1]
    if scan not in scans.keys():
        return None
    print(scan, name)
    params = scans[scan]

    field = obj["x magnet field"]
    ibias = obj["dc current bias"]
    dvdi = np.abs(obj["lock-in (impedance)"])

    # extract fraunhofer from data
    ic = extract_switching_current(ibias, dvdi, threshold=params["threshold"])
    fig, ax = plot2d(field, ibias, dvdi)
    plot(
        np.unique(field),
        ic,
        ax=ax,
        title="Ic extraction",
        color="k",
        lw="0",
        marker=".",
        markersize=5,
    )
    ax.axis("off")
    stamp(ax, scan)
    fig.savefig(outdir / f"{scan}_ic-extraction.png")

    field = np.unique(field)

    # center fraunhofer
    argmax_ic = find_fraunhofer_center(field, ic)
    ic_n = extract_switching_current(ibias,
                                     dvdi,
                                     threshold=params["threshold"],
                                     side="negative")
    argmax_ic_n = find_fraunhofer_center(field, np.abs(ic_n))
    field -= (argmax_ic + argmax_ic_n) / 2
    # field = recenter_fraunhofer(np.unique(field), ic) # if just centering at argmax(Ic+)
    fig, ax = plot(
        field / 1e-3,
        np.array([ic, ic_n]).T / 1e-6,
        xlabel="field (mT)",
        ylabel="critical current (μA)",
        title="fraunhofer centered",
    )
    ax.axvline(0, color="k")
    fig.savefig(outdir / f"{scan}_fraunhofer-centered.png")

    # reconstruct current distribution
    x, jx = extract_current_distribution(
        field,
        ic,
        f2k=2 * np.pi * params["jj_length"] / phys_c["mag. flux quantum"][0],
        jj_width=params["jj_width"],
        jj_points=400,
    )
    fig, ax = subplots()
    ax.fill_between(x / 1e-6, jx)
    ax.set_xlabel("position (μA)")
    ax.set_ylabel("critical current density (μA/μm)")
    ax.set_title(
        f"$\ell_\mathrm{{eff}}$ = {round(params['jj_length'] / 1e-6, 1)}μm")
    fig.savefig(outdir / f"{scan}_current-distribution.png")
Exemplo n.º 3
0
    dvdi = np.abs(lockin)
    temp_meas = f.get_data(CHAN_TEMP_MEAS)

# check for significant temperature deviations
MAX_TEMPERATURE_STD = 1e-3
temp_std = np.std(temp_meas)
if temp_std > MAX_TEMPERATURE_STD:
    warnings.warn(
        f"Temperature standard deviation {temp_std} K > {MAX_TEMPERATURE_STD} K"
    )

# plot the raw data
fig, ax = plot2d(
    *np.broadcast_arrays(bfield[..., np.newaxis] / 1e-3, ibias / 1e-6, dvdi),
    xlabel="x coil field (mT)",
    ylabel="dc bias (μA)",
    zlabel="dV/dI (Ω)",
    title="raw data",
    stamp=COOLDOWN_SCAN,
)
fig.savefig(str(OUTPATH) + "_raw-data.png")

# extract the switching currents
ic_n, ic_p = extract_switching_current(
    ibias,
    dvdi,
    side="both",
    threshold=RESISTANCE_THRESHOLD,
    interp=True,
)
ax.set_title("$I_c$ extraction")
plot(bfield / 1e-3, ic_p / 1e-6, ax=ax, color="w", lw=0, marker=".")
Exemplo n.º 4
0
    ylabel="Current Bias (μA)",
)
fig.savefig(OUTDIR / f"{FILENAME}_Ic.png")

# broadcast scalar data over vectorial data to have same shape
iflux, bfield, ibias, dc_volts = np.broadcast_arrays(iflux[..., np.newaxis],
                                                     bfield[..., np.newaxis],
                                                     ibias, dc_volts)

# plot the first CPR
fig, ax = plot2d(
    bfield[0] / 1e-6,
    ibias[0] / 1e-6,
    np.diff(dc_volts[0]) / np.diff(ibias[0]),
    xlabel="$B_\perp^\mathrm{ext}$ (μT)",
    ylabel="$I_\\mathrm{bias}$ (μA)",
    zlabel="dV/dI (Ω)",
    vmin=0,
    vmax=500,
    extend_min=False,
)
qmesh = ax.get_children()[0]
assert isinstance(qmesh,
                  QuadMesh), "Violated assumption that first child is QuadMesh"
line = ax.axvline(200, color="black", linestyle="--")
text = ax.text(
    220,
    0,
    r"$I_\mathrm{flux} = " + f"{int(round(iflux[0, 0, 0])) / 1e-6}$ μA",
    color="white",
    size=32,