5
5

More than 5 years have passed since last update.

Gnuplotで、はやぶさ2の軌道アニメーションを作ってみた

Last updated at Posted at 2019-02-10

はじめに

 JAXAのサイトで小惑星探査機はやぶさ2の空間座標が公開されていたので、gnuplotでGIFを描いてみた。

完成例

 t=0 [day](打上げ、2014年12月3日)から、t=1832 [day](リュウグウ滞在の最後の頃、2019年12月9日)まである。
haya2.gif

データファイルの出典

 まずは、以下のサイトから"Trajectory_20180226.txt"を拾ってくる。

プログラムの作成

 上記サイトからダウンロードした"Trajectory_20180226.txt"と、以下に作成する"haya2.plt""haya2plot.plt"を同じディレクトリに用意する。

"haya2.plt"

haya2.plt
set terminal aqua font 'ヒラギノ丸ゴ ProN W4, 8' 
# aquaじゃなければx11でも良いと思います。試してないですが。
set zeroaxis
set ticslevel 0 # z軸を底面にくっつける
set xlabel "x [au]" font 'ヒラギノ丸ゴ ProN W4, 8'
set ylabel "y [au]" font 'ヒラギノ丸ゴ ProN W4, 8'
set zlabel "z [au]" font 'ヒラギノ丸ゴ ProN W4, 8'
set xrange [-1.5:1.5];set yrange [-1.5:1.5];set zrange [-0.15:0.15]
set view 45, 300, 1, 1 # 視点を調整

set terminal gif animate delay 5 optimize size 640, 480
# delay 5 ぐらいがちょうど良い再生速度になる。
set output "haya2.gif"

load "haya2plot.plt"
i = 0

"haya2plot.plt"

haya2plot.plt
if (exist("i")==0 || i<0) i=0 #変数の初期化
title(i) = sprintf("t = %d [day]",i)  #タイトル名
unset label 
set label title(i) font 'ヒラギノ丸ゴ ProN W4, 12' at 1.2,-1.2,0
set label sprintf("提供:JAXA") font 'ヒラギノ丸ゴ ProN W4, 8' at 1.5,-1.5,-0.4
set label sprintf("「はやぶさ2」、地球、リュウグウの位置 \n ※z軸は10倍にしてある。") font 'ヒラギノ丸ゴ ProN W4, 12' at -1.9,1.9,0.4

splot "Trajectory_20180226.txt" every ::57::57+i using 3:4:5 lc rgb "yellow" notitle with lines\
    ,"Trajectory_20180226.txt" every ::57::57+i using 6:7:8 lc rgb "blue" notitle with lines\
    ,"Trajectory_20180226.txt" every ::57::57+i using 9:10:11 lc rgb "grey" notitle with lines\
    ,"Trajectory_20180226.txt" every ::57+i::57+i using 3:4:5 pt 5 lc rgb "yellow" title "Hayabusa2" with points\
    ,"Trajectory_20180226.txt" every ::57+i::57+i using 6:7:8 pt 7 lc rgb "blue" title "Earth" with points\
    ,"Trajectory_20180226.txt" every ::57+i::57+i using 9:10:11 pt 13 lc rgb "grey" title "Ryugu (1999 JU3)" with points

if (i<1832)  i=i+1; reread

 ターミナルを開く。"Trajectory_20180226.txt"などがあるディレクトリへ移動する。以下のようにコマンドを打てば、"haya2.gif"が同じディレクトリに出力される。

$ gnuplot
gnuplot> load "haya2.plt"

補足

 他にもこのデータファイルを使って色々プロットしたので良かったらどうぞ。
 https://github.com/m-kunugi/gnuplot/tree/master/haya2

参考サイト

 GIFにする際、以下のサイトを参考にさせていただきました。

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5