Astronify: Sonifying Time Series

This tutorial will demonstrate the sonification of time series data, specifically light curves using Astronify. It will cover basic usage, adjusting sonification parameters, playing the sonification within the browser, and saving the sonification as a wav file.

  1. Imports

  2. Getting data

  3. Basic sonification

  4. Changing sonification parameters

  5. Outputting an audio file


In addition to Astronify, we will use the Lightkurve package to query and download Kepler light curves, matplotlib to plot the light curves (these cells will be markes and can be skipped by those for whom plots are not useful), and Astropy for various data manipulation tasks.

* Don’t worry if you get a warning about WxPython not being found, it’s used for the GUI functionality audio library, which Astronify does not use.

>>> from astronify.series import SoniSeries
>>> import lightkurve

>>> import matplotlib
>>> import matplotlib.pyplot as plt

Getting data

Fundamentally all that Astronify requires is an Astropy Table object where one colum will be translated into time (default is “time”) and one column will be translated into pitch (default is “flux”).

I will download a Kepler light curve using Lightkurve (Lightkurve is a user friendly way to get Kepler and TESS data). This is a light curve that shows Kepler 12b, a transiting exoplanet.

>>> kep12b_lc = lightkurve.search_lightcurvefile("KIC 11804465", cadence="long", quarter=1).download_all()[0].SAP_FLUX.to_table()

Basic sonification

Here we will use all of the sonification defaults and see what we get.

First a small peak at the data visually for those of us who find that useful.

>>> f, ax = plt.subplots(figsize=(12, 6))
>>> ax.plot(kep12b_lc['time'].jd, kep12b_lc['flux'])
>>> ax.set_xlabel("Time (JD)")
>>> ax.set_ylabel("Flux")


Now to sonify the same data.

>>> kep12b_obj = SoniSeries(kep12b_lc)
>>> kep12b_obj.sonify()

And play the sonification.


The playback will stop at the end, but we can also stop it early.

>>> kep12b_obj.stop()

Changing sonification parameters

Let’s look at the current sonification parameters.

>>> kep12b_obj.pitch_mapper.pitch_map_args
{'pitch_range': [100, 10000],
 'center_pitch': 440,
 'zero_point': 'median',
 'stretch': 'linear'}

We can change all of these default arguments as well as adding any additional arguments allowed by the pitch mapping function.

Changing the center pitch

>>> kep12b_obj.pitch_mapper.pitch_map_args["center_pitch"] = 880

>>> kep12b_obj.sonify()
>>> kep12b_obj.stop()

>>> kep12b_obj.pitch_mapper.pitch_map_args["center_pitch"] = 440

Changing the stretch to logarithmic

>>> kep12b_obj.pitch_mapper.pitch_map_args["stretch"] = "log"

>>> kep12b_obj.sonify()
>>> kep12b_obj.stop()

>>> kep12b_obj.pitch_mapper.pitch_map_args["stretch"] = "linear"

Removing the outer 1% of data points

>>> kep12b_obj.pitch_mapper.pitch_map_args["minmax_percent"] = [0.5, 99.5]

>>> kep12b_obj.sonify()
>>> kep12b_obj.stop()

>>> del kep12b_obj.pitch_mapper.pitch_map_args["minmax_percent"]

Outputting an audio file

Once the sonification sounds the way we like we can output the result to a wav file.

>>> kep12b_obj.write("kepler_12b.wav")
Pyo message: Offline Server rendering file kepler_12b.wav dur=16.879996
Pyo message: Offline Server rendering finished.

Kepler 12b audio file