Esempio n. 1
0
class Fitter(Operative):
    offset = FloatRange(-1.0, 1.0, -0.035).tag(tracking=True)
    flux_factor = FloatRange(0.01, 1.0, 0.2925).tag(tracking=True)

    @tag_Property(plot=True, private=True)
    def flux_parabola(self):
        flux_over_flux0 = qdt.call_func("flux_over_flux0",
                                        voltage=self.yoko,
                                        offset=self.offset,
                                        flux_factor=self.flux_factor)
        Ej = qdt.call_func("Ej", flux_over_flux0=flux_over_flux0)
        return qdt._get_fq(Ej, qdt.Ec)
        #return qdt.flux_parabola(voltage=self.yoko, offset=self.offset, flux_factor=self.flux_factor)

    yoko = Array().tag(unit="V", plot=True, label="Yoko", private=True)

    plotter = Typed(Plotter).tag(private=True)

    @observe("offset", "flux_factor")
    def update_plot(self, change):
        if change["type"] == "update":
            self.get_member("flux_parabola").reset(self)
            self.plotter.plot_dict["flux_parabola"].clt.set_ydata(
                self.flux_parabola)

            self.plotter.draw()
Esempio n. 2
0
class Fitter(Operative):
    offset = FloatRange(-1.0, 1.0, -0.015).tag(tracking=True)
    flux_factor = FloatRange(0.01, 1.0, 0.2945).tag(tracking=True)
    Ec = FloatRange(100.0, 200.0, 150.0).tag(tracking=True)

    @tag_Property(plot=True, private=True)
    def flux_parabola(self):
        flux_over_flux0 = qdt.call_func("flux_over_flux0",
                                        voltage=self.yoko,
                                        offset=self.offset,
                                        flux_factor=self.flux_factor)
        Ej = qdt.call_func("Ej", flux_over_flux0=flux_over_flux0)
        return qdt._get_fq(Ej, h * self.Ec * 1e6)
        #return qdt.flux_parabola(voltage=self.yoko, offset=self.offset, flux_factor=self.flux_factor)

    yoko = Array().tag(unit="V", plot=True, label="Yoko", private=True)

    freq = FloatRange(4.0e9, 5.0e9, 4.354e9)  #
    plotter = Typed(Plotter).tag(private=True)

    @observe("offset", "flux_factor", "Ec", "freq")
    def update_plot(self, change):
        if change["type"] == "update":
            self.get_member("flux_parabola").reset(self)
            self.plotter.plot_dict["flux_1"].clt.set_xdata(self.freq)
            self.plotter.plot_dict["flux_2"].clt.set_xdata(self.freq +
                                                           self.Ec * 1e6)
            self.plotter.plot_dict["flux_3"].clt.set_xdata(self.freq +
                                                           2 * self.Ec * 1e6)

            self.plotter.draw()
Esempio n. 3
0
class Test(Atom):
    name = Unicode("test_name").tag(private=True)
    a = Int().tag(label="Big A")
    b = Float().tag(unit=" mm")
    c = Unicode()
    d = List()
    en = Enum(1, 2, 3)
    arr = Array()
    f = Dict()

    @private_property
    def en_mapping(self):
        return {1: "a", 2: "b", 3: "c"}
Esempio n. 4
0
class Fitter(Operative):
     offset=FloatRange(-1.0, 1.0, qdt.offset).tag(tracking=True)
     flux_factor=FloatRange(0.01, 1.0, qdt.flux_factor).tag(tracking=True)
     extra_atten=FloatRange(0.0, 30.0, 0.0).tag(tracking=True)
     #pwr=Array()

     @tag_Property(plot=True, private=True)
     def PdBm_from_Ic(self):
         flux_over_flux0=(a.yoko-self.offset)*self.flux_factor
         Ej=qdt.Ejmax*absolute(cos(pi*flux_over_flux0))
         I=Ej*(2.0*e)/hbar
         mu_q=0.8*qdt.K2*qdt.Np
         gm=2*mu_q*qdt.W*qdt.epsinf*2*pi*qdt.f0/qdt.K2
         phi=I/gm #=gm*phi

         mu=0.8*qdt.K2*idt.Np
         V=phi/mu
         Pwatts=(V**2)/50.0
         PdBm=10.0*log10(Pwatts/0.001)+self.extra_atten
         return PdBm
         #pwr=a.pwr-a.rt_atten-a.fridge_atten
         #Pwatts=0.001*10.0**(pwr/10.0)
         #V=sqrt(Pwatts*50.0)







     @tag_Property(plot=True, private=True)
     def flux_parabola(self):
        flux_over_flux0=qdt.call_func("flux_over_flux0", voltage=self.yoko, offset=self.offset, flux_factor=self.flux_factor)
        Ej=qdt.call_func("Ej", flux_over_flux0=flux_over_flux0)
        return qdt._get_fq(Ej, qdt.Ec)
         #return qdt.flux_parabola(voltage=self.yoko, offset=self.offset, flux_factor=self.flux_factor)

     yoko=Array().tag(unit="V", plot=True, label="Yoko", private=True)

     plotter=Typed(Plotter).tag(private=True)

     @observe("offset", "flux_factor", "extra_atten")
     def update_plot(self, change):
         if change["type"]=="update":
             if "flux_parabola" in self.plotter.plot_dict:
                 self.get_member("flux_parabola").reset(self)
                 self.plotter.plot_dict["flux_parabola"].clt.set_ydata(self.flux_parabola)
             if "PdBm_from_Ic" in self.plotter.plot_dict:
                 self.get_member("PdBm_from_Ic").reset(self)
                 self.plotter.plot_dict["PdBm_from_Ic"].clt.set_ydata(self.PdBm_from_Ic)
             self.plotter.draw()
Esempio n. 5
0
class QDT(IDT, Qubit):
    base_name="QDT"

    @tagged_property(desc="""Coupling at IDT center frequency""", unit="GHz", label="Coupling at center frequency", tex_str=r"$G_{f0}$")
    def G_f0(self, Np, K2, f0):
        return 0.45*Np*K2*f0

    @tagged_property(desc="""Coupling adjusted by sinc sq""", unit="GHz", tex_str=r"$G_f$", label="frequency adjusted coupling")
    def G_f(self, G_f0, Np, fq, f0):
        #return G_f0*sinc_sq(Np*pi*(fq-f0)/f0)
        return absolute(G_f0*sinc(Np*pi*(fq-f0)/f0))

    ng=Float(0.5).tag(desc="charge on gate line")
    Nstates=Int(50).tag(desc="number of states to include in mathieu approximation. More states is better approximation")
    order=Int(3)
    EkdivEc=Array().tag(unit2="Ec")

    @tagged_property(desc="shunt capacitance of QDT", unit="fF")
    def Cq(self, Ct):
        return Ct

    @Cq.fget.setter
    def _get_Ct(self, Cq):
        return Cq
Esempio n. 6
0
class PlotFormat(PlotUpdate):
    """base class corresponding to one graph or collection on axes"""
    plot_name = ReadOnly()

    append = Bool(False)
    remove = Bool(False)

    xcoord = Float()
    ycoord = Float()
    xind = Int()
    yind = Int()

    #    x_min=Float()
    #    x_max=Float()
    #    y_min=Float()
    #    y_max=Float()
    #
    #    def _default_x_min(self):
    #        return min(self.xdata)
    #
    #    def _default_x_max(self):
    #        return max(self.xdata)
    #
    #    def _default_y_min(self):
    #        return min(self.ydata)
    #
    #    def _default_y_max(self):
    #        return max(self.ydata)

    def do_autolim(self):
        if self.plotter.auto_xlim:
            self.plotter.x_min = float(
                min((self.plotter.x_min, nanmin(self.xdata))))
            self.plotter.x_max = float(
                max((self.plotter.x_max, nanmax(self.xdata))))
        else:
            self.plotter.set_xlim(self.plotter.x_min, self.plotter.x_max)
        if self.plotter.auto_ylim:
            self.plotter.y_min = float(
                min((self.plotter.y_min, nanmin(self.ydata))))
            self.plotter.y_max = float(
                max((self.plotter.y_max, nanmax(self.ydata))))
        else:
            self.plotter.set_ylim(self.plotter.y_min, self.plotter.y_max)
        if self.plotter.show_legend:
            self.plotter.legend()

    xdata = Array()
    ydata = Array()

    plot_type = Enum("line", "scatter", "multiline", "colormap", "vline",
                     "hline", "polygon", "cross_cursor")

    clt = Typed(Line2D)

    visible = Bool(True).tag(former="visible")

    def clt_values(self):
        if isinstance(self.clt, dict):
            return self.clt.values()
        return [self.clt]

    def plot_set(self, param):
        for clt in self.clt_values():
            simple_set(clt, self, get_tag(self, param, "former", param))

    @plot_observe("visible")
    def plot_update(self, change):
        """set the clt's parameter to the obj's value using clt's set function"""
        self.plot_set(change["name"])

    def remove_collection(self):
        if self.remove:
            if self.clt is not None:
                self.clt.remove()

    def __init__(self, **kwargs):
        plot_name = kwargs.pop(
            "plot_name", self.plot_type)  #defaulter(self, "plot_name", kwargs)
        plotter = kwargs["plotter"]
        self.plot_name = name_generator(
            plot_name, plotter.plot_dict,
            kwargs.get("plot_type", self.plot_type))
        super(PlotFormat, self).__init__(**kwargs)
        self.plotter.plot_dict[self.plot_name] = self

    @cached_property
    def view_window(self):
        with imports():
            from plot_format_e import Main
        view = Main(pltr=self.plotter)
        return view
