galpy事始め

(1)自分の座標系

太陽:(xGC,yGC,zGC)=(-R0, 0, 0)

LSR: (vxGC,vyGC,vzGC)=(0, LSR, 0)

 

(2)galpyの座標系

太陽:(xGC_B,yGC_B,zGC_B)=(R0, 0, 0)

LSR: (vxGC_B,vyGC_B,vzGC_B)=(0, -LSR, 0)

 

(3)近いうちに、座標系をもう一度確認しよう

x_galpy = -xGC

vx_galpy = -vxGC

とすれば、自分の座標系と一致する。

galpyは、y=0平面で鏡像対称の世界を計算していると理解すればよい。

orbitの各時刻の値にアクセスするときにだけ注意をすればよい。

[galpyのメソッドで(ell, bee)などの計算は正しい。]

 

MCMCのPythonライブラリ

macbook air

(1)emcee
(2)emcee test
(3)nose
(4)Cython
(5)triangle_plot
(6)astropy
(7)scikit-learn
(8)astroML
(9)healpy
(10)pymc


(1)emcee install

#air の場合、 pip ではうまくいかなかった。
#mini はpipでOK

$ easy_install emcee

Searching for emcee
Reading http://pypi.python.org/simple/emcee/
Best match: emcee 2.1.0
Downloading https://pypi.python.org/packages/source/e/emcee/emcee-2.1.0.tar.gz#md5=c6b6fad05c824d40671d4a4fc58dfff7
Processing emcee-2.1.0.tar.gz
Writing /var/folders/rp/pl6_r3nd4jx77n_41w_wxv_c0000gn/T/easy_install-7Pi0Us/emcee-2.1.0/setup.cfg
Running emcee-2.1.0/setup.py -q bdist_egg --dist-dir /var/folders/rp/pl6_r3nd4jx77n_41w_wxv_c0000gn/T/easy_install-7Pi0Us/emcee-2.1.0/egg-dist-tmp-z_yyFt
zip_safe flag not set; analyzing archive contents...
Adding emcee 2.1.0 to easy-install.pth file

Installed /Users/user_name_of_this_mac/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/emcee-2.1.0-py2.7.egg
Processing dependencies for emcee
Finished processing dependencies for emcee

(2) test installation

$ python -c 'import emcee; emcee.test()'
Starting tests...
test_blobs ...
Passed.
test_ensemble ...
Passed.
test_inf_nan_params ...
Passed.
test_mh ...
Passed.
test_nan_lnprob ...
Passed.
test_parallel ...
Passed.
test_pt_sampler ...
[[ 4.28078961 9.65907666 12.04358703 2.87660849 7.82525845]
[ 3.2170057 4.24150198 5.38886129 2.57120086 3.5628032 ]
[ 3.34190318 3.93665869 0.82218183 2.12615653 2.49409284]
[ 2.96794288 4.44072437 3.32023843 1.41856222 2.0569162 ]
[ 3.61527134 5.3512537 4.55853738 2.75207078 3.02549049]
[ 3.95276797 6.1557117 4.38194265 3.01447094 3.24526784]
[ 3.96019439 6.18795309 4.57944292 3.06475761 3.37076447]
[ 4.11819964 5.7659697 4.8562809 3.0359267 3.32589204]
[ 3.85603363 5.8957338 4.66856969 2.73020252 3.26294585]
[ 3.99426772 5.59603551 4.77616469 2.71490972 3.06735538]
[ 3.84855889 5.30711848 4.39331468 2.63502553 3.03036884]
[ 3.72773645 5.31566673 4.29787118 2.68011324 3.30029418]
[ 3.70281773 5.21921852 4.31161499 2.54182746 3.18707777]
[ 3.51953548 5.44804836 4.34200003 2.43029784 3.21089521]
[ 3.52115997 5.57011287 4.22717807 2.33530092 3.01453834]
[ 3.53066543 5.59681081 4.16195481 2.32190219 2.96314379]
[ 3.61405652 5.67793786 4.54752642 2.36962106 2.96819806]
[ 3.73036245 5.69646144 4.49372029 2.44394668 2.91694628]
[ 3.51842425 5.69187972 4.84872206 2.24377814 3.20128908]
[ 3.55529756 6.06242817 4.92321959 2.36286834 3.41771155]]
Passed.
0 tests failed


(3)ついでにnose

$ easy_install nose

 

(4)Cython
$ easy_install cython

(5)triangle_plot
$ pip install triangle_plot

(6)astropy
$ pip install --no-deps astropy


(7)scikit-learn
$ pip install -U numpy scipy scikit-learn

(8)astroML
$ pip install astroML
$ pip install astroML_addons

(9)healpy
$ sudo port install py27-healpy

(10)
・まず、githubからインストールを試みる
・zip解凍して
$ cd pymc-master/
$ python setup.py config_fc --fcompiler gfortran build
$ python setup.py install

