Multiple peaks in fft spectrum

122 views
Skip to first unread message

Diksha Prajapati

unread,
Oct 10, 2023, 12:14:31 PM10/10/23
to mumax2
Hello all,
I am trying to get fft of each cell corresponding to a particular frequency value. However I am getting multiple peaks in the fft spectrum of y-component of magnetization (plot attached). I referred to the 'Skyrmion excitation example'. Kindly refer to the code below.
# MODE IDENTIFICATION
mode1_idx = 7   # determined visually
mode2_idx = 58  # determined visually
mode1_freq = freq[mode1_idx]
mode2_freq = freq[mode2_idx]
print("Mode 1 frequency: %.2f GHz"%(mode1_freq/1e9))
print("Mode 2 frequency: %.2f GHz"%(mode2_freq/1e9))

# PLOT THE SPECTRUM
plt.plot(freq/1e9, spectr)
plt.axvline(mode1_freq/1e9, lw=1, ls='--', c='gray')
plt.axvline(mode2_freq/1e9, lw=1, ls='--', c='gray')
plt.xlim(0,fmax/1e9)
plt.ylabel("Spectrum (a.u.)")
plt.xlabel("Frequency (GHz)")
plt.show()
In this example there were only two peaks so it is convenient to plot them manually, howsoever in my case I am
getting multiple peaks, hence it is very time taking to first determine visually each peak and then to calculate fft of each cell
corresponding to each frequency value. Is there any way by which-
1. I can get value of frequency corresponding to each peak?
2. FFT of each cell corresponding to particular value of frequencies obtained above.
I would be very thankful if someone can help me with this.
With regards
Diksha
grp.png

Josh Lauzier

unread,
Oct 10, 2023, 2:34:22 PM10/10/23
to mumax2
Hi,

Instead of finding them visually, you can use a peak finding algorithm. There are many different types, so I would pick one off of Google that you like. It probably doesn't need to be very complex. Since you're already using python, something such as this built in scipy function might be convenient: https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.find_peaks.html

To select the modes, you can replace the portion of the code "mode1 = mz_fft[mode1_idx]" with a little for loop for each peak frequency value. You would probably also want to adjust the plotting to also be in a for loop.

Best,
Josh L.
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages