2008年12月30日 星期二

2008年12月15日 星期一

CTFFIND的參數

Input parameters:
input_image
output_powerSpect
Cs, HT, AmpCnst, XMag, Dstep
Box, ResMin, ResMax, dFmin, dFmax, FStep

2008年12月4日 星期四

Building Python in framework in Mac OSX

./configure --enable-universalsdk --enable-framework

Error message參考: http://bugs.python.org/issue3381 

2008年12月1日 星期一

Building Boost-Python on Windows

原始文章:
http://yukuan.blogspot.com/2006/08/boost-to-python.html

Build and make instructions:
http://www.mpi-inf.mpg.de/~dfischer/manual/manual_topic38.html

2008年11月20日 星期四

2008年11月18日 星期二

[Python code] 執行shell或program中的commands

1) The standard way of executing an application without capturing its output is to use the call function:

from subprocess import call
try:
returncode = call(cmd, shell=True)
if returncode:
print 'Failure with returncode', returncode; sys.exit(1)
except OSError, message:
print 'Execution failed! \n', message; sys.exit(1)

2) 使用Popen object:
例子如下 ----
from subprocess import Popen, PIPE
cmd = 'myprog -c file.1 -p <>
p = Popen(cmd, shell=True, stdout=PIPE)
output, errors = p.communicate()

另一個例子是在程式中使用 (ex. SPIDER這種interactive的program) ----
pipe = Popen('gnuplot -persist', shell=True, stdin=PIPE).stdin
pipe.write('set xrange [0:10]; set yrange [-2:2]\n')
pipe.write('plot sin(x)\n')
pipe.write(quit') # quit Gnuplot

2008年11月16日 星期日

[Python code] Run commands in shell

import commands
cmd = 'programName < %s.i' % case # command to run
failure, output = commands.getstatusoutput(cmd)
if failure:
print 'Running the programName code failed\n%s\n%s' % (cmd, output)
sys.exit(1)

[Python code] Create a subdirectory

import os, shutil
d = case # name of the subdirectory
if os.path.isdir(d): # does d exist?
shutil.rmtree(d) # yes, then remove the old directory
os.mkdir(d) # make a new directory
os.chdir(d) # change to new directory

2008年11月3日 星期一

Compiling 2dx source in Ubuntu on 11/04/2008

1. 改mrcHeaderDisplay中的member function "setHeader"
2. 在fftlib.cpp中, strcpy和getenv需要include string.h和stdlib.h

2008年11月2日 星期日

How to uncompress a file with tar?

Commands:
tar xzvf ****.tar.gz
tar xvjf ****.tar.bz2
tar xvf ****.tar

x = eXtract
v = Verbose (optional) the files with relative locations will be displayed
z = gZipped; j = bzip2-zipped
f = from/to file

2008年10月28日 星期二

降低FIREFOX的記憶體使用量

在網址列輸入[about:config]
==> 在滑鼠右鍵的清單上選擇[新增]/[真假(Boolean)值]
==> 在對話空盒內輸入[config.trim_on_minimize]後選[true], 按下確定

FFTW的使用

FFTW (Fastest Fourier Transform in the West), 一個計算DFT (Discrete Fourier Transform) 的C語言函式庫,是目前世界公認執行速度最快的傅立葉轉換軟體。FFTW是由當時為MIT博士班的兩位學生Matteo Frigo Steven G. Johnson 在1997年所撰寫,並在1999年獲得Wilkinson數值軟體獎 (J. H. Wilkinson Prize for Numerical Software)。

FFTW的原理大致是這樣: 我們知道FFT是一種divide-and-conquer的演算法,這種演算法的特性就是將所輸入的N筆資料平分成幾組,再對這幾組資料繼續平分下去,直到每組資料只會含最少的容許數量 (比如一筆),然後再一層一層merge起來。這時,每次要分成幾組就值得分析了。根據實驗結果,輸入的資料量不同,若適當給予不同分組,其執行效能會有明顯改善!

FFTW的使用方法如下:

1. 複數的資料型態:
fftw_complex ComplexNum;
ComplexNum[0] = 10.1; // real part
ComplexNum[1] = 20.5; // imaginary part


2. 1維 DFT:

// 資料宣告
int N = 256;
fftw_complex *in, *out;
fftw_plan p;
// 空間配置
in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
// 製作輸入資料
// 產生最佳化的程式碼
p = fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
// 執行這個最佳化的程式碼
fftw_execute(p); /* repeat as needed */
// 釋放空間
fftw_destroy_plan(p);
fftw_free(in); fftw_free(out);

3. 多維 DFT:

fftw_plan_dft_1d改為:
fftw_plan_dft_2d
fftw_plan_dft_3d