# usage ephemeride.bash year month day
#longitude
DD=71
MM=7
SS=33
#latitude
dd=45
mm=25
ss=23
#nom site
NAME="Cosmolab"
altitude=579
# conversion de la longitude en deg vers heures
#  Strip possible leading zero(s) from argument passed
if [ ${#DD} -eq 2 ] ; then dlon=${DD#0} ; else dlon=$DD ; fi
if [ ${#MM} -eq 2 ] ; then mlon=${MM#0} ; else mlon=$MM ; fi
if [ ${#SS} -eq 2 ] ; then slon=${SS#0} ; else slon=$SS ; fi
if [ ${#dd} -eq 2 ] ; then dlat=${dd#0} ; else dlat=$dd ; fi
if [ ${#mm} -eq 2 ] ; then mlat=${mm#0} ; else mlat=$mm ; fi
if [ ${#ss} -eq 2 ] ; then slat=${ss#0} ; else slat=$ss ; fi
# calcul de la longitude en heures
let hourdeg=15
let deglon="$dlon"*3600+"$mlon"*60+"$slon"
let seclon="$deglon"/"$hourdeg"
let hrlon="$seclon"/3600
let mnlon=("$seclon"-"$hrlon"*3600)/60
let sclon="$seclon"-"$hrlon"*3600-"$mnlon"*60
/bin/echo "n" > skycalc.in
/bin/echo $hrlon $mnlon $sclon>> skycalc.in
/bin/echo $dd $mm $ss >> skycalc.in
/bin/echo $altitude >> skycalc.in
/bin/echo "700" >> skycalc.in
/bin/echo $NAME >> skycalc.in
/bin/echo "0" >> skycalc.in
/bin/echo "-" >> skycalc.in
/bin/echo "-" >> skycalc.in
/bin/echo "0" >> skycalc.in
/bin/echo "g " >> skycalc.in
/bin/echo "y" $1 $2 $3 "a" >> skycalc.in
/bin/echo "a" >> skycalc.in
/bin/echo "Q" >> skycalc.in
/usr/local/bin/skycalc < skycalc.in  > skycalc.out
/bin/cat skycalc.out | grep "Moon at"  > moonfrac.out



