Пример #1
0
def retrieve_data(ip, port, fname, fmat, executor):
    executor.execute_command(":FORM:DATA ASC") # Set data to ASCII

    data = executor.ask(":CALC1:DATA:FDAT?")

    data = data.split(",")
    # Dealing with complex values, convert pairs into complex numbers
    # even when returning reals, the VNA responds with rows of zeros for the imaginary part
    data = [complex(float(pair[0]), float(pair[1])) for pair in chunker(data, 2)] 

    sdata.append(data)

    if len(sdata) == 4: # Everything measured
        
        write_4vectors(sdata, fname+"_vna_s") 
        write_4vectors(z_from_s(sdata), fname+"_vna_z")
        write_4vectors(y_from_s(sdata), fname+"_vna_y") 
        freq_data = executor.ask(":SENS1:FREQ:DATA?")
        freq_data = freq_data.split(",")
        freq_data = [float(i) for i in freq_data]
        write_2vectors([cga_from_s(freq_data, sdata),cgs_from_s(freq_data, sdata)], fname+"_cap")
        with open(fname + "_freqdata.csv", "w+") as f:
            for line in freq_data:
                f.write(str(line)+"\r\n")

        # Clean sdata
        del sdata[0:len(sdata)]
Пример #2
0
def retrieve_vna_data(vna, vna_params):
    sdata = []
    freq_data = []
    template = ":CALC{ch}:DATA:FDAT?"
    for channel in [1,2,3,4]:
        data = vna.executor.ask(template.format(ch=str(channel)))
        data = data.split(',')
        data = [complex(float(pair[0]), float(pair[1])) for pair in chunker(data, 2)]
        sdata.append(data)
    
    template_freq = ":SENS{ch}:FREQ:DATA?"
    freq_data = vna.executor.ask(template_freq.format(ch=1))
    freq_data = freq_data.split(',')
    freq_data = [float(fdatum) for fdatum in freq_data]


    ydata = y_from_s(sdata)
    zdata = z_from_s(sdata)
    cga_data = cga_from_s(freq_data, sdata)
    cgs_data = cgs_from_s(freq_data, sdata)
    capacitance = [cga_data, cgs_data]
    gdata["cap"] = capacitance
    write_vector(freq_data, vna_params["file"] + "_freqs")
    write_4vectors(sdata, vna_params["file"] + "_s")
    write_4vectors(zdata, vna_params["file"] + "_z")
    write_4vectors(ydata, vna_params["file"] + "_y")
    write_2vectors(capacitance, vna_params["file"] + "_cap")
    
    retrieve_both()