Esempio n. 7
0
class Lyzer(TA88_Fund):
    rd_hdf = Typed(TA88_Read)

    comment = Unicode().tag(read_only=True, spec="multiline")

    rt_atten = Float(40)

    rt_gain = Float(23 * 2)

    frequency = Array().tag(unit="GHz", plot=True, label="Frequency")
    yoko = Array().tag(unit="V", plot=True, label="Yoko")
    Magcom = Array().tag(private=True)

    probe_frq = Float().tag(unit="GHz",
                            label="Probe frequency",
                            read_only=True)
    probe_pwr = Float().tag(label="Probe power",
                            read_only=True,
                            display_unit="dBm/mW")

    pind = Int()

    @tag_Property(display_unit="dB", plot=True)
    def MagdB(self):
        return self.Magcom[:, :] / dB - mean(
            self.Magcom[:, 169:171], axis=1, keepdims=True) / dB

    @tag_Property(plot=True)
    def Phase(self):
        return angle(self.Magcom[:, :] -
                     mean(self.Magcom[:, 169:170], axis=1, keepdims=True))

    @tag_Property(plot=True)
    def MagAbs(self):
        #return absolute(self.Magcom[:, :])
        return absolute(
            self.Magcom[:, :]
        )**2  #-mean(self.Magcom[:, 0:1], axis=1, keepdims=True))

    def _default_rd_hdf(self):
        return TA88_Read(
            main_file="Data_0315/S1A1_TA88_coupling_search_midpeak.hdf5"
        )  #"Data_0312/S4A1_TA88_coupling_search.hdf5")

    def read_data(self):
        with File(self.rd_hdf.file_path, 'r') as f:
            print f["Traces"].keys()
            self.comment = f.attrs["comment"]
            print f["Instrument config"].keys()
            self.probe_frq = f["Instrument config"][
                'Rohde&Schwarz Network Analyzer - IP: 169.254.107.192, RS VNA at localhost'].attrs[
                    "Start frequency"]
            self.probe_pwr = f["Instrument config"][
                'Rohde&Schwarz Network Analyzer - IP: 169.254.107.192, RS VNA at localhost'].attrs[
                    "Output power"]
            print f["Instrument config"][
                'Rohde&Schwarz Network Analyzer - IP: 169.254.107.192, RS VNA at localhost'].attrs
            #
            print f["Data"]["Channel names"][:]
            Magvec = f["Traces"]["RS VNA - S21"]  #[:]
            data = f["Data"]["Data"]
            print shape(data)
            #
            self.yoko = data[:, 0, 0].astype(float64)
            fstart = f["Traces"]['RS VNA - S21_t0dt'][0][0]
            fstep = f["Traces"]['RS VNA - S21_t0dt'][0][1]
            print shape(Magvec)
            sm = shape(Magvec)[0]
            sy = shape(data)
            s = (sm, sy[0], 1)  #sy[2])
            print s
            Magcom = Magvec[:, 0, :] + 1j * Magvec[:, 1, :]

            Magcom = reshape(Magcom, s, order="F")
            self.frequency = linspace(fstart, fstart + fstep * (sm - 1), sm)
            print shape(Magcom)
            self.Magcom = squeeze(Magcom)
        with File(
                "/Users/thomasaref/Dropbox/Current stuff/Logbook/TA210715A88_cooldown210216/Data_0308/S1A4_TA88_coupling_search_midpeak.hdf5",
                "r") as f:
            Magvec = f["Traces"]["RS VNA - S21"]  #[:]
            data = f["Data"]["Data"]
            yoko = data[:, 0, 0].astype(float64)
            fstart = f["Traces"]['RS VNA - S21_t0dt'][0][0]
            fstep = f["Traces"]['RS VNA - S21_t0dt'][0][1]
            sm = shape(Magvec)[0]
            sy = shape(data)
            s = (sm, sy[0], 1)  #sy[2])
            Magcom = Magvec[:, 0, :] + 1j * Magvec[:, 1, :]
            Magcom = reshape(Magcom, s, order="F")
            frequency = linspace(fstart, fstart + fstep * (sm - 1), sm)
            Magcom = squeeze(Magcom)
            return frequency, yoko, Magcom

        with File(
                "/Users/thomasaref/Dropbox/Current stuff/Logbook/TA210715A45_cooldown270216/Data_0227/S4A4_TA88_wideSC1116unswitched.hdf5",
                "r") as f:
            Magvec = f["Traces"]["RS VNA - S21"]
            fstart = f["Traces"]['RS VNA - S21_t0dt'][0][0]
            fstep = f["Traces"]['RS VNA - S21_t0dt'][0][1]
            sm = shape(Magvec)[0]
            s = (sm, 1, 1)
            Magcom = Magvec[:, 0, :] + 1j * Magvec[:, 1, :]
            Magcom = reshape(Magcom, s, order="F")
            frequency = linspace(fstart, fstart + fstep * (sm - 1), sm)
            Magcom = squeeze(Magcom)
        return frequency, Magcom