うまくいっているか調べるためにDesktopにpymc_test.pyを作り走らせる:
$ cd ../Desktop/
$ python pymc_test.txt
Running unit tests for pymc.tests
NumPy version 1.7.1
NumPy is installed in /Users/user_name_of_this_mac/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy
Python version 2.7.3 | 64-bit | (default, Aug 8 2013, 05:37:06) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
nose version 1.2.1

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK

全然OKじゃない。笑

・この一連の操作をやったあとに、
$ easy_install pymc
$ python pymc_test.txt

Running unit tests for pymc.tests
NumPy version 1.7.1
NumPy is installed in /Users/user_name_of_this_mac/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy
Python version 2.7.3 | 64-bit | (default, Aug 8 2013, 05:37:06) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
nose version 1.2.1
...............S..S.............S.......................................................................................................0 x
1 (x_pow_2)
dtype: object
.....SS....................[-----------------51% ] 517 of 1000 complete in 0.5 sec
[-----------------91%-------------- ] 912 of 1000 complete in 1.0 sec
[-----------------100%-----------------] 1000 of 1000 complete in 1.1 sec
.[-----------------100%-----------------] 1000 of 1000 complete in 0.4 sec
............
----------------------------------------------------------------------
Ran 175 tests in 27.616s

OK (SKIP=5)

これでようやくうまくいった。

権威からのメール

英国の大御所教授からメールが来た。

 

教授は3月に自分が投稿した論文の査読者になったのだが、あいにくその教授は俺の論文の仮定の甘さを理由に

「こんなひどい論文を通す気にはなれない」

と真っ向から否定された。

 

知り合いが以前、こういっていた。

「自分が査読者で誰かの論文をrejectする場合は、

”異議があるなら私に直接連絡すればいくらでも議論に応じます"

と書くようにしている」

と言っていた。まさにこのパターンである。

 

まだrejectが確定されたわけではないが、査読者のcriticalな意見は主に2つ:

(1)「真の速度分散」「仮の速度分散」を求める式変形の近似が2カ所甘い。

(2)数値実験の結果「真=仮」になっているのはよいとしても、その理由をつかみ損ねている。数値実験で用いた分布関数が特定の引数に対してseparateだからうまくいった、と主張しているが、反例が存在する。

(3)ベイズ定理を利用した確率の式に不用意な式変形がある

 

(1)(2)は、数値実験だとうまくいっているので、数値実験で得た結果の本質をとらえ直すことで解決できるはずである。

(2)の結果を用いて観測結果のいろいろな解釈を行っているので、その部分は再考した結果に応じて改訂されることになるだろう。

(3)は、先行研究でごまかしてあった場所を厳密に扱おうとしたのだが、言われてみると自分も似たようなごまかしをしている気もして来た。

 

「大御所と若手のバトル」という格好の良いレベルの戦いではなく、今回は自分の計算に非があったということをきちんと認識したい。

正直、大御所からメールが来たときは、「何を言ってるんだ俺が正しい」なんて思っていた。が、自分の修行が足りないだけだった。笑

rejectされるかはここできっちり考えた結果に依存する。自分からまいた種だが、大御所と意見を交えることができることは光栄なことだ。(修士の学生の頃、大御所の書いた教科書にサインをしてもらったこともあるww)そう考えて、真摯に取り組もう。

出張メモ

個人用メモ。持ち物をまとめる:

 

[最低限]

・パスポート

・財布(お金/カード)

・眼鏡

 

[仕事]

・ポスター

Macbook Air & 充電器

・携帯電話 充電器 [=目覚まし]

・電源プラグのアダプタ

・筆記用具

・USB

 

[日常]

・e-ticket

・旅程表

・腕時計

・家のカギ(研究所のカギはおいていく)

※ 出発時間は?

※ 電車の乗換は? 

 

[日用品]

・歯ブラシ(電動なら充電)

・歯磨き粉(機内持ち込み不可)

・ひげ剃り

・小タオル(あっても困ることはない)

・風邪薬

・傘

 

[衣類]

・下着1枚/日+2枚;洗濯も可能だが、時間的余裕がないことも多い

・羽織るもの(寒暖に対応)

・ワイシャツやポロシャツ(季節による)

・ズボン & ベルト

・靴下

・パジャマ

 

 [その他]

・音楽walkman

・カメラ

 

画像変換 ImageMagickの周辺事項(convert, pdfcrop)

Imagemagickでいろんなことができるのだと学んだ。

(1)convert
pdf > eps or level-2 eps
などができる。

$ convert test.pdf test_level1.eps
$ convert test.pdf eps2:test_level2.eps


(例)圧縮率が違うとこんなに違う

・pdf: 0.45MB
・level-1 eps: 32MB
・level-2 eps: 0.88MB

参考1
http://osksn2.hep.sci.osaka-u.ac.jp/~naga/miscellaneous/tex/tex-eps.html

参考2
http://m.ils.uec.ac.jp/memo/eps.txt


(2)pdfcrop
pdfの余白を自動で切り取ってくれる。
keynoteで図を作成したりするとどうしても余白ができてしまう。

$ pdfcrop test.pdf
>> test-crop.pdf という、トリミングされたpdfができる(60秒ほど要することもある)。

