Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
165 views
in Technique[技术] by (71.8m points)

Translating from Fortran to Python a Fourier transform

I was trying to solve a Fourier transform integration in python.The code should do this: --I already have all the n coordinates of a function acceleration over time in a list, the number is the Acc value and the position in the list is its correspondent time. --integration is done by adding all the acceleration values one time --The process of integration has to be repeated nf times --Each time the whole loop is complete, the result should be another list (Frequency) of coordinates, composed by "The integration of the acceleration" and "the frequency value" you did the integration for

So in resume, for every value in range nf I need the program to evaluate another function that iterates for n values and then repeat the process until the first range is exhausted of course. Let me show you how that looks like in Fortran:

   do k=1, nf                           # this is equivalent to "in range"
      w = 2.d0 * pai * (k-1) * df       # "pai" is pi (3.14...)
      ctemp = 0.d0                      # like when we do ctemp = []
      do i=1,n                          # the other range
         tt = (i - 1) * dt              
         ctemp = ctemp + Acc(i) * exp(-ai * w * tt) * dt      # here there's something similar to append
      end do                                                  
      F(k) = ctemp
   end do

Can you help me translate it to python?

question from:https://stackoverflow.com/questions/65948930/translating-from-fortran-to-python-a-fourier-transform

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...