JPARSEC 1.9 just cooked


JPARSEC 1.9 just cooked

After two months I have finally put everything consistently for the new release of JPARSEC, which is full of new features I had previously in 'incubating' mode. For this major release I have revised the reduction of ephemerides to implement polar motion and to add the effects of the diurnal/subdiurnal tides to the EOP parameters. I have compared results with NOVAS and with other calculations I found by Patrick Wallace in some articles or in the SLALIB package. A new implementation of ephemerides based on the CIO (using matrices) is available in IAU2006 class, that complements the NPB and GCRS-to-TIRS matrix calculations previously available. The inconsistency I've seen between the two reduction modes (CIO-based and J2000 dynamical equinox) is around 40 microarcseconds, using double values and sometimes BigDecimal in critical situations. When comparing the results between NOVAS for both methods the inconsistency is similar. In less words, the accuracy of JPARSEC is now better than 0.1 milliarcseconds.

I have implemented also several algorithms for the correction of elevation and RA/DEC by refraction. Besides the classical equation by Bennet (extended now to radio wavelenths) I have added the implementation by Yan (1996) for optical and radio wavelengths as well as the implementation by P. Wallace in the SLALIB package, using numerical integration. These options as well as others affecting ephemerides and previously available in Configuration class are now located in the EphemerisElement class, and can be selected individually for each ephemerides calculation in the corresponding instance of that class.

Another point is a boost in the calculation of astronomical events, using a new class called EventReport. It uses the Feed class to create a report of many astronomical events that can be published as an RSS feed easily. Besides eclipses, occultations, mutual events, and other fundamental events the class allows to calculate other non-ussual events, but sometimes interesting to amateurs, like when a given comet/asteroid crosses in the field of view of a deep sky object to take a shot. Another special event I have added is the calculation of possible periodic LTP (Lunar Transient Phenomena). I remember a funny summer I pass a long time ago studying some NASA reports from the 50s to 70s on the subject, and trying to correlate the LTP phenomena with the elevation of the Sun at that moment in the crater where the LTP appeard. I found several correlations for some craters (Plato, Ptolemaeus, and others) during sunrise/sunset on them (the abrupt change of the surface temperature can produce levitation of the grains and this produces moving shadows and red spots on the surface), and decided to 'predict' new LTPs and to try to observe them. From a given location that means the possibility of observing a few of them over the year, but fortunately I had two of them on that summer. Predictions are now here, but be aware that I didn't observe any of them. Anyway the sunrise on these craters is impressive and worths a look through the telescope.

However, the main features of this release are the support for Android platform and the possibility of rendering the sky and planets from any position in the Solar System. Let's go with both.

Rendering the sky and planets in Android

To achieve this I have worked in two directions. Firstly I reduced JPARSEC to the minimum to create a version suitable for Android, but eliminating only the less relevant things. Almost everything related to ephemerides can still be done, but without the detailed options and extreme accuracy of the full desktop version. JPARSEC has now two desktop versions, the full one and the Android-equivalent one. Secondly I created a DataBase class, also used in the desktop version, that allows to manage the data used in the library efficiently, selecting to hold everything in memory or in external files. Second option results is less memory use but also in a performance penalty. Obviously I also worked to reduce memory consumption in general, and now JPARSEC reaches peaks of 50 MB instead of the 300 reached before. Current version of the planetarium example for Android holds data in memory since the ratio performance/memory is still not good enough to use it.

The DataBase class also helps to hold data in a thread-safe way. In previous versions the ephemerides of natural satellites were computed as an offset (obtained from a given theory for that satellite) from the mother planet. Now it's the same, but the offset can be different in different threads and no static variables are used.

