skyfielders / python-skyfield

Elegant astronomy for Python
MIT License
1.41k stars 211 forks source link

Getting Astorids like 2007 RH283 #196

Closed pukai30 closed 4 years ago

pukai30 commented 6 years ago

Is there any way to get the information astorids like '2007 RH283'. This is from DE431?

ghost commented 6 years ago

This isn't really a skyfield question, but https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/asteroids/ may help

brandon-rhodes commented 6 years ago

Printing out DE431 to get the list of supported objects

from skyfield import api

ts = api.load.timescale()
e = api.load('de431t.bsp')
print(e)

gives:

SPICE kernel file 'de431t.bsp' has 15 segments
  JD -3100015.50 - JD 8000016.50  (-13200-05-06 through 17191-03-14)
      2 -> 299  VENUS BARYCENTER -> VENUS
      1 -> 199  MERCURY BARYCENTER -> MERCURY
      3 -> 399  EARTH BARYCENTER -> EARTH
      3 -> 301  EARTH BARYCENTER -> MOON
      0 -> 10   SOLAR SYSTEM BARYCENTER -> SUN
      0 -> 9    SOLAR SYSTEM BARYCENTER -> PLUTO BARYCENTER
      0 -> 8    SOLAR SYSTEM BARYCENTER -> NEPTUNE BARYCENTER
      0 -> 7    SOLAR SYSTEM BARYCENTER -> URANUS BARYCENTER
      0 -> 6    SOLAR SYSTEM BARYCENTER -> SATURN BARYCENTER
      0 -> 5    SOLAR SYSTEM BARYCENTER -> JUPITER BARYCENTER
      0 -> 4    SOLAR SYSTEM BARYCENTER -> MARS BARYCENTER
      0 -> 3    SOLAR SYSTEM BARYCENTER -> EARTH BARYCENTER
      0 -> 2    SOLAR SYSTEM BARYCENTER -> VENUS BARYCENTER
      0 -> 1    SOLAR SYSTEM BARYCENTER -> MERCURY BARYCENTER
    1000000000 -> 1000000001  TDB -> TT

Which does not, alas, include any asteroids. You will have to find a different data source that provides you with information about asteroids.

brandon-rhodes commented 6 years ago

It looks like the official data file for that asteroid is available from:

https://minorplanetcenter.net/iau/MPCORB.html

We'll want Skyfield to download the compressed version, to consume as little MPC bandwidth as possible:

https://minorplanetcenter.net/iau/MPCORB/MPCORB.DAT.gz

Skyfield will need a way to turn the lines from this file into floating point orbital elements:

K07RS3H  8.7   0.15 K183N 147.97757  329.20556  286.41411   21.38204  0.3423667  0.01556767  15.8849887  0 E2018-R04    98  16 1983-2018 0.33 M-v 38h MPCLINUX   040A          2007 RH283         20180103

And then a routine to turn orbital elements into positions.

whiskie14142 commented 5 years ago

I can provide another way to access asteroid data, I think. HORIZONS system of NASA/JPL provides data for asteroids and comets. https://ssd.jpl.nasa.gov/?horizons

If you can use TELNET, try it to connect HORIZONS system as follows:

telnet horizons.jpl.nasa.gov 6775

on the command prompt or something like that

On the prompt of HORIZONS system, request to search an object by name as follows: Horizons> name = 2007 RH283 HORIZONS system will find the object, and you can get ephemeris and other data for the object by TELNET.

ghost commented 5 years ago

I'm leaving the below for legacy purposes, but I was looking at the wrong thing. If you type [S] after finding the asteroid, it will generate an SPK file and give you an anonymous FTP link to download it.

PLEASE IGNORE THE BELOW:

@whiskie14142 I tried this, and I couldn't find a way to get a BSP file or similar ephemeris out of it. I could get osculating orbital elements, vectors, and observer parameters, but I think the web interface gives you the same thing: https://ssd.jpl.nasa.gov/horizons.cgi#top (just type in "2007 RH283" for target).

However, I know the telnet interface is more powerful than the web interface, so I might be missing something. Is there a way to get an actual SPK kernel file out of the telnet interface? If so, that would be fantastic

ghost commented 5 years ago

Negotiating telnet to get a file can be difficult to do automatically, but NASA has provided a script: ftp://ssd.jpl.nasa.gov/pub/ssd/SCRIPTS/smb_spk

It actually uses 'expect' to telnet to horizons and get the data (so it's not a "magic backdoor"), but skyfield may be able to use this pre-written script to grab small body SPK files on the fly.

JoshPaterson commented 5 years ago

There's also a web form for generating and downloading spk files from Horizons:

https://ssd.jpl.nasa.gov/x/spk.html

ghost commented 5 years ago

Thanks, @JoshPaterson ! This makes it much easier to download BSPs. Just visit the URL:

https://ssd.jpl.nasa.gov/x/smb_spk.cgi?OBJECT=2007+RH283&OPT=Make+SPK&OPTION=Make+SPK&START=1000-JAN-01&STOP=2101-JAN-01&EMAIL=foo@bar.com&TYPE=-B

and you will get the BSP in return. This should be a lot easier to implement in skyfield.

WARNING: if you actually click on the link above, you will download a 7.9 megabyte file.

brandon-rhodes commented 4 years ago

Happily, Skyfield now documents how to get positions for asteroids from MPC data, as well as from Type 21 ephemerides from HORIZONS:

Feel free to follow up with a comment here if you have any trouble with the new feature!