Hola a todos.

El siguiente codigo me funciona bien cuando utilizo archivos que contienen
datos positivos:

import numpy as np
import matplotlib.pyplot as plt
import argparse

parser = argparse.ArgumentParser(description="Script that plots the bram's
data obtained from the IBOB.")
parser.add_argument('-b','--bram', help="Name of BRAM that will be
processed")
parser.add_argument('-f','--fre', help="Test frequency signal in MHz.
Example: $python plot_bram.py -b bram_file -f 33 (33MHz)")
args = parser.parse_args()


freq = args.fre
open_bram = open(args.bram, 'r')
bram = open_bram.readlines()

cols = np.loadtxt(bram, dtype=str)

x = cols[:,2]
y = cols[:,8]

max_x = np.argmax(y)

#Regla de 3 para determinar el valor del numero de canales teorico
ancho_de_banda_MHz = 100
canales = 1024
test_signal = int(freq)
dato_teorico = (test_signal*canales)/ancho_de_banda_MHz

plt.rc('font', size=9.2)
plt.subplot(1,1,1)
plt.plot(x,y)
plt.title('Autocorrelation \nTest Frequency Signal= %iMHz, Channels of the
Maximum Value= %i, Theoretical Channel Value=
%i'%(int(freq),max_x,dato_teorico))
plt.ylabel('Power (arbitrary units)')
plt.grid()
plt.xlabel('Channels')
plt.xlim(0,1024)
plt.show()

Sin embargo algunos archivos contienen datos negativos, que debo cambiar a
absolutos.

Yo intente esto:

y = np.absolute(y)

Pero me surge este error:

$ python plot_bram.py -b bram_ac_real -f 50
Traceback (most recent call last):
  File "plot_bram.py", line 37, in <module>
    plt.plot(x,np.absolute(y))
TypeError: Not implemented for this type

Que opinan?

Saludos

Rolando Paz
_______________________________________________
Python-es mailing list
Python-es@python.org
https://mail.python.org/mailman/listinfo/python-es
FAQ: http://python-es-faq.wikidot.com/

Responder a