Esempio n. 8
0
class Lyzer(TA88_Fund):

    #def _default_main_params(self):
    #    return ["rt_atten", "fridge_atten", "fridge_gain", "rt_gain", "comment", "flux_factor", "offset", "fit_type",
    #            "on_res_ind", "start_ind", "stop_ind", "filt_start_ind", "filt_end_ind"]

    rd_hdf=Typed(TA88_Read)
    rt_atten=Float(40)
    rt_gain=Float(23*2)
    comment=Unicode().tag(read_only=True, spec="multiline")
    frequency=Array().tag(unit="GHz", plot=True, label="Frequency", sub=True)
    yoko=Array().tag(unit="V", plot=True, label="Yoko", sub=True)
    pwr=Array().tag(unit="V", plot=True, label="Yoko", sub=True)
    frq2=Array().tag(unit="V", plot=True, label="Yoko", sub=True)
    Magcom=Array().tag(sub=True)
    offset=Float(-0.035)
    flux_factor=Float(0.2925)

    on_res_ind=Int()
    start_ind=Int()
    stop_ind=Int()
    filt_end_ind=Int(58)
    filt_start_ind=Int(5)


    fit_func=Callable(fano).tag(private=True)
    #resid_func=Callable(fano_residuals).tag(private=True)

    def resid_func(self, p, y, x):
        return y-self.fit_func(x, p)

    fit_type=Enum("Transmission", "Reflection")

    @tag_Property(plot=True, sub=True)
    def flux_par(self):
        flux_over_flux0=qdt.call_func("flux_over_flux0", voltage=self.yoko, offset=self.offset, flux_factor=self.flux_factor)
        Ej=qdt.call_func("Ej", flux_over_flux0=flux_over_flux0)
        return qdt._get_fq(Ej, qdt.Ec)

    @tag_Property(sub=True)
    def flux_over_flux0(self):
        return (self.yoko-self.offset)*self.flux_factor

    @tag_Property()
    def p_guess(self):
        #return [200e6,4.5e9, 0.002, 0.022, 0.1]
        return [200e6,4.5e9, 0.002, 0.022]

    @tag_Property(sub=True)
    def indices(self):
        return range(len(self.frequency))
        #return [range(81, 120+1), range(137, 260+1), range(269, 320+1), range(411, 449+1)]#, [490]]#, [186]]

    def fft_filter(self, n):
        myifft=fft.ifft(self.Magcom[:,n])
        myifft[self.filt_end_ind:-self.filt_end_ind]=0.0
        if self.filt_start_ind!=0:
            myifft[:self.filt_start_ind]=0.0
            myifft[-self.filt_start_ind:]=0.0
        return fft.fft(myifft)

    @tag_Property(plot=True, sub=True)
    def MagdB(self):
        return 10.0*log10(self.MagAbs)

    @tag_Property(plot=True, sub=True)
    def MagAbs(self):
        return absolute(self.Magcom)

    @tag_Property(plot=True, sub=True)
    def MagAbsFilt(self):
        return absolute(self.MagcomFilt)

    @tag_Property(plot=True, sub=True)
    def MagdBFilt(self):
        return 10.0*log10(self.MagAbsFilt)

    @tag_Property(plot=True, sub=True)
    def MagdBFiltbgsub(self):
        #return self.MagAbsFilt/mean(self.MagAbsFilt[:, 0:5], axis=1, keepdims=True)
        return self.MagdBFilt-10.0*log10(mean(self.MagAbsFilt[:, 0:5], axis=1, keepdims=True))

    @tag_Property(plot=True, sub=True)
    def MagAbsFilt_sq(self):
        return self.MagAbsFilt**2

    @tag_Property(plot=True, sub=True)
    def MagcomFilt(self):
        return array([self.fft_filter(n) for n in range(len(self.yoko))]).transpose()

    @plots
    def magabs_colormesh(self, plotter):
        plotter.colormesh("magabs_{}".format(self.name), self.yoko, self.frequency, self.MagAbs)
        plotter.set_ylim(min(self.frequency), max(self.frequency))
        plotter.set_xlim(min(self.yoko), max(self.yoko))
        plotter.mpl_axes.xlabel="Yoko (V)"
        plotter.mpl_axes.ylabel="Frequency (Hz)"
        plotter.mpl_axes.title="Magabs fluxmap {}".format(self.name)

    @plots
    def ifft_plot(self, plotter):
        plotter.line_plot("ifft_{}".format(self.name), absolute(fft.ifft(self.Magcom[:,self.on_res_ind])))
        plotter.line_plot("ifft_{}".format(self.name), absolute(fft.ifft(self.Magcom[:,self.start_ind])))
        plotter.line_plot("ifft_{}".format(self.name), absolute(fft.ifft(self.Magcom[:,self.stop_ind])))

    @plots
    def ifft_dif_plot(self, plotter):
        plotter.line_plot("ifft_dif1_{}".format(self.name), absolute(absolute(fft.ifft(self.Magcom[:,self.start_ind]))-absolute(fft.ifft(self.Magcom[:,self.on_res_ind]))))
        plotter.line_plot("ifft_dif2_{}".format(self.name), absolute(absolute(fft.ifft(self.Magcom[:,self.stop_ind]))-absolute(fft.ifft(self.Magcom[:,self.on_res_ind]))))
        plotter.line_plot("ifft_dif3_{}".format(self.name), absolute(absolute(fft.ifft(self.Magcom[:,self.stop_ind]))-absolute(fft.ifft(self.Magcom[:,self.start_ind]))))

    @plots
    def filt_compare(self, ind, plotter=None):
        plotter.line_plot("magabs_{}".format(self.name), self.frequency, self.MagdB[:, ind], label="MagAbs (unfiltered)")
        plotter.line_plot("magabs_{}".format(self.name), self.frequency, self.MagdBFilt[:, ind], label="MagAbs (filtered)")

    @plots
    def magabsfilt_colormesh(self, plotter):
        plotter.colormesh("magabsfilt_{}".format(self.name), self.yoko, self.frequency, self.MagAbsFilt)
        plotter.set_ylim(min(self.frequency), max(self.frequency))
        plotter.set_xlim(min(self.yoko), max(self.yoko))
        plotter.mpl_axes.xlabel="Yoko (V)"
        plotter.mpl_axes.ylabel="Frequency (Hz)"
        plotter.mpl_axes.title="Magabs fluxmap {}".format(self.name)

    @plots
    def magdBfilt_colormesh(self, plotter):
        plotter.colormesh("magdBfilt_{}".format(self.name), self.yoko, self.frequency, self.MagdBFilt)
        plotter.set_ylim(min(self.frequency), max(self.frequency))
        plotter.set_xlim(min(self.yoko), max(self.yoko))
        plotter.mpl_axes.xlabel="Yoko (V)"
        plotter.mpl_axes.ylabel="Frequency (Hz)"
        plotter.mpl_axes.title="MagdB fluxmap {}".format(self.name)

    @plots
    def magdBfiltbgsub_colormesh(self, plotter):
        plotter.colormesh("magdBfiltbgsub_{}".format(self.name), self.yoko, self.frequency, self.MagdBFiltbgsub)
        plotter.set_ylim(min(self.frequency), max(self.frequency))
        plotter.set_xlim(min(self.yoko), max(self.yoko))
        plotter.mpl_axes.xlabel="Yoko (V)"
        plotter.mpl_axes.ylabel="Frequency (Hz)"
        plotter.mpl_axes.title="MagdB bg sub fluxmap {}".format(self.name)

    def read_data(self):
        with File(self.rd_hdf.file_path, 'r') as f:
            Magvec=f["Traces"]["RS VNA - S21"]
            data=f["Data"]["Data"]
            self.comment=f.attrs["comment"]
            self.yoko=data[:,0,0].astype(float64)
            fstart=f["Traces"]['RS VNA - S21_t0dt'][0][0]
            fstep=f["Traces"]['RS VNA - S21_t0dt'][0][1]
            sm=shape(Magvec)[0]
            sy=shape(data)
            print sy
            s=(sm, sy[0], 1)#sy[2])
            Magcom=Magvec[:,0, :]+1j*Magvec[:,1, :]
            Magcom=reshape(Magcom, s, order="F")
            self.frequency=linspace(fstart, fstart+fstep*(sm-1), sm)
            self.Magcom=squeeze(Magcom)
            self.stop_ind=len(self.yoko)-1

    def full_fano_fit(self):
        log_debug("started fano fitting")
        fit_params=[self.fano_fit(n)  for n in self.indices]
        fit_params=array(zip(*fit_params))
        log_debug("ended fano fitting")
        return fit_params

    @plots
    def plot_widths(self, plotter):
        fit_params=self.full_fano_fit()
        plotter.scatter_plot("widths_{}".format(self.name), fit_params[0, :], absolute(fit_params[1, :]), color="red", label=self.name)

    def fano_fit(self, n):
        pbest= leastsq(self.resid_func, self.p_guess, args=(self.MagAbsFilt_sq[n, :], self.flux_par), full_output=1)
        best_parameters = pbest[0]
        #log_debug(best_parameters)
        #if 0:#n==539 or n==554:#n % 10:
            #b.line_plot("magabs_flux", self.flux_par*1e-9, (self.MagAbsFilt_sq[n, :], label="{}".format(n), linewidth=0.2)
            #b.line_plot("lorentzian", self.flux_par*1e-9, self.fit_func(self.flux_par,best_parameters), label="fit {}".format(n), linewidth=0.5)
        return (self.frequency[n], best_parameters[0], best_parameters[1], best_parameters[2], best_parameters[3])
Esempio n. 9
0
class Lyzer(TA88_Fund):
    rd_hdf = Typed(TA88_Read)

    comment = Unicode().tag(read_only=True, spec="multiline")

    rt_atten = Float(40)

    rt_gain = Float(23 * 2)

    frequency = Array().tag(unit="GHz", plot=True, label="Frequency")
    yoko = Array().tag(unit="V", plot=True, label="Yoko")
    Magcom = Array().tag(private=True)
    pwr = Array()

    probe_frq = Float().tag(unit="GHz",
                            label="Probe frequency",
                            read_only=True)
    probe_pwr = Float().tag(label="Probe power",
                            read_only=True,
                            display_unit="dBm/mW")

    powind = Int(1)

    @tag_Property(display_unit="dB", plot=True)
    def MagdB(self):
        return self.Magcom[:, self.powind, :] / dB

    @tag_Property(plot=True)
    def Phase(self):
        return angle(
            self.Magcom[:, self.powind, :] -
            mean(self.Magcom[:, self.powind, 297:303], axis=1, keepdims=True))

    @tag_Property(plot=True)
    def MagAbs(self):
        #return absolute(self.Magcom[:, :])
        return absolute(
            self.Magcom[:, self.powind, :] -
            mean(self.Magcom[:, self.powind, 0:1], axis=1, keepdims=True))

    def _default_rd_hdf(self):
        return TA88_Read(main_file="Data_0221/S4A4_TA88_pwrswp.hdf5")

    def read_data(self):
        with File(self.rd_hdf.file_path, 'r') as f:
            print f["Traces"].keys()
            self.comment = f.attrs["comment"]
            print f["Instrument config"].keys()
            self.probe_frq = f["Instrument config"][
                'Rohde&Schwarz Network Analyzer - IP: 169.254.107.192, RS VNA at localhost'].attrs[
                    "Start frequency"]
            self.probe_pwr = f["Instrument config"][
                'Rohde&Schwarz Network Analyzer - IP: 169.254.107.192, RS VNA at localhost'].attrs[
                    "Output power"]
            print f["Instrument config"][
                'Rohde&Schwarz Network Analyzer - IP: 169.254.107.192, RS VNA at localhost'].attrs
            #
            print f["Data"]["Channel names"][:]
            Magvec = f["Traces"]["RS VNA - S21"]  #[:]
            data = f["Data"]["Data"]
            print shape(data)
            #
            self.yoko = data[0, 1, :].astype(float64)
            self.pwr = data[:, 0, 0].astype(float64)

            print self.yoko
            fstart = f["Traces"]['RS VNA - S21_t0dt'][0][0]
            fstep = f["Traces"]['RS VNA - S21_t0dt'][0][1]
            print shape(Magvec)
            sm = shape(Magvec)[0]
            sy = shape(data)
            s = (sm, sy[0], sy[2])
            print s
            Magcom = Magvec[:, 0, :] + 1j * Magvec[:, 1, :]
            Magcom = reshape(Magcom, s, order="F")
            self.frequency = linspace(fstart, fstart + fstep * (sm - 1), sm)
            print shape(Magcom)
            self.Magcom = squeeze(Magcom)
