sentakuitaの日記: biorhythm.sh
日記 by
sentakuita
biorhythm.sh
----
#!/bin/bash
version='0.2.1'
birthday="$1"
targetday=${targetday:=$(date '+%Y-%m-%d')}
ut_birth=$(date -d $birthday '+%s')
ut_target=$(date -d $targetday '+%s')
passday=$(echo "(${ut_target} - ${ut_birth}) / 86400" |bc)
day_phy=$((${passday} % 23))
day_emo=$((${passday} % 28))
day_int=$((${passday} % 33))
#phy=$(echo 'scale=3; s(2 * 3.1416* '${day_phy}' / 23)' |bc -l)
#emo=$(echo 'scale=3; s(2 * 3.1416* '${day_emo}' / 28)' |bc -l)
#int=$(echo 'scale=3; s(2 * 3.1416* '${day_int}' / 33)' |bc -l)
#echo "phy=$phy , emo=$emo , int=$int"
echo -e 'set xtics ('$(for n in -1 0 1 2 3 4; do \
echo -n '"'$(date -d "${targetday} $n week" "+%Y-%m-%d")"\" $n , "; done)\
'0) \n'"pday = ${day_phy}\neday = ${day_emo}\niday = ${day_int}\n\
plot P(x),E(x),I(x)" |cat bio.plt - |gnuplot -persist
----
bio.plt
----
set mxtics 7
set format x " "
set format y ""
set grid xtics noytics
set xzeroaxis lt 0 lw 1.000
set yzeroaxis lt 0 lw 1.000
set xrange [ -1.42 : 4.28 ] noreverse nowriteback
P(x)=sin(2*pi*(7*x+pday)/23)
E(x)=sin(2*pi*(7*x+eday)/28)
I(x)=sin(2*pi*(7*x+iday)/33)
----
要gnuplot
bash組込関数で計算すると見事にオーバーフロー。bc頼り。
gnuplotのプロットを強引に生成してGUI志向に(ぉ
targetdayオプション未実装。
にしてもスマートじゃないなぁ。。
----
#!/bin/bash
version='0.2.1'
birthday="$1"
targetday=${targetday:=$(date '+%Y-%m-%d')}
ut_birth=$(date -d $birthday '+%s')
ut_target=$(date -d $targetday '+%s')
passday=$(echo "(${ut_target} - ${ut_birth}) / 86400" |bc)
day_phy=$((${passday} % 23))
day_emo=$((${passday} % 28))
day_int=$((${passday} % 33))
#phy=$(echo 'scale=3; s(2 * 3.1416* '${day_phy}' / 23)' |bc -l)
#emo=$(echo 'scale=3; s(2 * 3.1416* '${day_emo}' / 28)' |bc -l)
#int=$(echo 'scale=3; s(2 * 3.1416* '${day_int}' / 33)' |bc -l)
#echo "phy=$phy , emo=$emo , int=$int"
echo -e 'set xtics ('$(for n in -1 0 1 2 3 4; do \
echo -n '"'$(date -d "${targetday} $n week" "+%Y-%m-%d")"\" $n , "; done)\
'0) \n'"pday = ${day_phy}\neday = ${day_emo}\niday = ${day_int}\n\
plot P(x),E(x),I(x)" |cat bio.plt - |gnuplot -persist
----
bio.plt
----
set mxtics 7
set format x " "
set format y ""
set grid xtics noytics
set xzeroaxis lt 0 lw 1.000
set yzeroaxis lt 0 lw 1.000
set xrange [ -1.42 : 4.28 ] noreverse nowriteback
P(x)=sin(2*pi*(7*x+pday)/23)
E(x)=sin(2*pi*(7*x+eday)/28)
I(x)=sin(2*pi*(7*x+iday)/33)
----
要gnuplot
bash組込関数で計算すると見事にオーバーフロー。bc頼り。
gnuplotのプロットを強引に生成してGUI志向に(ぉ
targetdayオプション未実装。
にしてもスマートじゃないなぁ。。
biorhythm.sh More ログイン