Sky and planetary rendering looks cool in Android. On my old 1.6 Android phone I cannot show planets due to its internal 24 MB limitation, but I can show the sky and drag it without problems (and quite fast). The Android 1.6 emulator on my desktop PC has more problems and inmediately crashes when dragging, since in this case the memory limitation seems to be 16 MB. In Android 2.x and 3.x I have no idea since the emulators don't boot on my PC. Fortunately, in Android 4 the memory limitations are lower and the emulator is quite fast provided that one stops a given app and launches it manually using the emulator. It's an annoying thing when testing an app: when you launch it the app is installed on the emulator like in a tablet, and launched, but it runs very slow, requiring minutes to start. But if you stop the app on the emulator and launch it again from it, first rendering is shown in 30s only, which is not bad considering the amount of ephemerides calculations, mainly with stars. I don't know why this happens. Taking into account that this process runs around 3 times faster than in my very old Android phone, with a 500 MHz ARM CPU, probably the startup process will be quite fast in any mid-range Tablet.


At startup the app needs around 15 MB. When zooming on a planet the memory requirement reaches 25 MB after showing the satellites, and around 32 to render Saturn with the rings. I have reduced the resolution of the textures by a factor 4 (more in some cases since I have also limited the maximum width of the textures to 512 pixels) to include all of them (even deep sky objects) in just 1 MB, without sacrifying a lot of detail. In case the milky way is shown with textures along with deep sky objects, memory consumption peaks at around 50 MB, and the Android 4 emulator starts to give problems. This is because I set the memory limit to 48 MB in this case, but this level can be greater in the emulator to solve this. I suppose this can be configured also in a real Android 4 device, but it is necessary to show a lot of things to make this happen. I will investigate how to save more memory and improve the behavior of the DataBase class for this, but anyway performance is quite acceptable and should be much faster in a real Android 4 tablet, so memory is the only technical issue.

The implementation of the Graphics interface in AndroidGraphics class (see this as an intro) required a lot of tweaks to mimic the behavior of the AWT library in Java desktop platform. It seems Android is not designed or optimized for this kind of tasks, and the implementation of some methods (drawPoint, drawLine, or fillOval) show differences that should not be there.

Since out of memory errors appears only when showing a lot of things I consider Android platform to be supported by JPARSEC, maybe in an experimental phase and maybe only for Android 4, but as you see in the pictures it works fine, and soon it will be possible to produce a full featured planetarium.

Renderings from different directions

JPARSEC now supports the calculation of ephemerides as seen from a given point in the Solar System, including the effects of light-time, aberration (for a given speed of the observer at that point), and deflection of light, to say some of them. There's a new class called ExtraterrestrialObserverElement that can be parsed (like a city or an observatory on Earth) to produce an ObserverElement object to use it in ephemerides. Some hard reorganization was required in JPARSEC to support the abrupt change in the reference position of the observer, and also to support this feature when rendering the sky and planets, but the result is excellent. This feature is still not supported when rendering artificial satellites (I plan to support rendering probes around other planets, Mars for instance), and some minor errors still exist in the planetary rendering pipeline, but again it is looking good. This effort is a first step towards the support of other bodies besides the Earth when rendering the sky, something I remember I tried two years ago for Mark Powell (engineer at JPL), but I didn't have enough time to do it properly. Soon it will be done. In Android it is supported too.


As you see in the figures the rendering capabilities of JPARSEC are reaching a considerably degree of realism. The support for different observing positions also makes possible true 3d anaglyph views, instead of the fake 3d mode implemented previously. Although it gives a similar output and much faster, a true 3d mode will be more accurate for close views of planets and rings, and would allow to produce very realistic videos. An observer position outside the Earth can be used in the SkyChart component by using the mentioned extraterrestrial object, but inside the component there's still no way to move the observer within the Solar System. I will decide if it is better to provide this support or to develope a new applet to visualize the Solar System. It would be mainly to show space probes and the history of space exploration, something like Celestia, but with much more accurate maths and slower since I'm not using the 3d graphics card.

There are some major features still missing in JPARSEC, but probably this will be the last major release in JPARSEC. End of development seems soon, maybe around February or March of the next year. I really want to do other things. I plan to release 3 or 4 new versions spaced in two months until the end, but now I will stop development for some time to complete other tasks.


Fernando Margueirat, 2012/10/02 23:02


La verdad que se ve impresionante. Lamentablemente no tengo un Android :(. Quiero aprovechar para felicitarte por tu creacion. Soy un aficionado a la mecanica celeste y me he entretenido mucho “jugando” con el JParsec. Me gustaria tener proyectos mas cientificos para poder aprovechar todas las capacidades de esta libreria, pero por ahora me conformo reproduciendo los calculos de Meeus en su serie de libros de Astronomy Morserls :).



Mark, 2012/11/06 04:47

simply its great. well design and well written. keep it up.

Thank You

Tomás Alonso Albi, 2012/11/08 22:59

Gracias Fernando, me alegro de que encuentres interesante mi trabajo. La próxima versión de la libreria va a ser bastante mejor que la actual a la hora de graficar el cielo, te animo a que la pruebes cuando la publique. Por cierto, yo tampoco tengo un Android si quitamos un móvil muy antiguo, así que el programa lo testeo sólo con el emulador y a veces con la tableta de un amigo…

Thanks Mark, sure I will continue with this project since it will be the core of any other thing I will do later. Now I'm working full time to finish it and having a lot of fun!

Tomás Alonso Albi, 2012/12/10 10:48

Si alguien quiere jugar con la versión para Android es posible descargar un programa muy básico desde aquí.

If you want to play with a basic Android app using JPARSEC you can download an apk package from here.

Darren Enns, 2013/01/01 19:14

Wow! Accidentally stumbled across your PDF titled “Development of a web ephemeris server”, and then tracked down your webpages here via Google. I am very impressed by the effort you have put into this, going way beyond my own (also starting with Basic many years ago, then Python, and most recently HTML5/javascript).

I am particularly intrigued with your port to Android. I also have no cell phone, but my plans are to eventually (soon?) purchase an android tablet e.g. Nexus 7 or Nexus 10. I can just imagine how beautiful your stuff would be on the extreme-high-res Nexus 10! For the benefit of the vast majority of Android users, though, do you intend to make your app available in the 'Google Play Store' – it would make finding and installing this much easier, right? :)

Tomás Alonso Albi, 2013/01/01 21:21

Hi Darren! A few days ago I had the opportunity to test JPARSEC in a Nexus 7 (after testing some weeks ago in a 'cheap' tablet), and I got impressed with the quality of the output, similar to the desktop version (much better than the output from the emulator), and with the speed. I also wondered how it would look in Nexus 10, and decided immediately to work more on it to create an app for the Android Market. I cannot say when it will be ready (around few months, after finishing the main library), but my plan is to work on it soon. Probably it will be called ClearSky, the same name I put to the desktop version.

Thanks for your comments and happy new year!

Emilio Rueda, 2013/03/10 12:40

Impresionante trabajo, Tomás.

Acabo de probarlo hoy mismo en mi Samsung Note.

He detectado un pequeño bug, por el cual no funciona el Zoom en los dispositivos móviles.

Para detectar el evento ACTION_POINTER_DOWN debemos cambiar la línea int action = event.getAction(); por esta otra: int action = event.getAction() & MotionEvent.ACTION_MASK;


Tomás Alonso Albi, 2013/03/10 13:15

Hola Emilio. Gracias por el aporte, recientemente me compre un Nexus 4 para empezar a desarrollar mas el programa de cara al Android Market, y ya era consciente del problema del zoom. Utilize cierto tutorial de Internet, pero algo se me escapo y no sabia lo que era. Espero sacar la proxima version de mi libreria y del programa Android en menos de 2 semanas, ira un 30% mas rapido y corregire el problema del zoom. Saludos.

Enter your comment
   ___    _  __   ___   __  __   _  __
  / _ |  / |/ /  / _ | / / / /  | |/_/
 / __ | /    /  / __ |/ /_/ /  _>  <  
/_/ |_|/_/|_/  /_/ |_|\____/  /_/|_|
blog/jparsec_1_9.txt · created: 2012/08/30 16:56 (Last modified 2019/04/14 16:37) by Tomás Alonso Albi
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki