Commit 3a0fadb1 authored by Jan Luc's avatar Jan Luc
Browse files

adicionada regressao linear e leitura de energia a partir do nome do arquivo...

adicionada regressao linear e leitura de energia a partir do nome do arquivo para calibracao de RBS com ouro
parent ca115907
# Realizacao de fitting de funcao erro complementar dos dados dos arquvos de RBS do ouro e calibracao em energia
#
# Ainda falta fazer o fitting usando o k*E do ouro para aquelas energias (facil)
# OBS: Os arquivos devem possuir nomes no formato "AuJpjMeV.dat",
# onde J = inteiro definindo energia do feixe em MeV,
# j = inteiro definindo primeira casa decimal de energia.
#
# Exemplo: Um feixe de 2,3 MeVteria nome: Au2p3MeV.dat
from bokeh.plotting import figure, output_file, show
import scipy as sp
......@@ -31,14 +35,25 @@ def func (x, A, B, C, D):
# Observe que os parametros nao podem estar muito longe dos dados a serem fitados
return y
def linear(x, A, B):
return (A*x + B)
def linplot (x, A, B):
# por alguma razao o plot nao funciona com a linear normal.
i = 0
saida = []
for valor in x:
saida.append(A*x[i] + B)
return saida
########################################################
#################### definitions #######################
########################################################
colors = ["Blue", "DarkOliveGreen", "BlueViolet", "Brown", "CadetBlue", "Coral"]
altura = 1000 # ate agora funcionou, entao deixei esse valor. Ele deve variar caso a medida tenha contagens muito diferentes.
arquivos_ouro = [ "./calibracao_1p5MeV/Au1p0Mev.dat", "./calibracao_1p5MeV/Au1p5Mev.dat", "./calibracao_1p5MeV/Au2p0Mev.dat", "./calibracao_1p5MeV/Au2p5Mev.dat"]
#arquivos_ouro = sys.argv[1:]
#arquivos_ouro = [ "./calibracao_1p5MeV/Au1p0Mev.dat", "./calibracao_1p5MeV/Au1p5Mev.dat", "./calibracao_1p5MeV/Au2p0Mev.dat", "./calibracao_1p5MeV/Au2p5Mev.dat"]
arquivos_ouro = sys.argv[1:]
rois = []
########################################################
......@@ -74,4 +89,29 @@ for arquivo in arquivos_ouro:
p.line(canais[roi-40:roi+40], contagens[roi-40:roi+40], legend=("contagens " + arquivo[-12:-4]), line_width=2, line_color= colors[i])
i += 1
show(p)
\ No newline at end of file
show(p)
########################################################
############# fazendo a regressao linear ###############
########################################################
kAu=.9224
# lendo os nomes de arquivo para determinar a energia usada no feixe:
energias = []
for arquivo in arquivos_ouro:
energias.append(int(arquivo[-10]) * 1000. + int(arquivo[-8])*100)
energias = np.array(energias)*kAu
popt, pcov = curve_fit(linear, corte, energias)
print("Valor da inclinacao [keV/canal]:", popt[0], "\n valor do offset [keV]:", popt[1])
q = figure(title="Conversao obtida: \n energia = canal*" + str(popt[0]) + " + "+ str(popt[1]) , x_axis_label='canais', y_axis_label='energias [keV]')
x = np.arange(10, 512, .1)
q.line(x, linear(x, popt[0], popt[1]), legend = "canais e energias", line_width=2, line_color = colors[-1])
q.asterisk(corte, energias,legend="valores medidos", size=20, color="#F0027F")
show (q)
########################################################
########################################################
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment