<jupyter_start><jupyter_text>Astronify: Sonifying Time SeriesThis 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](Imports)2. [Getting data](Getting-data)3. [Basic sonification](Basic-sonification)4. [Changing sonification parameters](Changing-sonification-parameters)5. [Outputing an audio file](Outputing-an-audio-file)  ImportsIn addition to Astronify, we will use the [Lightkurve](https://docs.lightkurve.org/) package to query and download Kepler light curves, [matplotlib](https://matplotlib.org/) to plot the light curves (these cells will be markes and can be skipped by those for whom plots are not useful), and [Astropy](https://www.astropy.org/) 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.<jupyter_code>from astronify.series import SoniSeries
import lightkurve

import matplotlib
%matplotlib inline
import matplotlib.pyplot as plt

from astropy.table import Table<jupyter_output><empty_output><jupyter_text>Getting dataFundamentally 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”).Simply because it is easy 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.<jupyter_code>kep12b_lc = lightkurve.search_lightcurvefile("KIC 11804465", cadence="long", quarter=1).download_all()[0].SAP_FLUX.to_table()<jupyter_output><empty_output><jupyter_text>Basic sonificationHere 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.<jupyter_code>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")
        
plt.show()<jupyter_output><empty_output><jupyter_text>Now to sonify the same data.<jupyter_code>kep12b_obj = SoniSeries(kep12b_lc)
kep12b_obj.sonify()<jupyter_output><empty_output><jupyter_text>And play the sonification.<jupyter_code>kep12b_obj.play()<jupyter_output><empty_output><jupyter_text>The playback will stop at the end, but we can also stop it early.<jupyter_code>kep12b_obj.stop()<jupyter_output><empty_output><jupyter_text>Changing sonification parametersLet's look at the current sonification parameters.<jupyter_code>kep12b_obj.pitch_mapper.pitch_map_args<jupyter_output><empty_output><jupyter_text>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<jupyter_code>kep12b_obj.pitch_mapper.pitch_map_args["center_pitch"] = 880

kep12b_obj.sonify()
kep12b_obj.play()
kep12b_obj.stop()

kep12b_obj.pitch_mapper.pitch_map_args["center_pitch"] = 440<jupyter_output><empty_output><jupyter_text>Changing the  stretch to logarithmic<jupyter_code>kep12b_obj.pitch_mapper.pitch_map_args["stretch"] = "log"

kep12b_obj.sonify()
kep12b_obj.play()
kep12b_obj.stop()

kep12b_obj.pitch_mapper.pitch_map_args["stretch"] = "linear"<jupyter_output><empty_output><jupyter_text>Removing the outer 1% of data points<jupyter_code>kep12b_obj.pitch_mapper.pitch_map_args["minmax_percent"] = [0.5, 99.5]

kep12b_obj.sonify()
kep12b_obj.play()
kep12b_obj.stop()

del kep12b_obj.pitch_mapper.pitch_map_args["minmax_percent"]<jupyter_output><empty_output><jupyter_text>Outputing an audio fileOnce the sonification sounds the way we like we can output the result to a wav file.<jupyter_code>kep12b_obj.write("kepler_12b.wav")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08987341772151898, 'fraction_numerical': 0.021265822784810127, 'mean_word_length': 7.460385438972163, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 3, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '262891', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1404, 'n_tokens_neox': 1309, 'n_words': 355, 'path': 'docs/notebooks/Intro_Astronify_Series.ipynb', 'repo_name': 'OutdatedPine906/astronify', 'size': '3950'}