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


Tag index

Recent Posts

Most recent posts.

Solar System in 3d (part 3)

Due to COVID last summer was long, and in addition to the project related to numerical integration of planetary orbits I made a 3d project using Java3D to simulate the entire Solar System. In fact this was my main project and as a break I did the other. I also enjoyed many youtube videos about AI and machine learning from MIT, and played with WEKA (a machine learning library). While confined I learned a lot, but fortunately this year will end soon.

I expected to improve this project and present it during the Spring here, but new ideas are coming to my head and I prefer to present this project before the end of the year so I can forget about 3d stuff for a while (hopefully forever) and go back to more practical astronomy with a new control system for telescopes. For now there is only a youtube video about it, in Spanish, but even if you understand it I wouldn't recommend wasting your time watching it, it's quite boring…

Respect the 3d Solar System the idea was to create a Java3D implementation of the Celestia space simulator, just to learn some Java3D and do something funny during the summer. I know there are more powerful libraries, but Java3D is easy to learn. It is a pity I cannot project shadows with it like in the previous 3d blog entries about Mars and Moon using JMonkeyEngine. Of course the program I wrote depends heavily on my JPARSEC library, but it has only 2100 lines of code to create the VirtualUniverse, put on it the tree of objects (BranchGroup, Transform3D stuff), and include the animation (PositionPathInterpolator and RotationInterpolator) and user interaction. The planets are shown as spheres in this first version, and many other things are listed as TODO at the top. As some from the MIT would say, TODO stuff are things you will never do … At least the code is clean enough to be easy to follow and understand (I think so), even in this first version, and despite having all the stuff in just one class. So if you have more time than me then you can continue the project.

This program is quite useful to learn the basics about Java3D and 3d in general. All objects are added in a tree depending one on another, so that if a planet is moving around the Sun and a satellite orbiting around the planet, the satellite is also moving around the Sun. The PositionPathInterpolator is updated in intervals of half an orbit so that the simulation shows the accurate position of the satellite and the time can be reversed. The planets are Shape3D objects added at the end of all the transforms, with their appearance and material properties. The atmospheres of the Earth or Mars are created with a set of almost transparent spheres trying to simulate the atmospheric opacity. For the Earth the clouds layer is added with a particular rotation so they move around the Earth surface independently. To mimic the behavior of Celestia I included a transition effect when the navigation mode is set to free so that the camera is rotated towards the destination body and then its position is interpolated to simulate a trip. The free mode will not follow the planet or satellite as it moves, to do that the free mode should be disabled to enter the orbit mode, in which you can follow even the satellite as it moves around the mother planet. The user interaction supports the alt and shift keys to move the camera in a similar way as Celestia does.

The program also shows the sky, constellations, and the ecliptic line. As a TODO I had the idea of implementing all the sky with Java3D including deep sky objects with textures, to be later integrated in JPARSEC along with the current but powerful 2d mode for sky rendering. My library can even be used to render 3d videos pixel by pixel without the need of any 3d library (with geometry and lighting done by hand, quite funny to implement), but of course with a 3d library the animation is more smooth and enjoyable. The face of the terrestrial planets or the Great Red Spot in Jupiter are also incorrect in the simulation, I was in fact working on that (longitude of central meridian of the planets) right before the end of the Summer. Of course, I may work on all this in a future, or not, who knows …

Here is a 5 minute video of the program in action.


→

2020/12/14 12:45 · Tomás Alonso Albi · 0 Comments

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/little summer project 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.

→

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


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!

→

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.

→

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.

→

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


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