{"id":26282957,"url":"https://github.com/mlefkir/pioran.jl","last_synced_at":"2025-10-12T10:10:27.537Z","repository":{"id":209844941,"uuid":"725081674","full_name":"mlefkir/Pioran.jl","owner":"mlefkir","description":" Power spectrum inference of irregularly sampled time series using Gaussian Processes in Julia ","archived":false,"fork":false,"pushed_at":"2025-09-23T09:37:25.000Z","size":114126,"stargazers_count":14,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-23T11:25:47.554Z","etag":null,"topics":["fourier-analysis","gaussian-processes","julia","power-spectrum-estimation","time-series","time-series-analysis"],"latest_commit_sha":null,"homepage":"https://mlefkir.github.io/Pioran.jl/","language":"Julia","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/mlefkir.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-11-29T11:58:18.000Z","updated_at":"2025-09-23T09:15:09.000Z","dependencies_parsed_at":"2024-03-18T17:29:07.972Z","dependency_job_id":"8dacfaaa-fdfb-45d1-9be3-ff43c812dc6c","html_url":"https://github.com/mlefkir/Pioran.jl","commit_stats":null,"previous_names":["mlefkir/pioran.jl"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/mlefkir/Pioran.jl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlefkir%2FPioran.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlefkir%2FPioran.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlefkir%2FPioran.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlefkir%2FPioran.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mlefkir","download_url":"https://codeload.github.com/mlefkir/Pioran.jl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlefkir%2FPioran.jl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279011048,"owners_count":26084863,"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","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["fourier-analysis","gaussian-processes","julia","power-spectrum-estimation","time-series","time-series-analysis"],"created_at":"2025-03-14T17:16:08.177Z","updated_at":"2025-10-12T10:10:27.532Z","avatar_url":"https://github.com/mlefkir.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Banner of pioran power spectrum inference of random time series](./docs/src/assets/banner_desc.svg)](#)\n\n[![Documentation](https://github.com/mlefkir/Pioran.jl/actions/workflows/documentation.yml/badge.svg)](https://github.com/mlefkir/Pioran.jl/actions/workflows/documentation.yml) [![Build](https://github.com/mlefkir/Pioran.jl/actions/workflows/testbuild.yml/badge.svg)](https://github.com/mlefkir/Pioran.jl/actions/workflows/testbuild.yml)\n[![codecov](https://codecov.io/gh/mlefkir/Pioran.jl/graph/badge.svg?token=88LNFU2VKD)](https://codecov.io/gh/mlefkir/Pioran.jl)\n\nPioran is a Julia package to estimate bending power-law power spectrum of time series. This method uses Gaussian process regression with the fast algorithm of [Foreman-Mackey, et al. 2017](https://ui.adsabs.harvard.edu/abs/2017AJ....154..220F/abstract). The bending power-law model is approximated using basis functions as shown in the Figure below:\n\n[![Basis functions of the bending power-law model](./extra/approximation.svg)](#)\n\nThe method is described in [Lefkir et. al 2025](https://ui.adsabs.harvard.edu/abs/2025MNRAS.539.1775L/abstract), where it is used to model the random flux variability observed in active galaxies.\n\n## Installation\n\n```julia\nusing Pkg; Pkg.add(\"Pioran\")\n```\n\n## Documentation\n\nRead the documentation here: [https://mlefkir.github.io/Pioran.jl/stable/](https://mlefkir.github.io/Pioran.jl/stable/).\n\n## Examples\n\nExample scripts are provided in the [examples](./examples) directory. To infer the parameters of the power spectrum, I use either [`Turing.jl`](https://github.com/TuringLang/Turing.jl) for Hamiltonian Monte Carlo or the Python library [`ultranest`](https://github.com/JohannesBuchner/UltraNest) for nested sampling.\n\n### Ultranest\n\nHere a very quick example on how to use it with `ultranest`. I assume you have installed `PyCall` and `ultranest` following the guide in the documentation [`here`](https://mlefkir.github.io/Pioran.jl/stable/ultranest/).\n\nAssuming you have a Gaussian time series `y` at times `t` with errorbars `σ`. The GP can be built using a function as follows:\n\n```julia\nusing Pioran, Distributions\n\nfunction GP_model(t, y, σ, params, n_components = 20, basis_function = \"DRWCelerite\")\n    T = (t[end] - t[1]) # duration of the time series\n    Δt = minimum(diff(t)) # min time separation\n\n    f_min, f_max = 1 / T, 1 / Δt / 2\n\n    # Get the parameters\n    α₁, f₁, α₂, variance, ν, μ = params\n\n    # Rescale the measurement variance\n    σ² = ν .* σ .^ 2\n\n    # Define the power spectral density function\n    𝓟 = SingleBendingPowerLaw(α₁, f₁, α₂)\n\n    # Approximate the PSD to form a covariance function\n    𝓡 = approx(𝓟, f_min, f_max, n_components, variance, basis_function = basis_function)\n\n    # Build the GP\n    GP = ScalableGP(μ, 𝓡)\n\n    # return the conditioned GP on the times and errors and the transformed values\n    return GP(t, σ²)\nend\n```\n\nThe log-likelihood can be obtained using the `logpdf` function from `Distributions.jl`:\n\n```julia\nfunction loglikelihood(t, y, σ, params)\n    GP = GP_model(t, y, σ, params)\n    return logpdf(GP, y)\nend\nlogl(pars) = loglikelihood(t, y, yerr, pars)\n```\nWe use distributions from  `Distributions.jl` to define the priors for nested sampling. For this example, we can have:\n\n```julia\nfunction prior_transform(cube)\n    α₁ = quantile(Uniform(0.0, 1.5), cube[1])\n    f₁ = quantile(LogUniform(1e-3, 1e3), cube[2])\n    α₂ = quantile(Uniform(α₁, 4.0), cube[3])\n    variance = quantile(LogNormal(0, 1), cube[4])\n    ν = quantile(Gamma(2, 0.5), cube[5])\n    μ = quantile(Normal(x̄, 5 * sqrt(va)), cube[6])\n    return [α₁, f₁, α₂, variance, ν, μ]\nend\nparamnames = [\"α₁\", \"f₁\", \"α₂\", \"variance\", \"ν\", \"μ\"]\n```\n\nWe can load `ultranest` using `PyCall`:\n```julia\nusing PyCall\nultranest = pyimport(\"ultranest\")\n```\n\nand start sampling the posterior:\n\n```julia\nsampler = ultranest.ReactiveNestedSampler(paramnames, logl, resume = true, transform = prior_transform, log_dir = \"path/to/dir\", vectorized = false)\nresults = sampler.run()\nsampler.print_results()\nsampler.plot()\n```\n\n## Citing the method\n\nIf this method or code was useful to you, you can cite [Lefkir et. al 2025](https://ui.adsabs.harvard.edu/abs/2025MNRAS.539.1775L/abstract) for method and [Foreman-Mackey, et al. 2017](https://ui.adsabs.harvard.edu/abs/2017AJ....154..220F/abstract) for the celerite algorithm.\n\nIf you have used [`ultranest`](https://github.com/JohannesBuchner/UltraNest) or [`Turing.jl`](https://github.com/TuringLang/Turing.jl) to sample the posterior, have a look at their documentation on how to cite them properly.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlefkir%2Fpioran.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmlefkir%2Fpioran.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlefkir%2Fpioran.jl/lists"}