# Moutmout's blog

Astronomy, computers, random thoughts

## Lucy in Space Engine

Pimping Space Engine to visualize a space mission

And0uille

For a video I have been preparing about my trip to Spain with NASA (you can read about it in French here (part 1) and here (part 2)), I wanted to show Jupiter’s trojan asteroids, the asteroid Polymele and the spacecraft Lucy. I asked And0uille for help setting everything up in Space Engine. Here is her explanation on how to add everything you need in Space Engine to illustrate the Lucy mission.

## Installing Space Engine on Debian

Let’s start with some good news: it is possible to run Space Engin 0.990 on Debian (tested on Debian 11)!

First, install Steam by following the instructions given here. Then start the Steam client and purchase the game (~$20). To make it “installable"on Debian, go to the menu Steam > Settings > Steam Play and check “Enable Steam Play for all other titles”. In the menu right underneath (“Run other titles with”), select “Proton 6.3-7” (that’s the most up to date version at the moment of publication). Steam needs to be restarted. Once Steam has restarted, you can start the installation of Space Engine. Once Space Engine is installed, click on “Play”. A window will appear asking you to install Linux Steam Runtime - Soldier”. Let Steam install this tool, then restart Space Engine! ## Adding an asteroid By default, Polymele doesn’t exist in Space Engine. We will create a new file to define this asteroid so that you can se it in the software. To do this, we use the Space Engine guide on how to create a planet (the process is exactly the same when creating an asteroid). In the folder [steam folder]/common/SpaceEngine/data/catalogs/planets/ create the file polymele.sc (downloadable here). Asteroid "Polymele/15094 Polymele (1999 WB2)" { ParentBody "Sol" AsterType "JupiterTrojan" AbsMagn 11.78 SlopeParam 0.15 Albedo 0.091 Radius 10.5375 RotationPeriod 5.8607 Orbit { Epoch 2459396.5 SemiMajorAxis 5.174 Period 4.3e+03 Eccentricity 0.0959 Inclination 12.99 AscendingNode 50.33 ArgOfPericenter 4.31 MeanAnomaly 354.19 PericenterDist 4.678 } }  You can find information about Polymele on (for instance) its Wikipedia page. The parameter description (definition, use, units,…) is available in the documentation of Space Engine. We could create an asteroid in a similar fashion in Celestia by adding in the right directory a file describing the physical parameters of Polymele. One of the nice things with Space Engine is that it is possible to see logs describing the processing of our “.sc” file. When a line is poorly formatted, this makes it easy to know which one by taking a look at the log file [steam folder]/common/SpaceEngine/system/se.log. We could go even further by creating a texture and a shape for Polymele, but we’ll just go with a generic shape (we don’t really know yet what Polymele looks like anyway). We get the following result: ## Importing many asteroids automatically Now that we’ve imported Polymele in Space Engin, we figured that it might be a bit lonely. Space Engine only references 155 trojan asteroids out of… many. But we’re not going to import them one by one! There are online databases maintained by public institutions that list (among other things) trojan asteroids and some of their known properties. That is in particular the case of this database (NASA Jet Propulsion Laboratory). It lists roughly 100,000 trojan asteroids for Jupiter. For each asteroid, additional information is listed on its orbit, size, magnitude, etc… We can query this database by selecting our parameters of interest: • Limit by Object Kind / Group - We select “object kind : asteroids” • Limit by Orbit Class : “Jupiter Trojan” • Output Selection Controls : this is where we select the informations that are of interest to us for each asteroid. In order to easily import our asteroids into Space Engine, we need to know for each asteroid the following info: • Date of first observation (date of first obs.) [DiscDate] • Diameter (diameter) [Radius] : the units need to be converted • Absolute magnitude (H) [AbsMagn] • Rotation period (rot_per) [RotationPeriod] • Obliquity (NO DATA) [Obliquity] • Albedo (albedo) [Albedo] • Description of the orbit: • Epoch (epoch) [Epoch] • Semi-major axis (a) [SemiMajorAxis] • Revolution period (period) [Period] • Mean anomaly (M) [MeanAnomaly] • Argument of the pericenter (peri) [ArgOfPericenter] • Excentricity (e) [Eccentricity] • Inclination (i) [Inclination] • Ascending node (node) [AscendingNode] • Periapsid (q) [PericenterDist] Note: The parameter names for the JPL database are written bewteen parentheses. Those for Space Engine are written between brackets. Once our query is written, we can download the corresponding JSON file. A fair warning: the website says “Download CSV-format”, but you will in fact be downloading a JSON file. This can be done from the API with the command given below. I developped a small Python script that uses the data we just downloaded and organizes it in such a way that it can be imported by Space Engine. In practice, here are the steps: 1. Download the trojan asteroid database from the website, or with the API using the following command: $ curl -s -X $'GET' 'https://ssd-api.jpl.nasa.gov/sbdb_query.api?fields=full_name,first_obs,diameter,H,rot_per,albedo,epoch,a,per,ma,w,e,i,om,q&full-prec=false&sb-class=TJN&sb-kind=a&www=1' -o JPL-trojans.json  2. Convert this database into a format that Space Engine can understand: $ python3 create-se-trojans-db.py -i JPL-trojans.json -o trojans-asteroids-spaceengine.sc

