Code Monkey home page Code Monkey logo

astronify's Introduction

Astronify logo

Sonification of astronomical data.

Powered by Astropy Badge PyPi Status Documentation Status

Tools for sonifying astronomical data.

This package is currently in the very beginning stages and is under active development to include sonification of time series data, specifically light curves.

Project Status

Astronify's GitHub Actions CI Status Astronify's Codecov coverage status

Developer Documentation

Installation

$ git clone https://github.com/spacetelescope/astronify.git
$ cd astronify
$ pip install .

For active development, install in develop mode

$ pip install -e .

Testing

Testing is run with tox (pip install tox). Tests can be found in tests/ sub-directories.

$ tox -e test

Tests can also be run directly with pytest:

$ pip install -e .[test]
$ pytest

Documentation

Documentation files are found in docs/.

We build the documentation with tox (pip install tox):

$ tox -e build_docs

You can also build the documentation with Sphinx directly using:

$ pip install -e .[docs]
$ cd docs
$ make html

The built docs will be in docs/_build/html/, to view them go to file:///path/to/astronify/repo/docs/_build/html/index.html in the browser of your choice.

Release Protocol

Follow the Astropy template release instructions.

Contributing

We love contributions! Astronify is open source, built on open source, and we'd love to have you hang out in our community.

Imposter syndrome disclaimer: We want your help. No, really.

There may be a little voice inside your head that is telling you that you're not ready to be an open source contributor; that your skills aren't nearly good enough to contribute. What could you possibly offer a project like this one?

We assure you - the little voice in your head is wrong. If you can write code at all, you can contribute code to open source. Contributing to open source projects is a fantastic way to advance one's coding skills. Writing perfect code isn't the measure of a good developer (that would disqualify all of us!); it's trying to create something, making mistakes, and learning from those mistakes. That's how we all improve, and we are happy to help others learn.

Being an open source contributor doesn't just mean writing code either. You can help out by writing documentation, tests, or even giving feedback about the project (and yes - that includes giving feedback about the contribution process). Some of these contributions may be the most valuable to the project as a whole, because you're coming to the project with fresh eyes, so you can see the errors and assumptions that seasoned contributors have glossed over.

Note: This disclaimer was originally written by Adrienne Lowe for a PyCon talk, and was adapted by Astronify based on its use in the README file for the MetPy project.

License

This project is Copyright (c) Clara Brasseur, Scott Fleming, Jennifer Kotler, Kate Meredith and licensed under the terms of the BSD 3-Clause license. This package is based upon the Astropy package template which is licensed under the BSD 3-clause licence. See the licenses folder for more information.

astronify's People

Contributors

ceb8 avatar dhuppenkothen avatar outdatedpine906 avatar pllim avatar scfleming avatar theresadower avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

astronify's Issues

Polyphonic Functionality

Add ability to sonify multiple objects in different channels allowing more than one dataset to play at the same time

No sound output when running through command line.

While I am able to hear sound as expected for a single .play() command in a Python notebook, if running as part of a script from the command line I do not hear any sound at all, just a very brief "click" from my speakers.

Test edge cases for transit injection.

Haven't done a ton of testing for edge cases, especially for transit signals that end right near / on / right after the end of the light curve array to make sure the code doesn't miss the final bin, or add an extra, etc.

Fix Documentation Navigation Links

Add links to easily move between docs sections and a link back to the home page within each section.
Read the Docs side bar currently only shows links within that section, but not for the entire project.

Error while imporrting.

Hi, I'm having the following traceback while importing astronify.
I'm under Win11, Python 3.11.8, iPython 8.22:
In [1]: import astronify

ImportError Traceback (most recent call last)
Cell In[1], line 1
----> 1 import astronify
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\astronify_init_.py:7
1 # Licensed under a 3-clause BSD style license - see LICENSE.rst
2
3
4 # Packages may add whatever they like to this file, but
5 # should keep this content at the top.
6 # ----------------------------------------------------------------------------
----> 7 from ._astropy_init import * # noqa
8 # ----------------------------------------------------------------------------
11 from . import series # noqa
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\astronify_astropy_init.py:21
19 import os
20 from warnings import warn
---> 21 from astropy.config.configuration import (
22 update_default_config,
23 ConfigurationDefaultMissingError,
24 ConfigurationDefaultMissingWarning)
26 # Create the test function for self test
27 from astropy.tests.runner import TestRunner
ImportError: cannot import name 'update_default_config' from 'astropy.config.configuration' (C:\Users\Utente\AppData\Local\Programs\Python\Python311\Lib\site-packages\astropy\config\configuration.py)

Thanks for any help on how to fix it.

Enhance readme

Add additional information to the readme

  • Information on how to run tests locally
  • Information on how to build docs locally
  • Better description of the project

Fix issues that come from negative values

We have issues with calculating the total area and standard deviation error when data points go into the negative y-axis. The current possible solution for this would be to offset all the data by some value to shift it up and out of the negatives, but this would be creating false flux and therefore auditory comparison between spectra would not be possible in the future.

Pitch mapping function

utils.pitch_mapping.data_to_pitch

Needs:

  • Stretching functions are not working - fix (they are from Astrocut and worked fine there, not sure what changed)
  • Allow for pitch limits in Hz
  • Allow for value limits (clipping) as minmax percent
  • Allow for value limits (clipping) as values in same units as original data
  • center_point -> zero_point should be able to take Hz, "median" or "mean"

Why does sonification not work if only two values present?

For transit simulator or case of top of square (e.g., square wave) the output sound isn't as expected. One would expect two distinct sounds at roughly 1/3 and 2/3 the allowed tone range, but instead it is basically monotone. This could be a bug, or could be result of algorithm being used, will investigate.

Handle clipping

It's possible and in fact too easy to overwhelm the speaker and get unpleasant sounds, we need to implement automatic clipping so this can't happen.

ANN: Please migrate away from pytest-openfiles

Hello. The Astropy Project has decided to retire pytest-openfiles, a plugin to detect open files in pytest runs. We see that you are using it in this repo. While you may continue to use it, please be advised that it will no longer be maintained going forward. See https://github.com/astropy/pytest-openfiles#important-retirement-roadmap for more information. We apologize for any inconvenienced cause.

If this issue was opened in error and is irrelevant, feel free to close.

Thank you for your patience.

xref astropy/pytest-openfiles#47

Metronome

Create function to easily add a regular beat behind sonification that acts as tics on the time axis. (default to data time, ie: 4 days)

User should be able to define the frequency of the beat.

Improve long data series handling

Above a certain number of data points (somewhere between the number in a Kepler long cadence light curve and the number in a Kepler short cadence light curve) playing or writing a sonification starts to hang and kill the kernal. Ideally we would fix Astronofy so that any length is fine. But if that is not possible at the least there should be a hard limit and error thrown so that unsuspecting users do not repeatedly kill their kernel not knowing what the problem is.

R/D: Explore pyo streams

Currently we're doing one stream per note, this seems unnecessary and spawns way too many streams. Figure out a better way to do this.

Can not call write() in Python notebooks.

I am unable to make a call to write() on a sonified object. I haven't debugged it a ton yet, but it seems there is an order-of-operations problem in the _write() pyo statement (at least for me) where it again causes an error about the server being booted.

It complains around this set of code:

` self.server.reinit(audio="offline")
self.server.boot()
self.server.recordOptions(dur=delays[-1]+duration, filename=filepath)

    env = pyo.Linseg(list=[(0, 0), (0.1, 1), (duration - 0.1, 1),
                           (duration - 0.05, 0.5), (duration - 0.005, 0)],
                     mul=[self.gain for i in range(len(pitches))]).play(
                         delay=list(delays), dur=duration)
    sine = pyo.Sine(list(pitches), 0, env).out(delay=list(delays),
                                               dur=duration)
    self.server.start()`

where it is unhappy with the .play() command inside the 'env' line. I tried moving the server.start() above the env line, but no avail.

Unable to play more than one sound in a single notebook.

Within a Python notebook, I am unable to run a .play() on more than one sonified object. The error I get is one where it states "the server must be botted before...", the first call to .play() works as expected, but a second call to another sonified object fails.

Save multiple sonified data from 'soni_obj.play()'

Hi,
I heard the other day about Astronify, what a great project!

As I started exploring and creating sound objects. In Jupyter Notebook I can play simultaneously several files just by having multiple soni_obj.play() one after the other, however, I can .wirte() only individual files, so I was wondering is it possible to write all into a file - as it is played?
I'm using it to sonify galaxy groups - therefore, trying to test how clear would be to hear an entire group of galaxies played/saved at the same time.

