# How to see the output from DSP.Periodograms.periodogram?

**URL:** https://discourse.julialang.org/t/how-to-see-the-output-from-dsp-periodograms-periodogram/26732
**Category:** Signal and Image Processing
**Tags:** dsp
**Created:** [July 24, 2019, 11:56am UTC](https://discourse.julialang.org/t/how-to-see-the-output-from-dsp-periodograms-periodogram/26732 "2019-07-24T11:56:59Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Andrzej\_Ceglowski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrzej_ceglowski/32/7869_2.png) [@Andrzej\_Ceglowski](https://discourse.julialang.org/u/Andrzej_Ceglowski)
#### Post date: [July 24, 2019, 11:57am UTC](https://discourse.julialang.org/t/how-to-see-the-output-from-dsp-periodograms-periodogram/26732/1 "2019-07-24T11:57:00Z")

</div>

Thank you for taking the time to look at my rookie problem. I cannot find documentation on the periodogram type variable and consequently cannot access the results of DSP periodograms routine.  
Can you help?  
The steps/data I’m using are listed below.

```julia
julia> using DSP

julia> s
4096-element Array{Float64,1}:
 -13.02
 -14.07
 -19.87
 :
 -20.3
 -20.78
 -14.65

 ps=periodogram(s)
DSP.Periodograms.Periodogram{Float64,Frequencies}([475.002, 747.338, 88.3251, 1890.08, 938.792, 4904.95, 7845.16, 1386.74, 4073.1, 4158.63 … 409.203, 310.278, 845.878, 312.647, 382.544, 423.588, 596.257, 64.2432, 848.588, 348.645], [0.0, 0.000244141, 0.000488281, 0.000732422, 0.000976563, 0.0012207, 0.00146484, 0.00170898, 0.00195313, 0.00219727 … 0.497803, 0.498047, 0.498291, 0.498535, 0.498779, 0.499023, 0.499268, 0.499512, 0.499756, 0.5])

julia> ps
DSP.Periodograms.Periodogram{Float64,Frequencies}([475.002, 747.338, 88.3251, 1890.08, 938.792, 4904.95, 7845.16, 1386.74, 4073.1, 4158.63 … 409.203, 310.278, 845.878, 312.647, 382.544, 423.588, 596.257, 64.2432, 848.588, 348.645], [0.0, 0.000244141, 0.000488281, 0.000732422, 0.000976563, 0.0012207, 0.00146484, 0.00170898, 0.00195313, 0.00219727 … 0.497803, 0.498047, 0.498291, 0.498535, 0.498779, 0.499023, 0.499268, 0.499512, 0.499756, 0.5])

julia> typeof(ps)
DSP.Periodograms.Periodogram{Float64,Frequencies}

```

Showall() does not appear to work for this type of variable.

1. How do I see all the rows/save the periodogram variable to a file?
2. How do I plot the periodogram variable? (I see DSP had a plot\_spectrogram(f,fs) but cannot find documentation on the fs parameter.)

Edit note: added intro and clarified questions.

---

<div class="post-metadata">

### Author: ![cchderrick](https://avatars.discourse-cdn.com/v4/letter/c/ecd19e/32.png) [@cchderrick](https://discourse.julialang.org/u/cchderrick)
#### Post date: [July 26, 2019, 1:07pm UTC](https://discourse.julialang.org/t/how-to-see-the-output-from-dsp-periodograms-periodogram/26732/2 "2019-07-26T13:07:38Z")

</div>

In general, you can use `fieldnames` to inspect what are the fields of the **type** of the variable (hint: typeof).

```julia-repl
julia> fieldnames(typeof(ps))
(:power, :freq)

```

So now you can retrieve the information from `ps`

```julia-repl
julia> ps.power
4096-element Array{Float64,1}:
...

```

If you need to see the result in a plot, here is an example of plotting the power spectrum using `Plots.jl`

```julia
using DSP, Plots

fs = 44_000;
fc = 12_000;
t = 0:1/fs:1024*(1/fc)

m = sinc.(fc/8*t)

y = cos.(2*pi*fc*t) .* m

Y = periodogram(y; fs=fs)

plot(Y.freq, DSP.pow2db.(Y.power))

```

---

<div class="post-metadata">

### Author: ![Andrzej\_Ceglowski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrzej_ceglowski/32/7869_2.png) [@Andrzej\_Ceglowski](https://discourse.julialang.org/u/Andrzej_Ceglowski)
#### Post date: [August 6, 2019, 2:26am UTC](https://discourse.julialang.org/t/how-to-see-the-output-from-dsp-periodograms-periodogram/26732/3 "2019-08-06T02:26:23Z")

</div>

Thank you. The retrieval of the single column is a great clue and the plot command is valuable.  
I will investigate when I reinstall Atom after the recent debacle with its update.