3. Copy the resulting file to [steam folder]/common/SpaceEngine/data/catalogs/planets/

Note : the polymele.sc file created earlier can be deleted. Polymele is included in the list of trojans we just created (under the designation “15094 Polymele (1999 WB2)").

Here is what Space Engine looks like before and after adding the trojans :)

Now let’s add the star that Polymele briefly passed in front of on October 1st (read about it in French). Just like when we created an asteroid, we have to create a file that describes the star. The star that we are interested in has the following coordinates (indicated on the Lucy mission website):

RA 04:21:15.8, Dec +23:13:24 (J2000).

We can look for this star in the SIMBAD database by its coordinates. Type the star’s coordinates with this format, for example: 04:21:15.8+23:13:24. This brings us here. To interpret the information presented on the SIMBAD website, you can use a little help from this website.

We copy the right ascension, the declination and the apparent magnitude. To get the distance in parsecs between the Sun and this star, we need to convert the parallax.

In SIMBAD, the “flux” information indicates how much light we receive from this star in a few wavelength bands. By default, we decide to make this star a “G” star (“Normal star”). Also by default, we select the subclass “5V” (see the Space Engine documentation). This gives us the file describing the star which is available here. And you can see the result in this next image:

At last, let’s add the spacecraft Lucy!

First we download the 3D blender model (free) from this website (credit murilo.kleine). This model needs to be converted to the “obj” format to be imported in Space Engine. We open the file with Blender and simply go to “File > Export to > obj”. Two files are created: an “mlt” file and a “obj” file. We will need both.

Create the following file structure:

• [Steam]/common/SpaceEngine/addons/lucy/models/spacecraft/lucy.obj
• [Steam]/common/SpaceEngine/addons/lucy/models/spacecraft/lucy.sss
• [Steam]/common/SpaceEngine/addons/lucy/textures/spacecraft/lucy.mtl

The “sss” file (for “SpaceEngine Spacecraft Scheme”) is built based on the parameters described in the documentation of Space Engine. To build this spacecraft, we started off with a spacecraft already available in Space Engine named “Apollo Eagle”. You can change a few paramters if you wish, but we only changed the “Class” of the spacecraft to indicate that it is a probe. There likely are many more things to look at for spacecraft, and it might be the topic of a future article. But for now, that’s the only change we will make.

Then launch Space Engine in order to “build” Lucy. In the startup menu, select “Flight Simulator”. The “SpaceCraft Manager” window will open. Select “Build”. Pick the spacecraft we want to import and for which we created the “sss” file, then click on “Build”. Close the window and return to the “Spacecraft Manager”. Our spacecraft should have appeared in the list. Select it and go take a look at it (Go to)!

## Conclusion

In Space Engine, we can now access some extra trojan asteroids, and we can even see the trojan and the greek camps pretty clearly! We also have the star that was occulted by Polymele on October 1st. It’s a lot of fun to be able to explain an astronomical phenomenon with a pretty 3D visualization and the possibility to navigate through space. Lastly, I have to say that Space Engine is rather well thought out. Many things (stars, asteroids, spacecraft based on a Blender model,…) can be added without too much toil. In any case, I hope that these few lines will help some of you add stuff to Space Engine :)

I haven’t really delved into the scenario script system, which makes it possible to create “visits” of outer space. I started to take a look… but I’m not convinced yet. To be continued! I haven’t found yet how to move the spacecraft in space (set a route, use it like the Millenium Falcon spaceship,…) either, but I would like to, so there might be more tutorials to come!