Esempio n. 10
0
class Lyzer(TA45_Fund):
    base_name = "lyzer"

    @private_property
    def main_params(self):
        return [
            "comment", "rt_atten", "rt_gain", "probe_frq", "probe_pwr",
            "actual_pwr"
        ]

    rd_hdf = Typed(TA45_Read)

    comment = Unicode().tag(read_only=True, spec="multiline")

    rt_atten = Float(40)

    rt_gain = Float(23 * 2)

    time = Array().tag(plot=True, label="Time")
    yoko = Array().tag(unit="V", plot=True, label="Yoko")
    Magcom = Array().tag(private=True)

    probe_frq = Float().tag(unit="GHz",
                            label="Probe frequency",
                            read_only=True)
    probe_pwr = Float().tag(label="Probe power",
                            read_only=True,
                            display_unit="dBm/mW")

    @tag_Property(display_unit="dBm/mW", label="Power to sample")
    def actual_pwr(self):
        return self.probe_pwr - self.fridge_atten - self.rt_atten

    @tag_Property(display_unit="dB", plot=True)
    def MagdB(self):
        return self.Magcom[:, :] / dB

    @tag_Property(plot=True)
    def Phase(self):
        return angle(self.Magcom[:, :]
                     )  #-mean(self.Magcom[:, 297:303], axis=1, keepdims=True))

    @tag_Property(plot=True)
    def MagAbs(self):
        #return absolute(self.Magcom[:, :])
        return absolute(
            self.Magcom[:, :]
        )  #-mean(self.Magcom[:, 2500:2501], axis=1, keepdims=True))

    def _default_rd_hdf(self):
        return TA45_Read(
            main_file="Data_0305/S1A1_TA45_time_flux_sweep_long.hdf5")

    def read_data(self):
        with File(self.rd_hdf.file_path, 'r') as f:
            #print f["Traces"].keys()
            self.comment = f.attrs["comment"]
            #print f["Instrument config"]["Anritsu 68377C Signal generator - GPIB: 8, Pump3 at localhost"].attrs.keys()
            self.probe_frq = f["Instrument config"][
                "Anritsu 68377C Signal generator - GPIB: 8, Pump3 at localhost"].attrs[
                    "Frequency"]
            self.probe_pwr = f["Instrument config"][
                "Anritsu 68377C Signal generator - GPIB: 8, Pump3 at localhost"].attrs[
                    "Power"]

            #print f["Data"]["Channel names"][:]
            Magvec = f["Traces"]["Digitizer 1 - Trace"]  #[:]
            data = f["Data"]["Data"]
            print shape(data)
            #
            self.yoko = data[:, 0, 0].astype(float64)
            tstart = f["Traces"]['Digitizer 1 - Trace_t0dt'][0][0]
            tstep = f["Traces"]['Digitizer 1 - Trace_t0dt'][0][1]
            #print shape(Magvec)
            sm = shape(Magvec)[0]
            sy = shape(data)
            s = (sm, sy[0], sy[2])
            print s
            Magcom = Magvec[:, 0, :] + 1j * Magvec[:, 1, :]
            Magcom = reshape(Magcom, s, order="F")
            self.time = linspace(tstart, tstart + tstep * (sm - 1), sm)
            #print shape(Magcom)
            Magcom = squeeze(Magcom)
            self.Magcom = Magcom.transpose()
Esempio n. 11
0
class TA88_Dig_Lyzer(TA88_Lyzer):
    frequency = Array().tag(unit="GHz", plot=True, label="Frequency", sub=True)
    yoko = Array().tag(unit="V", plot=True, label="Yoko", sub=True)
    time = Array().tag(unit="s")  #, plot=True, label="Frequency", sub=True)

    MagcomData = Array().tag(sub=True, desc="raw data in compex form")
Esempio n. 12
0
class Lyzer(Agent):
    rd_hdf = Typed(Read_HDF5)  #.tag(private=True)
    #fd=Typed(Fund, ())

    powind = Int(4)
    probe_frq = Float().tag(unit=GHz, label="Probe frequency", read_only=True)
    probe_pwr = Float().tag(label="Probe power",
                            read_only=True,
                            display_unit=dBm_per_mW)
    yoko = Array().tag(unit=V, plot=True, label="Yoko")
    pwr = Array().tag(display_unit=dBm, plot=True)
    Magcom = Array().tag(private=True)
    freq = Array().tag(unit=GHz, plot=True, label="Frequency")
    comment = Unicode().tag(read_only=True, spec="multiline")

    @tag_Property(display_unit=dB, plot=True)
    def MagdB(self):
        return self.Magcom[:, :, self.powind] / dB

    @tag_Property(plot=True)
    def Phase(self):
        return angle(self.Magcom[:, :, self.powind])

    @tag_Property(plot=True)
    def MagAbs(self):
        return absolute(self.Magcom[:, :, self.powind])

    def _observe_powind(self, change):
        if change["type"] == "update":
            reset_properties(self)

    def _default_rd_hdf(self):
        return Read_HDF5(
            file_path=
            "/Users/thomasaref/Dropbox/Current stuff/Logbook/TA210715A46_cooldown1/Data_1008/TA46_refll_fluxpowswp_4p2GHz4pGHz.hdf5"
        )

    def read_data(self):
        with File(self.rd_hdf.file_path, 'r') as f:
            print f["Traces"].keys()
            self.comment = f.attrs["comment"]
            print f["Instrument config"].keys()
            self.probe_frq = f["Instrument config"][
                'Rohde&Schwarz Network Analyzer - IP: 169.254.107.192,  at localhost'].attrs[
                    "Start frequency"]
            self.probe_pwr = f["Instrument config"][
                'Rohde&Schwarz Network Analyzer - IP: 169.254.107.192,  at localhost'].attrs[
                    "Output power"]

            print f["Data"]["Channel names"][:]
            Magvec = f["Traces"]["Rohde&Schwarz Network Analyzer - S12"]  #[:]
            data = f["Data"]["Data"]
            print shape(data)

            self.yoko = data[:, 0, 0].astype(float64)
            self.pwr = data[0, 1, :].astype(float64)
            fstart = f["Traces"]['Rohde&Schwarz Network Analyzer - S12_t0dt'][
                0][0]
            fstep = f["Traces"]['Rohde&Schwarz Network Analyzer - S12_t0dt'][
                0][1]
            print shape(Magvec)
            sm = shape(Magvec)[0]
            sy = shape(data)
            s = (sm, sy[0], sy[2])
            print s
            Magcom = Magvec[:, 0, :] + 1j * Magvec[:, 1, :]
            Magcom = reshape(Magcom, s, order="F")
            self.freq = linspace(fstart, fstart + fstep * (sm - 1), sm)
            print shape(Magcom)
            self.Magcom = squeeze(Magcom)
            #Magabs=Magcom[:, :, :]-mean(Magcom[:, 197:200, :], axis=1, keepdims=True)

            fridge_att = 87.0 + 20.0 + 5.0
Esempio n. 13
0
class TransTimeLyzer(TransLyzer):
    f_ind=Int()
    t_ind=Int()
    t_start_ind=Int(63)
    t_stop_ind=Int(77)

    time=Array().tag( plot=True, label="Time", sub=True)
    probe_pwr=Float().tag(label="Probe power", read_only=True, display_unit="dBm/mW")

    @tag_Property( plot=True, sub=True)
    def MagAbs(self):
        print self.frequency[self.f_ind]
        return absolute(self.Magcom[:, self.f_ind, :].transpose())#-mean(self.Magcom[:, 99:100, self.pind].transpose(), axis=1, keepdims=True))

    #@tag_Property( plot=True, sub=True)
    #def MagAbsTime(self):
    #    return absolute(mean(self.Magcom[self.t_start_ind:self.t_stop_ind, :, :], axis=0).transpose())
    @tag_Property(plot=True, sub=True)
    def MagAbsFilt(self):

        return 10.0**((20.0*log10(absolute(self.MagcomFilt))-self.probe_pwr)/20.0)#/(self.probe_pwr*dBm)

    @tag_Property(plot=True, sub=True)
    def MagcomFilt(self):
        return mean(self.Magcom[self.t_start_ind:self.t_stop_ind, :, :], axis=0)#/(self.probe_pwr*dBm)#.transpose()

    def read_data(self):
        with File(self.rd_hdf.file_path, 'r') as f:
            self.probe_pwr=f["Instrument config"]["Anritsu 68377C Signal generator - GPIB: 8, Pump3 at localhost"].attrs["Power"]

            print f["Traces"].keys()
            self.comment=f.attrs["comment"]
            print f["Data"]["Channel names"][:]
            Magvec=f["Traces"]["TA - LC Trace"]
            #Magvec=f["Traces"]["Digitizer2 - Trace"]#[:]
            data=f["Data"]["Data"]
            print shape(data)
            self.frequency=data[:,0,0].astype(float64)
            self.yoko=data[0,1,:].astype(float64)
            print self.frequency
            tstart=f["Traces"]['TA - Trace_t0dt'][0][0]
            tstep=f["Traces"]['TA - Trace_t0dt'][0][1]
            print shape(Magvec)
            sm=shape(Magvec)[0]
            sy=shape(data)
            s=(sm, sy[0], sy[2])
            print s
            Magcom=Magvec[:,0,:]+1j*Magvec[:,1,:]
            Magcom=reshape(Magcom, s, order="F")
            self.time=linspace(tstart, tstart+tstep*(sm-1), sm)
            print shape(Magcom)
            Magcom=squeeze(Magcom)
            self.Magcom=Magcom[:]#.transpose()
            print shape(self.Magcom)

    @plots
    def magabs_colormesh(self, plotter=None):
        plotter.colormesh("magabs", self.time*1e6, self.yoko, self.MagAbs)
        plotter.xlabel="Time (us)"
        plotter.ylabel="Magnitude (abs)"
        plotter.title="Reflection vs time"
        plotter.set_ylim(min(self.yoko), max(self.yoko))
        plotter.set_xlim(min(self.time)*1e6, max(self.time)*1e6)
        plotter.xlabel="Yoko (V)"
        plotter.ylabel="Frequency (Hz)"
        plotter.title="Magabs fluxmap {}".format(self.name)

    @plots
    def filt_compare(self, ind, plotter=None):
        #plotter.line_plot("magabs_{}".format(self.name), self.frequency, self.MagAbs[:, ind], label="MagAbs (unfiltered)")
        plotter.line_plot("magabs_{}".format(self.name), self.frequency, self.MagAbsFilt[:, ind], label="MagAbs (time)")
