Wolfram Computation Meets Knowledge

Rendering the Structure of the Universe in Your Spare Time

The Sloan Digital Sky Survey (SDSS) is an ongoing endeavor to map the sky in great detail, with many different goals. One of the larger objectives is to map the structure of the cosmos by determining the positions of galaxies and their relativistic redshift (basically their distance). Using this data and Mathematica, you can plot the information and reveal the structure of the cosmos.

In my spare time, I queried the SDSS website, which is database driven, and in eight separate queries I was able to get all galaxies in the survey out to a redshift of 0.5. According to Wolfram|Alpha, this corresponds to looking back in time 5.02 billion years ago, or a distance of 6.14 billion light years, when the light we’re now seeing from the most distant galaxies started its journey here. That’s a billion years before our solar system formed. It’s taken this long for the light to reach us.

This animation is of only a tiny fraction of the visible universe, but still more than enough to give you a glimpse of the size and scale of the universe.

Each point represents a galaxy. Our galaxy would be at the very center (no, we aren’t the center of the universe—just the center of this animation). As you can see, galaxies tend to cluster along a web-like structure with “voids” interspersed. The survey images the sky in slices, which form the wedge-like pieces in the animation. These are the areas of the sky imaged so far.

The well-known Hubble Ultra Deep Field, while imaging galaxies to a much greater distance (about 13 billion years ago and redshifts between 7 and 12), covers only a tiny pinprick of the sky (11 arcminutes) and so doesn’t show the structure that this animation does.

This was achieved in Mathematica with a very tiny amount of code:

Graphics3D[{Opacity[.5], Lighter[ColorData[1, 1], 0.3`], PointSize[0], Point[proj]}, ImageSize → {1024, 768}, SphericalRegion → True, PlotRange → 0.5`, Background → Black, Boxed → False, ViewAngle → π/30]

Here proj is just the collection of triples {x, y, z} obtained from the SDSS data. I then just varied the ViewPoint and exported each frame. Find out more about using Mathematica in the field of astronomy on our Astronomy Solution page.


Join the discussion

!Please enter your comment (at least 5 characters).

!Please enter your name.

!Please enter a valid email address.


  1. Unfortunately youtube seems to have some problems because i can’t load the video. From your description it seems a very interesting animation.

  2. Good post, but it could have been much better. What were the MMA commands used to query the SDSS databases? What processing was required for the data? Did you try other view points?

    Answers to all these might have made a much much better post.

  3. Really cool. The Mathematica code really is short too, impressive.

    I think I’ve seen this rendered somewhere else too, oh yeah, the Millenium Simulation: http://www.mpa-garching.mpg.de/galform/millennium/

    Awesome stuff

  4. It’s so lucky for me to find your blog! So shocking and great! Just one suggestion: It will be better and easier to follow if your blog can offer rrs subscription service.

  5. great stuff, but trying to replicate all I got was a sphrical distribution of the points with a bright line in the middle. Could you please post the SQL code you used to obtain the data and also what distance scale did you use and how you converted from z to distance, here is what I used in the SQL:
    select ra,dec,z
    from specObj WHERE
    z BETWEEN 0.001 AND 0.5


  6. Its been quite a while and I’m not usually a database guy. I didn’t make the database calls from Mathematica since their website didn’t make it obvious how to do that, but I was able to get the data using the following SQL commands:

    sp.bestObjID as oid,
    sp.z as z,
    sp.specClass as specClass,
    sp.ra as ra,
    sp.dec as dec,
    sp.mag_0 as mag_g,
    sp.mag_1 as mag_r,
    sp.mag_2 as mag_i,
    gal.expMag_r as emag_r,
    gal.expAB_r as AB,
    gal.expPhi_r as phi,
    gal.expRad_r as rad_r,
    gal.expRad_i as rad_i,
    gal.petroR90_r / gal.petroR50_r as conc90_50
    FROM SpecObj as sp,
    Galaxy as gal
    WHERE sp.bestObjID = gal.objID
    and sp.z = 16000

    The last line needs to be tweaked to get a specific batch. Their site times out if the batch is too large. I downloaded each batch to a CSV file and then imported them. Each row had the form:

    {“oid”, “z”, “specClass”, “ra”, “dec”, “mag_g”, “mag_r”, “mag_i”, “emag_r”, “AB”, “phi”, “rad_r”, “rad_i”, “conc90_50”}

    To transform this data into something ready to be plotted in 3D, I used:

    proj = reduceddata /. {z_, ra_,
    dec_} :> {z Cos[ra Degree] Sin[dec Degree + Pi/2],
    z Sin[ra Degree] Sin[dec Degree + Pi/2], z Cos[dec Degree + Pi/2]}

    DIstance was not computed. Only redshift is plotted directly.