pyPeriod


NamepyPeriod JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/woolgathering/pyPeriod
SummarySethares and Staley's Periodicity Transforms
upload_time2020-09-16 17:33:50
maintainer
docs_urlNone
authorJacob Sundstrom
requires_python>=3.0
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pyPeriod

Sethares and Staley's Periodicity Transforms in Python. See the paper [here](https://sethares.engr.wisc.edu/paperspdf/pertrans.pdf).

There is still much work to be done on these in terms of efficiency but it is a faithful implementation of the ideas and algorithms found in the paper. This is an alpha version so expect breaking changes in the future.

## Usage
```
import numpy as np
from pyPeriod import Periods
from random import uniform

# define a signal
sr = 1000 # samplerate
f1 = 10 # frequency
f2 = 17
noise = 0.2 # percent noise

# Make some signals with some noise. The second signal has a slightly offset phase.
a = [np.sin((x*np.pi*2*f1)/sr)+(uniform(-1*noise, noise)) for x in range(2000)]
b = [np.sin(((x*np.pi*2*f2)/sr) + (np.pi*1.1))+(uniform(-1*noise, noise)) for x in range(2000)]
c = np.array(a)+np.array(b) # combine the signals

# normalize, though the algorithms can handle any range of signals (best if DC is removed)
c /= np.max(np.abs(c),axis=0)

p = Periods(c) # make an instance of Period

"""
The output of each algorithm are three arrays consisting of:
  periods: the integer values of the periods found
  powers: the floating point values of the amount of "energy" removed by each period found
  bases: the arrays, equal in length to the input signal length, that contain the periodicities found
"""

# find periodicities using the small-to-large algorithm
periods, powers, bases = p.small_to_large(thresh=0.1)

# find periodicities using the M-best algorithm
periods, powers, bases = p.m_best(num=10)

# find periodicities using the M-best gamma algorithm
periods, powers, bases = p.m_best_gamma(num=10)

# find periodicities using the best correlation algorithm
periods, powers, bases = p.best_correlation(num=10)

# find periodicities using the best frequency algorithm
periods, powers, bases = p.best_frequency(sr=sr, win_size=None, num=10)
## note that for best frequency, we need a samplerate. The window size, if not provided,
## is the same length as the input signal. A larger window is zero-padded, a smaller
## window is truncated (not good).

```

### Algorithms
- Small-to-large
- M-best
- M-best gamma
- Best correlation
- Best frequency

### Documentation
Forthcoming. Between the source and the paper, it should be pretty easy to understand in the meantime.

## Requirements
- `numpy>=1.19.2`


## Contributors
- Jacob Sundstrom: University of California, San Diego



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/woolgathering/pyPeriod",
    "name": "pyPeriod",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Jacob Sundstrom",
    "author_email": "jacob.sundstrom@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/0d/89/21db565e97f056356d19f7564c8b0bb0f21eef70c957a34c9fbaeb9c53af/pyPeriod-0.1.0.tar.gz",
    "platform": "",
    "description": "# pyPeriod\n\nSethares and Staley's Periodicity Transforms in Python. See the paper [here](https://sethares.engr.wisc.edu/paperspdf/pertrans.pdf).\n\nThere is still much work to be done on these in terms of efficiency but it is a faithful implementation of the ideas and algorithms found in the paper. This is an alpha version so expect breaking changes in the future.\n\n## Usage\n```\nimport numpy as np\nfrom pyPeriod import Periods\nfrom random import uniform\n\n# define a signal\nsr = 1000 # samplerate\nf1 = 10 # frequency\nf2 = 17\nnoise = 0.2 # percent noise\n\n# Make some signals with some noise. The second signal has a slightly offset phase.\na = [np.sin((x*np.pi*2*f1)/sr)+(uniform(-1*noise, noise)) for x in range(2000)]\nb = [np.sin(((x*np.pi*2*f2)/sr) + (np.pi*1.1))+(uniform(-1*noise, noise)) for x in range(2000)]\nc = np.array(a)+np.array(b) # combine the signals\n\n# normalize, though the algorithms can handle any range of signals (best if DC is removed)\nc /= np.max(np.abs(c),axis=0)\n\np = Periods(c) # make an instance of Period\n\n\"\"\"\nThe output of each algorithm are three arrays consisting of:\n  periods: the integer values of the periods found\n  powers: the floating point values of the amount of \"energy\" removed by each period found\n  bases: the arrays, equal in length to the input signal length, that contain the periodicities found\n\"\"\"\n\n# find periodicities using the small-to-large algorithm\nperiods, powers, bases = p.small_to_large(thresh=0.1)\n\n# find periodicities using the M-best algorithm\nperiods, powers, bases = p.m_best(num=10)\n\n# find periodicities using the M-best gamma algorithm\nperiods, powers, bases = p.m_best_gamma(num=10)\n\n# find periodicities using the best correlation algorithm\nperiods, powers, bases = p.best_correlation(num=10)\n\n# find periodicities using the best frequency algorithm\nperiods, powers, bases = p.best_frequency(sr=sr, win_size=None, num=10)\n## note that for best frequency, we need a samplerate. The window size, if not provided,\n## is the same length as the input signal. A larger window is zero-padded, a smaller\n## window is truncated (not good).\n\n```\n\n### Algorithms\n- Small-to-large\n- M-best\n- M-best gamma\n- Best correlation\n- Best frequency\n\n### Documentation\nForthcoming. Between the source and the paper, it should be pretty easy to understand in the meantime.\n\n## Requirements\n- `numpy>=1.19.2`\n\n\n## Contributors\n- Jacob Sundstrom: University of California, San Diego\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Sethares and Staley's Periodicity Transforms",
    "version": "0.1.0",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "0d7fc01bac6aff20f34566b23bf8d196",
                "sha256": "f29d5ea5455ad1d8b79749a8b6aa9e9269ddd54d1411bfbc3f87dfed275ea114"
            },
            "downloads": -1,
            "filename": "pyPeriod-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0d7fc01bac6aff20f34566b23bf8d196",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.0",
            "size": 6852,
            "upload_time": "2020-09-16T17:33:48",
            "upload_time_iso_8601": "2020-09-16T17:33:48.468951Z",
            "url": "https://files.pythonhosted.org/packages/02/d9/c816442418d1429956af00c8dbc9ae4c2d1dbdd0799130d81b9a83c96823/pyPeriod-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "ec674534d0e96af1ac39939da6b997d6",
                "sha256": "72490be1813e836c2e7f64324b615e338f17bf87e91d0d06d0ca8ee6e100cb14"
            },
            "downloads": -1,
            "filename": "pyPeriod-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ec674534d0e96af1ac39939da6b997d6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.0",
            "size": 5460,
            "upload_time": "2020-09-16T17:33:50",
            "upload_time_iso_8601": "2020-09-16T17:33:50.834998Z",
            "url": "https://files.pythonhosted.org/packages/0d/89/21db565e97f056356d19f7564c8b0bb0f21eef70c957a34c9fbaeb9c53af/pyPeriod-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-09-16 17:33:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "woolgathering",
    "error": "Could not fetch GitHub repository",
    "lcname": "pyperiod"
}
        
Elapsed time: 0.14161s