Esempio n. 14
0
class Lyzer(TA88_Fund):
    rd_hdf = Typed(TA88_Read)

    comment = Unicode().tag(read_only=True, spec="multiline")

    rt_atten = Float(20)

    rt_gain = Float(26 * 2)

    pwr = Array().tag(plot=True, label="Time")
    yoko = Array().tag(unit="V", plot=True, label="Yoko")
    Magcom = Array().tag(private=True)

    probe_frq = Float().tag(unit="GHz",
                            label="Probe frequency",
                            read_only=True)
    probe_pwr = Float().tag(label="Probe power",
                            read_only=True,
                            display_unit="dBm/mW")

    @tag_Property(display_unit="dB", plot=True)
    def MagdB(self):
        return self.Magcom[:, :] / dB - self.fridge_gain - self.rt_gain

    @tag_Property(ddisplay_unit="dB", plot=True)
    def ReldB(self):
        return self.MagdB - self.pwr

    @tag_Property(plot=True)
    def RelAbs(self):
        return 10.0**(self.ReldB / 20.0)

    @tag_Property(plot=True)
    def Phase(self):
        return angle(self.Magcom[:, :]
                     )  #-mean(self.Magcom[:, 297:303], axis=1, keepdims=True))

    @tag_Property(plot=True)
    def MagAbs(self):
        #return absolute(self.Magcom[:, :])
        return absolute(self.Magcom[:, :]
                        )  #-mean(self.Magcom[0:1, :], axis=0, keepdims=True))

    def _default_rd_hdf(self):
        return TA88_Read(main_file="Data_0224/S1A4_TA88_dig_trans_sat.hdf5")

    def read_data(self):
        with File(self.rd_hdf.file_path, 'r') as f:
            print f.keys()
            print f["Data"].keys()
            #I=f["Data"][:] #["('Digitizer 1 - AvgTrace', 'Real')"]
            #Q=f["Data"][('Digitizer 1 - AvgTrace', 'Imaginary')]
            self.comment = f.attrs["comment"]
            print f["Instrument config"].keys()
            self.probe_frq = f["Instrument config"][
                'Rohde&Schwarz Network Analyzer - IP: 169.254.107.192, RS VNA at localhost'].attrs[
                    "Start frequency"]
            self.probe_pwr = f["Instrument config"][
                'Rohde&Schwarz Network Analyzer - IP: 169.254.107.192, RS VNA at localhost'].attrs[
                    "Output power"]
            print f["Instrument config"][
                'Rohde&Schwarz Network Analyzer - IP: 169.254.107.192, RS VNA at localhost'].attrs.keys(
                )
            #
            print f["Data"]["Channel names"][:]
            #Magvec=f["Traces"]["Digitizer 1 - Trace"]#[:]
            data = f["Data"]["Data"]
            print shape(data)
            #
            self.yoko = data[0, 1, :].astype(float64)
            pwr = data[:, 0,
                       0].astype(float64) - self.fridge_atten - self.rt_atten
            self.pwr = pwr[:, newaxis]
            I = data[:, 2, :]
            Q = data[:, 3, :]
            self.Magcom = I + 1j * Q
Esempio n. 15
0
class Lyzer(GaAs_Fund):
    rd_hdf = Typed(GaAs_Read)

    comment = Unicode().tag(read_only=True, spec="multiline")

    rt_atten = Float(60)

    rt_gain = Float(23 * 2)

    frequency = Array().tag(unit="GHz", plot=True, label="Frequency")
    yoko = Array().tag(unit="V", plot=True, label="Yoko")
    Magcom = Array().tag(private=True)
    Magcom2 = Array().tag(private=True)

    probe_frq = Float().tag(unit="GHz",
                            label="Probe frequency",
                            read_only=True)
    probe_pwr = Float().tag(label="Probe power",
                            read_only=True,
                            display_unit="dBm/mW")

    @tag_Property(display_unit="dB", plot=True)
    def MagdB(self):
        return self.Magcom[:, :] / dB

    @tag_Property(plot=True)
    def Phase(self):
        return absolute(self.Magcom2)
        return angle(self.Magcom
                     )  #-mean(self.Magcom[:, 297:303], axis=1, keepdims=True))

    @tag_Property(plot=True)
    def MagAbs(self):
        #return absolute(self.Magcom[:, :])
        return absolute(
            self.Magcom)  #-mean(self.Magcom[:, 0:1], axis=1, keepdims=True))

    def _default_rd_hdf(self):
        return GaAs_Read(main_file="S11_close_flux/meas.h5")

    def read_data(self):
        S11_offset = -31.2
        with File(self.rd_hdf.file_path, 'r') as f:
            print f.keys()
            print f["mag"].keys()
            self.frequency = f["mag"]["Frequency"][:]

            self.yoko = f["mag"]["Yoko voltage"][:]
            Magvec = f["mag"]["Mag"][:]
            phase = f["phase"]["Phase"][:]
            zfm_phase = phase * pi / 180
            zfm_S11_dB = Magvec - S11_offset
            zfm_S11_amp = 10.0**(zfm_S11_dB / 20.0)
            zfm_S11_complex = zfm_S11_amp * exp(1.0j * zfm_phase)
            self.Magcom = zfm_S11_complex
            self.Magcom2 = zfm_S11_complex[:]
            self.comment = f.attrs["comment"]
        with File(
                self.rd_hdf.folder.dir_path + self.rd_hdf.folder.divider +
                "referencequbitoffres.h5", "r") as f:
            Magoff = f["mag"]["Mag"][:]
            phase_off = f["phase"]["Phase"][:]
            zfm_detuned_phase = phase_off * pi / 180
            zfm_detuned_S11_dB = Magoff - S11_offset
            zfm_detuned_S11_amp = 10.0**(zfm_detuned_S11_dB / 20.0)
            zfm_detuned_S11_complex = mean(zfm_detuned_S11_amp *
                                           exp(1.0j * zfm_detuned_phase),
                                           axis=1)
            #self.Magcom=zfm_detuned_S11_complex
            self.Magcom = self.Magcom - tile(zfm_detuned_S11_complex,
                                             (len(self.yoko), 1)).transpose()
            bg = (mean(self.Magcom2[:, 0:1], axis=1, keepdims=True) +
                  mean(self.Magcom2[:, 239:240], axis=1, keepdims=True)) / 2.0
            self.Magcom2 = self.Magcom2 - bg  #mean(self.Magcom[:, 0:1], axis=1, keepdims=True)
Esempio n. 16
0
class AgilentNetworkAnalyzer(COM_Instrument):
    base_name = "E8354B"

    @private_property
    def S_names(self):
        return ('S11', 'S21', 'S12', 'S22')

    @private_property
    def main_params(self):
        return [
            "doS11", "doS21", "doS12", "doS22", "trigger_mode", "VNA_abort",
            "start_freq", "stop_freq", "points", "averaging", "averages",
            'timeout', "power", 'clear_average', 'acquire_data', 'error_query'
        ]

    #::inst0::INSTR"
    #enable SICL in system settings
    #"TCPIP::129.16.115.134::5025::SOCKET"
    address = Unicode("TCPIP::129.16.115.134").tag(sub=True, no_spacer=True)
    simulate = Bool(False).tag(sub=True)
    VNA = Value().tag(private=True,
                      desc="a link to the session of the instrument.")
    ch1 = Value().tag(private=True, desc="link to main instrument channel")
    measS11 = Value().tag(private=True, desc="link to measurement S11")
    measS12 = Value().tag(private=True, desc="link to measurement S12")
    measS21 = Value().tag(private=True, desc="link to measurement S21")
    measS22 = Value().tag(private=True, desc="link to measurements S22")

    trace_plot = Typed(Plotter).tag(private=True)

    def update_trace_plot(self):
        self.trace_plot.plot_dict["trace_mag S21"].clt.set_xdata(self.freq)
        S21dB = absolute(self.S21)  #20.0*log10(absolute(self.S21))
        print shape(self.freq)
        print shape(S21dB)
        if self.simulate:
            S21dB = absolute(self.S21)
        self.trace_plot.plot_dict["trace_mag S21"].clt.set_ydata(S21dB)
        if min(self.freq) != max(self.freq):
            self.trace_plot.set_xlim(min(self.freq), max(self.freq))
        if min(S21dB) != max(S21dB):
            self.trace_plot.set_ylim(min(S21dB), max(S21dB))
        self.trace_plot.draw()

    def _default_trace_plot(self):
        tp = Plotter(name=self.name + ' trace plot')
        print self.freq
        print absolute(self.S21)
        print shape(self.freq)
        print shape(self.S21)
        tp.line_plot('trace_mag S21', self.freq,
                     absolute(self.S21))  #S20.0*log10(absolute(self.S21)))
        return tp

    doS11 = Bool(False)
    doS21 = Bool(False)
    doS12 = Bool(False)
    doS22 = Bool(False)
    do_freq = Bool(False)
    timeout = Int(10000)

    #clear_average=Bool(True).tag(sub=True)

    @observe("doS11", "doS21", "doS21", "doS22")
    def observe_doSs(self, change):
        log_debug(change)
        if change['type'] == 'update':
            Sname = change["name"][2:]
            if change.get("oldvalue", False):
                log_debug('del old meas')
                log_debug(getattr(self, 'meas' + Sname).Delete())
                self.error_query()
            elif change["value"]:
                ReceiverPort = int(Sname[1])
                SourcePort = int(Sname[2])
                log_debug(ReceiverPort, SourcePort)
                if Sname not in self.query_measurements().values():
                    self.writer("CALC:PAR:DEF:EXT MEAS{0},{0}".format(Sname))
                log_debug(
                    getattr(self,
                            'meas' + Sname).Create(ReceiverPort, SourcePort))
                self.error_query()
                print self.query_measurements()
                sleep(1)
                getattr(self, 'meas' + Sname).Format = 0
        #self.error_query()

    def query_measurements(self):
        sAll = self.asker("CALC:PAR:CAT:EXT?")[1:-1]
        if self.simulate:
            sAll = 'NO CATALOG'
        if sAll == 'NO CATALOG':
            return {}
        t = sAll.split(",")
        return {t[i]: t[i + 1] for i in range(0, len(t), 2)}

    @reader
    def reader(self):
        """calls VNA ReadString"""
        return self.VNA.System2.ReadString()

    @writer
    def writer(self, VNA_string):
        """calls VNA WriteString using string formatting by kwargs"""
        self.VNA.System2.WriteString(VNA_string)

    @asker
    def asker(self, VNA_string):
        """calls VNA WriteString followed by VNA ReadString"""
        self.writer(VNA_string)
        return self.reader()

    @tag_Callable(do=True)
    def VNA_abort(self):
        self.VNA.Channels.Abort()
        self.writer("CALC:PAR:DEL:ALL")
        self.VNA.Status.Clear()

        #self.ch1.TriggerMode=TriggerModeDict['Hold']

    @booter
    def booter(self, address):
        self.VNA = CreateObject("AgilentNA.AgilentNA")
        init_list = [
            'Simulate={0}'.format(self.simulate),
            #'QueryInstrStatus=true'
        ]
        init_str = ','.join(init_list)
        print init_str
        log_debug(self.VNA.Initialize(self.address, False, False, init_str))
        self.ch1 = self.VNA.Channels["Channel1"]
        if not self.simulate:
            print self.VNA.System2.IO.IO.LockRsrc()

        if get_tag(self, 'abort', 'do', False):
            self.VNA_abort()
        #self.VNA_write("CALC:PAR:DEL:ALL")
        self.error_query()
        #log_debug(self.VNA.System2.WaitForOperationComplete(self.timeout))
        #self.error_query()
        self.measS11 = self.ch1.Measurements["Measurement1"]
        self.measS21 = self.ch1.Measurements["Measurement2"]
        self.measS12 = self.ch1.Measurements["Measurement3"]
        self.measS22 = self.ch1.Measurements["Measurement4"]
        if self.simulate:
            self.stop_freq = 4.0e9
        #sleep(1)
        #self.measS11.Create(1, 1)
        #self.error_query()
        #sleep(1)
        #self.measS11.Delete()
        #self.synchronize()
        self.error_query()

    def synchronize(self):
        self.receive('points')

    @tag_Callable()
    def error_query(self):
        for n in range(11):
            err_query = self.VNA.Utility.ErrorQuery()
            log_debug(err_query, n=3)
            if err_query[0] == 0:
                break

    def clear_all_traces(self):
        self.VNA.System2.WriteString("CALC:PAR:DEL:ALL")

