# difference between logged power spectrum and power spectrum?

What is the difference between a logged power spectrum and power spectrum... Well the log part. So can a normal power spectrum be converted to a logged power spectrum just by taking the log of the power spectrum?

Here is the code in which I am trying to convert:

import os
import sys
from os import listdir
from os.path import isfile, join
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import seaborn as sb
from matplotlib.colors import Normalize
import matplotlib
from matplotlib import cm
from PIL import Image
import ast

def make_plot_store_data(name,interweaved,static,delta,delta_delta,isTrain,isTest,isDev):
Y =  np.array(range(0,static.shape[1]))
X =  np.array(range(0,static.shape[0]))
X,Y = np.meshgrid(X, Y)

plt.pcolormesh(X,Y,np.log10(static.T),cmap=cm.jet,vmin=-6, vmax=2)
plt.xlabel('Frames')
plt.ylabel('Frequency(Hz)')
plt.title('Power spectrum of ' + name)
plt.colorbar()
#plt.show()
plt.savefig(plot+"/"+name+"_plot_static_conv.png")
#raw_input("Something")
plt.close()

plt.pcolormesh(X,Y,np.log10(delta.T),cmap=cm.jet,vmin=-6, vmax=2)
plt.xlabel('Frames')
plt.ylabel('Frequency(Hz)')
plt.title('Power spectrum of ' + name)
plt.colorbar()
#plt.show()
plt.savefig(plot+"/"+name+"_plot_delta_conv.png")
#raw_input("Something")
plt.close()

plt.pcolormesh(X,Y,np.log10(delta_delta.T),cmap=cm.jet,vmin=-6, vmax=2)
plt.xlabel('Frames')
plt.ylabel('Frequency(Hz)')
plt.title('Power spectrum of ' + name)
plt.colorbar()
#plt.show()
plt.savefig(plot+"/"+name+"_plot_delta_delta_conv.png")
#raw_input("Something")
plt.close()

Y =  np.array(range(0,interweaved.shape[1]))
X =  np.array(range(0,interweaved.shape[0]))
X,Y = np.meshgrid(X, Y)

plt.pcolormesh(X,Y,np.log10(interweaved.T),cmap=cm.jet,vmin=-6, vmax=2)
##plt.xlim(xmin, xmax)
plt.xlabel('Frames')
plt.ylabel('Frequency(Hz)')
plt.title('Power spectrum of ' + name)
plt.colorbar()
#plt.show()
plt.savefig(plot+"/"+name+"_interweaved.png")
plt.close()
if isTrain == True:
convert = plt.get_cmap(cm.jet)
norm = Normalize(vmin=-6, vmax=2)
numpy_output_interweawed = convert(norm(plot_interweaved))
numpy_output_interweawed.dump(numpy_train+name+"_normalized_interweaved"+".dat")
numpy_output_interweawed_or = convert(norm(plot_interweaved))*255
numpy_output_interweawed_or.dump(numpy_train+name+"_interweaved"+".dat")
if isTest == True:
convert = plt.get_cmap(cm.jet)
norm = Normalize(vmin=-6, vmax=2)
numpy_output_interweawed = convert(norm(plot_interweaved))
numpy_output_interweawed.dump(numpy_test+name+"_normalized_interweaved"+".dat")
numpy_output_interweawed_or = convert(norm(plot_interweaved))*255
numpy_output_interweawed_or.dump(numpy_test+name+"_interweaved"+".dat")
if isDev == True:
convert = plt.get_cmap(cm.jet)
norm = Normalize(vmin=-6, vmax=2)
numpy_output_interweawed = convert(norm(plot_interweaved))
numpy_output_interweawed.dump(numpy_dev+name+"_normalized_interweaved"+".dat")
numpy_output_interweawed_or = convert(norm(plot_interweaved))*255
numpy_output_interweawed_or.dump(numpy_dev+name+"_interweaved"+".dat")
print str(name) + " Numpy Stored"


I am trying to store the logged filter bank energies here both as plot and data. But I seem to be doing it wrong based on the images I get.

• So, if $P(f,t)$ is the power spectrum (i.e. your top figure), the log-power spectrum is given by $P_{log}(f,t)=10log10(P(f,t))$. – Maximilian Matthé Mar 13 '17 at 11:30
• why 10log?..... – Bob Burt Mar 13 '17 at 11:59
• It's a conventions to have 10log(P) to transform linear scale to decibel scale (which is what is meant via log-scale). Have a look here for example. – Maximilian Matthé Mar 13 '17 at 12:25
• decibel means deci- bel, which means 10 Bel. Bel is a ratio of power. Decibel is 10 x ratio of power. – Dan Boschen Mar 14 '17 at 0:05
• Post a gist of your code and we can help fix it up :) – ruoho ruotsi Apr 4 '17 at 16:28