diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/horizon.api.get | 29 | ||||
-rwxr-xr-x | tools/horizon.getdata.awk | 3 | ||||
-rwxr-xr-x | tools/horizonget | 31 |
3 files changed, 63 insertions, 0 deletions
diff --git a/tools/horizon.api.get b/tools/horizon.api.get new file mode 100755 index 0000000..22a909e --- /dev/null +++ b/tools/horizon.api.get @@ -0,0 +1,29 @@ +#!/bin/rc +# +# NASA JPL Horizons API +# https://ssd.jpl.nasa.gov/horizons/ +# +rfork ne +center=() +target=() +t0=() +t1=() +step=() +flagfmt='' +args='center target t0 t1 step' + +fn usage { + aux/usage + exit usage +} + +if(! ifs=() eval `{aux/getflags $*} || ! ~ $#* 5) + usage + +center=$1 +target=$2 +t0=$3 +t1=$4 +step=$5 + +hget 'https://ssd.jpl.nasa.gov/api/horizons.api?format=text&COMMAND='''$target'''&OBJ_DATA=''YES''&MAKE_EPHEM=''YES''&EPHEM_TYPE=''VECTORS''&CENTER='''$center'''&START_TIME='''$t0'''&STOP_TIME='''$t1'''&STEP_SIZE='''$step'''&VEC_TABLE=''1''' diff --git a/tools/horizon.getdata.awk b/tools/horizon.getdata.awk new file mode 100755 index 0000000..2fa62ee --- /dev/null +++ b/tools/horizon.getdata.awk @@ -0,0 +1,3 @@ +#!/bin/awk -f +BEGIN{ doprint=0 } +{ if($1 == "$$EOE") doprint=0; if(doprint) print; if($1 == "$$SOE") doprint=1; } diff --git a/tools/horizonget b/tools/horizonget new file mode 100755 index 0000000..8aa9308 --- /dev/null +++ b/tools/horizonget @@ -0,0 +1,31 @@ +#!/bin/rc +rfork ne +cwd=`{basename -d $0} +center='@sun' +target=() +t0=`{date -f 'YYYY-MM-DD' `{echo `{date -n} - 86400 | bc}} +t1=`{date -f 'YYYY-MM-DD'} +step='1 d' +flagfmt='' +args='target [t0 t1]' + +fn usage { + aux/usage + exit usage +} + +if(! ifs=() eval `{aux/getflags $*}) + usage + +switch($#*){ +case 1 + target=$1 +case 3 + target=$1 + t0=$2 + t1=$3 +case * + usage +} + +$cwd^/horizon.api.get $center $target $t0 $t1 $step | $cwd^/horizon.getdata.awk | tr A-Z a-z |