#    def close_measurement(self, key):
#        try:
#            self.meas_dict[key].Delete()
#        except COMError as e:
#            log_debug(e)
#
#    def close_all_measurements(self):
#        for key in self.meas_dict:
#            self.close_measurement(key)

    @closer
    def closer(self):
        for key in self.S_names:
            if getattr(self, 'do' + key):
                getattr(self, 'meas' + key).Delete()
        #self.VNA_abort()
        if not self.simulate:
            print self.VNA.System2.IO.IO.UnlockRsrc()
        log_debug(self.VNA.Close())
        for n in self.loop(10):
            if self.VNA.Release() == 0:
                break

    #VNA.Channels["Channel1"].StimulusRange.Span
    #VNA.Channels["Channel1"].StimulusRange.Center
    #VNA.System2.WriteString(":OUTP 0")

    @tag_Callable()
    def clear_average(self):
        self.ch1.ClearAverage()


#    def acq2(self):
#        log_debug('acq2 started')
#        self.ch1.TriggerMode=1
#        self.ch1.ClearAverage()
#        for n in range(self.averages):
#            self.ch1.TriggerSweep(1000)
#            self.VNA.System2.WaitForOperationComplete(10000)
#        log_debug('acq2 stopped')
#
#    def acq(self):
#        log_debug('acq started')
#        self.VNA_write("SENSE:SWE:GRO:COUN {}".format(self.averages))
#
#        self.ch1.ClearAverage()
#        self.VNA.System2.WriteString("SENSE:SWE:MODE GROUPS")
#        getattr(self, 'meas'+'S21').Trace.AutoScale()
#        try:
#            log_debug(self.VNA.System2.WaitForOperationComplete(30000))
#            #print self.error_query()
#        except Exception as e:
#            raise Exception(str(e))
#        log_debug('acq stopped')

    @tag_Callable()
    def acquire_data(self):
        self.send(trigger_mode='Hold')
        #if get_tag(self, "clear_average", "do"):
        self.clear_average()
        if self.averaging:
            numTriggers = self.averages
        else:
            numTriggers = 1
        for n in self.loop(numTriggers):
            self.ch1.TriggerSweep(1000)
            self.VNA.System2.WaitForOperationComplete(self.timeout)

            if n == 9:
                for key in self.S_names:
                    if getattr(self, "do" + key):
                        getattr(self, 'meas' + key).Trace.AutoScale()

        for key in self.S_names:
            if getattr(self, "do" + key):
                data = array(getattr(self, 'meas' + key).FetchComplex())
                setattr(self, key, data[0] + 1.0j * data[1])
                #log_debug(getattr(self, key))
                if self.do_freq:
                    self.freq = getattr(self, 'meas' + key).FetchX()
        if not self.do_freq:
            self.freq = linspace(self.start_freq, self.stop_freq, self.points)
        self.update_trace_plot()
        #print list(frq)==list(self.freq)

    start_freq = Float(4.0e9).tag(high=50.0e9,
                                  low=10.0e6,
                                  label='VNA start frequency',
                                  unit2='GHz',
                                  aka="self.ch1.StimulusRange.Start",
                                  show_value=True)

    stop_freq = Float(5.0e9).tag(low=10.0e6,
                                 high=50.0e9,
                                 label='VNA stop frequency',
                                 unit2='GHz',
                                 aka="self.ch1.StimulusRange.Stop",
                                 show_value=True)

    points = Int(1601).tag(low=1, high=20001, aka="self.ch1.Points")
    averages = Int(1).tag(low=1, high=50000, aka="self.ch1.AveragingFactor")
    averaging = Bool(True).tag(aka="self.ch1.Averaging")
    power = Float(-27.0).tag(low=-27.0,
                             high=0.0,
                             display_unit='dBm',
                             aka="self.ch1.SourcePower.Level[1]")
    #electrical_delay = Float(0).tag(label='VNA electrical delay', unit = 's',
    #                                GPIB_writes=":CALCulate1:CORRection:EDELay:TIME {electrical_delay}")
    #subtract_background = Bool(False)
    #measurement_type = Enum('S11', 'S12', 'S21', 'S22')
    #start = Button()
    #adjust_electrical_delay = Button()
    #acquire_background = Button()
    freq = Array().tag(label='Frequency', sub=True)
    S11 = Array().tag(sub=True)
    S12 = Array().tag(sub=True)
    S21 = Array().tag(sub=True)
    S22 = Array().tag(sub=True)

    trigger_mode = Enum('Continuous', 'Hold').tag(mapping=TriggerModeDict,
                                                  aka="self.ch1.TriggerMode")
Esempio n. 17
0
class Plotter(SubAgent):
    base_name = "plot"
    plt_colors = mycolors  #['auto', 'blue', 'red', 'green', 'purple',  'black', 'darkgray', 'cyan', 'magenta', 'orange']

    title = Unicode()

    alldata = Array()

    xdist = Float().tag(read_only=True)
    ydist = Float().tag(read_only=True)
    xcoord = Float()
    ycoord = Float()
    xind = Int()
    yind = Int()

    show_cs = Bool(False)
    drawline = Bool(False)
    xstart = Float()
    ystart = Float()

    @tag_Property()
    def total_dist(self):
        return sqrt(self.xdist**2 + self.ydist**2)

    @observe("xdist", "ydist")
    def xydist_calc(self, change):
        if change["type"] == "update":
            self.get_member("total_dist").reset(self)

    def activated(self):
        pass
        #self.fig.canvas.mpl_connect('motion_notify_event', mpl_drag_event(self))
        #self.fig.canvas.mpl_connect('motion_notify_event', mpl_click_event(self, arange(200), arange(200))) #button_press_event

        #self.fig.canvas.mpl_connect('button_press_event', mpl_click_event(self))
        #self.fig.canvas.mpl_connect('scroll_event', mpl_scroll_event(self))

    xyfs = Typed(OrderedDict)

    def _default_xyfs(self):
        xyfs = OrderedDict()
        xyfs["All"] = AllXYFormat(plotter=self, name="All")
        return xyfs

    @private_property
    def xyfs_keys(self):
        return self.xyfs.keys()

    @private_property
    def xyfs_items(self):
        return self.xyfs.values()

    fig = Typed(Figure).tag(private=True)
    axe = Typed(Axes).tag(private=True)

    plot_type_list = [
        "Line plot", "Scatter plot", "Colormap", "Polygon", "Text"
    ]

    @private_property
    def plot_type_map(self):
        return {
            "Line plot": self.line_plot,
            "Scatter plot": self.scatter_plot,
            "Colormap": self.colormap,
            "Polygon": self.poly_plot,
            "Text": self.add_text
        }

    def set_data(self, zname=None, zdata=None, zcolor=None, plot_type="poly"):
        if zdata != None:
            if plot_type is "poly":
                if zname not in self.clts:  #plottables['plotted']:#self.pd.list_data():
                    clt = PolyCollection(
                        [], alpha=0.5, antialiased=True
                    )  #, rasterized=False, antialiased=False)
                    if zcolor is not None:
                        clt.set_color(colorConverter.to_rgba(zcolor))
                    self.clts[zname] = clt
                    self.axe.add_collection(self.clts[zname])
                self.clts[zname].set_verts(zdata)

            elif plot_type is "line":
                if zname not in self.clts:
                    clt = LineCollection(
                        zdata)  #, linewidths=(0.5, 1, 1.5, 2),
                    #linestyles='solid', colors=("red", "blue", "green"))
                    if zcolor is not None:
                        clt.set_color(zcolor)
                    else:
                        clt.set_array(arange(len(zdata)))
                else:
                    self.clts[zname].set_verts(zdata)
                    #self.set_xlim(x.min(), x.max())
                    #self.set_ylim(ys.min(), ys.max())

            elif plot_type is "scatter":
                self.axe.scatter(zdata, zdata)
            elif plot_type is "colormap":
                self.axe.pcolormesh(x, y, z)

        if 0:
            x = arange(3)
            ys = array([x + i for i in arange(5)])
            #xdata=arange(len(getattr(self, zname)))

            data = [list(zip(x, y)) for y in ys]
            line_segments = LineCollection(data,
                                           linewidths=1,
                                           linestyles='solid',
                                           colors=mycolors)
            print data
            print len(data)
            #print line_segments.properties()
            #print line_segments.set_hatch("O")
            #print dir(self.axe)

            print[p.vertices for p in line_segments.get_paths()]  #)
            print line_segments.get_segments()
            line_segments.set_array(arange(len(data)))

            x = arange(3)
            ys = array([x + i for i in arange(2)])
            #xdata=arange(len(getattr(self, zname)))

            data = [list(zip(x, y)) for y in ys]

            line_segments.set_verts(data)
            #self.axe.add_collection(line_segments, autolim=True)

            clt = self.axe.scatter(x, x)
            #clt.set_linestyle("solid")
            print dir(clt)
            print clt.get_paths()
        if 0:
            #clt=QuadMesh(0, 0, [1])

            n = 12
            x = linspace(-1.5, 1.5, n)
            y = linspace(-1.5, 1.5, n * 2)
            X, Y = meshgrid(x, y)
            print X
            Qx = cos(Y) - cos(X)
            Qz = sin(Y) + sin(X)
            Qx = (Qx + 1.1)
            Z = sqrt(X**2 + Y**2) / 5
            Z = (Z - Z.min()) / (Z.max() - Z.min())
            Zm = ma.masked_where(fabs(Qz) < 0.5 * amax(Qz), Z)

            #ax = fig.add_subplot(121)
            #self.axe.set_axis_bgcolor("#bdb76b")
            clt = self.axe.pcolormesh(Z)
            #print dir(clt)
            self.axe.set_title('Without masked values')

            #ax = fig.add_subplot(122)
            #ax.set_axis_bgcolor("#bdb76b")
            #  You can control the color of the masked region:
            #cmap = cm.jet
            #cmap.set_bad('r', 1.0)
            #ax.pcolormesh(Qx,Qz,Zm, cmap=cmap)
            #  Or use the default, which is transparent:
            #col = self.axe.pcolormesh(Qx, Qz, Zm, shading='gouraud')
            #ax.set_title('With masked values')


