JuliaWaveScattering / MultipleScattering.jl

A Julia library for simulating, processing, and plotting multiple scattering of waves.
Other
45 stars 12 forks source link

Specialise function frequency_to_time for real time signal #4

Closed arturgower closed 6 years ago

arturgower commented 6 years ago

We should assume all time signals are real and specialise the inverse fourier for that scenario. In which case we can use only positive frequencies, but need to take the real part and multiple by two: img_20171110_140759

Note that any frequency ωi not given is the same as taking F(ωi) =0. For very large ωi, we expect F(ωi) to decay and therefore become less significant, but this is not true for ωi =0. If F(0) is not given, one simple solution is to interpolate F(0) ~= (ω2 F(ω1) - ω1 F(ω2))/(ω2 - ω1).

Thoughts?

jondea commented 6 years ago

Good idea, I agree we should assume the time signals are real (also means we no longer need and apply function in moments). I also agree with the analysis, although I'm a little confused by the constant, because we appear to be getting sensible results without it (could be something to do with the impulse function as it is currently implemented?)

I'm not sure about the interpolation for ω = 0, I think it would need more justification. Perhaps make it an option which defaults to false until we have a better idea.

arturgower commented 6 years ago

By the constant do you mean 2π right? This sometimes gets absorbed into dω, I'll look into it.

Yes let's make correcting for ω = 0 an option, but I think it should default to true. That's because our software doesn't allow the user to calculate the response for ω = 0. And without ω = 0, this function is not calculating a good approximation to the time signal. So to me it seems more natural to auto correct and add for ω = 0.

jondea commented 6 years ago

Yeah, thanks.

I'm still nervous about interpolating by default, it seems like a more dangerous assumption than just implicitly assuming it is zero. How would we go about actually calculating the true frequency response at ω = 0?

jondea commented 6 years ago

It is now failing the TimeModel tests because the method has changed sufficiently. Could you convince yourself that it is now correct and change the test values?

arturgower commented 6 years ago

I think to calculate ω = 0 exactly we would need to do asymptotic expansion. Assuming the response at ω = 0 is zero could brake causality by translating the whole time response up or down, though it doesn't seem to make much difference in our examples. Think of it this way, the function is called frequency_to_time, so it should do, by default, the best it can to recover the time signal, right? Otherwise we would have to call it, project frequency onto Fourier basis.

jondea commented 6 years ago

Not sure if you've seen these but they looked interesting. If nothing else we can use them for later reference. https://math.stackexchange.com/questions/388009/numerical-approximation-of-the-continuous-fourier-transform

http://www.davidhbailey.com/dhbpapers/fourint.pdf

arturgower commented 6 years ago

Okay have specialised time responses to be real, wrote several tests and benchmarks, and by default add the frequency ω=0 by extrapolation when it's not present.