めも書き

Python練習帳

http://www.scipy.org/Getting_Started より

In [1]: %logstart
Activating auto-logging. Current session state plus future input saved.
Filename       : ipython_log.py
Mode           : rotate
Output logging : False
Raw input log  : False
Timestamping   : False
State          : active

In [2]: from scipy import *

In [3]: a = zeros(1000)
 → ゼロが1000個、のarray([...])

In [4]: a[:100]=1
 → a[0]〜a[99] に1を

In [5]: b =fft(a)
 → FFT (scipy)

In [6]: plot(abs(b))
Out[6]: [<matplotlib.lines.Line2D instance at 0xb7b9144c>]

In [7]: show()
 →plot()の段階で見えてない?

f:id:to33k:20111226152231p:plain

In [8]: concatenate?
Type:           builtin_function_or_method
Base Class:     <type 'builtin_function_or_method'>
String Form:    <built-in function concatenate>
Namespace:      Interactive
Docstring:
    concatenate((a1, a2, ...), axis=0)
    Join arrays together.
    The tuple of sequences (a1, a2, ...) are joined along the given axis
    (default is the first one) into a single numpy array.
    Example:
    >>> concatenate( ([0,1,2], [5,6,7]) )
    array([0, 1, 2, 5, 6, 7])

In [9]: f = arange(-500,500,1)
 → -500〜499の範囲のarray([...])

In [10]: grid(True)

In [11]: plot(f,abs(concatenate((b[500:],b[:500]))))
Out[11]: [<matplotlib.lines.Line2D instance at 0xb360ca4c>]

In [12]: show()

f:id:to33k:20111226152737p:plain