FrontPage
/
Python
/
Scipy+Numpy
-- 雛形とするページ --
10Th Annual Moonlight Music Romantic Days Celebration Concert 21409
20 Fun Free And Meaningful Things Every Student Can Do It Christmas Vacation
20 Fun Free And Meaningful Things Every Student Can Repeat This Christmas Vacation
20 Fun Free And Meaningful Things Every Student Can Take The Plunge Christmas Vacation
2006 Graduation Gift Suggestions For College Students
3Verse?
5 Birthday Gift Ideas For That Special Girl
5 Ideas For A Retirement Gift This Also Surely Be Appreciated
5 Solutions To Save On Online Concert Tickets
5 Suggestions For A Retirement Gift That All Retiree Will Clearly Love
5 Tips For A Retirement Gift Anyone Surely Be Appreciated
5 Ways To Save On Online Concert Tickets
6 NoFail Gift Suggestions For Your Spouse
A Facts Gift Tips For Women Aged 20 To 30
A Means To Buying Discount Concert Tickets
A Path To Buying Discount Concert Tickets
Adam Lambert Concert Tickets How We Can Find Them
Affordable Florida Marlins Tickets Available
An Easy Grab For Hard To Obtain Tickets
Anniversary Gifts 5 Gift Applying For Grants What To Anniversary Gift
Anniversary Gifts 5 Gift Tips On What The Anniversary Gift
Anniversary Gifts 5 Gift Tips On What To Anniversary Gift
Apologetix In Concert April 29Th 2011
Archway
Arealeum
Barry Manilow Tickets Concert Tickets For Barry Manilow Are Easier To Find Online
Best Dallas Music Venues
Best Ways To Win Tickets To An Event
Bitwave Unique Features
Bob Dylan Concert Ticket Get In For Free
BracketName
Britney Spears Tickets The World Class Young Music Icon
Brokering Concert Tickets 101
Burnsville Riddlefest Celebrates Traditional Mountain Music On Feb 19
Buy Bieber Concert Tickets
Buy Concert Tickets Online
Buying Concert Tickets
Buying Country Concert Tickets At Discounted Rates
Buying Discount Britney Spears Tickets Tips Tricks To Achieve The Tickets You Want
Buying HardToFind Concert, Sport, Theater, Season And Event Tickets
Buying Your Justin Bieber Concert Tickets
Bzetcoin
Carole King Concert Tickets The Very Value For Your Money
Casino detailliert was Sie müssen lernen
Catch The Sensation, Grab The Adam Lambert Concert Tickets
Cheap Bon Jovi Concert Tickets
Cheap Christmas Gifts For Your Boyfriend
Cheap Christmas Gifts Inside Your Boyfriend
Cheap Christmas Gifts To Get Your Boyfriend
Cheap Concert Tickets
Cheap Concert Tickets Save Money Tickets Where To Look
Cheap Last Minute Christmas Gift Ideas
Cheap Sports Event Tickets
Cheap Taylor Swift Concert Tickets
Child Safety Poster An Essential Tool For Letting Babies And Toddlers Explore
Chris Brown Concert Tickets
Chris Tomlin Kicks Off Burning Lights Concert Tour With Free Tickets
Christmas Floki X Unique Features
Christmas Floki X?
Christmas Gifts For Kids Best Of The Highest On Associated Content
Christmas Gifts For The Musicians
Christmas Giftsbest Xmas Presents For Men Women Girls Boys Festive BabyToddler Ideas
Christmas Presents For 2010
Christmas StockingStuffer Gifts For Dads AllInOne Remotes To Concert Tickets
Concert Tickets Buying Them Safely On Ebay
Country Music Alphabet Vince Gill
Country Songs Alphabet Vince Gill
Country Songs You May Not Detest Even If You Dont Like Nation Music
Country Tunes You Might Not Detest Even If You Dont Like Nation Songs
Craigslist Tickets Sports Theatre Las Vegas Save Money
Create Really Own Valentines Gift Basket
Dad, Be Her Hero This Valentines Day Taylor Swift Concert Tickets Perfect Gift
Dads Run In Pumps For Hannah Montana Concert Tickets
Dallas Live Music 101 What Is Often A Street People
Dallas Live Music 101 Where Are You Able To Buy Concert Tickets
Dallas Live Music 101 Where Is It Possible To Buy Concert Tickets
David Archuleta His Taste In Music
Decadent LastMinute Christmas Gifts For Under 100
Der ultimative Tipps für Blackjack
Details Zum Roulette Mit Bonus Man kann einfach nicht Ignorieren
Deutsche Blackjack Zu Spielen Online Leistungs Verhältnis Tipps Beratung Von a Kenntnisreich Veteran
Deutsche Casino Spiel Revealed Tipps zur Verstehen
Die effektivste Neue Casino Information Verfügbar
Discount La Lakers Tickets How To Look
Don Henley Live Performance At The Hard Rock Casino
Enjoy The Fairy Tale Music Of Tailor Swift
Enjoy Your Favorite Show By Expending Less Through Online Booking Of Tickets
Entertainment Music Faq
Erfahrene Glücksspielgesetze Beratung Tipps
Every Breath You Take, Buying Your Sting Concert Tickets
Ferndale Higher School Choir And Orchestra Fall Live Performance
Find Affordable Live Performance Tickets
Find Event Tickets Online Using Google And The Bbb
Find Her A Unique Gift Could Love
Find Her A Unique Gift Your Girl Friend Will Love
Finding A Really Perfect Bridesmaid Gift
Finding A Really Wonderful Bridesmaid Gift
Finding Concert And Sports Tickets Online
Finding Exactly How To Buy Concert Tickets
Finding Tickets For Concerts Online Inside Of Most Trouble Free Way
Finding Tickets To Concerts And Events Is Easy Online
Fire Safety During Camping
FitBurn
FormattingRules
Forschung Deutschland Die Besten Online Roulette Durch die Verwendung dieser Beratung
Four Best Reasons When You Buy Tickets Online
Four Best Reasons Why You Ought To Buy Tickets Online
FrontPage
FrontPage/30Design
FrontPage/AWS
FrontPage/After Effects
FrontPage/AppleID-iCloud
FrontPage/Bitcoin
FrontPage/Blender
FrontPage/Download Application
FrontPage/FiSig
FrontPage/GLROWS/LogoAnimation調査
FrontPage/GoogleAppEngine
FrontPage/HTML+JS+CSS
FrontPage/HTML+JS+CSS/jQuery-DragandDropPlugin
FrontPage/HTML+JS+CSS/jQuery-DragandDropPlugin/PHP+jsonの保存と読み込み
FrontPage/OpenFoam
FrontPage/PHP
FrontPage/Python
FrontPage/Python その2
FrontPage/Python/Matplotlib
FrontPage/Python/OpenCV
FrontPage/Python/OpenGL
FrontPage/Python/Pandas
FrontPage/Python/PostgreSQL
FrontPage/Python/PySide
FrontPage/Python/PySide/QPainter-skelton.py
FrontPage/Python/PySide/mpl_stylesheet.py
FrontPage/Python/PySide/plotter.py
FrontPage/Python/PySideその2
FrontPage/Python/SQLite
FrontPage/Python/Scipy+Numpy
FrontPage/Python/Scrayping
FrontPage/Python/Sound
FrontPage/Python/Sphinx
FrontPage/Python/module-list(151120)
FrontPage/Python/windowsモジュール
FrontPage/Python/資格試験
FrontPage/RaspberryPi
FrontPage/SEO
FrontPage/ShipsLogs
FrontPage/SublimeText
FrontPage/TensorFlow
FrontPage/Tips
FrontPage/UML
FrontPage/Ubuntu
FrontPage/Visualization
FrontPage/WeddingMovie
FrontPage/Windows
FrontPage/Windowsプログラミング
FrontPage/bat処理
FrontPage/facebook
FrontPage/ffmpeg
FrontPage/git
FrontPage/pukiwiki
FrontPage/python/Flask
FrontPage/python/SQLalchemy
FrontPage/python/logger
FrontPage/python/packageing
FrontPage/python/twitterbot
FrontPage/test
FrontPage/web
FrontPage/サクラレンタルサーバーTips
FrontPage/ホーンスピーカ
FrontPage/モジュール管理(ライブラリ)
FrontPage/一流Youtube
FrontPage/会計ソフト
FrontPage/機械学習
FrontPage/機械学習/QLearning
FrontPage/物理シミュレーション
FrontPage/目指せパイソニスタ
FrontPage/自宅サーバー
FrontPage/製作ヒアリング
FrontPage/製作記録100
Garth Brooks And Toby Keith Set Benefit Concert Date
George Strait, Martina Mcbride St Louis Tickets Available November 18
George Strait, Martina Mcbride St Louis Tickets You Can Find November 18
Get Cheap Concert Tickets For Sale For The Greatest Bands
Get Their Hands On Celine Dion Tickets Fast
Get Their Hands On The Tickets Of Enchanting Events
Get Your Hands On The Tickets Of Enchanting Events
Get Your Rush Concert Tickets Online
Getting Tough To Get Concert Tickets
Getting Your Hands On Quality Concert Tickets
Gift Ideas For Teenage Boys
Gift Suggestions For Teenage Boys
Gift Suggestions For The 12 Days Of Christmas
Gift Tips For Teenage Boys
Gift Tips For The 12 Days Of Christmas
Glee Tour Tickets Glee Solid Hits The Stage This May
Glücksspiel Online gesetze Informationen Fakten Sie wissen müssen
Going Quickly Gaga Tickets
Good Schemes Of Concert Tickets Vendors
Grab The U2 Tickets Of Simple Shows
Grab The U2 Tickets Of Your Favorite Shows
Grab Those Bon Jovi Concert Tickets
Great Late Holiday Gift Ideas
Green Wedding Gift Ideas
Guidelines Exactly How To To Score Cheap Concert Tickets
Guidelines Regarding How To Score Cheap Concert Tickets
Handy Things To Know About Concert Tickets
Hannah Montana Concert Tickets
Hannah Montana Concert Tickets Are Hot
Have A Rocking And Rolling Time With John Mayer Concert Tickets
Heiko Finance
Help
HiMen
Hilfe benötigen mit Roulette lesen Sie dies
Hostgator Promotional Code Tips Instructions
How Acquire Keith Urban Concert Tickets
How Anyone Buy A Legislator Sex, Spankings And Britney Spears Tickets
How Being A Ticket Broker In Order To Buy Promote Concert Tickets
How Come Across Cheap Tickets For Britney Spears See Her One More Time
How Consumer Keith Urban Concert Tickets
How Coordinator Ticket Broker Learn To Buy Promote Concert Tickets
How Decide To Buy Pink Concert Tickets
How Discover Cheap Concert Tickets 5 Surefire Techniques
How Invest In Keith Urban Concert Tickets
How Locate Backstage Concert Tickets
How To Book Concert Tickets In Los Angeles
How To Buy Keith Urban Concert Tickets
How To Choose A Gift For Your Loved Ones
How To Discover Cheap Tickets For Britney Spears See Her One More Time
How To Establish A Birthday Gift Basket
How To Generate Money From Selling Concert Tickets
How To Get Concert Tickets Before You Can Purchase Out
How To Get Michael Buble Concert Tickets Without A Fuss
How To Get Tickets From Radio Stations Tampa Florida Fashion
How To Leonard Cohen Concert Tickets
How To Locate Cheap Tickets
How To Obtain Cheap And Free Concert Tickets
How To Obtain Concert Tickets You Know Are Going To Sell Out
How To Produce Birthday Gift Basket
How To Scout And Avail For Reasonable Concert Tickets
How To Seek Great Christmas Ideas For Men
How Unearth Sold Out Concert Tickets
How You Can Also Make Money By Selling Disney On Ice Tickets
HyperCycle
Important Consider When Selling Your Concert Tickets Online
Important Facts To Consider When Selling Your Concert Tickets Online
In Anbetracht Roulette Siehe Dieses Erste
Indie Music Promotion Get Signed Independently
Indie Songs Promotion Get Signed Independently
InterWiki
InterWikiName
InterWikiSandBox
Jessie J Tickets Bournemouth What Could Be The Best Approach To Buy Them
John Legend Tour Tickets Ways To Find Them Right Now
Jonas Brothers 2009 World Tour Concert Dates Announced
Jonas Brothers Concert Tickets Best Bets
Justin Bieber Attacked With Eggs Throughout Australian Concert Video
Justin Bieber Tickets My World Tour
Katy Perry Tickets California Dreams Tour 2011
KvantsAI
Lady Gaga Concert Tickets The Perfect Performance For Their Little Price
Lady Gaga Tickets Chicago Theatre
Lee Dewyze Hometown Concert
Live Nation Giving Away Pair Of Season Pass Tickets
Live Nation Providing Away Pair Of Season Move Tickets
Livenation Concert Deal On Groupon Today
Make Christmas Less Stressed And More Blessed
Maroon 5 Concert Tickets Hands Throughout Tour
Maroon Five Tickets Hands All More Than Tour
MemeFarm
MenuBar
MetaMic E-Sports Game
Metamic (MEG) Token Economy
Metamic (MEG) Unique Features
Methods To Obtain Concert Tickets Safely And Also At Great Value From The Internet
Methods To Obtain Concert Tickets Safely And Great Value From The Internet
More Healing In The Heartland Relief Benefit Concert Tickets Become Available
Music Artist Fiona Apple Bio
Music Is Connection Towards Your Teen
My First Musical Concert
Nachdenken über Schlagen Online Blackjack Sehen Sie sich diese Zuvor
Nashville Is Not Just For The Nation Music Lover
Nashville Music Scene The Wildhorse Saloon
Nfl Tickets Nfc West Preview
Nfl Tickets Preseason Predictions Nfc South
Online Concert Tickets
Online Dating 4 Major Benefits Associated With Online Dating
Online Dating 4 Major Primary Advantages Of Online Dating
Online Spielen Roulette Informationen Sie wissen müssen
Online Ticket Brokers Consider The Hassle Outside Your Event Ticket Search
Online Ticket Brokers Consider The Hassle Regarding Your Event Ticket Search
Online Ticket Brokers Take The Hassle From The Your Event Ticket Search
Order Magnetic Signs For Concert Events
OtterHome
PHP
Parallel Finance
Pink Floyd Wish Possibly Here Concert Tickets At Discount November 28
Pink Floyd Wish You Are Here Concert Tickets Worth The Money November 28
Pink Floyd Wish You Had Been Here Concert Tickets On Sale November 28
Pink Floyd Wish You Had Been Here Live Performance Tickets On Sale November 28
Polygame
Prevent Future Listening To Reduction By Going To A Hearing Middle
PtggQfCn
PukiWiki
PukiWiki/1.4
PukiWiki/1.4/Manual
PukiWiki/1.4/Manual/Plugin
PukiWiki/1.4/Manual/Plugin/A-D
PukiWiki/1.4/Manual/Plugin/E-G
PukiWiki/1.4/Manual/Plugin/H-K
PukiWiki/1.4/Manual/Plugin/L-N
PukiWiki/1.4/Manual/Plugin/O-R
PukiWiki/1.4/Manual/Plugin/S-U
PukiWiki/1.4/Manual/Plugin/V-Z
Purchasing Obtaining Concert Tickets
PySide
Rascal Flatts Tickets Why It Is Hard To Get Rascal Flatts Ticket
RecentDeleted
Review Of Hannah Montana Miley Cyrus Best Of Both Worlds Concert In Disney Digital 3D
Ringing In My Ears Following A Concert Is This Regular
Robbie Williams Concert Enable You To Get Good Tickets With These Tips
Robbie Williams Concert Take You Good Tickets With These Tips
Roch Deals For October 9911 Chris Brown Tickets, Food Deals Galore More
Rock With All The Camp Rock Concert Tickets
Rock With The Camp Rock Concert Tickets
Rolling Stones Tickets Tips When Buying The Tickets
Roulette Strategien und Taktik
San Francisco Giants Tickets Fantasy Predictions Analyzed
SandBox
Sayari
Scooping The Jack Johnson Concert Tickets
See A Legend Receiving Your Roger Waters Tickets
Selling Concert Tickets Overview
Shop From Dealandyou And Put Free Flo Rida Concert Tickets
Slipknot Concert Tickets Good Deals Around
Social Service
Sold Out Tickets Required
Special Gifts Like Tickets Can Also Be Purchased Online
Spice Girls Tickets Where To Get Spice Girls Concert Tickets And Tour Tickets
Sting Tickets And Tour Dates 2012
Subway Fresh Buzz 5 Concert Tickets
Subway Offers 5 Concert Tickets For Nickelback And Also The Fray Concerts
Subway Offers 5 Concert Tickets For Nickelback As Well As The Fray Concerts
Summer Concerts And Music Festivals In Charlotte, Nc
Super Bowl 2010 Concerts
Swift Tickets Fearless Tour 2010
Taylor Swift Concert Tickets These While There Are Chance
Taylor Swift Concert Tickets Expected To Sell Out Quickly
Taylor Swift Concert Tickets In Greenville, Sc
Taylor Swift Tickets Speak Now Tour
Taylor Swift Tour 2010 Dates Announced And Tickets On Sale
The Associated With Purchasing Online Concert Tickets
The Convenience Of Buying Concert Tickets Of Your Liking Online
The Convenience Of Buying Live Performance Tickets Of Your Choice Online
The Convenience Of Purchasing Online Concert Tickets
The Ease Of Buying Concert Tickets Which You Decide Online
The Ease Of Purchasing Online Concert Tickets
The FitBurn
The Method To Purchase Tickets To Events
The Mintera Token
The Most Treasured Concert Ticket At That Time
The Online Classifieds Industry Guide
The Online Classifieds Sell And Buy Guide
The Six Sigma Music Business Keep Your Audiences Coming Back For More
The Social Bookmark Submitting Teaching Youngsters Fire Safety
The Stars Go Blue For Colon Cancer 2Nd Annual Benefit Concert
The To Help Obtain Taylor Swift Concert Tickets
The Tradition Of Ads Still Holds True
The Ultimate Christmas Gift
Tips Acquire Cheap Event Tickets
Tips Carried Out Correctly Tickets For Concert
Tips For Choosing Concert Tickets And Sports Tickets
Tips For Getting Concert Tickets And Sports Tickets
Tips For Gift Baskets
Tips For Selecting Concert Tickets And Sports Tickets
Tips Means Purchase Tickets To Events
Tips On Promoting Your Music Band
Tips Process To Purchase Tickets To Events
Tips Which Will Get Genuine Cheap Concert Tickets
Top 10 Best Christmas Gifts 2010 For Him
Top 3 Ways To Get Free Tickets To Cleveland Occasions
Top 3 Ways To Win Free Tickets To Cleveland Events
Top 5 Hard RockMetal Concert Tickets
Top 5 Rock And Pop Concert Tickets
Top Websites To Funds From Online Easily
Useful Christmas Present Concepts For College Students
Valentines Day Gift Concepts For A Younger Man
Valentines Day Gift Concepts For Your Boyfriend 2010
Valentines Day Gift Suggestions For Your Boyfriend 2010
Valentines Day Gift Tips For Your Boyfriend 2010
Vehron
VetAPP
What Is Bitwave?
What To Look Around For To Components Fake Concert Tickets
What is Christmas Floki X?
What is Crypto Lottery
What is Honorworld?
Whats Greatest Place To See Live Music In The Capital
Whats Leading Place To Discover Live Music In The Capital
Whats Next At Seaworld Christmas Is Over, Solely For Kids Starts January 12
Whats Quite Place Notice Live Music In Liverpool
Where Invest In Concert Event Tickets
Where Locate Inexpensive Concert Tickets
Where To Locate Inexpensive Concert Tickets
Why Theres Nothing Like A Gaga Concert
WikiEngines
WikiName
WikiWikiWeb
Win Madonna Tickets 1 Fm At Pridefest
Win Taylor Swift Concert Tickets With St Louis Country Music Station The Bull
Wrap Your Current Shopping Early With Online Tickets
Wrap Your Shopping Early With Online Tickets
YukiWiki
am Casino von diesen Gebrauch machen Techniken
an excellent discount
chamnha
firstpage
florester
hohe Qualität Einzelheiten zu Casino Sie müssen
idodar
n
pukiwiki
soft1
wie ich gefunden die Realität betreffend SlotSpiele
x
** numpy [#pbad2eee] [[→ndarray:rest-term>http://rest-term.com/archives/2999/]] ** ベクトライズによる高速化 [#vdd41bc9] http://postd.cc/python_meets_julia_micro_performance/ いったん配列を取得してから、それをループ処理し、要素1ずつにhex()とint()関数を適用するのは一見無駄なことのようにも見えます。ありがたいことに、Numpyはループというより、むしろ配列に対し関数を呼び出す方法を提供します。すなわちnumpy.vectorize()関数です。この関数は、一度に1つのオブジェクトを操作する関数を入力としてとります。これは配列に作用する新しい関数を返します。 vhex = np.vectorize(hex) vint = np.vectorize(int) def parse_int_numpy(): n = np.random.randint(0,2**32-1,1000) s = vhex(n) m = vint(s,16) np.all(m == n) return s ** (重要) 配列操作の注意! [#w3deae23] a = [0,1,2,3,4,5] In[8]: a Out[8]: [0, 1, 2, 3, 4] In[9]: a[0:3] Out[9]: [0, 1, 2] window = 100 start = 0 end = 99 のとき b = x[start : end+1] もしくは b = x[start : start+window] In[10]: window=100 In[11]: start=0 In[12]: end = 99 In[13]: x = range(200) In[14]: b = x[start:end+1] In[15]: len(b) Out[15]: 100 In[16]: b = x[start:start+window] In[17]: len(b) Out[17]: 100 ** インストール [#ue151d9b] アップデートの際にはまったので備忘録を残します。numpyをアップデートしようとした際にMingw32Compilerのなんちゃらでエラーが発生。 pip install numpy -U アンインストール後、再度インストールしようとしてもエラー。 pip install numpy そこで, [[こちらから>http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy]]numpy‑1.9.3+mkl‑cp27‑none‑win_amd64.whlをダウンロード。適当なフォルダにおいて、'shift+右クリック'>'コマンドラインでひらく'をして, pip install 'numpy-1.9.3*****.whl' .whlからインストールすると一発で上手くいった。良かった。。。 ** ログの保存 [#l110da97] def debuglog(name='', data=[]): with open('log.csv', 'a') as f: writer = csv.writer(f, lineterminator='\n') writer.writerow(name) writer.writerow(data) ** ログの保存2 [#y65afdea] from datetime import date import csv def debuglog(s=None, data=None): d = date.today().isoformat() with open('log.csv', 'a') as f: writer = csv.writer(f, lineterminator='\n') if not s is None: writer.writerow([d , s]) if not data is None: writer.writerow([d, data]) print s, data ** バイナリデータの読み書き [#gd88ed0e] http://hydrocul.github.io/wiki/numpy/ndarray-io.html *** np.save, np.load [#f95901d9] ndarr1 = np.array([0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]) np.save('test.npy', ndarr1) ndarr2 = np.load('test.npy') *** np.savez, np.load [#j534b0de] np.savez を使うと複数のndarrayを名前付きで、しかも圧縮してファイルに保存できる。保存したファイルを読み込むには上と同じく np.load を使う。 np.load はファイルの保存形式を拡張子で判断しているようで、 np.savez での保存形式の場合は拡張子は .npz を使う。 ndarr1 = np.array([0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]) ndarr2 = np.array([10, 20, 30]) np.savez('test.npz', x=ndarr1, y=ndarr2) ndarr3 = np.load('test.npz') print(ndarr3['x']) # 出力結果 # [ 0. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1. ] print(ndarr3['y']) # 出力結果 # [10 20 30] *** np.savetxt, np.loadtxt [#v90400eb] 2次元ndarryをテキスト形式で保存・読み込み. 区切り文字は空白がデフォルトなのでcsvにするためにはdelimiterオプションを利用 ndarr1 = np.array([[1., 2., 3.], [4., 5., 6.], [7., 8., 9.]]) np.savetxt('test.csv', ndarr1, delimiter=',') ndarr2 = np.loadtxt('test.csv', delimiter=',') print(ndarr2) # 出力結果 # [[ 1. 2. 3.] # [ 4. 5. 6.] # [ 7. 8. 9.]] ** 初めての信号処理 [#a94b925d] 人工信号に対して、FFT、STFT解析を行うサンプルコード [[→初めての信号処理>https://gist.github.com/peace098beat/b233857e44b1abe3bebf]] ** オーディオのロード [#sac51b33] + scipyを使う場合 返り値のdataはnumpy.array() # オーディオのロード from scipy.io.wavfile import read fs, data = read(filename) data = data[0:fs/2-1] ** Numpy Array (np.ndarray) [#wdb3c394] ary = np.array([1,2,3,4,5]) = np.array( (1,2,3,4,5)) # ゼロベクトル ary = np.zeros(3) # 1次元の場合はスカラーでよい ary = np.zeros((3, 2)) # N次元の場合はタプルを忘れずに # 空配列 ary = np.empty((Nx,Ny)) ary = np.empty_like(ary0) # 1ベクトル ary = np.ones((Nx,Ny)) ary = np.ones_like(ary0) # 単位行列 ary = identity(N) #NxNの単位行列が生成される - ndarrayの属性・プロパティ ary = np.array([1,2,3]) # データタイプ(np.bool, np.int, np.float, np.complex... np.int32, np.float64...) ary.dtype # タイプの変更 ary = ary.astype(np.float) # 配列サイズ ary = np.empty((3,5,2), dtype = np.float) ary.shape >> (3,5,2) # 配列次元 ary = np.empty((3,5,2), dtype = np.float) ary.ndim >> 3 # 要素数 ary = np.empty((3,5,2), dtype = np.float) ary.size >> 30 ** Numpy Array (ndarray) 便利機能 [#q7969d99] [[→The N-dimensional array>http://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html]] #ref(s-ndarray.jpg) [[→ndarray atribute and method>https://gist.github.com/peace098beat/9eb9270c97060ae0c48f]] ** Numpy dtype [#g7d9e97b] dtype_range = {np.bool_: (False, True), np.bool8: (False, True), np.uint8: (0, 255), np.uint16: (0, 65535), np.int8: (-128, 127), np.int16: (-32768, 32767), np.int64: (-2**63, 2**63 - 1), np.uint64: (0, 2**64 - 1), np.int32: (-2**31, 2**31 - 1), np.uint32: (0, 2**32 - 1), np.float32: (-1, 1), np.float64: (-1, 1)} ** オーディオI/O [#ra14cb50] pythonでオーディオを再生するにはpyaudioがよさそう。pyaudioに再生させるためには、バイナリに戻す必要がある。 [[→numpy.unpackbit>http://docs.scipy.org/doc/numpy/reference/generated/numpy.unpackbits.html]] >>> a = np.array([[2], [7], [23]], dtype=np.uint8) >>> a array([[ 2], [ 7], [23]], dtype=uint8) >>> b = np.unpackbits(a, axis=1) >>> b array([[0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 0, 1, 1, 1]], dtype=uint8) ** np.frombufferで24bitファイルを読み込む [#u09b00d3] [[→Speed up loading 24-bit binary data into 16-bit numpy array>http://stackoverflow.com/questions/22128961/speed-up-loading-24-bit-binary-data-into-16-bit-numpy-array]] output = np.frombuffer(data,'b').reshape(-1,3)[:,1:].flatten().view('i2') ** sndhdr — サウンドファイルの識別 [#y37af40a] path = './audio/sin_44100_24bit_stereo_5s.wav' print sndhdr.what(path) >>> ('wav', 44100, 2, -1, 24) print sndhdr.whathdr(path) >>>('wav', 44100, 2, -1, 24) import sndhdr, wave, struct if sndhdr.what(fname)[0] != 'wav' raise StandardError("file doesn't have wav header") try: wav = wave.open(fname) params = (nchannels,sampwidth,rate,nframes,comp,compname) = wav.getparams() frames = wav.readframes(nframes*nchannels) finally: wav.close() out = struct.unpack_from ("%dh" % nframes*nchannels, frames) ** 配列の拡張(行列の各列ベクトルを標準化) [#t268cbfc] ** 配列の拡張(行列の各列ベクトルを標準化) [#n529e4d8] X = np.arange(12).reshape((3,4)) >> array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]]) // 平均ベクトル m = np.mean(X, axis=0) >> array([ 4., 5., 6., 7.]) // X-m そのまま各行ごとに演算できる >> array([ [-4., -4., -4., -4.], [ 0., 0., 0., 0.], [ 4., 4., 4., 4.]]) //標準偏差 s = np.std(X, axis=0) >> array([ [-0.3381028 , -1.20939778, 0.5124003 , 1.35738762], [-2.12531859, 0.60120223, 1.75273089, 0.4617148 ], [-0.14482128, -0.73401208, 0.63781457, -0.33835372]]) // 標準化 // (X-m)/s >> array([ [-1.22474487, -1.22474487, -1.22474487, -1.22474487], [ 0. , 0. , 0. , 0. ], [ 1.22474487, 1.22474487, 1.22474487, 1.22474487]]) なんて便利なんだ。 ** ** 配列の拡張(行列の各行ベクトルを標準化) [#y6f5308c] ** ** 配列の拡張(行列の各行ベクトルを標準化) [#z84ef687] ポイントはm = np.mean(X, axis=1)[:, np.newaxis] np.newaxisは軸を追加する。これによりnumpyが自動で軸ごとに演算してくれる。[[ブロードキャスト>http://seesaawiki.jp/met-python/d/array#content_4_12]]というらしい。 X=np.arange(12).reshape(3,4) [[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11]] m = np.mean(X, axis=1) [ 1.5 5.5 9.5] m.T[:,np.newaxis] [[ 1.5] [ 5.5] [ 9.5]] X-m [[-1.5 -0.5 0.5 1.5] [-1.5 -0.5 0.5 1.5] [-1.5 -0.5 0.5 1.5]] ** # numpy配列をプリントした場合の表示桁数 [#r9594de7] np.set_printoptions(precision=3) def ndprint(a, format_string='{0:.2f}'): """ ndarrayをprintする関数 :example: ndprint(x) """ return [format_string.format(v, i) for i, v in enumerate(a)] def ndprints(s, a, format_string='{0:.2f}'): """ ndarrayをprintする関数 :example: ndprint(x) """ print s, [format_string.format(v, i) for i, v in enumerate(a)] ** 配列の結合 [#h5fb7178] >>> a = np.arange(9).reshape((3,3)) >>> a array([[0, 1, 2], [3, 4, 5], [6, 7, 8]]) >>> b = np.arange(8,-1,-1).reshape((3,3)) >>> b array([[8, 7, 6], [5, 4, 3], [2, 1, 0]]) ## numpy.dstack() で二次元配列を結合して三次元配列にする >>> np.dstack((a,b)) array([[[0, 8], [1, 7], [2, 6]], [[3, 5], [4, 4], [5, 3]], [[6, 2], [7, 1], [8, 0]]]) ## numpy.hstack() で列方向に結合 >>> np.hstack((a,b)) array([[0, 1, 2, 8, 7, 6], [3, 4, 5, 5, 4, 3], [6, 7, 8, 2, 1, 0]]) ## numpy.vstack() で行方向に結合 >>> np.vstack((a,b)) array([[0, 1, 2], [3, 4, 5], [6, 7, 8], [8, 7, 6], [5, 4, 3], [2, 1, 0]]) ## numpy.dsplit() で三次元配列を分割 >>> a = np.arange(16).reshape(2,2,4) >>> a array([[[ 0, 1, 2, 3], [ 4, 5, 6, 7]], [[ 8, 9, 10, 11], [12, 13, 14, 15]]]) >>> np.dsplit(a,2) [array([[[ 0, 1], [ 4, 5]], [[ 8, 9], [12, 13]]]), array([[[ 2, 3], [ 6, 7]], [[10, 11], [14, 15]]])] ## numpy.hsplit() で列方向に分割 >>> a = np.arange(16).reshape(4,4) >>> a array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) >>> np.hsplit(a,2) [array([[ 0, 1], [ 4, 5], [ 8, 9], [12, 13]]), array([[ 2, 3], [ 6, 7], [10, 11], [14, 15]])] ## numpy.vsplit() で行方向に分割 >>> np.vsplit(a,2) [array([[0, 1, 2, 3], [4, 5, 6, 7]]), array([[ 8, 9, 10, 11], [12, 13, 14, 15]])] ## numpy.transpose() で配列を転置 >>> a = np.array([[1, 2], [3, 4]]) >>> a array([[1, 2], [3, 4]]) >>> np.transpose(a) array([[1, 3], [2, 4]]) ## ndarray.T でも良い >>> a.T array([[1, 3], [2, 4]]) ## numpy.swapaxes() で軸の交換 >>> a = np.array([[1,2,3]]) >>> np.swapaxes(a, 0, 1) array([[1], [2], [3]])
タイムスタンプを変更しない
** numpy [#pbad2eee] [[→ndarray:rest-term>http://rest-term.com/archives/2999/]] ** ベクトライズによる高速化 [#vdd41bc9] http://postd.cc/python_meets_julia_micro_performance/ いったん配列を取得してから、それをループ処理し、要素1ずつにhex()とint()関数を適用するのは一見無駄なことのようにも見えます。ありがたいことに、Numpyはループというより、むしろ配列に対し関数を呼び出す方法を提供します。すなわちnumpy.vectorize()関数です。この関数は、一度に1つのオブジェクトを操作する関数を入力としてとります。これは配列に作用する新しい関数を返します。 vhex = np.vectorize(hex) vint = np.vectorize(int) def parse_int_numpy(): n = np.random.randint(0,2**32-1,1000) s = vhex(n) m = vint(s,16) np.all(m == n) return s ** (重要) 配列操作の注意! [#w3deae23] a = [0,1,2,3,4,5] In[8]: a Out[8]: [0, 1, 2, 3, 4] In[9]: a[0:3] Out[9]: [0, 1, 2] window = 100 start = 0 end = 99 のとき b = x[start : end+1] もしくは b = x[start : start+window] In[10]: window=100 In[11]: start=0 In[12]: end = 99 In[13]: x = range(200) In[14]: b = x[start:end+1] In[15]: len(b) Out[15]: 100 In[16]: b = x[start:start+window] In[17]: len(b) Out[17]: 100 ** インストール [#ue151d9b] アップデートの際にはまったので備忘録を残します。numpyをアップデートしようとした際にMingw32Compilerのなんちゃらでエラーが発生。 pip install numpy -U アンインストール後、再度インストールしようとしてもエラー。 pip install numpy そこで, [[こちらから>http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy]]numpy‑1.9.3+mkl‑cp27‑none‑win_amd64.whlをダウンロード。適当なフォルダにおいて、'shift+右クリック'>'コマンドラインでひらく'をして, pip install 'numpy-1.9.3*****.whl' .whlからインストールすると一発で上手くいった。良かった。。。 ** ログの保存 [#l110da97] def debuglog(name='', data=[]): with open('log.csv', 'a') as f: writer = csv.writer(f, lineterminator='\n') writer.writerow(name) writer.writerow(data) ** ログの保存2 [#y65afdea] from datetime import date import csv def debuglog(s=None, data=None): d = date.today().isoformat() with open('log.csv', 'a') as f: writer = csv.writer(f, lineterminator='\n') if not s is None: writer.writerow([d , s]) if not data is None: writer.writerow([d, data]) print s, data ** バイナリデータの読み書き [#gd88ed0e] http://hydrocul.github.io/wiki/numpy/ndarray-io.html *** np.save, np.load [#f95901d9] ndarr1 = np.array([0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]) np.save('test.npy', ndarr1) ndarr2 = np.load('test.npy') *** np.savez, np.load [#j534b0de] np.savez を使うと複数のndarrayを名前付きで、しかも圧縮してファイルに保存できる。保存したファイルを読み込むには上と同じく np.load を使う。 np.load はファイルの保存形式を拡張子で判断しているようで、 np.savez での保存形式の場合は拡張子は .npz を使う。 ndarr1 = np.array([0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]) ndarr2 = np.array([10, 20, 30]) np.savez('test.npz', x=ndarr1, y=ndarr2) ndarr3 = np.load('test.npz') print(ndarr3['x']) # 出力結果 # [ 0. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1. ] print(ndarr3['y']) # 出力結果 # [10 20 30] *** np.savetxt, np.loadtxt [#v90400eb] 2次元ndarryをテキスト形式で保存・読み込み. 区切り文字は空白がデフォルトなのでcsvにするためにはdelimiterオプションを利用 ndarr1 = np.array([[1., 2., 3.], [4., 5., 6.], [7., 8., 9.]]) np.savetxt('test.csv', ndarr1, delimiter=',') ndarr2 = np.loadtxt('test.csv', delimiter=',') print(ndarr2) # 出力結果 # [[ 1. 2. 3.] # [ 4. 5. 6.] # [ 7. 8. 9.]] ** 初めての信号処理 [#a94b925d] 人工信号に対して、FFT、STFT解析を行うサンプルコード [[→初めての信号処理>https://gist.github.com/peace098beat/b233857e44b1abe3bebf]] ** オーディオのロード [#sac51b33] + scipyを使う場合 返り値のdataはnumpy.array() # オーディオのロード from scipy.io.wavfile import read fs, data = read(filename) data = data[0:fs/2-1] ** Numpy Array (np.ndarray) [#wdb3c394] ary = np.array([1,2,3,4,5]) = np.array( (1,2,3,4,5)) # ゼロベクトル ary = np.zeros(3) # 1次元の場合はスカラーでよい ary = np.zeros((3, 2)) # N次元の場合はタプルを忘れずに # 空配列 ary = np.empty((Nx,Ny)) ary = np.empty_like(ary0) # 1ベクトル ary = np.ones((Nx,Ny)) ary = np.ones_like(ary0) # 単位行列 ary = identity(N) #NxNの単位行列が生成される - ndarrayの属性・プロパティ ary = np.array([1,2,3]) # データタイプ(np.bool, np.int, np.float, np.complex... np.int32, np.float64...) ary.dtype # タイプの変更 ary = ary.astype(np.float) # 配列サイズ ary = np.empty((3,5,2), dtype = np.float) ary.shape >> (3,5,2) # 配列次元 ary = np.empty((3,5,2), dtype = np.float) ary.ndim >> 3 # 要素数 ary = np.empty((3,5,2), dtype = np.float) ary.size >> 30 ** Numpy Array (ndarray) 便利機能 [#q7969d99] [[→The N-dimensional array>http://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html]] #ref(s-ndarray.jpg) [[→ndarray atribute and method>https://gist.github.com/peace098beat/9eb9270c97060ae0c48f]] ** Numpy dtype [#g7d9e97b] dtype_range = {np.bool_: (False, True), np.bool8: (False, True), np.uint8: (0, 255), np.uint16: (0, 65535), np.int8: (-128, 127), np.int16: (-32768, 32767), np.int64: (-2**63, 2**63 - 1), np.uint64: (0, 2**64 - 1), np.int32: (-2**31, 2**31 - 1), np.uint32: (0, 2**32 - 1), np.float32: (-1, 1), np.float64: (-1, 1)} ** オーディオI/O [#ra14cb50] pythonでオーディオを再生するにはpyaudioがよさそう。pyaudioに再生させるためには、バイナリに戻す必要がある。 [[→numpy.unpackbit>http://docs.scipy.org/doc/numpy/reference/generated/numpy.unpackbits.html]] >>> a = np.array([[2], [7], [23]], dtype=np.uint8) >>> a array([[ 2], [ 7], [23]], dtype=uint8) >>> b = np.unpackbits(a, axis=1) >>> b array([[0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 0, 1, 1, 1]], dtype=uint8) ** np.frombufferで24bitファイルを読み込む [#u09b00d3] [[→Speed up loading 24-bit binary data into 16-bit numpy array>http://stackoverflow.com/questions/22128961/speed-up-loading-24-bit-binary-data-into-16-bit-numpy-array]] output = np.frombuffer(data,'b').reshape(-1,3)[:,1:].flatten().view('i2') ** sndhdr — サウンドファイルの識別 [#y37af40a] path = './audio/sin_44100_24bit_stereo_5s.wav' print sndhdr.what(path) >>> ('wav', 44100, 2, -1, 24) print sndhdr.whathdr(path) >>>('wav', 44100, 2, -1, 24) import sndhdr, wave, struct if sndhdr.what(fname)[0] != 'wav' raise StandardError("file doesn't have wav header") try: wav = wave.open(fname) params = (nchannels,sampwidth,rate,nframes,comp,compname) = wav.getparams() frames = wav.readframes(nframes*nchannels) finally: wav.close() out = struct.unpack_from ("%dh" % nframes*nchannels, frames) ** 配列の拡張(行列の各列ベクトルを標準化) [#t268cbfc] ** 配列の拡張(行列の各列ベクトルを標準化) [#n529e4d8] X = np.arange(12).reshape((3,4)) >> array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]]) // 平均ベクトル m = np.mean(X, axis=0) >> array([ 4., 5., 6., 7.]) // X-m そのまま各行ごとに演算できる >> array([ [-4., -4., -4., -4.], [ 0., 0., 0., 0.], [ 4., 4., 4., 4.]]) //標準偏差 s = np.std(X, axis=0) >> array([ [-0.3381028 , -1.20939778, 0.5124003 , 1.35738762], [-2.12531859, 0.60120223, 1.75273089, 0.4617148 ], [-0.14482128, -0.73401208, 0.63781457, -0.33835372]]) // 標準化 // (X-m)/s >> array([ [-1.22474487, -1.22474487, -1.22474487, -1.22474487], [ 0. , 0. , 0. , 0. ], [ 1.22474487, 1.22474487, 1.22474487, 1.22474487]]) なんて便利なんだ。 ** ** 配列の拡張(行列の各行ベクトルを標準化) [#y6f5308c] ** ** 配列の拡張(行列の各行ベクトルを標準化) [#z84ef687] ポイントはm = np.mean(X, axis=1)[:, np.newaxis] np.newaxisは軸を追加する。これによりnumpyが自動で軸ごとに演算してくれる。[[ブロードキャスト>http://seesaawiki.jp/met-python/d/array#content_4_12]]というらしい。 X=np.arange(12).reshape(3,4) [[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11]] m = np.mean(X, axis=1) [ 1.5 5.5 9.5] m.T[:,np.newaxis] [[ 1.5] [ 5.5] [ 9.5]] X-m [[-1.5 -0.5 0.5 1.5] [-1.5 -0.5 0.5 1.5] [-1.5 -0.5 0.5 1.5]] ** # numpy配列をプリントした場合の表示桁数 [#r9594de7] np.set_printoptions(precision=3) def ndprint(a, format_string='{0:.2f}'): """ ndarrayをprintする関数 :example: ndprint(x) """ return [format_string.format(v, i) for i, v in enumerate(a)] def ndprints(s, a, format_string='{0:.2f}'): """ ndarrayをprintする関数 :example: ndprint(x) """ print s, [format_string.format(v, i) for i, v in enumerate(a)] ** 配列の結合 [#h5fb7178] >>> a = np.arange(9).reshape((3,3)) >>> a array([[0, 1, 2], [3, 4, 5], [6, 7, 8]]) >>> b = np.arange(8,-1,-1).reshape((3,3)) >>> b array([[8, 7, 6], [5, 4, 3], [2, 1, 0]]) ## numpy.dstack() で二次元配列を結合して三次元配列にする >>> np.dstack((a,b)) array([[[0, 8], [1, 7], [2, 6]], [[3, 5], [4, 4], [5, 3]], [[6, 2], [7, 1], [8, 0]]]) ## numpy.hstack() で列方向に結合 >>> np.hstack((a,b)) array([[0, 1, 2, 8, 7, 6], [3, 4, 5, 5, 4, 3], [6, 7, 8, 2, 1, 0]]) ## numpy.vstack() で行方向に結合 >>> np.vstack((a,b)) array([[0, 1, 2], [3, 4, 5], [6, 7, 8], [8, 7, 6], [5, 4, 3], [2, 1, 0]]) ## numpy.dsplit() で三次元配列を分割 >>> a = np.arange(16).reshape(2,2,4) >>> a array([[[ 0, 1, 2, 3], [ 4, 5, 6, 7]], [[ 8, 9, 10, 11], [12, 13, 14, 15]]]) >>> np.dsplit(a,2) [array([[[ 0, 1], [ 4, 5]], [[ 8, 9], [12, 13]]]), array([[[ 2, 3], [ 6, 7]], [[10, 11], [14, 15]]])] ## numpy.hsplit() で列方向に分割 >>> a = np.arange(16).reshape(4,4) >>> a array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) >>> np.hsplit(a,2) [array([[ 0, 1], [ 4, 5], [ 8, 9], [12, 13]]), array([[ 2, 3], [ 6, 7], [10, 11], [14, 15]])] ## numpy.vsplit() で行方向に分割 >>> np.vsplit(a,2) [array([[0, 1, 2, 3], [4, 5, 6, 7]]), array([[ 8, 9, 10, 11], [12, 13, 14, 15]])] ## numpy.transpose() で配列を転置 >>> a = np.array([[1, 2], [3, 4]]) >>> a array([[1, 2], [3, 4]]) >>> np.transpose(a) array([[1, 3], [2, 4]]) ## ndarray.T でも良い >>> a.T array([[1, 3], [2, 4]]) ## numpy.swapaxes() で軸の交換 >>> a = np.array([[1,2,3]]) >>> np.swapaxes(a, 0, 1) array([[1], [2], [3]])
テキスト整形のルールを表示する