0

So I am trying to define a function for each vector variable in my mode_0 values. I then want to create a plot of all of these values together. Attached is the code below and a screenshot of a graph with the first two values of mode_0, I want to do this for up to 50 values in the mode_0 list.

#impose a lorenztian
# define lorenztian fit
def lor0(A, Tau, v, vk):
 lorenzian_fit = (((A**2)/(np.pi*Tau))/(1+(((2*(v-vk))/Tau)**2)))
 return lorenzian_fit

# A_k is the mode amplitude = np.sqrt(pi * Max height * Tau)
# Tau_k is the mode linewidth (FWHM) = 0.1-0.2
# V_k is the ossillation mode frequency = modes 

lor0 = lor(np.sqrt(np.pi * 200000 * 0.15), 0.15, frequencies, mode_0[1])
lor0_1 = lor(np.sqrt(np.pi * 200000 * 0.15), 0.15, frequencies, mode_0[2])
#lor1 = lor(np.sqrt(np.pi * 200000 * 0.15), 0.15, frequencies, mode_1)
#lor2 = lor(np.sqrt(np.pi * 200000 * 0.15), 0.15, frequencies, mode_2)

''' enter image description here

Lily
  • 43
  • 1
  • 6

1 Answers1

1

Iterate through mode_0. Something like this should work:

for vec in mode_0[:50]: # in case you just want 50 values of mode_0
    lor = lor0(np.sqrt(np.pi * 200000 * 0.15), 0.15, frequencies, vec)
    plt.plot(frequencies, lor, '--')
plt.xlim(0, 50)
plt.grid()
plt.show()
Guimoute
  • 4,407
  • 3
  • 12
  • 28