Beispiel #1
0
def subniquistMediciones():
    entrada = SignalsReadWrite.readSignalCsv(
        "ExpressInput/Mediciones basicas/med_22.csv", "1")
    signal = SignalsReadWrite.readSignalCsv(
        "ExpressInput/Mediciones basicas/med_22.csv", "2")
    f_entrada = FourierTransform.fourierTransform(entrada)
    f_signal = FourierTransform.fourierTransform(signal)
    fs = 1070

    ExpressPlot.CombinedPlot()\
        .setTitle("Mediciones espectro $f_s=1.07k$")\
        .setXTitle("Frecuencia (Hz)")\
        .setYTitle("Amplitud (% del total)") \
        .extraPlot(
        plotFunction,
        {"fs": fs}) \
        .addSignalPlot(
            signal=f_entrada,
            color="green",
            name="Entrada"
        )\
        .addSignalPlot(
        signal=f_signal,
        color="orange",
        name="Medicion llave analógica")\
        .plotAndSave(
            filename="ExpressOutput/espectro_subniquist1.png"
        )

    plt.show()

    entrada = SignalsReadWrite.readSignalCsv(
        "ExpressInput/Mediciones basicas/med_23.csv", "1")
    signal = SignalsReadWrite.readSignalCsv(
        "ExpressInput/Mediciones basicas/med_23.csv", "2")
    f_entrada = FourierTransform.fourierTransform(entrada)
    f_signal = FourierTransform.fourierTransform(signal)
    fs = 1070

    ExpressPlot.CombinedPlot() \
        .setTitle("Mediciones espectro $f_s=1.07k$") \
        .setXTitle("Frecuencia (Hz)") \
        .setYTitle("Amplitud (% del total)") \
        .extraPlot(
        plotFunction,
        {"fs": fs}) \
        .addSignalPlot(
        signal=f_entrada,
        color="green",
        name="Entrada"
    ) \
        .addSignalPlot(
        signal=f_signal,
        color="orange",
        name="Medicion sample and hold") \
        .plotAndSave(
        filename="ExpressOutput/espectro_subniquist2.png"
    )

    plt.show()
Beispiel #2
0
def SubniquistSpectrum(input, fs, filename):
    config.GetConfigData().setFs(fs)
    config.GetConfigData().setSampleCycle(5)

    inputSpectrum = FourierTransform.fourierTransform(input)

    output = SampleAndHold.getSampleAndHold().processInput(input, None, 1)

    outputSpectrum = FourierTransform.fourierTransform(output)

    ExpressPlot.CombinedPlot()\
        .setTitle("Simulación espectro $f_s="+str(fs/1000)+"k$")\
        .setXTitle("Frecuencia (hz)")\
        .setYTitle("Potencia (% del total)") \
        .extraPlot(
         plotFunction,
         {"fs": fs}) \
        .addSignalPlot(
            signal=inputSpectrum,
            color="green",
            name="Entrada"
        )\
        .addSignalPlot(
            signal=outputSpectrum,
            color="orange",
            name="Salida sample and hold"
        ).plotAndSave(
            filename="ExpressOutput/"+filename
        )
def joaco_spectrum():

    fs = 1000
    #config.GetConfigData().setFs(fs)
    #config.GetConfigData().setSampleCycle(5)

    input = SignalsReadWrite.readSignal()

    inputSpectrum = FourierTransform.fourierTransform(input)

    ExpressPlot.CombinedPlot() \
        .setTitle("Simulación espectro $f_s=" + str(fs / 1000) + "k$") \
        .setXTitle("Frecuencia (hz)") \
        .setYTitle("Potencia (% del total)") \
        .extraPlot(
        plotFunction,
        {"fs": fs}) \
        .addSignalPlot(
        signal=inputSpectrum,
        color="green",
        name="Salida llave analógica"
    ).plotAndSave(
        filename="ExpressOutput/espectro_09"
    )
    plt.show()
Beispiel #4
0
    def modeSelected(self):
        mode = self.buttonSelector.var.get()

        inputSignal = PlotSignals.getSignalsData().signals[mode]
        self.plotContainerTabs.tab1.plot(inputSignal)
        self.plotContainerTabs.tab2.plot(FourierTransform.fourierTransform(inputSignal))

        self.plotContainerTabs.autoscale()

        self.currentSignal = inputSignal
def joaco_spectrum2():
    fmuestra = 30000
    dmuestra = 1 / fmuestra

    xvar = arange(0, 2, dmuestra)
    print(xvar)
    # print(len(xvar))

    periodSegundos = 0.2

    period = periodSegundos / dmuestra

    fc = 1000
    fm = 200

    yvar = np.zeros(len(xvar))
    for i in range(len(yvar)):
        if i % period <= period * 0.25:
            yvar[i] = 1  #*np.sin(2*np.pi*fc)*np.sin(2*np.pi*fm)
        else:
            yvar[i] = 0

    s1 = Senial.Senial(xvar, yvar)
    s1f = FourierTransform.fourierTransform(s1)

    xaux = s1f.xvar
    tau = period * 0.25
    print(1 / periodSegundos)
    yaux = [abs(np.sinc(it * 0.25)) for it in xaux]
    lxvar = len(s1f.xvar) / 2
    lxvar2 = len(xaux) / 2
    ExpressPlot.CombinedPlot()\
        .setTitle("Espectro")\
        .setXTitle("Frecuencia (Hz)")\
        .setYTitle("Ampltiud (%)")\
        .addSignalPlot(
        signal=Senial.Senial(s1f.xvar, s1f.values), color="blue",name="espectro1")\
        .addSignalPlot(
            signal=Senial.Senial(xaux, yaux),
            color="orange",
            name="sinc"
        )\
        .plotAndSave("testjoaco.png")

    # plt.plot(xaux,yaux,color="orange")
    plt.show()
Beispiel #6
0
def spectra_plot(medcsv, simxml, out, fmax=None):
    fmed = []
    pmed = []

    with open(medcsv, 'rt') as csvfile:
        reader = list(csv.reader(csvfile))
        # hola = csv.reader(csvfile)

        reader.pop(0)  # saco el header, me quedo solo con las mediciones
        if fmax is None:
            fmax = float(reader[-1][0])

        for row in reader:
            f = float(row[0])
            if f > fmax:
                break
            fmed.append(f)
            pmed.append((10**(float(row[1]) / 20))**2)

    #plt.plot(fmed, pmed)
    #plt.show()

    s1 = Senial.Senial(fmed, pmed)
    s_xml = SignalsReadWrite.readSignal(simxml)
    s2 = FourierTransform.fourierTransform(s_xml)
    fsim = []
    psim = []
    for f in s2.xvar:
        if f < 0:
            continue
        if f > fmax:
            break
        fsim.append(f)
        psim.append(s2.values[s2.xvar.index(f)])

    s2.xvar = fsim
    s2.values = psim
    psum = sum(s2.values)
    s2.values = [v / psum * 100 for v in s2.values]

    psum = sum(pmed)
    s1.values = [v / psum * 100 for v in s1.values]

    ExpressPlot.CombinedPlot()\
    .setTitle(" ")\
    .setXTitle("Frecuencia (Hz)")\
    .setYTitle("Potencia (% de total)")\
    .addSignalPlot(
     signal=s1,
     color="orange",
     name="Medido"
    )\
    .addSignalPlot(
     signal=s2,
     color="blue",
     name="Simulado"
    )\
     .plotAndSave(
     filename=out
    )
    plt.show()