Py淡

Python, Python, Python! In the spirit of "import antigravity"

Entries from 2015-01-01 to 1 year

Yet another hunt for nice matplotlib colormaps

This snipet will plot many colormaps in one go. The above example is for 4 levels of shades.

One liner for choosing a nice matplotlib colormap

Memo for myself...Since jet is becoming less and less popular these days and the default color styles will be revamped in the comming release of MPL, I also tend to avoid jet. When choosing a nice colormap for data that needs only several …

How to record the panda3d app screen as avi file using ffmpeg

# It's better to use base.movie() instead of this code. see belowHere is an example script I wrote today. To run this on your PC, at least the model in the script needs to be replaced with your egg file. Panda3d has a nice facility to save…

Making 3D model from 2D side view image with Smoothie-3D

Smoothie-3D: squirrel modeling - YouTubeI made a 3d fish model for my current project. As you can see in the above Youtube demo video, they made making 3d model really easy. It would have been quite a lot of work if I did this in blender f…

忍者ブログの独自タグをつかって各記事をはてなブログに転送してみた。

忍者ブログでは複数のカテゴリを設定できないという制限があり、英語のページを分けるのが簡単ではないということではてなブログへと移転しました。無料ブログから独自ドメインに引っ越すときに便利。忍者ブログから独自ドメインにjavascriptでリダイレクト…

Using buffer protocol to dynamically texture with 2D numpy array in Panda3d

I followed this official blog post "Buffer protocol support" and came up with a short example of simple video player in panda3d using numpy 2d array as texture. The trick was to use setRamImage on Texture object. To do that, we have to set…

Geany 1.25 is out! Overview plugin is now included in Geany-Plugins!

There was an announcement in the Geany-Users email list that Overview plugin is now officially included in the Geany-Plugins! Overview plugin is a plugin that provides sublime text minimap like feature for Geany. I had built it from source…

Numpy: NaNをリニアインターポレーションして置き換える

def interp_nan(x): ''' Replace nan by interporation http://stackoverflow.com/questions/6518811/interpolate-nan-values-in-a-numpy-array ''' ok = -np.isnan(x) xp = ok.nonzero()[0] fp = x[ok] _x = np.isnan(x).nonzero()[0] x[-ok] = np.interp(_…

BlenderとYABEEでPanda3d用にモデルを作る

Panda3d用のモデル製作にはMayaが一番相性がいいらしいが月額123ドル?。フリーのBlenderでは以前はChickenというかなり完成度の高いエクスポーターがあったが古くなり使われてなく、現在はYABEEというプラグインが使われている。 Blenderのバージョンとの相…

Panda3dを使用したPythonスクリプト用のSublime Textビルドコマンド設定

{ "cmd": ["C:/Panda3D-1.9.0/python/ppython.exe", "$file"], "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", "selector": "source.python", "working_dir": "C:/Panda3D-1.9.0/bin" } をppython.sublime-buildとしてPortableApps\sublime_text\Da…

Google日本語入力とSublime Textの相性が悪い問題が解決!

Sublime Textは開発者がオーストラリア人のJon Skinnerさんで、Gtkをベースにした独自のGUIでできているらしいのでやはり日本語に弱く、日本語IMEを使うと入力中の日本語がカーソルのある位置でインライン表示されずに画面左上あたりに表示されてしまう問題…

np.ones_like, np.zeros_likeでboolアレイの初期化。

覚書です。 array1 = np.zeros((w,h)) なんかであらかじめプリアロケーションしたゼロ行列を作ることはよくありますが、ブーリアンのときはどうやるとスマートなのかと思って調べました。 bool値で満たされた行列の初期化 私の場合、既にあるmyarrayと同じ次…

matplotlibの図をBMPとしてクリップボードにコピーする関数作った。

よくデータ解析しているとmatplotlibでfigure(facecolor='w')にしてプロットした図をウィンドウズのSnipping toolでクリップボードにコピーして、パワーポイントに貼って、ノーテーションしたりするわけですが、これが何度も続くと面倒い。 ぐぐってみたらwx…

bibtexマネージャーを作ってみる。その2:wxPython3.0でwx.lib.agw.auiを使う。

作り始めて3日目のスクリーンショット。現在コメントやICONのリソースのバッファ21行を含めて265行。 さて、いろいろな空き時間にコーディングして、とりあえず使えるものが出来ました。 上にあるスクリーン ショットで、authorのところの下矢印はAuth…

bibtexマネージャーを作ってみる。その1:BibtexParserを使う。

JabRefやCiteulikeを長く使ってきましたが、以下の機能が欲しいのでCiteulikeを補完するツールとして自分用bibtexマネージャーを作ってみようと思います。 欲しい機能 シンプルなJabRefのインターフェイスっぽいもの。 タブグループマネージャー機能。Bib ma…

"import antigravity" actually works!

Wow. I did not expect it to work but I just tried it for fun. And guess what! It actually works! Fire up your python console and try importing "antigravity". It brings you to that xkcd page http://www.xkcd.com/353/. The history behind how …

Sublime Text2からPythonコードをgeany_run_script.batっぽく実行。

OpenCVで複数namedWindowを使ったコードをSublime Text2から走らせるとなぜか最初のウィンドウが出てこないという奇妙なバグがあって、これのせいでSublime Text断念して、Geanyへ戻ったというエントリーを書いたばかりですが、自分でビルドしたoverviewプラ…

Sublime TextのミニマップみたいなGeanyプラグインOverviewをウィンドウズでビルドしてみた。

Sublime Textのミニマップはとてもかっこいい見た目だし、しかも使ってみると便利。Geanyから乗り換えようと何度か したことがあるけども、SublimeからOpenCVを使うとnamedWindowの挙動がたまに変なので結局戻ってきてしまった。 Sublimeもちゃんと設定すれ…