Blog

A blog about astronomy and software development, mainly focused on my experiences during the development of JPARSEC.

Blog

Tag index

Recent Posts

Most recent posts.

Numerical integration of planetary orbits with Newton's law

I remember when I was a kid drawing with my Amstrad the orbits of the satellites of Jupiter and the planets. I was 12 when I started doing that. Later at 16 or so, with a PC, I did my first n-body simulation of the planetary orbits in QBasic based on the Newton's law of gravitation, improved later with some ideas from the codes by S. Aarseth to reduce the time step of the simulation when two particles are very close. After that I did not think anymore about these simple n-body simulations.

At that time the JPL DE200 integration was already available, and S. Moshier had just published a C code reproducing those results (de118i program). Understanding that program is hard, I sometimes think how interesting could be to port it to Java. But the question I asked myself this time is how necessary is to consider some of the effects implemented in that program, like the figure of the Earth and Moon, the tides, or non-linear relativistic corrections to the gravity, to reproduce the JPL DE4xx rectangular coordinates. In other words, how accurate can be a numerical integration of the planets when using only the Newton's law ? So my idea with this educational post is to present a simple example program (included in the examples provided with JPARSEC) to propagate orbits and also to show/animate them in Java to obtain an updated implementation of my old programs.

Planetary ephemerides can be computed in a variety of ways, from numerical integration to analytical methods, or by using orbital elements. For an example of the two last methods you can take a look at my post about computing the position of the Sun, Moon, and planets. Here I will show the most simple case of numerical integration in which the target is to show the orbits visually (as in my old programs) but to also compute ephemerides up to the accuracy of the Newton's law of gravitation. As you will see this does not require necessarily an implementation with extended precision arithmetics. I will show some well-known but interesting effects like the movement of the Sun around the barycenter, or how to take advantage of this integrator to create a custom ephemerides file to obtain approximate results without messing with many GB of data from JPL files.

Although it is very simple, as an introduction I will revise how to implement the Newton's law programatically, with some notes about my particular implementation that uses as initial conditions the values obtained from a given JPL integration.

→ Read more...

2020/07/31 14:44 · Tomás Alonso Albi · 0 Comments

Solar System in 3d (part 2)

In an old, previous post I showed some renderings of Mars in 3d using Java3d. That library was abandoned long ago and I mentioned I was working in a newer version using JMonkeyEngine. Indeed I did that but never spend enough time to post the results here, as I was always busy with other things. Finally, it's time to show the results I obtained.

The starting point was the jmeplanet project by Aaron Perkins, which seems to be only available now on SourceForge as spaceworld. You can also enjoy some test videos he has on Youtube. The latest code there is probably the best option now, since I took an old version of his engine. Then I prepared the Mars images for each section of the planet using the MOLA altimetry data and a high resolution texture. I encoded some RGB and bump images using the channels to avoid losing accuracy in the altimetry (encoded as RGB channels also to conserve MOLA accuracy), so that these images can be directly loaded into the GPU and less space is needed. The code and textures used for such tasks are provided in the project link below, but obviously the original MOLA data is not included since the download is around 2 GB only for the altimetry.

As always I prefer to show results instead of describing in detail the code. In this case this is inevitable since I forgot almost everything about 3d programming (the little I learned with this project), and I developed this years ago. In addition, I simply put things together like in a puzzle, I'm not the author of the engine. But I think it can be useful and funny for others. I know a video would be better, but more time consuming, so I will put only screenshots (sorry).




 

There are some keys to control the movement (W, S, A, D; Q and E to rotate; S and X to go up and down), and in addition other keys like L and K to disable/enable the illumination and planet atmosphere. The program can also render the Earth, but using a low resolution bump map. Anyway, the global view with the atmosphere is quite nice, although not very realistic.


 

One of the few things I added to the original code (besides the real Mars textures) was the option to show an 'ocean' at a given height on the surface. The key g can be used to enable (or disable) gravity so that you will fall on the surface with the possibility of walking or even diving on the ocean. I show here two screenshots of the Chryse planitia (the region between Chryse and Vallis Marineris more exactly) in which it is evident the effects of the presence of water (erosion, sediments, lack of craters). It is also very clear the signs of the interaction of the lava with frozen water, visible as regions with many little fractures due to water vapor liberated from below the surface. The north region of Mars is about 2 km below the mean height and it is clear it was below water in ancient times. The key o will toggle the ocean at a level that emulates the approximate depth it had, which wasn't too high anyway, only a few hundred meters. This region is very interesting and some missions like Viking or Mars Pathfinder landed here. With the ocean activated it is very easy to follow its limits (the Mars coastline) and explore some others interesting places also linked to Vallis Marineris or even the Olympus Mons.



 

I had many ideas to evolve this project: identifying features, allow learning about the history of Mars, or doing the same with the Moon using the data from Clementine. Porting it to Android could be also feasible, but it seems I'm getting … old for such time demanding tasks. You are invited to download my not-so-little Mars project and play with or even evolve it. You will need of course the JMonkeyEngine library in the classpath, together with JOGL, JPARSEC, and the pngj libraries. The code is not very clean, but it works. Execute the SolarSystemTest class and enjoy!

2019/03/20 12:57 · Tomás Alonso Albi · 0 Comments

JPARSEC Sky Atlas

One of the little projects I developed some years ago was a sky atlas. It was a very first version showing the capabilites of JPARSEC to create renderings of the sky in different color modes, from the classical white background to the black one with real photographic textures of many deep sky objects. The atlas was a simplified version of the classical Sky Atlas 2000, by Wil Tirion, but updated for the latest equinox year and with less stars and objects (to print it in a more confortable A4 size). Since then the rendering options in JPARSEC has been improved, including the possibility of rendering the sky in a realistic, Stellarium-like way, but I didn't find this feature useful for this project in particular.

I didn't expect that post to become very interesting to others, but during these years some people, first from Russia, and then from Italy, showed interest and asked me to continue with this project creating the atlas for the next years and improving it. In the last two weeks I have taken some time to do some additional touches and to extend the atlas in different directions. There is now a first section showing the sky during the year with a list of astronomical events for each month, which is useful to later anallize the region in detail with the atlas itself. A first explanatory page is useful to directly go to a particular atlas chart, and in each chart I have improved the information shown and added a navigation aid. One point is that here at the Observatorio Astronómico Nacional we are working in an amateur-like equipment for outreach purposes, and this atlas could be interesting to use it in our observatory. Here we have a 30 cm and 40 cm refractors in parallel from the 1940s, an older 30 cm refractor from around 1910, and an even older meridian circle that is inside the museum building. We now have bought a Celestron C11 with a little refractor and a camera, and plan to use it mainly to show the Sun, but without sacrifying the possible use of this telescope during the night. We plan to recuperate the older telescopes also for this purpose. As a member of the Agrupación Astronómica de Madrid (the main amateur group of astronomers here) I'm also showing this atlas for the team involved in showing the sky to the group of beginners, the new people potentially joining our group. And, of course, because it is just fun to take an old project and improve it.

Probably the catalyst to this decision was the incredible Bungee Sky Atlas created by Angelo Nicolini with JPARSEC. This amazing atlas, maybe the best free atlas ever made, is extremely complete and detailed, very useful for expert observers. But one evident problem that this atlas leaves is the relatively lack of a less detailed atlas, in-between the Bungee Sky Atlas and the different atlases for beginners you can find in the web, like my favourite one the Free Beginners Star Atlas by Ed Vazhorov. Riccardo Camboni also contributed to make me work on this right now since he asked to do some improvements, for instance to remove the trajectories of planets and other bodies, which is something I may add in the future in another section of the atlas. Riccardo has also started some posts in forums to spread the existence of this atlas.


 

So in the last two weeks I have worked in the code, to clean it up enough and to publish it as GPL down below. The code is in just one laaaarge file (sorry!), since my code quality standards are limited to the library, not the projects I develop from it. There are different options in the first lines to set the color mode, language, and so on. As always I don't find interesting to extend a lot in my blog explaining the code: if you find it interesting and useful you will use it and play with it (so you will not need any help), if not, I will not lose my time to describe it in detail. Anyway, you have always the discussion section at the bottom to ask anything. There are a few todo things in Spanish at the top, so this code may improve and the 2020 version of the atlas could be even better.

You will find the new version of the atlas in Spanish and English in the Other projects section, currently only for year 2019. In case you want to create you own atlas with the code below, just remember the code is GPL and if you modify it, please publish it, and whatever atlas you may produce starting from this code must be published free of charge under the Creative Commons or similar license. You will need JPARSEC with its dependencies and the iText PDF library in the classpath to compile and execute this program. Just enjoy!

→ Read more...

Rendering the sky like Stellarium with JPARSEC

There is an old project called Stellarium for Java. It is a port of the old 0.8 version of Stellarium, which is a very popular planetarium due to its high quality, realistic renderings. This project uses the JOGL library to offer a similar experience to the original using Java, but unfortunately it was later abandoned.

I have recently analized the original code to look how this port renders the sky, in particular how it computes the atmosphere brightness and the sky colors considering the position of the Sun or the Moon. I have taken just this code and connected it to the rendering process used in JPARSEC, so that similar renderings can be done (pixel by pixel, so slower) without using the GPU. For this task I have updated JPARSEC with a few improvements (availables from the JPARSEC repository at bitbucket) to improve the horizon rendering with terrain, adding two more more textures.