User control

Add more user controls:

  • Time range
  • Speed (time between notes really)

Handling uncertainty?

Seeing as uncertainty is vital to communicating scientific results properly, I was wondering if there are ways to use astronify to embed uncertainty information in outputs? I noticed that SoniSeries doesn't explicitly support this, but workarounds and hacks for doing this would be useful.

Possible error if given a series of fluxes that are exactly identical.

While not expected in real data, when I tried to sonify a simulated light curve that was perfectly constant (all fluxes were exactly the same value) I got "divide by zero" errors and no sound. I suspect the problem is in calculating one or more ranges for setting some parameters. The expectation is that if the array is exactly all the same value, one should get a constant tone out.

Handle presence of NaN's correctly.

Currently the Jupyter kernel will die if sonify() is given a set of fluxes with NaN values in it. These should be filtered out, or the algorithm should be made NaN-safe, depending on our decision for a mitigation strategy. Kepler/K2 data can sometimes have NaN values in the time array to, so the solution should be applied to both the time and flux axes.

Installing astronify at the Rubin Science Platform in `data.lsst.cloud`

I'm trying to install astronify at the Rubin Science Platform (RSP) in data.lsst.cloud to create a short Jupyter Notebook demonstration on how to use astronify with LSST-like data.

At first, pip install --user astronify would run into problems with portaudio (the details are in this public forum question: https://community.lsst.org/t/installing-astronify-via-homebrew-on-rsp-notebooks/8066). A colleague from Rubin suggested doing a minimal installation of pyo to exclude portaudio since portaudio is used when you want to play audio on the same computer that you’re running the code on, but on the RSP the code runs in a data center somewhere, so instead you need to use IPython to interface with the browser to play the audio. This solution worked fine as of November of 2023, but now the following error message appears when trying to import astronify in a notebook:

ImportError: libsndfile.so.1: cannot open shared object file: No such file or directory

A colleague from Rubin suggested that astronify might be out of date with respect to the astropy built into rubin-env, which has astropy 6.0.0..

Create .wav duration warning message

Write up a condition to catch for when n_spacing creates a .wav file that takes too long (>10 seconds?). Given the n_spacing + the num. of individual data points that will be sonified, calculate the length of time it will take to sonify the entire data table. If it takes too long, warn the user and let them know their n_spacing is too large.

Basic documentation

Readthedocs documentation to the level where we can show it to users

  • Fix logo
  • Add installation instructions
  • Example that shows:
  • Getting Kepler light curve
  • Setting up a SoniSeries object
  • Sonifying data
  • Playing sonification
  • Adjusting parameter(s)
  • Writing sonification to wav file
  • Embedded sound file
  • Show plot as well for sighted users
  • Downloadable pyfile with all the code from the example(s)
  • Docstring documentation

Get rid of 6th bin for some data files

Sometimes we end up with a 6th bin (filled with zeros, so does not affect the actual output) probably due to the num. of data points not being divisible by 5. Low priority, but still needs to be addressed.

Hearing Test

Create a way for a user to test their hearing so they can learn optimal pitch outputs to use when sonifying data they want to study

Similar to how fancy earbuds do this when you first configure them

Store Sonification Configurations

Create a way for a user to name and store a group of configs for things like pitch, speed, timing, point spacing, etc.

This can also be used to name and store default configs for different types of data
 (ie: flares vs transit).

Basic tests and CI

Add basic testing framework

  • Write basic unit tests
  • Hook up github actions CI
  • Hook up codecov
  • Hook up astropybot for pep8/changelog/milestone checking

Remove example files

The Astropy template come with a number of example files. These need to be removed from the repository.

Add pitch range parameter

Allow users to select the pitch range they are most comfortable listening to for Astronify snapshot functionality (and for the main functionality), for more accessibility.

Animation Function

Write Python function that generates mp4 animation by combining the .gif graph images and .wav sonification sound.

@ceb8 has notebook with code to get started with this

IO improvement

Allow for more flexibility in input formats

  • Allow time column to be float or AstropyDate
  • Check that other tabular forms are accepted (pandas dataframes? numpy ndtables?) not just Astropy Tables
  • Replace hard coded values with actual arguments

Allow doctests to use lightkurve

Several examples in the main docs require lightkurve, it should be possible to add lightkurve as a required package just for the doctests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.