Pythonã使ç¨ãããã¼ã¿è§£æå ¥é01
ã©ãããããã°ã®ãµãã¿ã¤ãã«éãæ´æ°ããµãã£ã¦ããææ«ã§ãã
åã¯çç©å¦ãå°æ»ãã¦ããé¢ä¿ä¸Pythonã¯ä¸»ã«ç 究ãã¼ã¿ã®è§£æã«ä½¿ç¨ãã¦ãã¾ããæ¬è¨äºã§ã¯æç³ã«é¢ãã¦ä»ã¾ã§è©¦è¡é¯èª¤ãã¦å¾ã¦ãããã¦ãã¦ãå ±æãããã¨æãã¾ãã主ã«çãã¼ã¿ã®ã°ã©ãåã«ã¤ãã¦æ¸ãã¦ããã¾ããã¿ã¤ãã«ã«01ã¨ãã¤ãã¦ã¾ããå¾ç¶ãªãã¾ã¾ã«æ´æ°ãããªãããã°ãªã®ã§æ¬¡åä½ã«ã¯ãã¾ãæå¾ ããªãã§ãã ããã
åæ
æ¬è¨äºã§ã¯ä»¥ä¸ã®æ¡ä»¶ãåæã¨ãã¦ãã¾ããä¾ã®éãWindowsã¯å¯¾è±¡å¤ã§ãã®ã§Googleå çã«èããªã©ãã¦åç¨®å¿ è¦ã©ã¤ãã©ãªã®ã¤ã³ã¹ãã¼ã«ãªã©ãè¡ãªã£ã¦ãã ããããªãä¸è¨ã§ä½¿ç¨ãã¦ããpipã¯Windowsã«å¯¾å¿ãã¦ããªãã£ãã¨æãã®ã§ä»£ããã«easy_installã使ç¨ãããã¨ã«ãªãã¨æãã¾ãã
- OS: Debian Wheezy 64bit
- Python: Python 2.7
- å¿
è¦ã©ã¤ãã©ãª
- pip - Pythonã®ããã±ã¼ã¸ããã¼ã¸ã£ï¼ã©ã¤ãã©ãªã¤ã³ã¹ãã¼ã«ã«ä½¿ç¨ï¼
- numpy - Pythonã§æ°åã»è¡åè¨ç®ãé«éã«è¡ãã©ã¤ãã©ãª
- scipy - Pythonã§ç§å¦è¨ç®ãé«éã«è¡ãããã®ã©ã¤ãã©ãª
- matplotlib - Pythonã§ã°ã©ããæç»ããããã®ã©ã¤ãã©ãª
- mpltools - matplotlibã便å©ã«ä½¿ç¨ããããã®ãã¼ã«éï¼ä¸»ã«ãã¶ã¤ã³é¢ä¿ï¼
ãªãä¸è¨ä¾ã«ããã¦%ããå§ã¾ãè¡ã¯ã¿ã¼ããã«ã§ã®ä½æ¥ã表ãã¦ãã¾ããã¿ã¼ããã«ä½æ¥ã«é¢ãã¦ããããªãããã¯ä¸è¨Webãã¼ã¸ãåç §ãã¦ãã ããã
pip ã®ã¤ã³ã¹ãã¼ã«
Pythonã«ã¯pipã¨å¼ã°ããããã±ã¼ã¸ç®¡çã½ãããããã®ã§ãããå©ç¨ãã¾ããåã®å ´åã¯Pythonãä»ã®éçºãªã©ã«ã使ç¨ãã¦ããããpythonbrewã¨ããã½ããã§ãã¼ã¸ã§ãã³ã°ãè¡ãªã£ã¦ãã¾ãããç 究çµæã®è§£æç¨åº¦ã§ããã°OSã«ãã³ãã«ããã¦ããPythonã§åé¡ãªãã§ããããä¸è¨ã§ã¯OSãã³ãã«ãã¼ã¸ã§ã³ãå©ç¨ããä¾ãç´¹ä»ãã¾ãã
Debianç³»OSï¼Ubuntu, Debianï¼ã®å ´å
% sudo apt-get install python-pip
Fedora, CentOS, RedHatã®å ´å
% sudo yum install python-pip
Mac OS Xã®å ´å
Homebrewãã¤ã³ã¹ãã¼ã«ããã¦ãããã¨ãåæã§ãã
% echo "export PATH=/usr/local/bin:$PATH" >> ~/.bashrc
% echo "export PATH=/usr/local/share/python:$PATH" >> ~/.bashrc
% brew install python --framework
% /usr/local/share/python/easy_install pip
詳ããæ å ±ã¯Mac OS Xã«Pythonãã¤ã³ã¹ãã¼ã«ããã«æ¸ããã¦ããã®ã§åç §ãã¦ãã ããã
ä»å¿ è¦ã©ã¤ãã©ãªã®ã¤ã³ã¹ãã¼ã«
pipããã¤ã³ã¹ãã¼ã«ãã¦ãã¾ãã°æ®ãã®ã¤ã³ã¹ãã¼ã«ã¯ç°¡åã§ãâ¦â¦ã¨è¨ããã°è¯ãã®ã§ããå®ã¯numpy, scipyãªã©ã¯ç´Pythonã§ã¯ç¡ãããpipã使ç¨ããã¤ã³ã¹ãã¼ã«ã¯ä¸ç´åãã«ãªãã¾ãï¼ã³ã³ãã¤ã«ã¨ããä½æ¥ãçºçããããåå¿è ã§ã¯å¤ªåæã¡ã§ããªãï¼ããããã£ã¦mpltools以å¤ã¯OSãã³ãã«ãã¼ã¸ã§ã³ãã¤ã³ã¹ãã¼ã«ããã®ãæãç°¡åãªæ¹æ³ã«ãªãã¾ãã
Debianç³»OSï¼Ubuntu, Debianï¼ã®å ´å
% sudo apt-get install python-numpy python-scipy python-matplotlib
% sudo pip install mpltools
Fedora, CentOS, RedHatã®å ´å
% sudo yum install python-numpy python-scipy python-matplotlib
% sudo pip install mpltools
Mac OS Xã®å ´å
numpyã«é¢ãã¦ã¯pipã§è¡ããããã§ããscipyã¯Fortranãå¿ è¦ãªã©æ¡ä»¶ãæ§ã ããããã§ããä¸è¨ã«å¾ã£ã¦ãã ãããã¾ãè±èªãå¾æãªæ¹ã¯åç §å ãåèã«ãã¦ãã ããã
% pip install numpy
% brew install gfortran
% pip install scipy
% brew install pkg-config
% pip install matplotlib
% pip install mpltools
åç §å : Install Python, NumPy, SciPy, and matplotlib on Mac OS X
XYãã¼ã¿ã®ã°ã©ãå
çãã¼ã¿ã¨ãã¦æãå¤ãã¿ã¤ãããã®ãã¼ã¿å½¢å¼ã«ãªãã¨æãã¾ããä¾ãã°ä¸è¨ã¯ECFPã¨ããã·ã¢ã³è²èå ã¿ã³ãã¯è³ªã®èå ãæ³¢é·ããµã£ã¦åå¾ãããã¼ã¿ã«ãªãã¾ããçãã¼ã¿ã¯ãã¡ã
445.0000 72.5479 446.0000 86.7363 447.0000 106.924 ... 649.0000 9.14575 650.0000 11.7931
ãã®ããã«Xãã¼ã¿ï¼æ³¢é·ï¼ã¨Yãã¼ã¿ï¼èå
強度ï¼ãããã¿ã¤ããããã§ã¯ä¾¿å®ä¸XYãã¼ã¿ã¨å¼ã¶ãã¨ã«ãã¾ããXYãã¼ã¿ã§ã¯åç´ã«åç´ã«åç¹ãããããããã°ããããä¸è¨ããã°ã©ã ã§ã°ã©ããæç»ã§ãã¾ãï¼çãã¼ã¿ãã¡ã¤ã«ãraw.dat
ã¨ãã¦åãã©ã«ãå
ã«ä¿åãã¦ããã¨ä»®å®ãã¦ãã¾ãï¼ã
ä¸è¨ããã°ã©ã ã§ä½æãããã°ã©ãï¼ã表示ãã¦ããã¦ã£ã³ãã¦ï¼ã以ä¸ã«ãªãã¾ãã
ãªãä¸è¨ããã°ã©ã ã®æ³¨æäºé
ã¨ãã¦ãã½ã¼ã¹ã³ã¼ãä¸ã§æ¥æ¬èªã使ç¨ãã¦ããããã³ã¼ãä¸é¨ã«ãã# vim: set fileencoding=utf-8 :
ã®è¡¨è¨ããªãå ´åã¯ã¨ã©ã¼ã«ãªãã¾ãããã®ããã«ã½ã¼ã¹ã³ã¼ãä¸ã§æ¥æ¬èªã使ç¨ããå ´åã¯ã½ã¼ã¹ã³ã¼ãã®æåã³ã¼ããæå®ãã¦ãã ãããåã¯Vimmerãªã®ã§Vimå½¢å¼ã§æå®ãã¦ãã¾ãããé常# -*- coding: utf-8 -*-
ã®ããã«Emacså½¢å¼ã§æå®ãããã¨ãå¤ãããã§ããéæ³ã®è¨èã ã¨æã常ã«æå®ããããã«ãã¦ããã¦ãã ããã
XYãã¼ã¿ã®ç¸å¯¾å¤ãã°ã©ãå
å¥ãã¼ã¿ã¨æ¯è¼ããå ´åä½ï¼ æ¸å°ãããï¼ãªã©ã®ç¸å¯¾å¤ãéè¦ã«ãªãã¨æãã¾ããä¸è¨ã°ã©ãã¯ããæ¡ä»¶ä¸ã«ãããèå 強度å¤åã測å®ãããã®ã§ããå¥ã¿ã³ãã¯è³ªãå¥ç°å¢ã¨æ¯è¼ããããã«åææ¡ä»¶ããã©ã®ç¨åº¦å¤åããã®ãã表ãç¸å¯¾å¤ã§ãããããã¦ãã¾ãã
ãã®ãããªç¸å¯¾å¤ãã°ã©ãåããã«ã¯å ã®ããã°ã©ã ã«å°ãä¿®æ£ãå ãã¾ããä¸è¨ãåç §ãã¦ãã ããã
XYãã¼ã¿ã®æ¡ä»¶ã«ããããã¼ã¯å¤åéãã°ã©ãåãã
å ã®ã°ã©ãã§ã¯XYãã¼ã¿ãæ¡ä»¶å¤åã«ããã©ã®ããã«å¤åããã®ãã®æ¦è¦ãã¤ãããã¨ã¯ã§ãã¾ããããã¼ã¯ã®å¤ãã©ã®ç¨åº¦å¤åããã®ãï¼ãç¥ãã«ã¯ä¸é©åãªã°ã©ãã¨ãªãã¾ãããªã®ã§ä¸è¨ã°ã©ãã®ããã«æ¨ªè»¸ã«æ¡ä»¶ã縦軸ã«ãã¼ã¯ã®å¤ãã¨ã£ãã°ã©ããä½ãã¾ãããã
å ã®ããã°ã©ã ã«æ´ã«æ¹è¯ãå ããã¨ãã®ãããªã°ã©ããä½ããã¨ãã§ãã¾ããä¸è¨ãåç §ãã¦ãã ããã
ç¸å¯¾å¤ã°ã©ãã¨ãã¼ã¯å¤åã°ã©ããä¸ã¤ã«ã¾ã¨ããã
æå¾ã«ä½æããäºã¤ã®ã°ã©ããä¸ã¤ã«ã¾ã¨ãã¾ãããããã¡ããWordãªã©ãå©ç¨ãã¦ã¾ã¨ãã¦ãè¯ãã®ã§ããmatplotlibã«ã¯subplotã¨å¼ã°ããæ©è½ããããè¤æ°ã®ã°ã©ããã¾ã¨ãããã¨ãã§ããã®ã§ä»åã¯ãããå©ç¨ãã¾ããä¸è¨ããã°ã©ã ãå®è¡ããã¨ãã®è¨äºã®æçµµã®ãããªã°ã©ããåºæ¥ä¸ããã¾ãã
æå¾ã«
åæ°ãã¼ã¿ãªã©ã¯å¯¾å¿ã§ããªãã®ã§ãã¹ãã°ã©ã ãç¨ãã¦ãã ãããPythonã§ãã¹ãã°ã©ã ãæ¸ãã¦ã¬ã¦ã·ã¢ã³ãã£ããã£ã³ã°ã§ã¯ã©ã¹ã¿ãªã³ã°ãããµã³ãã«ãææ¸ããã®ã§ãã¡ããåèã«ãã¦ãã ãããã©ãããã®èæ¯ã¹ï¼æ··åã¬ã¦ã¹ã¢ãã«ã«ããã¯ã©ã¹ã¿ãªã³ã°ï¼