4
4
5
5
[ ![ codecov] ( https://codecov.io/gh/PerezHz/HORIZONS.jl/branch/master/graph/badge.svg )] ( https://codecov.io/gh/PerezHz/HORIZONS.jl ) [ ![ Coverage Status] ( https://coveralls.io/repos/github/PerezHz/HORIZONS.jl/badge.svg?branch=master )] ( https://coveralls.io/github/PerezHz/HORIZONS.jl?branch=master )
6
6
7
- An interface to NASA- JPL [ HORIZONS ] ( https://ssd.jpl.nasa.gov/?horizons ) system in
7
+ An interface to JPL Solar System Dynamics [ APIs ] ( https://ssd.jpl.nasa.gov/api.html ) in
8
8
[ Julia] ( http://julialang.org ) .
9
9
10
10
## Author
@@ -17,16 +17,17 @@ Comments, suggestions, and improvements are welcome and appreciated.
17
17
## Installation
18
18
19
19
` HORIZONS.jl ` is a registered Julia package and may be installed
20
- from the Julia REPL doing ` import Pkg; Pkg.add("HORIZONS") ` . Current stable
21
- release is ` v0.3.0 ` , which is compatible with Julia 1.0, 1.3 and 1.4.
22
-
23
- ## External dependencies
24
-
25
- Connection to the HORIZONS machine is done via the ` telnet ` command line
26
- utility, which should be locally installed and enabled. File downloading is done via ` ftp ` .
20
+ from the Julia REPL doing
21
+ ```
22
+ ] add HORIZONS
23
+ ```
24
+ Current stable
25
+ release is ` v0.4.0 ` , which is compatible with Julia >= 1.6.
27
26
28
27
## Usage examples
29
28
29
+ ### Horizons API
30
+
30
31
The ` horizons() ` function is a shortcut to the HORIZONS ` telnet ` interface
31
32
prompt from the Julia REPL:
32
33
@@ -41,36 +42,39 @@ System news updated June 08, 2020
41
42
42
43
Horizons>
43
44
```
45
+ To run this function, the ` telnet ` command line utility should be locally installed and enabled.
46
+
44
47
45
- ` HORIZONS.jl ` also has Julia functions which for some of the scripts authored by
48
+
49
+ ` HORIZONS.jl ` also has Julia functions for some of the scripts authored by
46
50
Jon D. Giorgini for automated generation of small-body binary SPK files and tables.
47
51
These scripts were originally written in ` expect ` , and can be found at the
48
52
JPL's Solar System Dynamics group ftp server ` ftp://ssd.jpl.nasa.gov/pub/ssd/SCRIPTS/ ` .
49
53
Below, we describe the functions ` smb_spk ` , ` smb_spk_ele ` and ` vec_tbl ` .
50
54
51
- ### ` smb_spk `
55
+ #### ` smb_spk `
52
56
53
57
The ` smb_spk ` function automates generation and downloading of Solar System
54
58
small-bodies binary SPK files from HORIZONS:
55
59
``` julia
56
60
using HORIZONS, Dates
57
61
58
- # generate a binary SPK file for asteroid 99942 Apophis covering from 2021 to 2029
59
- ftp_name, local_file = smb_spk (" b " , " DES= 2099942 ;" , DateTime (2021 ,Jan,1 ), DateTime (2029 ,Apr,13 ))
62
+ # Generate a binary SPK file for asteroid 99942 Apophis covering from 2021 to 2029
63
+ local_file = smb_spk (" DES = 20099942 ;" , DateTime (2021 ,Jan,1 ), DateTime (2029 ,Apr,13 ))
60
64
61
- isfile (local_file) # check that the binary SPK file `local_file` exists
65
+ isfile (local_file) # Check that the binary SPK file `local_file` exists
62
66
```
63
67
Binary SPK files (i.e., extension ` .bsp ` ) can be read using e.g.
64
68
[ ` SPICE.jl ` ] ( https://github.com/JuliaAstro/SPICE.jl ) :
65
69
``` julia
66
- # import Pkg; Pkg. add(" SPICE") # uncomment this line to add `SPICE.jl` to current environment
70
+ # ] add SPICE" # uncomment this line to add `SPICE.jl` to current environment
67
71
using SPICE, Dates
68
72
furnsh (local_file)
69
73
et = 86400 * (datetime2julian (DateTime (2024 ,3 ,1 )) - 2.451545e6 )
70
- pv = spkgeo (2099942 , et, " J2000" , 0 )
74
+ pv = spkgeo (20099942 , et, " J2000" , 0 )
71
75
```
72
76
73
- ### ` smb_spk_ele `
77
+ #### ` smb_spk_ele `
74
78
75
79
` HORIZONS.jl ` function ` smb_spk_ele ` generates ` .bsp ` binary SPK files for
76
80
small-bodies from a set of osculating orbital elements at a given epoch:
@@ -88,120 +92,77 @@ inc = 24.4225258251465 # Inclination
88
92
start_time = DateTime (2021 ,Jan,1 )
89
93
stop_time = DateTime (2022 ,Jan,1 )
90
94
91
- # generate a binary SPK file for asteroid 1990 MU at `epoch`
92
- ftp_name, local_file = smb_spk_ele (" b " , " 1990 MU" , start_time, stop_time, epoch, ec, qr, tp, om, w, inc)
95
+ # Generate a binary SPK file for asteroid 1990 MU at `epoch`
96
+ local_file = smb_spk_ele (" 1990 MU" , start_time, stop_time, epoch, ec, qr, tp, om, w, inc)
93
97
94
- isfile (local_file) # check that the binary SPK was downloaded
98
+ isfile (local_file) # Check that the binary SPK was downloaded
95
99
```
96
100
97
- ### ` vec_tbl `
101
+ #### ` vec_tbl `
98
102
99
103
` HORIZONS.jl ` function ` vec_tbl ` allows the user to generate vector tables for
100
104
designated objects and save the output into a file:
101
105
102
106
``` julia
103
- # date variables for start and stop times
107
+ # Date variables for start and stop times
104
108
t_start = DateTime (2029 ,4 ,13 )
105
109
t_stop = Date (2029 ,4 ,14 )
106
110
107
- # step size (allowed types: Period, Int, String)
111
+ # Step size (allowed types: Period, Int, String)
108
112
δt = Hour (1 ) # 1 hour step size
109
113
110
- # generate tables and save output to Apophis.txt in current directory:
111
- vec_tbl (" Apophis" , " Apophis.txt " , t_start, t_stop, δt; CENTER= " @ssb" , REF_PLANE= " FRAME" , OUT_UNITS= 2 , CSV_FORMAT= true , VEC_TABLE= 2 )
114
+ # Generate tables and save output to Apophis.txt in current directory:
115
+ vec_tbl (" Apophis" , t_start, t_stop, δt; FILENAME = " Apophis.txt " , CENTER = " @ssb" , REF_PLANE = " FRAME" , OUT_UNITS = " AU-D " , CSV_FORMAT = true , VEC_TABLE = 2 )
112
116
```
113
117
114
118
Note that ` CENTER ` , ` REF_PLANE ` , etc., are keyword arguments. If they are omitted
115
119
from the ` vec_tbl ` call, then they will take default values:
116
120
117
121
``` julia
118
- δt = 1 # return only one step
122
+ δt = 1 # Return only one step
119
123
120
- # generate tables with default values and save output to Apophis.txt in current directory:
124
+ # Generate tables with default values and save output to Apophis.txt in current directory:
121
125
122
- vec_tbl (" Apophis" , " Apophis.txt " , t_start, t_stop, δt)
126
+ vec_tbl (" Apophis" , t_start, t_stop, δt; FILENAME = " Apophis.txt " )
123
127
```
124
128
125
129
More details about default values of keyword arguments are available in the
126
130
` vec_tbl ` docstrings.
127
131
128
132
If the output file is not specified, then ` vec_tbl ` returns the output as a
129
- string , which may be then used for further processing within Julia:
133
+ ` String ` , which may be then used for further processing within Julia:
130
134
131
135
``` julia
132
136
δt = " 2 hours" # 2 hour step size
133
137
134
- # save into `apophisvt::String` the output from HORIZONS
138
+ # Save into `apophisvt::String` the output from HORIZONS
135
139
apophisvt = vec_tbl (" Apophis" , t_start, t_stop, δt)
136
140
137
- # do stuff with `apophisvt` inside julia...
141
+ # Do stuff with `apophisvt` inside julia...
138
142
```
139
143
140
- Julia's broadcasting allows the user to get many vector tables at once:
141
-
142
- ``` julia
143
- julia> using HORIZONS
144
-
145
- julia> IDs = string .([99942 , 90000033 ])
146
- 2 - element Array{String,1 }:
147
- " 99942"
148
- " 90000033"
144
+ ### Small-Body DataBase API
149
145
150
- julia> local_files = string .(IDs," .txt" )
151
- 2 - element Array{String,1 }:
152
- " 99942.txt"
153
- " 90000033.txt"
154
-
155
- julia> vec_tbl .(IDs, local_files, t_start, t_stop, δt) # save output to local files 99942.txt and 90000033.txt in current folder
156
- 2 - element Array{Void,1 }:
157
- nothing
158
- nothing
159
-
160
- julia>
161
- ```
162
-
163
- Additionally, the ` vec_tbl_csv ` function returns HORIZONS output both as an
164
- ` Array{Any,2} ` and a CSV-formatted ` String ` , which
165
- can in turn be used to construct a ` DataFrame ` (requires
166
- [ DataFrames.jl] ( https://github.com/JuliaData/DataFrames.jl ) to be installed):
146
+ ` HORIZONS.jl ` function ` sbdb ` fetchs data for a specific small-body in JPL's Small-Body DataBase (SBDB) and returns the output as a ` Dict{String, Any} ` :
167
147
168
148
``` julia
169
- using HORIZONS, DataFrames
170
-
171
- dt0 = Date (2000 )
172
- dtmax = Date (2015 )
173
- δt = Year (1 )
149
+ # Fetch data of asteroid 433 Eros
150
+ sbdb (" sstr" => " Eros" )
174
151
175
- # tbl is an Array{Any,2}; str is a String with CSV format
176
- tbl, str = vec_tbl_csv (" 1950 DA" , dt0, dtmax, δt;
177
- VEC_TABLE = " 2" , REF_PLANE= " F" , CENTER= " coord" , COORD_TYPE= " C" , SITE_COORD= " 1,45,45" );
178
-
179
- mydataframe = readtable (IOBuffer (str))
152
+ # Fetch data of asteroid 99942 Apophis, including close-approach information
153
+ sbdb (" sstr" => " Apophis" , " ca-data" => " true" )
180
154
```
181
155
182
- Then, ` mydataframe ` is a 16×8 ` DataFrame ` :
156
+ ### Small-Body Radar Astrometry API
183
157
184
- ```
185
- # mydataframe:
186
- # 16×8 DataFrames.DataFrame
187
- │ Row │ JDTDB │ Calendar_Date_TDB │ X │ Y │ Z │ VX │ VY │ VZ │
188
- ├─────┼───────────┼──────────────────────────────────┼────────────┼────────────┼────────────┼─────────┼──────────┼──────────┤
189
- │ 1 │ 2.45154e6 │ "A.D. 2000-Jan-01 00:00:00.0000" │ 3.49475e8 │ 2.10629e7 │ 5.71688e7 │ 25.2192 │ 15.1321 │ 9.42222 │
190
- │ 2 │ 2.45191e6 │ "A.D. 2001-Jan-01 00:00:00.0000" │ -6.98285e7 │ 2.58022e7 │ 5.45238e7 │ 14.9524 │ -12.6021 │ -10.6881 │
191
- │ 3 │ 2.45228e6 │ "A.D. 2002-Jan-01 00:00:00.0000" │ 3.61348e8 │ -5.69666e7 │ 1.54172e6 │ 31.3711 │ 17.5209 │ 11.1536 │
192
- │ 4 │ 2.45264e6 │ "A.D. 2003-Jan-01 00:00:00.0000" │ 4.38864e7 │ 1.05596e8 │ 1.13413e8 │ 12.2543 │ -1.86915 │ -2.97705 │
193
- │ 5 │ 2.45301e6 │ "A.D. 2004-Jan-01 00:00:00.0000" │ 3.22054e8 │ -1.46042e8 │ -6.27119e7 │ 39.9381 │ 18.0432 │ 11.7154 │
194
- │ 6 │ 2.45337e6 │ "A.D. 2005-Jan-01 00:00:00.0000" │ 1.58117e8 │ 1.26817e8 │ 1.30187e8 │ 14.1172 │ 5.18222 │ 2.03615 │
195
- │ 7 │ 2.45374e6 │ "A.D. 2006-Jan-01 00:00:00.0000" │ 2.16183e8 │ -2.27991e8 │ -1.22995e8 │ 52.494 │ 15.0644 │ 9.69931 │
196
- │ 8 │ 2.4541e6 │ "A.D. 2007-Jan-01 00:00:00.0000" │ 2.52251e8 │ 1.08971e8 │ 1.18844e8 │ 17.5583 │ 9.77493 │ 5.43963 │
197
- │ 9 │ 2.45447e6 │ "A.D. 2008-Jan-01 00:00:00.0000" │ 7.88944e6 │ -2.43067e8 │ -1.36722e8 │ 65.0567 │ -6.41305 │ -5.42335 │
198
- │ 10 │ 2.45483e6 │ "A.D. 2009-Jan-01 00:00:00.0000" │ 3.21987e8 │ 6.3783e7 │ 8.74408e7 │ 21.7692 │ 13.586 │ 8.1631 │
199
- │ 11 │ 2.4552e6 │ "A.D. 2010-Jan-01 00:00:00.0000" │ -1.15663e8 │ -7.63649e7 │ -1.92427e7 │ 27.1975 │ -22.6347 │ -17.6561 │
200
- │ 12 │ 2.45556e6 │ "A.D. 2011-Jan-01 00:00:00.0000" │ 3.57936e8 │ -3.91115e6 │ 3.95854e7 │ 27.1418 │ 16.0684 │ 10.0908 │
201
- │ 13 │ 2.45593e6 │ "A.D. 2012-Jan-01 00:00:00.0000" │ -3.42864e7 │ 6.17015e7 │ 8.08374e7 │ 13.0119 │ -8.54587 │ -7.70992 │
202
- │ 14 │ 2.45629e6 │ "A.D. 2013-Jan-01 00:00:00.0000" │ 3.55506e8 │ -8.52031e7 │ -1.86717e7 │ 33.8279 │ 18.0591 │ 11.5473 │
203
- │ 15 │ 2.45666e6 │ "A.D. 2014-Jan-01 00:00:00.0000" │ 8.32588e7 │ 1.17897e8 │ 1.22693e8 │ 12.6344 │ 0.803698 │ -1.08723 │
204
- │ 16 │ 2.45702e6 │ "A.D. 2015-Jan-01 00:00:00.0000" │ 2.96116e8 │ -1.75053e8 │ -8.37231e7 │ 43.4907 │ 17.7757 │ 11.5517 │
158
+ ` HORIZONS.jl ` function ` sbradar ` searches for radar astrometry of asteroids/commets and returns the output as a ` Dict{String, Any} ` :
159
+
160
+ ``` julia
161
+ # Search Apophis' radar astrometry
162
+ sbradar (" spk" => " 20099942" )
163
+
164
+ # Add observer information
165
+ sbradar (" spk" => " 20099942" , " observer" => " true" )
205
166
```
206
167
207
168
## License
@@ -226,11 +187,9 @@ The [HORIZONS](https://ssd.jpl.nasa.gov/?horizons) system itself is the work of
226
187
- Paul Chodas (some subroutines)
227
188
- The NAIF group (SPICELIB) (esp. Chuck Acton, Bill Taber, Nat Bachman)
228
189
229
- Translation from the original ` expect ` scripts to Julia was done using the
230
- [ Expect.jl] ( https://gitlab.com/wavexx/Expect.jl ) package.
231
-
232
190
## References
233
191
192
+ * [ JPL Solar System Dynamics APIs] ( https://ssd.jpl.nasa.gov/api.html )
234
193
* [ HORIZONS documentation (HTML)] ( https://ssd.jpl.nasa.gov/?horizons_doc )
235
194
* Giorgini, J.D., Yeomans, D.K., Chamberlin, A.B., Chodas, P.W.,
236
195
Jacobson, R.A., Keesey, M.S., Lieske, J.H., Ostro, S.J.,
0 commit comments