Telnet example
Connect:
telnet ssd.jpl.nasa.gov 6775
Choose Earth (399). 3: 3rd planet, 99: The planet itself:
Horizons> 399
Enter E
to select Ephemeris.
Enter to select Vectors.
Now: the coordinate center must be chosen. Using an id, one of 1500+ predefined sites can be selected. 500 is the geocenter. That's what I want here:
Coordinate center [ <id>,coord,geo ] : ~500~
Press enter to confirm.
Reference plane: Choose e for eclip.
Starting TDB: for example 2017-01-01
. Ending TDB: another date.
Output interval: 1d
gives one record per day.
The returned coordinates (X
, Y
and Z
) seem to be in kilometers.
Accessing cgi with a perl script
#!/usr/bin/perl
#
# Access JOP's Horizons web interface.
#
# This script is an adapted version of a sample
# perl script written 2006-Mar-02 by Alain B. Chamberlin (JPL/Caltech).
# Unfortunately, I am unable to locate the script's url anymore.
#
# Use of this script is at your own risk.
#
use strict;
use LWP::UserAgent;
my @data = ( #_{
"COMMAND = 399" ,
"CENTER = 500@0" ,
"MAKE_EPHEM = YES" ,
"TABLE_TYPE = VECTORS" ,
"START_TIME = 2017-01-01",
"STOP_TIME = 2017-01-10",
"STEP_SIZE = 1d" ,
"OUT_UNITS = KM-S" ,
"VECT_TABLE = 2" ,
"REF_PLANE = ECLIPTIC" ,
"REF_SYSTEM = J2000" ,
"VECT_CORR = NONE" ,
"VEC_LABELS = NO" ,
"CSV_FORMAT = YES" ,
"OBJ_DATA = YES" ,
); #_}
for (@data) { #_{
# Remove any spaces surrouning '=' for compactness
s/ *= */=/;
# Escape special URL characters
s/ /%20/g;
s/\&/%26/g;
s/;/%3B/g;
s/\?/%3F/g;
} #_}
# Create URL
my $url = 'https://ssd.jpl.nasa.gov/horizons_batch.cgi?batch=1&';
$url .= join('&', @data);
# print "URL: $url\n";
my $ua = new LWP::UserAgent;
my $req = new HTTP::Request;
$req->method("GET");
$req->url($url);
my $res = $ua->request($req);
die "$url\n" . $res->status_line . "\n" if ( $res->is_error );
print $res->content;