Exemplo n.º 1
0
 def save_spectrum(self, ret=False):
     spec = andor.get_spectrum()
     specd = qt.Data(name='spectrum')
     specd.add_value('Counts')
     specd.create_file()
     specd.add_data_point(spec)
     specd.close_file()
     qt.plot(specd, name='saved_spectrum', clear=True)
     if ret:
         return spec
Exemplo n.º 2
0
 def save_spectrum(self, ret=False):
     spec = winspec.get_spectrum()
     specd = qt.Data(name='spectrum')
     specd.add_coordinate('Wavelength', units='nm')
     specd.add_value('Counts')
     specd.create_file()
     specd.add_data_point(spec)
     specd.close_file()
     qt.plot(specd, name='saved_spectrum', clear=True)
     if ret:
         return spec
Exemplo n.º 3
0
def example1(f_vec, b_vec):
    '''
    this example is exactly the same as 'basic_measure_script.py'
    but now made into a function. The main advantage is that now
    the parameters f_vec and b_vec can be provided when calling
    the function: "measure_module.example1(vec1, vec2)", instead
    of having to change the script.

    To run the function type in the terminal:

    fv=numpy.arange(0,10,0.01)
    bv=numpy.arange(-5,5,0.1)
    measure_module.example1(fv, bv)
    '''

    qt.mstart()

    data = qt.Data(name='testmeasurement')
    data.add_coordinate('frequency, mw src 1 [Hz]')
    data.add_coordinate('Bfield, ivvi dac 3 [mV]')
    data.add_value('Psw SQUID')
    data.create_file()

    plot2d = qt.Plot2D(data, name='measure2D')
    plot3d = qt.Plot3D(data, name='measure3D', style='image')

    for b in b_vec:
        fake_ivvi_set_dac_3(b)
        for f in f_vec:
            fake_mw_src_set_freq(f)

            result = fake_readout_psw()
            data.add_data_point(f, b, result)

            qt.msleep(0.01)
        data.new_block()

    data.close_file()
    qt.mend()
Exemplo n.º 4
0
    def save_trace(self, filepath=None, plot=True):
        '''
        runs 'get_trace()' and saves the output to a file.

        Input:
            filepath (string):  Path to where the file should be saved.(optional)

        Output:
            filepath (string):  The filepath where the file has been created.
        '''
        #TODO: change value label 'S_ij' to represent actual measurement
        freqs, reply = self.get_trace()
        d = qt.Data(name='netan')
        d.add_coordinate('freq [Hz]')
        d.add_value('S_ij [dB]')
        d.create_file(filepath=filepath)
        d.add_data_point(zip(freqs, reply))
        d.close_file()
        if plot:
            p = qt.plot(d, name='netan', clear=True)
            p.save_png()
            p.save_gp()
        return d.get_filepath()
Exemplo n.º 5
0
import numpy as np
from qtlab.source import qt

x = np.arange(-10, 10, 0.2)
y = np.sinc(x)
yerr = 0.1 * np.random.rand(len(x))

d = qt.Data()
d.add_coordinate('x')
d.add_coordinate('y')
d.add_coordinate('yerr')
d.create_file()
d.add_data_point(x, y, yerr)

p = qt.Plot2D()
p.add_data(d, coorddim=0, valdim=1, yerrdim=2)

