1

Many people on the Astronomy stack exchange use the PyEphem package for the Python programmimg language to perform astronomical computations. Are the underlying numerical routines (from XEphem) also available for MATLAB?

Christo
  • 624
  • 5
  • 8

2 Answers2

2

Disclaimer: I've never used this toolbox and so cannot speak to the comparison of this toolbox with PyEphem.

There are some ephemeral and the like functions within Matlab, for example planetEphemeris, earthNutation, or moonLibration.

Unfortunately these functions are only accessible within the Aerospace Toolbox and do not come with a standard Matlab license. You'll need an entirely separate license for the Aerospace Toolbox to use these functions in your Matlab code.

If it is easy for you to obtain this license (be it from some university or organization), then by all means go for it. Otherwise, your best bet may be free packages like PyEphem.

I would also like to echo the comment made by David in that you should definitely learn Python. It is an amazingly simple, yet robust language that can do just about anything. And its free!

If you're really dead-set on using Matlab, but the PyEphem package is the only thing that does what you need, you can always consider porting between the two languages. Matlab has several tools and capabilities to interface with other languages. You can read more about using python packages natively in Matlab right here. I will say, this would probably be much harder than just going with Python outright though.

zephyr
  • 15,017
  • 1
  • 37
  • 58
2

The canonical reference for all astronomical calculations is the CSPICE library: http://naif.jpl.nasa.gov/naif/tutorials.html and some of the more important files they use are the ephemeris files: http://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/ is one example, but you can poke around for others.

I helped figure out the format (though it's actually fairly well documented) for Brandon's skyfield project (it's better than pyephem): https://github.com/skyfielders/python-skyfield/issues/19 even though I'm not a huge fan of Python myself.

I also created Perl and Mathematica programs to read/interpret the ephemeris files:

https://github.com/barrycarter/bcapps/blob/master/ASTRO/bc-xsp2math.pl

https://github.com/barrycarter/bcapps/blob/master/ASTRO/bc-ieee754.pl

https://github.com/barrycarter/bcapps/blob/master/STACK/bc-solve-mathematica-105671.m

https://github.com/barrycarter/bcapps/blob/master/STACK/bc-solve-mathematica-105671.pl

(these are all fairly ugly, so poke around a bit).

So, while I don't think there IS a MATLAB equivalent at the moment, it wouldn't be difficult to create one. Of course, using the well-tested CSPICE libraries is a better option unless you happen to loathe C