[julia-users] Re: FFT, PSD and Windowing functions

2016-07-26 Thread Islam Badreldin
Hi Yared,



On Tuesday, July 26, 2016 at 10:25:45 AM UTC-4, Yared Melese wrote:
>
> Hi Islam, 
>
> Thanks again for your inputs, 
>
> the first method worked, as  you mentioned it was missing dot to do 
> element wise multiplication. 
>
> Here is what it looks like 
> pow_fs = (((2^(adc_bits-1))-1))^2 / 2
> fb= fb.*hanning(length(fb))
>
> When I tried the weltch function, it actually has two sets of data as 
> shown below, how do you split data to plot and manipulate the array? 
> Here is the command I used,  periodogram(fb*; 
> onesided=eltype(fb)<:Real*, *nfft=nextfastfft(length(fb)*, *fs=150*, 
> *window=hanning*)*¶* 
>  
>
> data collected 
>
>
First, note that you don't have to supply all the keyword arguments if the 
default values work for you. For example, you can get the same result as 
above by using
pdg = periodogram(fb; fs=150, window=hanning)

Second, you can split the data by inspecting the field names of the 
returned result
> fieldnames(pdg)
2-element Array{Symbol,1}:
 :power
 :freq 

> fb_power = pdg.power
> fb_freq = pdg.freq

You can then plot this data, using PyPlot for example

using PyPlot
plot(pdg.freq, pdg.power)



I hope this helps.

  -Islam
 

>
>  Thanks 
> Yared 
>
> On Friday, July 22, 2016 at 10:33:36 AM UTC-5, Islam Badreldin wrote:
>
>> Hi Yared,
>>
>> Please see below,,
>>
>> On Thursday, July 21, 2016 at 11:19:44 AM UTC-4, Yared Melese wrote:
>>
>>> Hi Islam, 
>>>
>>> Thanks for your input 
>>>
>>>  I was able to find all windowing functions; however, there is nothing 
>>> about PSD ( power spectral density). In python and matlab, there is 
>>> function pwelch which does both windowing and FFT and wondering if there is 
>>> the same function in Julia.
>>>
>>
>> Did you take a look at `welch_pgram` function?
>> http://dspjl.readthedocs.io/en/latest/periodograms.html#welch_pgram 
>> 
>>  
>>
>>
>>> Here is simple trial I had but it is complaining about type mismatch
>>>
>>> fb= fb[:]*hamming(length(fb))
>>> fb = fft(fb) # take FFT of signal 
>>>
>>> LoadError: MethodError: `*` has no method matching 
>>> *(::Array{Complex{Float64},1}, ::Array{Float64,1})
>>> Closest candidates are:
>>>   *(::Any, ::Any, !Matched::Any, !Matched::Any...)
>>>   
>>> *{T<:Union{Complex{Float32},Complex{Float64},Float32,Float64},S}(!Matched::Union{DenseArray{T<:Union{Complex{Float32},Complex{Float64},Float32,Float64},2},SubArray{T<:Union{Complex{Float32},Complex{Float64},Float32,Float64},2,A<:DenseArray{T,N},I<:Tuple{Vararg{Union{Colon,Int64,Range{Int64,LD}},
>>>  
>>> ::Union{DenseArray{S,1},SubArray{S,1,A<:DenseArray{T,N},I<:Tuple{Vararg{Union{Colon,Int64,Range{Int64,LD}})
>>>   
>>> *{TA,TB}(!Matched::Base.LinAlg.AbstractTriangular{TA,S<:AbstractArray{T,2}},
>>>  
>>> ::Union{DenseArray{TB,1},DenseArray{TB,2},SubArray{TB,1,A<:DenseArray{T,N},I<:Tuple{Vararg{Union{Colon,Int64,Range{Int64,LD},SubArray{TB,2,A<:DenseArray{T,N},I<:Tuple{Vararg{Union{Colon,Int64,Range{Int64,LD}})
>>>   ...
>>> in include_string at loading.jl:282
>>> in include_string at C:\Users\melese\.julia\v0.4\CodeTools\src\eval.jl:32
>>> in anonymous at C:\Users\melese\.julia\v0.4\Atom\src\eval.jl:84
>>> in withpath at C:\Users\melese\.julia\v0.4\Requires\src\require.jl:37
>>> in withpath at C:\Users\melese\.julia\v0.4\Atom\src\eval.jl:53
>>> [inlined code] from C:\Users\melese\.julia\v0.4\Atom\src\eval.jl:83
>>> in anonymous at task.jl:58
>>> while loading D:\userdata\melese\Desktop\fft.jl, in expression starting 
>>> on line 23
>>>
>>>
>> This particular error seems to be occurring at the `fb= 
>> fb[:]*hamming(length(fb))` line. It looks like you are multiplying an 
>> _vector_ of complex doubles with a _vector_ of doubles, which is not 
>> mathematically defined because of the dimension mismatch, since both 
>> vectors are of dimension Nx1. Instead, my guess is that you meant 
>> element-wise multiplication using `.*`. But again, I think the 
>> `welch_pgram` function should meet your needs.
>>
>>   -Islam
>>  
>>
>>>
>>> On Wednesday, July 20, 2016 at 9:15:40 AM UTC-5, Yared Melese wrote:
>>>
 Hello 

 Would you please let me know the package available to do windowing, FFT 
 and PSD? 

 Currently, I have bin file that I have processed in Julia and need to 
 window it and take preferably PSD but FFT work as well

 Thanks 
 Yared

  



[julia-users] Re: FFT, PSD and Windowing functions

2016-07-26 Thread Yared Melese
Hi Islam, 

Thanks again for your inputs, 

the first method worked, as  you mentioned it was missing dot to do element 
wise multiplication. 

Here is what it looks like 
pow_fs = (((2^(adc_bits-1))-1))^2 / 2
fb= fb.*hanning(length(fb))

When I tried the weltch function, it actually has two sets of data as shown 
below, how do you split data to plot and manipulate the array? 
Here is the command I used,  periodogram(fb*; onesided=eltype(fb)<:Real*, 
*nfft=nextfastfft(length(fb)*, *fs=150*, *window=hanning*)*¶* 
 

data collected 


 Thanks 
Yared 

On Friday, July 22, 2016 at 10:33:36 AM UTC-5, Islam Badreldin wrote:

> Hi Yared,
>
> Please see below,,
>
> On Thursday, July 21, 2016 at 11:19:44 AM UTC-4, Yared Melese wrote:
>
>> Hi Islam, 
>>
>> Thanks for your input 
>>
>>  I was able to find all windowing functions; however, there is nothing 
>> about PSD ( power spectral density). In python and matlab, there is 
>> function pwelch which does both windowing and FFT and wondering if there is 
>> the same function in Julia.
>>
>
> Did you take a look at `welch_pgram` function?
> http://dspjl.readthedocs.io/en/latest/periodograms.html#welch_pgram 
> 
>  
>
>
>> Here is simple trial I had but it is complaining about type mismatch
>>
>> fb= fb[:]*hamming(length(fb))
>> fb = fft(fb) # take FFT of signal 
>>
>> LoadError: MethodError: `*` has no method matching 
>> *(::Array{Complex{Float64},1}, ::Array{Float64,1})
>> Closest candidates are:
>>   *(::Any, ::Any, !Matched::Any, !Matched::Any...)
>>   
>> *{T<:Union{Complex{Float32},Complex{Float64},Float32,Float64},S}(!Matched::Union{DenseArray{T<:Union{Complex{Float32},Complex{Float64},Float32,Float64},2},SubArray{T<:Union{Complex{Float32},Complex{Float64},Float32,Float64},2,A<:DenseArray{T,N},I<:Tuple{Vararg{Union{Colon,Int64,Range{Int64,LD}},
>>  
>> ::Union{DenseArray{S,1},SubArray{S,1,A<:DenseArray{T,N},I<:Tuple{Vararg{Union{Colon,Int64,Range{Int64,LD}})
>>   
>> *{TA,TB}(!Matched::Base.LinAlg.AbstractTriangular{TA,S<:AbstractArray{T,2}}, 
>> ::Union{DenseArray{TB,1},DenseArray{TB,2},SubArray{TB,1,A<:DenseArray{T,N},I<:Tuple{Vararg{Union{Colon,Int64,Range{Int64,LD},SubArray{TB,2,A<:DenseArray{T,N},I<:Tuple{Vararg{Union{Colon,Int64,Range{Int64,LD}})
>>   ...
>> in include_string at loading.jl:282
>> in include_string at C:\Users\melese\.julia\v0.4\CodeTools\src\eval.jl:32
>> in anonymous at C:\Users\melese\.julia\v0.4\Atom\src\eval.jl:84
>> in withpath at C:\Users\melese\.julia\v0.4\Requires\src\require.jl:37
>> in withpath at C:\Users\melese\.julia\v0.4\Atom\src\eval.jl:53
>> [inlined code] from C:\Users\melese\.julia\v0.4\Atom\src\eval.jl:83
>> in anonymous at task.jl:58
>> while loading D:\userdata\melese\Desktop\fft.jl, in expression starting 
>> on line 23
>>
>>
> This particular error seems to be occurring at the `fb= 
> fb[:]*hamming(length(fb))` line. It looks like you are multiplying an 
> _vector_ of complex doubles with a _vector_ of doubles, which is not 
> mathematically defined because of the dimension mismatch, since both 
> vectors are of dimension Nx1. Instead, my guess is that you meant 
> element-wise multiplication using `.*`. But again, I think the 
> `welch_pgram` function should meet your needs.
>
>   -Islam
>  
>
>>
>> On Wednesday, July 20, 2016 at 9:15:40 AM UTC-5, Yared Melese wrote:
>>
>>> Hello 
>>>
>>> Would you please let me know the package available to do windowing, FFT 
>>> and PSD? 
>>>
>>> Currently, I have bin file that I have processed in Julia and need to 
>>> window it and take preferably PSD but FFT work as well
>>>
>>> Thanks 
>>> Yared
>>>
>>>  
>>>
>>>

[julia-users] Re: FFT, PSD and Windowing functions

2016-07-22 Thread Islam Badreldin
Hi Yared,

Please see below,,

On Thursday, July 21, 2016 at 11:19:44 AM UTC-4, Yared Melese wrote:

> Hi Islam, 
>
> Thanks for your input 
>
>  I was able to find all windowing functions; however, there is nothing 
> about PSD ( power spectral density). In python and matlab, there is 
> function pwelch which does both windowing and FFT and wondering if there is 
> the same function in Julia.
>

Did you take a look at `welch_pgram` function?
http://dspjl.readthedocs.io/en/latest/periodograms.html#welch_pgram 


> Here is simple trial I had but it is complaining about type mismatch
>
> fb= fb[:]*hamming(length(fb))
> fb = fft(fb) # take FFT of signal 
>
> LoadError: MethodError: `*` has no method matching 
> *(::Array{Complex{Float64},1}, ::Array{Float64,1})
> Closest candidates are:
>   *(::Any, ::Any, !Matched::Any, !Matched::Any...)
>   
> *{T<:Union{Complex{Float32},Complex{Float64},Float32,Float64},S}(!Matched::Union{DenseArray{T<:Union{Complex{Float32},Complex{Float64},Float32,Float64},2},SubArray{T<:Union{Complex{Float32},Complex{Float64},Float32,Float64},2,A<:DenseArray{T,N},I<:Tuple{Vararg{Union{Colon,Int64,Range{Int64,LD}},
>  
> ::Union{DenseArray{S,1},SubArray{S,1,A<:DenseArray{T,N},I<:Tuple{Vararg{Union{Colon,Int64,Range{Int64,LD}})
>   
> *{TA,TB}(!Matched::Base.LinAlg.AbstractTriangular{TA,S<:AbstractArray{T,2}}, 
> ::Union{DenseArray{TB,1},DenseArray{TB,2},SubArray{TB,1,A<:DenseArray{T,N},I<:Tuple{Vararg{Union{Colon,Int64,Range{Int64,LD},SubArray{TB,2,A<:DenseArray{T,N},I<:Tuple{Vararg{Union{Colon,Int64,Range{Int64,LD}})
>   ...
> in include_string at loading.jl:282
> in include_string at C:\Users\melese\.julia\v0.4\CodeTools\src\eval.jl:32
> in anonymous at C:\Users\melese\.julia\v0.4\Atom\src\eval.jl:84
> in withpath at C:\Users\melese\.julia\v0.4\Requires\src\require.jl:37
> in withpath at C:\Users\melese\.julia\v0.4\Atom\src\eval.jl:53
> [inlined code] from C:\Users\melese\.julia\v0.4\Atom\src\eval.jl:83
> in anonymous at task.jl:58
> while loading D:\userdata\melese\Desktop\fft.jl, in expression starting on 
> line 23
>
>
This particular error seems to be occurring at the `fb= 
fb[:]*hamming(length(fb))` line. It looks like you are multiplying an 
_vector_ of complex doubles with a _vector_ of doubles, which is not 
mathematically defined because of the dimension mismatch, since both 
vectors are of dimension Nx1. Instead, my guess is that you meant 
element-wise multiplication using `.*`. But again, I think the 
`welch_pgram` function should meet your needs.

  -Islam
 

>
> On Wednesday, July 20, 2016 at 9:15:40 AM UTC-5, Yared Melese wrote:
>
>> Hello 
>>
>> Would you please let me know the package available to do windowing, FFT 
>> and PSD? 
>>
>> Currently, I have bin file that I have processed in Julia and need to 
>> window it and take preferably PSD but FFT work as well
>>
>> Thanks 
>> Yared
>>
>>  
>>
>>

[julia-users] Re: FFT, PSD and Windowing functions

2016-07-21 Thread Yared Melese
Hi Islam, 

Thanks for your input 

 I was able to find all windowing functions; however, there is nothing 
about PSD ( power spectral density). In python and matlab, there is 
function pwelch which does both windowing and FFT and wondering if there is 
the same function in Julia.

Here is simple trial I had but it is complaining about type mismatch

fb= fb[:]*hamming(length(fb))
fb = fft(fb) # take FFT of signal 

LoadError: MethodError: `*` has no method matching 
*(::Array{Complex{Float64},1}, ::Array{Float64,1})
Closest candidates are:
  *(::Any, ::Any, !Matched::Any, !Matched::Any...)
  
*{T<:Union{Complex{Float32},Complex{Float64},Float32,Float64},S}(!Matched::Union{DenseArray{T<:Union{Complex{Float32},Complex{Float64},Float32,Float64},2},SubArray{T<:Union{Complex{Float32},Complex{Float64},Float32,Float64},2,A<:DenseArray{T,N},I<:Tuple{Vararg{Union{Colon,Int64,Range{Int64,LD}},
 
::Union{DenseArray{S,1},SubArray{S,1,A<:DenseArray{T,N},I<:Tuple{Vararg{Union{Colon,Int64,Range{Int64,LD}})
  
*{TA,TB}(!Matched::Base.LinAlg.AbstractTriangular{TA,S<:AbstractArray{T,2}}, 
::Union{DenseArray{TB,1},DenseArray{TB,2},SubArray{TB,1,A<:DenseArray{T,N},I<:Tuple{Vararg{Union{Colon,Int64,Range{Int64,LD},SubArray{TB,2,A<:DenseArray{T,N},I<:Tuple{Vararg{Union{Colon,Int64,Range{Int64,LD}})
  ...
in include_string at loading.jl:282
in include_string at C:\Users\melese\.julia\v0.4\CodeTools\src\eval.jl:32
in anonymous at C:\Users\melese\.julia\v0.4\Atom\src\eval.jl:84
in withpath at C:\Users\melese\.julia\v0.4\Requires\src\require.jl:37
in withpath at C:\Users\melese\.julia\v0.4\Atom\src\eval.jl:53
[inlined code] from C:\Users\melese\.julia\v0.4\Atom\src\eval.jl:83
in anonymous at task.jl:58
while loading D:\userdata\melese\Desktop\fft.jl, in expression starting on 
line 23


On Wednesday, July 20, 2016 at 9:15:40 AM UTC-5, Yared Melese wrote:

> Hello 
>
> Would you please let me know the package available to do windowing, FFT 
> and PSD? 
>
> Currently, I have bin file that I have processed in Julia and need to 
> window it and take preferably PSD but FFT work as well
>
> Thanks 
> Yared
>
>  
>
>