Feeds:
Posts
Comments

Archive for July, 2011

For a Linux user, it happens to install a program which is not in the default repository, e.g., like professional programs for scientists. Such programs usually come with a .tar.gz file or similar. You have to open it, go into the folder it creates, and run “./configure”  and then “make“. Then, you face an error message like this: “the XYZ library was not found”. For instance, it complains about the CFITSIO or FFTW library that you have installed and are 100% sure it works correctly. Well, in this case, you have to give the path to the directory it was installed. Such libraries usually have a lib and an include folders which should be address properly.

$./configure CFLAGS=’-I/home/micropore/cfitsio/include’ LDFLAGS=’-L/home/micropore/cfitsio/lib’

Note to “-I” and “-L“. Then, it will most probably work. At least, it worked for me. There are certainly other methods to tell where is a certain library.

Advertisements

Read Full Post »

It happens that one uses the standard FFT routine of Python (or better to say Numy.fft) without knowing how can it return the proper frequency. In the following simple example, I show two methods to get it working correctly.

import numpy as np
from scipy import fft
import numpy, matplotlib, scipy.fftpack
from pylab import plt

num = 256
norm = 2.0 / float(num) # normalization factor
sample = 4.
time = np.arange(num) / sample
dx = time[1] – time[0]
f1 = .88
a1 = 2.
kont = a1 * np.sin(2 * np.pi * f1 * time)   # the input
g = fft(kont) * norm
#————————————————–
#– Method 1
freq = np.fft.fftshift(np.fft.fftfreq(kont.shape[-1]))/dx
plt.plot(freq, abs(np.fft.fftshift(g)))
#————————————————–
#– Method 2
#freq = np.fft.fftshift(np.fft.fftfreq(kont.shape[-1]))/dx
#plt.plot(freq, abs(np.fft.fftshift(g)))
#————————————————–
plt.axvline(x=f1, linewidth=2, color=’r’)
plt.xlim(xmin=1e-6)   # to have only positive frequencies
plt.xlabel(r’Frequency’)
plt.ylabel(r’Normalized amplitude’)
plt.title(‘method 1’)
plt.show()

If you have trouble due to  mismatch of some characters, try the PDF version.

Read Full Post »