#    def get_data(self, zname, index=None, axis=0):
#        data=[c.to_polygons() for c in self.clt.get_paths()]
#        if index==None:
#            return data
#        if axis==0:
#            return atleast_2d(data)[index, :]
#        return atleast_2d(data)[:, index]
#
#    def add_img_plot(self, zname, zdata, xname=None, xdata=None, yname=None,  ydata=None):
#         self.add_data(zname=zname, zdata=zdata, xname=xname, xdata=xdata, yname=yname, ydata=ydata, overwrite=True, concat=False)
#         print self.pd.get_data(zname)
#         xyf=XYFormat(plotter=self)
#         xyf.draw_img_plot(name='img_plot', zname=zname, xname=xname, yname=yname)
#         self.xyfs.update(**{xyf.name: xyf})
#         self.overall_plot_type="img plot"
#
#    def add_line_plot(self, name, zname, zdata, xname='', xdata=None):
#        #self.add_data(zname=zname, zdata=zdata, xname=xname, xdata=xdata, overwrite=True)
#        self.set_data(zname, zdata)
#        self.set_data(xname, xdata)
#        xyf=XYFormat(plotter=self)
#        zdata=self.get_data(zname)
#        #if 1: #zdata.ndim>1:
#        #    for i, arr in enumerate(self.splitMultiD(zdata, 0)):
#        #        self.add_line_plot(name+str(i), zname+str(i), squeeze(arr), xname, xdata )
#        #else:
#            #self.set_data(zname, zdata)
#            #if xname!=None and xdata!=None:
#            #    self.set_data(xname, xdata, coord='x')
#        xyf.draw_plot(name=name, zname=zname, xname=xname)
#        self.xyfs.update(**{xyf.name: xyf})
#        self.overall_plot_type="XY plot"
#
#    def splitMultiD(self, arr, axis=0):
#        if arr.ndim<2:
#            return atleast_2d(arr)
#        else:
#            return split(arr, arr.shape[axis], axis=axis)
#
#    def gatherMultiD(self, name, arrs, appen=None, concat=True, overwrite=False):
#         if not isinstance(arrs, tuple):
#             arrs=(arrs,)
#         if appen==None:
#             if shape(arrs)==(1,):
#                 appen=True
#             else:
#                 appen=False
#         orig=self.get_data(name)
#         if orig!=None and not overwrite:
#             arrs=(orig,)+arrs
#         if appen:
#             axis=1
#         else:
#             axis=0
#         print arrs[0]==atleast_2d(*arrs)
#         #if ndim(arrs[0])>1:
#         #    concat=False
#
#         if concat:
#             data=concatenate(atleast_2d(*arrs), axis)
#         self.set_data(name, data)
#
#    def add_data(self, zname, zdata, xname=None, xdata=None, yname=None, ydata=None, appen=None, concat=True, overwrite=False):
#         if xname!=None:
#             self.gatherMultiD(xname, xdata, appen=appen, overwrite=overwrite, concat=concat)
#         if yname!=None:
#             self.gatherMultiD(yname, ydata, appen=appen, overwrite=overwrite, concat=concat)
#         self.gatherMultiD(zname, zdata, appen=appen, overwrite=overwrite, concat=concat)

    @private_property
    def view_window(self):
        with imports():
            from taref.core.plotter_e import PlotMain
        return PlotMain(plotr=self)
