{"id":17272498,"url":"https://github.com/hbldh/lspopt","last_synced_at":"2025-04-14T08:31:58.591Z","repository":{"id":2727539,"uuid":"47278181","full_name":"hbldh/lspopt","owner":"hbldh","description":"Python implementation of a multitaper window method for estimating Wigner spectra for certain locally stationary processes","archived":false,"fork":false,"pushed_at":"2025-01-07T16:23:29.000Z","size":691,"stargazers_count":22,"open_issues_count":0,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-24T09:03:53.547Z","etag":null,"topics":["estimation","histogram","multitaper-windows","optimal-multitapers","python","spectrum","stochastic-processes"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hbldh.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-02T17:52:39.000Z","updated_at":"2025-01-14T07:32:43.000Z","dependencies_parsed_at":"2023-02-13T20:50:39.016Z","dependency_job_id":null,"html_url":"https://github.com/hbldh/lspopt","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hbldh%2Flspopt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hbldh%2Flspopt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hbldh%2Flspopt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hbldh%2Flspopt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hbldh","download_url":"https://codeload.github.com/hbldh/lspopt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248845912,"owners_count":21170867,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["estimation","histogram","multitaper-windows","optimal-multitapers","python","spectrum","stochastic-processes"],"created_at":"2024-10-15T08:48:47.825Z","updated_at":"2025-04-14T08:31:58.552Z","avatar_url":"https://github.com/hbldh.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LSPOpt\n\n![Build and Test](https://github.com/hbldh/lspopt/workflows/Build%20and%20Test/badge.svg)\n[![PyPI version](https://img.shields.io/pypi/v/lspopt.svg)](https://pypi.org/project/lspopt/)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)\n\nThis module is a Python implementation of the multitaper window method \ndescribed in [\\[1\\]](#references) for estimating Wigner spectra for certain locally\nstationary processes.\n\nAbstract from [\\[1\\]](#references):\n\n\u003e This paper investigates the time-discrete multitapers that give a mean square error optimal Wigner spectrum estimate for a class\n\u003e of locally stationary processes (LSPs). The accuracy in the estimation of the time-variable Wigner spectrum of the LSP is evaluated\n\u003e and compared with other frequently used methods. The optimal multitapers are also approximated by Hermite functions, which is\n\u003e computationally more efficient, and the errors introduced by this approximation are studied. Additionally, the number of windows\n\u003e included in a multitaper spectrum estimate is often crucial and an investigation of the error caused by limiting this number is made.\n\u003e Finally, the same optimal set of weights can be stored and utilized for different window lengths. As a result, the optimal multitapers\n\u003e are shown to be well approximated by Hermite functions, and a limited number of windows can be used for a mean square error\n\u003e optimal spectrogram estimate.\n    \n## Installation\n\nInstall via pip:\n\n    pip install lspopt\n\nIf you prefer to use `conda`, see [instructions in this repo](https://github.com/conda-forge/lspopt-feedstock).\n\n## Testing\n\nTest with `pytest`:\n\n    pytest tests/\n\nSee test badge at the top of this README for link to test coverage and reports.\n\n## Usage\n\nTo generate the taper windows only, use the `lspopt` method:\n\n```python\nfrom lspopt import lspopt\nH, w = lspopt(n=256, c_parameter=20.0)\n```\n    \nThere is also a convenience method for using the [SciPy spectrogram method](https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.spectrogram.html#scipy.signal.spectrogram)\nwith the `lspopt` multitaper windows:\n\n```python\nfrom lspopt import spectrogram_lspopt\nf, t, Sxx = spectrogram_lspopt(x, fs, c_parameter=20.0)\n```\n    \nThis can then be plotted with e.g. [matplotlib](http://matplotlib.org/).\n\n### Example\n\nOne can generate a [chirp](https://docs.scipy.org/doc/scipy-0.16.0/reference/generated/scipy.signal.chirp.html)\nprocess realisation and run spectrogram methods on this. \n\n```python\nimport numpy as np\nfrom scipy.signal import chirp, spectrogram\nimport matplotlib.pyplot as plt\n\nfrom lspopt.lsp import spectrogram_lspopt\n\nfs = 10000\nN = 100000\namp = 2 * np.sqrt(2)\nnoise_power = 0.001 * fs / 2\ntime = np.arange(N) / fs\nfreq = np.linspace(1000, 2000, N)\nx = amp * chirp(time, 1000, 2.0, 6000, method='quadratic') + \\\n    np.random.normal(scale=np.sqrt(noise_power), size=time.shape)\n\nf, t, Sxx = spectrogram(x, fs)\n\nax = plt.subplot(211)\nax.pcolormesh(t, f, Sxx)\nax.set_ylabel('Frequency [Hz]')\nax.set_xlabel('Time [sec]')\n\nf, t, Sxx = spectrogram_lspopt(x, fs, c_parameter=20.0)\n\nax = plt.subplot(212)\nax.pcolormesh(t, f, Sxx)\nax.set_ylabel('Frequency [Hz]')\nax.set_xlabel('Time [sec]')\n\nplt.tight_layout()\nplt.show()\n```\n\n![Spectrogram plot](https://github.com/hbldh/lspopt/blob/master/plot.png \"Top: Using SciPy's spectrogram method. Bottom: Using LSPOpt's spectrogram solution.\")\n\n*Top: Using SciPy's spectrogram method. Bottom: Using LSPOpt's spectrogram solution.*\n\n## References\n\n\\[1\\] [Hansson-Sandsten, M. (2011). Optimal multitaper Wigner spectrum \nestimation of a class of locally stationary processes using Hermite functions. \nEURASIP Journal on Advances in Signal Processing, 2011, 10.](https://dx.doi.org/10.1155/2011/980805)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhbldh%2Flspopt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhbldh%2Flspopt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhbldh%2Flspopt/lists"}