# or: ('ok' is style for black circles)
qt.plot(x, y, 'ok', yerr=yerr, name='test2')
Exemplo n.º 6
0
def example3(x_vec=numpy.linspace(0, 10, 10), y_vec=numpy.linspace(0, 10, 50)):
    '''
    To run the function type in the terminal:

    measure_module.example3()
    '''

    qt.mstart()

    data = qt.Data(name='testmeasurement')
    data.add_coordinate('x')
    data.add_coordinate('y')
    data.add_value('z1')
    data.add_value('z2')
    data.add_value('z3')
    data.create_file()

    plot2d_1 = qt.Plot2D(data, name='2D_1', coorddim=1, valdim=2)

    plot2d_2 = qt.Plot2D(data, name='2D_2', coorddim=1, valdim=2, maxtraces=1)

    plot2d_3 = qt.Plot2D(data, name='2D_3', coorddim=1, valdim=2, maxtraces=1)
    plot2d_3.add_data(data, coorddim=1, valdim=3, maxtraces=1)
    plot2d_3.add_data(data, coorddim=1, valdim=4, maxtraces=1)

    plot2d_4 = qt.Plot2D(data, name='2D_4', coorddim=1, valdim=2, mintime=0.3)

    plot2d_5 = qt.Plot2D(data,
                         name='2D_5',
                         coorddim=1,
                         valdim=2,
                         autoupdate=False)

    plot3d_1 = qt.Plot3D(data, name='3D_1', style='image')

    plot3d_2 = qt.Plot3D(data,
                         name='3D_2',
                         style='image',
                         coorddims=(1, 0),
                         valdim=4)

    for x in x_vec:
        for y in y_vec:

            z1 = numpy.sin(x + y)
            z2 = numpy.cos(x + y)
            z3 = numpy.sin(x + 2 * y)

            data.add_data_point(x, y, z1, z2, z3)

            if z1 > 0:
                plot2d_5.update()

            qt.msleep(0.1)
        data.new_block()

    plot2d_1.save_png()
    plot2d_1.save_gp()

    plot3d_2.save_png()
    plot3d_2.save_gp()

    data.close_file()
    qt.mend()
Exemplo n.º 7
0
def example2(f_vec, b_vec):
    '''
    This example introduces three new features:
    1) setting format and/or precision of data in the datafile.
       using 'precision' will keep the default scientific notation,
       'format' can be anything you like
        => add_coordinate(precision=<nr>)
        => add_coordinate(format='<format_string>')
    2) specify specific filepath for the data file (in stead of
       automatic filepath)
        => create_file(filepath=<filepath>)
    3) turn off automatic saving of instrument-settings-file.
        => create_file(settings_file=False)

    To run the function type in the terminal:

    fv=numpy.arange(0,10,0.01)
    bv=numpy.arange(-5,5,0.1)
    measure_module.example2(fv, bv)
    '''

    qt.mstart()

    # this shows how to change format of saved data (per column)
    data = qt.Data(name='testmeasurement')
    data.add_coordinate('frequency, mw src 1 [Hz]', precision=3)
    data.add_coordinate('Bfield, ivvi dac 3 [mV]', format='%.12f')
    data.add_value('Psw SQUID', format='%.3e')
    data.create_file()

    # this shows how to save to a specific path and name, and how
    # to avoid a settings file to be created. The directory is first
    # retreived from the previous data object
    dir = data.get_dir()
    maxfilepath = os.path.join(dir, 'maxvals.dat')

    data_max = qt.Data(name='maxvals')
    data_max.add_coordinate('Bfield, ivvi dac 3 [mV]')
    data_max.add_value('resonance frequency [Hz]')
    data_max.create_file(filepath=maxfilepath, settings_file=False)

    plot2d = qt.Plot2D(data, name='measure2D')
    plot3d = qt.Plot3D(data, name='measure3D', style='image')

    plot2dmax = qt.Plot2D(data_max, name='maxvals')

    for b in b_vec:
        fake_ivvi_set_dac_3(b)

        last_trace = []
        for f in f_vec:
            fake_mw_src_set_freq(f)

            result = fake_readout_psw()
            data.add_data_point(f, b, result)

            last_trace.append(result)

            qt.msleep(0.01)
        data.new_block()

        loc_of_max = numpy.argmax(last_trace)
        freq_at_max = f_vec[loc_of_max]

        data_max.add_data_point(b, freq_at_max)

    data.close_file()
    data_max.close_file()
    qt.mend()