Esempio n. 18
0
class Lyzer(TA88_Fund):
    rd_hdf = Typed(TA88_Read)
    rt_atten = Float(40)
    rt_gain = Float(23 * 2)
    comment = Unicode().tag(read_only=True, spec="multiline")
    frequency = Array().tag(unit="GHz", plot=True, label="Frequency")
    yoko = Array().tag(unit="V", plot=True, label="Yoko")
    Magcom = Array()  #.tag()
    offset = Float(-0.035)
    flux_factor = Float(0.2925)
    on_res_ind = Int()
    start_ind = Int()
    stop_ind = Int()
    filt_ind = Int(52)

    fit_type = Enum("Transmission", "Reflection")

    @tag_Property()
    def indices(self):
        return [
            range(81, 120 + 1),
            range(137, 260 + 1),
            range(269, 320 + 1),
            range(411, 449 + 1)
        ]  #, [490]]#, [186]]

    @tag_Property(plot=True)
    def flux_par(self):
        flux_over_flux0 = qdt.call_func("flux_over_flux0",
                                        voltage=self.yoko,
                                        offset=self.offset,
                                        flux_factor=self.flux_factor)
        Ej = qdt.call_func("Ej", flux_over_flux0=flux_over_flux0)
        return qdt._get_fq(Ej, qdt.Ec)

    @tag_Property(plot=True)
    def p_guess(self):
        return [200e6, 4.5e9, 0.002, 0.022, 0.1]

    def full_fano_fit(self):
        p = [200e6, 4.5e9, 0.002, 0.022, 0.1]
        fit_func, resid_func = fano_dict[self.fit_type]
        var = self.MagAbsFilt**2
        flux_par = self.flux_par
        freqs = self.frequency
        log_debug("started fano fitting")
        fit_params = [
            self.fano_fit(n, var, flux_par, freqs, resid_func, p)
            for n in range(len(self.frequency))
        ]
        fit_params = array(zip(*fit_params))
        log_debug("ended fano fitting")
        return fit_params

    def plot_widths(self, plotter):
        fit_params = self.full_fano_fit()
        #print shape(zip(*fit_params))
        plotter.scatter_plot("widths_{}".format(self.name),
                             fit_params[0, :],
                             absolute(fit_params[1, :]),
                             color="red",
                             label="-130 dBm")

    def fano_fit(self, n, var, flux_par, frq, resid_func, p):
        pbest = leastsq(resid_func,
                        p,
                        args=(var[n, :], flux_par),
                        full_output=1)
        best_parameters = pbest[0]
        #log_debug(best_parameters)
        if 0:  #n==539 or n==554:#n % 10:
            b.line_plot("magabs_flux",
                        flux_par * 1e-9, (magabs[n, :] - best_parameters[3]) /
                        best_parameters[2],
                        label="{}".format(n),
                        linewidth=0.2)
            b.line_plot("lorentzian",
                        flux_par * 1e-9,
                        fano(flux_par, best_parameters),
                        label="fit {}".format(n),
                        linewidth=0.5)
        return (frq[n], best_parameters[0], best_parameters[1] - frq[n],
                best_parameters[2], best_parameters[3])

    @tag_Property(plot=True)
    def MagAbs(self):
        return absolute(self.Magcom[:, :])

    @tag_Property(plot=True)
    def MagAbsFilt(self):
        return absolute(self.MagcomFilt[:, :])

    @tag_Property(plot=True)
    def MagAbsFilt_sq(self):
        return self.MagAbsFilt**2

    @tag_Property(plot=True)
    def MagcomFilt(self):
        #return array([self.ifft_peak(n) for n in range(len(self.yoko))])
        return array([self.fft_filter(n)
                      for n in range(len(self.yoko))]).transpose()

    def ifft_peak(self, n):
        ind = ind_dict[self.fit_type]
        return fft.ifft(self.Magcom[:, n])[ind]

    def fft_filter(self, n):
        #return self.Magcom[:, n]
        myifft = fft.ifft(self.Magcom[:, n])
        myifft[self.filt_ind:-self.filt_ind] = 0.0
        myifft[:5] = 0.0
        myifft[-5:] = 0.0
        return fft.fft(myifft)

    def magabs_colormesh(self, plotter=None):
        if plotter is None:
            plotter = self.plotter
        plotter.colormesh("magabs_{}".format(self.name), self.yoko,
                          self.frequency, self.MagAbs)
        plotter.set_ylim(min(self.frequency), max(self.frequency))
        plotter.set_xlim(min(self.yoko), max(self.yoko))
        plotter.xlabel = "Yoko (V)"
        plotter.ylabel = "Frequency (Hz)"
        plotter.title = "Magabs fluxmap {}".format(self.name)

    def ifft_plot(self, plotter=None):
        if plotter is None:
            plotter = self.plotter
        plotter.line_plot("ifft_{}".format(self.name),
                          absolute(fft.ifft(self.Magcom[:, self.on_res_ind])))
        plotter.line_plot("ifft_{}".format(self.name),
                          absolute(fft.ifft(self.Magcom[:, self.start_ind])))
        plotter.line_plot("ifft_{}".format(self.name),
                          absolute(fft.ifft(self.Magcom[:, self.stop_ind])))

    def filt_compare(self, ind, plotter=None):
        if plotter is None:
            plotter = self.plotter
        plotter.line_plot("magabs_{}".format(self.name), self.frequency,
                          self.MagAbs[:, ind])
        plotter.line_plot("magabs_{}".format(self.name), self.frequency,
                          self.MagAbsFilt[:, ind])

    def magabsfilt_colormesh(self, plotter=None):
        if plotter is None:
            plotter = self.plotter
        plotter.colormesh("magabsfilt_{}".format(self.name), self.yoko,
                          self.frequency, self.MagAbsFilt)
        plotter.set_ylim(min(self.frequency), max(self.frequency))
        plotter.set_xlim(min(self.yoko), max(self.yoko))
        plotter.xlabel = "Yoko (V)"
        plotter.ylabel = "Frequency (Hz)"
        plotter.title = "Magabs fluxmap {}".format(self.name)

    def _default_main_params(self):
        return [
            "rt_atten", "fridge_atten", "fridge_gain", "rt_gain", "comment",
            "flux_factor", "offset", "fit_type"
        ]

    def read_data(self):
        with File(self.rd_hdf.file_path, 'r') as f:
            Magvec = f["Traces"]["RS VNA - S21"]
            data = f["Data"]["Data"]
            self.comment = f.attrs["comment"]
            self.yoko = data[:, 0, 0].astype(float64)
            fstart = f["Traces"]['RS VNA - S21_t0dt'][0][0]
            fstep = f["Traces"]['RS VNA - S21_t0dt'][0][1]
            sm = shape(Magvec)[0]
            sy = shape(data)
            print sy
            s = (sm, sy[0], 1)  #sy[2])
            Magcom = Magvec[:, 0, :] + 1j * Magvec[:, 1, :]
            Magcom = reshape(Magcom, s, order="F")
            self.frequency = linspace(fstart, fstart + fstep * (sm - 1), sm)
            self.Magcom = squeeze(Magcom)
            self.stop_ind = len(self.yoko) - 1
Esempio n. 19
0
class ColormeshFormat(PlotFormat):
    clt = Typed(QuadMesh)
    zdata = Array()
    expand_XY = Bool(False).tag(
        desc="expands X and Y array by one so all zdata is plotted")

    include_colorbar = Bool(False)
    cmap = Enum(*colormap_names).tag(former="cmap")

    @plot_observe("cmap")
    def colormap_update(self, change):
        self.plot_set(change["name"])
        self.set_colorbar()

    @plot_observe("plotter.selected")
    def colorbar_update(self, change):
        if self.plotter.selected == self.plot_name:
            self.set_colorbar()

    def get_colorbar(self):
        if self.include_colorbar:
            if self.plotter.colorbar is None:
                self.plotter.colorbar = self.plotter.figure.colorbar(self.clt)
        return self.plotter.colorbar

    def set_colorbar(self):
        if self.include_colorbar:
            self.get_colorbar().update_bruteforce(self.clt)

    def set_clim(self, vmin, vmax):
        self.vmin = float(vmin)
        self.vmax = float(vmax)
        self.clt.set_clim(vmin, vmax)
        self.set_colorbar()

    @plot_observe("vmin", "vmax")
    def clim_update(self, change):
        self.set_clim(self.vmin, self.vmax)

    vmin = Float()
    vmax = Float()

    def _default_plot_type(self):
        return "colormap"

    h_line = Typed(Line2D)
    v_line = Typed(Line2D)

    cs_alpha = Float(1.0)
    cs_color = Enum(*colors_tuple[1:])
    cs_linewidth = Float(2.0)
    cs_linestyle = Enum('solid', 'dashed', 'dashdot', 'dotted')

    def cs_set(self, param):
        getattr(self.h_line, "set_" + param[3:])(getattr(self, param))
        getattr(self.v_line, "set_" + param[3:])(getattr(self, param))

    @observe("cs_alpha", "cs_linewidth", "cs_linestyle", "cs_color")
    def cs_update(self, change):
        if change["type"] == "update":
            self.cs_set(change["name"])
            if self.plotter.horiz_fig.canvas != None:
                self.plotter.horiz_fig.canvas.draw()
            if self.plotter.vert_fig.canvas != None:
                self.plotter.vert_fig.canvas.draw()

    def do_autolim(self):
        if self.plotter.auto_zlim:
            self.set_clim(nanmin(self.zdata), nanmax(self.zdata))
        else:
            self.set_clim(self.vmin, self.vmax)
        super(ColormeshFormat, self).do_autolim()

    def pcolormesh(self, *args, **kwargs):
        kwargs = process_kwargs(self, kwargs)
        self.remove_collection()
        if len(args) == 1:
            #if isinstance(args[0], tuple):
            #    self.zdata=zeros(args[0])
            #else:
            self.zdata = asanyarray(args[0])
            numRows, numCols = self.zdata.shape
            self.xdata = arange(numCols)
            self.ydata = arange(numRows)
        #elif len(args)==2:
        #    args=args+(zeros((len(self.xdata)-1, len(self.ydata)-1)),)
        #    self.xdata, self.ydata, self.zdata= [asanyarray(a) for a in args]
        elif len(args) == 3:
            self.xdata, self.ydata, self.zdata = [asanyarray(a) for a in args]
            if self.expand_XY:
                self.xdata = linspace(min(self.xdata), max(self.xdata),
                                      len(self.xdata) + 1)
                self.ydata = linspace(min(self.ydata), max(self.ydata),
                                      len(self.ydata) + 1)

        self.clt = self.plotter.axes.pcolormesh(self.xdata, self.ydata,
                                                self.zdata, **kwargs)
        self.do_autolim()
        #if self.plotter.auto_xlim:
        #    self.plotter.set_xlim(min(self.xdata), max(self.xdata))
        #if self.plotter.auto_ylim:
        #    self.plotter.set_ylim(min(self.ydata), max(self.ydata))
        #if self.plotter.auto_xlim:
        #    self.plotter.x_min=float(min((self.plotter.x_min, min(self.xdata))))
        #    self.plotter.x_min=float(max((self.plotter.x_min, max(self.xdata))))

        #self.plotter.set_xlim(min(self.xdata), max(self.xdata))
        #if self.plotter.auto_ylim:
        #    self.plotter.y_min=float(min((self.plotter.y_min, min(self.ydata))))
        #    self.plotter.y_min=float(max((self.plotter.y_min, max(self.ydata))))

    count = Int()

    def append_xy(self, z, index=None, axis=1):
        """appends points x and y if 2 args are passed and just y and len of xdata if one args is passed"""
        if index is None:
            index = self.count
            self.count += 1
        if axis == 1:
            self.zdata[:, index] = z
        else:
            self.zdata[index, :] = z
        self.clt.set_array(self.zdata.ravel())
        self.set_clim(amin(self.zdata), amax(self.zdata))
        #print dir(self.clt)
        #print dir(self.clt.get_axes())
        #print self.clt.get_axes().get_xlim()
        #print help(self.clt.get_axes().update_datalim)
        #print help(self.clt.set_axis)
        #self.clt.set_xdata(self.xdata)
        #self.pcolormesh(self.xdata, self.ydata, self.zdata)
        self.update_plot(update_legend=False)
        #fig=self.clt.get_figure()
        #if fig.canvas is not None:
        #    fig.canvas.draw()

    @transformation
    def colormap2horizlines(self):
        mlf = MultiLineFormat(plot_name=self.plot_name, plotter=self.plotter)
        mlf.multiline_plot([
            zip(self.xdata, self.zdata[n, :])
            for n in range(self.ydata.shape[0])
        ])
        mlf.ydata = self.ydata
        mlf.autocolor_set("color")
        return mlf

    @transformation
    def colormap2vertlines(self):
        mlf = MultiLineFormat(plot_name=self.plot_name, plotter=self.plotter)
        mlf.multiline_plot([
            zip(self.ydata, self.zdata[:, n])
            for n in range(self.xdata.shape[0])
        ])
        mlf.ydata = self.xdata
        mlf.autocolor_set("color")
        return mlf