$ convert test-crop.pdf eps2:test-crop.eps
>> test-crop.eps という、トリミングされたepsができる。

参考
http://tex.stackexchange.com/questions/171455/what-is-a-good-workflow-for-importing-and-cropping-eps-images


(3)参考

理由は不明だが、以下の方法では余白のないepsを作れない。

・previewで範囲を選択 Commend+c Command+n Command+s (名前をtest2.pdfとして保存)
>> test2.pdf は、トリミングされて「いる」。
・$ convert test2.pdf eps2:test2.eps
>> test2.eps は、トリミングされて「いない」。

 

 

Mac yosemite で convert を使えるようにする

紆余曲折を経て yosemite で convert コマンドが使えるようになった。

いろいろやったので何がうまくいったのかわからんが、最後にやった手順を残しておく。

(0)症状 symptoms
$ convert test.pdf test.jpg
-bash: convert: command not found

$ convert -v
-bash: convert: command not found

$ convert --help
-bash: convert: command not found

$ which convert
何も表示されない


(1)手順 procedures 
Homebrewのウィンドウで
$ brew --prefix
$ hash -r
$ brew info imagemagick
$ hash -r
$ brew link imagemagick
$ hash -r
$ brew reinstall imagemagick
$ hash -r

それぞれのコマンドに対する出力によって手順が変わる可能性があるので、下記サイトのリンクをはっておく。
参考 http://apple.stackexchange.com/questions/177594/to-install-brews-imagemagick-and-fix-its-symlink?answertab=votes#tab-top

... which was very helpful


(2)convert が使えるか確認
$ convert -v
Version: ImageMagick 6.9.0-10 Q16 x86_64 2015-03-09 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: DPC Modules
Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png xml zlib

Usage: convert [options ...] file [ [options ...] file ...] [options ...] file
(以下長い出力が続くが省略)

$ convert --help
Version: ImageMagick 6.9.0-10 Q16 x86_64 2015-03-09 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: DPC Modules
Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png xml zlib

Usage: convert [options ...] file [ [options ...] file ...] [options ...] file
(こちらも、同様に長い出力が続くが省略)


(3)(1)以前に試したこと[どれかは役に立っているかもしれないw]

(あ)Xquartzはすでにインストールしていた。

(い)ghostscript
http://pages.uoregon.edu/koch/ 
経由でghostscript 9.15をインストール
$ gs -v
GPL Ghostscript 9.15 (2014-09-22)
Copyright (C) 2014 Artifex Software, Inc. All rights reserved.
http://cactuslab.com/imagemagick/

(う)ImageMagick for Mac OS X
ImageMagick installer for Mac OS X [ http://cactuslab.com/imagemagick/ ]
から、
・「ImageMagick 6.9.1-0 for Mac OS X 10.5 – 10.10」(XQuartz不要の版 (7.5MB)) をインストール > しかし convert 使えない症状は改善せず
・「ImageMagick 6.9.1-0 for Mac OS X 10.5 – 10.10」(Requires XQuartz. (7.8 MB)) をインストール > しかし convert 使えない症状は改善せず

 

MacTex2014, TeXShop設定

日本語tex文書を作成するために設定。

以前mactex2012を使っていた頃に(設定を無闇にいじりすぎたせいか)日本語がことごとく文字化けするという現象になやまされていた。今回の設定で文字化けも解消。

 

(1)MacTex2014をインストール

1.

MacTeX-2012をアンインストール(これは不要らしいが、以前のは結局日本語が打てないので消した。)

$ which platex

/usr/texbin/platex

$ cd /usr/local/texlive/

$ ls
2012       texmf-local

$ sudo rm -rf 2012

 

2. ミラーサイトからMacTeX.pkgをダウンロード

Safariを用いる。(Chromeだとファイルが壊れていた。)

・正しいサイズか確認。

$ openssl md5 /Users/my_name/Downloads/MacTeX.pkg
MD5(/Users/my_name/Downloads/MacTeX.pkg)= 2cc593b1b35fba63a7bd27fab145b04c

 

3. MacTeX.pkgを使ってインストール

・なお、chromeを使ってDLしたものはインストールに失敗した。

=本家のウェブサイトのFAQが役立つ。

 

4. TeXShopを最新版にする。

・メニューバーから簡単にupdateできる。

・文字化けは最新版(ver3.36 >>> ver3.50)にしたら解消した。

 

5. TeXShop設定。

Preferenceで設定をするのは2つのみ:

[encoding] UTF-8

[set default values] を pTeX (ptex2pdf) にする(参考1を参照)。upTeXにはしなかった(参考2ではupTeX推奨らしい)。

 

参考1 Mac OS XへのLaTeXとTeXShopのインストレーション

参考2 http://oku.edu.mie-u.ac.jp/~okumura/texwiki/?TeXShop%2F%E8%A8%AD%E5%AE%9A#c0acd0ab

 

----

[追記]:以上はmacbook air OSX 10.7.5 Lion 

mac mini OSX 10.10 yosemite では、1-5をやっても文字化けが解消されなかった。が、

6.  mac mini を再起動

という手順を踏んだところ解決。