先週欠席の人へ テーマ 1 の実習 A がはじまっています TA の方に助けてもらい追いつきましょう
テーマ 1 データの処理と加工 実習 A 図 5 https://titechcomp.github.io/y18-il2j/1a-exercise.html
自習教材のダウンロード ブラウザ Safari を起動 ( 圧縮ファイルの扱いが簡単 ) https://titechcomp.github.io/y18-il2j/14-dataset.html こちらからダウンロード をクリックする thema1-data.zip が解凍され ダウンロードフォルダに thema1-data フォルダがダウンロードされてくる Finder で ダウンロードフォルダの thema1-data フォルダを Documents フォルダに適切な置き場所 ( フォルダ ディレクトリ ) を作って移す
実習 : 図のように各自のファイルシステムを整備しなさい フォルダ Unix 用語ではディレクトリ Documents thema1-data.zip を作って実習作業のためのオリジナルのデータも残しておくと良い ファイル Day1 gnutest IL2 theme1 実習は thema1-data フォルダのファイルを直接変更して行うが 失敗してファイルを壊す人が多い 失敗したらまたダウンロードするのは面倒だから 圧縮ファイルで持っておく theme1-data 前回作業したファイル thema1-data.zip テーマ 1 実習用のファイルが入った圧縮ファイル
自習教材の確認 thema1-data フォルダの中身を確認しなさい どんなディレクトリ構成で どんな中身ファイルがあるか できればすべてコマンドを使って thema1-data フォルダ内を移動しながら coteditor でファイルを開いて見られると良い thema1-data/plot フォルダには gnuplot のスクリプトファイル (.plot) があることを確認 また特に thema1-data/plot/images フォルダが 最初は空っぽ を確認しておく
theme1-data cnm he1 he2 hn plot etime-size.data ratio-join.data time-join-100k.data time-join-200k.data time-join-300k.data time-join-400k.data time-join-500k.data etime-size.data etime-size-m.data etime-size.data etime-size-m.data etime-size.data etime-size-m.data Ratio-join-500k.data カレントディレクトリを cd コマンドで移動上のディレクトリ (..) に行くのは cd.. data ファイル.plot ファイルの中身を確認する open a coteditor ファイル名 図 2 のための.plot 図 3 のための.plot 図 5 のための.plot images 最初は空っぽ.plot を実行してグラフを描いたら そのグラフの画像ファイルを保存するためのフォルダ
以降はターミナル窓でコマンド操作 $ pwd $ ls Documents $ cd Documents $ ls IL2 $ cd IL2/theme2/thema1-data $ pwd; ls README.md he1 hn cnm he2 plot $ cd plot $ pwd $ ls thema1-data/plot をカレントディレクトリにして作業しよう
実習 : カレントディレクトリを theme1-data/plot に移動しなさい フォルダ Unix 用語ではディレクトリ ファイル Documents IL2 ターミナルのカレントディレクトリを thema1-data/plot に移動しなさい Day1 gnutest theme1 Theme1-data 前回作業したファイル thema1-data.zip テーマ 1 実習用のファイルが入った圧縮ファイル plot images cnm
図 5 の gnuplot スクリプト $ ls fig2-cnm-joins-time-series.plot fig5-all-etime-size.plot fig3-cnm-ratio-joins.plot images $ open -a coteditor fig5-all-etime-size.plot 長いファイル名は全部打たなくても tab キーを押せば自動補完してくれる上記の open コマンドだと fig5 と打って tab キーを押す
図 5 のための.plot を実行 fig5-all-etime-size.plot を実行しよう $ gnuplot fig5-all-etime-size.plot 起きたことの確認 $ ls fig2-cnm-joins-time-series.plot fig3-cnm-ratio-joins.plot images fig5-all-etime-size.plot $ cd images $ ls fig5-all-etime-size.pdf $ open fig5-all-etime-size.pdf images フォルダに行き ls コマンドでファイルができているのを確認 その.pdf ファイルを開く ( 図 5)
fig5-all-etime-size.plot を理解しよう set encoding utf8 出力のターミナルタイプを pdf に指定 set terminal pdf set style line 1 linewidth 4 dashtype 1 linecolor rgb "black" set style line 2 linewidth 4 dashtype 2 linecolor rgb "black" set style line 3 linewidth 4 dashtype 3 linecolor rgb "black" set style line 4 linewidth 4 dashtype 4 linecolor rgb "black" 描画オプションの指定 線の種類 軸ラベルの指定 set output "images/fig5-all-etime-size.pdf" set xlabel "Size of Social Network" set ylabel "Elapsed Time [sec]" plot コマンドでグラフの描画を実行 カンマを使って 4 組のプロット ( 線で結ぶ ) をする注意!!! plot "../cnm/etime-size.data" title "CNM" with lines linestyle 4, "../he2/etime-size.data" title "HE'" with lines linestyle 3, "../he1/etime-size.data" title "HE" with lines linestyle 2, "../hn/etime-size.data" title "HN" with lines linestyle 1 plot コマンドは 1 行で書くべきだが 長くて途中で分けて書く場合は 行末にバックスラッシュ記号 ( コマンドキー + で入力 ) が必要 ( 改行したらそこまでで実行してしまうから )
テーマ 1 データの処理と加工 実習 A 図 6 https://titechcomp.github.io/y18-il2j/1a-exercise.html
注意 : plot フォルダで作業をしましょう ( つまりカレントディレクトリを plot にする の意味 ) (images フォルダにいる人は cd.. で上へ上がる )
図 6 に関係するファイル thema1-data cnm he1 he2 hn plot etime-size.data ratio-join.data time-join-100k.data time-join-200k.data time-join-300k.data time-join-400k.data time-join-500k.data etime-size.data etime-size-m.data etime-size.data etime-size-m.data 図 6 のグラフのための.data ファイルは 3 つ etime-size.data Etime-size-M.data Ratio-join-500k.data 図 2 のための.plot 図 3 のための.plot 図 5 のための.plot 図 6のための.plotは自分で作りましょう fig6-tw-etime-size-m2.plot images fig5-all-etime-size.pdf( 図 5) Images フォルダに図 6 ができる images/fig6-tw-etime-size-m.pdf
ヒント : 図 6 は 図 5 のスクリプトを 参考にして自分でスクリプトを作成する スクリプトファイルの名前は fig6-tw-etime-size-m2.plot 出力するグラフのpdfファイルの名前は images/fig6-twetime-size-m.pdf として下さい 図 6は図 5と同様なので fig6-tw-etime-size-m2.plot は fig5-all-etime-size.plotをコピーしたものを修正して作ります ファイルのコピーは cp コマンドで行います cp コピー元ファイルコピー先ファイル cp fig5-all-etime-size.plot fig6-tw-etime-size-m2.plot
(plot をカレントディレクトリにして行う ) tab キー長いファイル名を指定するとき全部打つ必要はありません 少し打って tab キーを押すと あとは自動補完してくれます $ cp fig5-all-etime-size.plot fig6-tw-etime-size-m2.plot $ ls fig2-cnm-joins-time-series.plot fig6-tw-etime-size-m2.plot fig3-cnm-ratio-joins.plot images fig5-all-etime-size.plot $ open -a coteditor fig6-tw-etime-size-m2.plot
fig6-tw-etime-size-m2.plot をエディタで修正 HE のデータは he2/etime-size-m.data です HEのデータは he1/etime-size-m.data です HNのデータは hn/etime-size-m.data です グラフの出力する pdf ファイルの名前は images/fig6-tw-etime-size-m.pdf coteditor で修正し 保存します gnuplot コマンドで fig6-tw-etime-size-m2.plot を実行させ グラフの出力を確認する
coteditor 便利なキーボードショートカット ( メニューの横に表示 ) コマンドキー +s で ( メニューを出さなくても ) 保存 バックスラッシュ記号 (plot コマンドが長くなる時行末に必要 ) は コマンドキーを押しながら キー とバックスラッシュの文字コードについて コピーはコマンドキー +c カット ( 削除してコピー ) はコマンドキー +c ペースト ( コピーしたものの貼付 ) はコマンドキー +v
$ cat fig6-tw-etime-size-m2.plot set encoding utf8 set terminal pdf cat はファイルの中身をその場で確認するコマンド set style line 1 linewidth 4 dashtype 1 linecolor rgb "black" set style line 2 linewidth 4 dashtype 2 linecolor rgb "black" set style line 3 linewidth 4 dashtype 3 linecolor rgb "black" set style line 4 linewidth 4 dashtype 4 linecolor rgb "black" set output "images/fig6-tw-etime-size-m.pdf" set xlabel "Size of Social Network" set ylabel "Elapsed Time [sec]" plot "../he2/etime-size-m.data" title "HE'" with lines linestyle 3, "../he1/etime-size-m.data" title "HE" with lines linestyle 2, "../hn/etime-size-m.data" title "HN" with lines linestyle 1 $ gnuplot fig6-tw-etime-size-m2.plot $ cd images $ ls fig5-all-etime-size.pdf fig6-tw-etime-size-m.pdf $ open fig6-tw-etime-size-m.pdf $ cd.. $ pwd 図 6 では線の種類は 3 つ必要 凡例で対応を表示するので お手本と線の種類まで全く同じにする必要はない