Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7412019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:28:35+00:00 2026-05-29T06:28:35+00:00

I am trying to implement a 3D DFT but I am running into some

  • 0

I am trying to implement a 3D DFT but I am running into some trouble. What I believe I should do is to just do 3 consecutive 1D DFTs, one in each direction. Assuming that the 1D DFT is correct, can you see what is wrong with this code:

def dft3d(self, real3d, img3d, nx, ny, nz, dir):

    #Transform depth
    for i in range(nx):
        for j in range(ny):
            real = numpy.zeros(nz)
            img = numpy.zeros(nz)
            for k in range(nz):
                real[k] = real3d[i][j][k]
                img[k] = img3d[i][j][k]
            self.dft(real, img, nz, 1) #This was indented too much. It should work now.
            for k in range(nz):
                real3d[i][j][k] = real[k]
                img3d[i][j][k] = img[k]

    #Transform cols
    for k in range(nz):
        for i in range(nx):
            real = numpy.zeros(ny)
            img = numpy.zeros(ny)
            for j in range(ny):
                real[j] = real3d[i][j][k]
                img[j] = img3d[i][j][k]
            self.dft(real, img, ny, 1)
            for j in range(ny):
                real3d[i][j][k] = real[j]
                img3d[i][j][k] = img[j]

    #Transform rows
    for j in range(ny):
        for k in range(nz):
            real = numpy.zeros(nx)
            img = numpy.zeros(nx)
            for i in range(nx):
                real[i] = real3d[i][j][k]
                img[i] = img3d[i][j][k]
            self.dft(real, img, nx, 1)
            for i in range(nx):
                real3d[i][j][k] = real[i]
                img3d[i][j][k] = img[i]

I know there are built in versions of this in python, but I can’t use those. I’m just testing my algorithm in python so I can compare results of my algorithm and the built in ones. As far as I could tell it worked fine for both 1D and 2D transforms, but once I expanded it to 3D the results no longer match. Does anyone know what is wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:28:36+00:00Added an answer on May 29, 2026 at 6:28 am

    The first instance of self.dft is indented too far.

    Other than that, I see nothing wrong from the code provided.

    As a side note, if you are using numpy as your code suggests, you can simplify your code significantly even without resorting to the built-in DFT/FFT.

    For example, you can index a 3D numpy array like data3D[i, j, k]. You can slice by doing data3D[:, j, k], data3D[i, :, k], data3D[:, :, k], etc., instead of assigning individual elements one at a time within a for loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just trying to implement mobFox into my app, but having trouble to make it
Trying to implement AVAudioplayer and get some metering data of the played music, but
Trying to implement the new FP 10.1 Global error handler into my projects but
im trying to implement some behaviors when a mapview element scrolls... by coding a
I'm trying to implement a DFT-based 8-band equalizer for the sole purpose of learning.
Trying to implement some nested loops that are spitting out good old nested html
iam trying to implement an Searchmachine into my site. Iam using Zend_Search_Lucene for this.
Im trying to implement some code i found on a website which duplicates a
I'm trying to implement a discrete fourier transform, but it's not working. I'm probably
Trying to implement a MSMQ-backed WCF PubSub. I understand that net.msmq is one-way; however

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.