The idea is to render the sky with JPARSEC using a given texture for the horizon and a transparent image, and reuse the SkyRendering object to compute, pixel by pixel, the illumination and color of the background atmosphere using the formulae from Stellarium. With this you only have to draw the sky image on top of the atmosphere image for the final image. So here are the great results…




 

I leave to you the task of analyzing the code to try to understand the underlying maths and physics, I prefer not to describe it since I'm not an expert, I have just borrowed the code. Here is the rather long Java class that can be used for such renderings in case you want to play with it.

→ Read more...

2018/02/19 16:10 · Tomás Alonso Albi · 1 Comment

Using GPhoto for move detection

This is my first blog entry in more than two years. I've been very busy with my Android planetarium project, now almost finished, but probably needed also some rest. Despite of that during this time I have developed a number of little nice projects, and waited for the right moment to resume my blog activity and release some of them. As ussual they are not oriented to specific goals, going from 3d renderings to solving complex and time consuming tasks in a completely automatic manner, or even to criptocurrencies.

In this post I present a little program aimed to detecting move and triggering shots with a camera automatically. It is based on the gphoto library, and uses the gphoto binding implemented in the JPARSEC library. Some features of the binding have been improved or developed to support this use case. For instance, the live view mode didn't support executing other commands except those to capture previews, and it wasn't possible to execute this mode without showing a panel object with those previews.

The program provides many (31) configuration options in a file named config.txt. Among others, it is possible to set some custom parameters for the camera at startup (ISO, shutter, aperture, among others) and right before the program ends, adjust the sensitivity of the move detection algorithm, configure masks the search for move only in certain areas, or to uppload the shots to a server.

My intenction is to use this program for security, shooting when move is detected with a high resolution camera instead of a webcam. After thinking from time to time on this a saw a post in the gphoto mail list from Alan Corey, asking for a way to do something similar for wild photography. So I decided to start writing the program and Alan collaborated testing it in his cameras. In fact, the program has been tested successfully in a Canon 40D, a Nikon D5200, and a Canon Powershot S70 and A520. It has also been tested in a variety of CPU devices, from a powerful desktop to a Raspberry PI 3. Here I will describe the basics of this program, some other details can be found in the gphoto mailing list and previous messages about the same subject.

The move detection algorithm is very simple. It searches for move in two ways: detecting a global change in the luminosity of the preview image, and detecting changes in the brightness level of the pixels. The preview image is internally converted to gray scale since the color data is not required to detect move. The global change is computed from the difference between the histograms of the preview image and a reference preview image taken when the program starts. This reference image should be free of movement, and is optionally updated in a given time interval to account for possible brightness changes due to the sky or the weather. The histogram difference is computed pixel by pixel, and this change in the gray color is also used to compute the number of individual pixels that present some move or change in that level, according to a different change criteria specific to individual pixels. So the second move detection check is computed from the percentage of individual pixels showing move, and the move is considered as detected when any of those two methods trigger a detection.

When this happens the program pauses the live view in the JPARSEC binding to execute other commands to take a number of shots, resuming back after that the live view mode.

The program has as dependency the jsch library to uppload images to a server, and the itextpdf for its Base64 class used here to include images in the web server. The idea is to compile it with Java 6 at least. Here is the code of the main class.

→ Read more...

2018/01/19 13:32 · Tomás Alonso Albi · 0 Comments

ClearSky for Android released

After 4 years developing from time to time a planetarium for Android (since the first experiments with this platform back in 2012), I have published the ClearSky planetarium in two versions: a free version quite generous in features and a paid version which is oriented to become useful to amateur astronomers with telescopes. This second page contains a detailed list of features of the commercial version, although the help document included in ClearSky describes everything with even more detail.

The free version contains almost everything a casual observer would need, including the possibility of showing comets and asteroids, which is usually offered only in commercial programs in Android. But the main difference from other tools is the great accuracy in JPARSEC, superior to most free and commercial programs available even on PC platform. In addition, Spanish and English are supported, with absolutely no adds.


 

→ Read more...

Gallery

Selected astronomical images taken with my equipment. As you will see, I'm not a professional photographer, but I do my best. Some of them are old images taken with a film camera, recent ones uses a digital SLR. In addition to the images I have also some videos:

Solar eclipse Solar annular eclipse on October, 3, 2005. It was my first day at OAN so I couldn't use my instrumental. I simply took the camera on my hands.

Venus transit: Venus transit on the Sun on July, 8, 2004. The black drop effect is clearly visible.

Solar eclipse: Solar eclipse of August, 11, 1999, as was shot through my S/C 20 cm telescope.

Log of visits

 
blog.txt · created: 2010/01/31 01:56 (Last modified 2020/08/06 22:15) 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