{"id":18961095,"url":"https://github.com/williamjameshandley/spherical_kde","last_synced_at":"2025-04-19T11:35:09.991Z","repository":{"id":54666026,"uuid":"126525378","full_name":"williamjameshandley/spherical_kde","owner":"williamjameshandley","description":"Kernel density estimation on a sphere","archived":false,"fork":false,"pushed_at":"2021-10-18T15:51:46.000Z","size":918,"stargazers_count":29,"open_issues_count":0,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-15T19:04:11.292Z","etag":null,"topics":["astronomy","bandwidth","cartopy","information-visualization","kernel-density-estimation","machine-learning","mollweide-projection","physics","probability","python","sphere","statistics","von-mises-fisher"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/spherical_kde/","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/williamjameshandley.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-23T18:35:05.000Z","updated_at":"2025-04-15T09:31:41.000Z","dependencies_parsed_at":"2022-08-13T23:20:10.900Z","dependency_job_id":null,"html_url":"https://github.com/williamjameshandley/spherical_kde","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamjameshandley%2Fspherical_kde","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamjameshandley%2Fspherical_kde/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamjameshandley%2Fspherical_kde/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamjameshandley%2Fspherical_kde/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/williamjameshandley","download_url":"https://codeload.github.com/williamjameshandley/spherical_kde/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249195384,"owners_count":21228187,"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":["astronomy","bandwidth","cartopy","information-visualization","kernel-density-estimation","machine-learning","mollweide-projection","physics","probability","python","sphere","statistics","von-mises-fisher"],"created_at":"2024-11-08T14:11:30.077Z","updated_at":"2025-04-16T04:32:39.256Z","avatar_url":"https://github.com/williamjameshandley.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/williamjameshandley/spherical_kde.svg?branch=master)](https://travis-ci.org/williamjameshandley/spherical_kde)\n[![codecov](https://codecov.io/gh/williamjameshandley/spherical_kde/branch/master/graph/badge.svg)](https://codecov.io/gh/williamjameshandley/spherical_kde)\n[![PyPI version](https://badge.fury.io/py/spherical_kde.svg)](https://badge.fury.io/py/spherical_kde)\n[![Documentation Status](https://readthedocs.org/projects/spherical-kde/badge/?version=latest)](http://spherical-kde.readthedocs.io/en/latest/?badge=latest)\n[![DOI](https://zenodo.org/badge/126525378.svg)](https://zenodo.org/badge/latestdoi/126525378)\n\n\n\n\nSpherical Kernel Density Estimation\n===================================\n\nThese packages allow you to do rudimentary kernel density estimation on a\nsphere. Suggestions for improvements/extensions welcome.\n\nThe fundamental principle is to replace the traditional Gaussian function used\nin \n[kernel density estimation](https://en.wikipedia.org/wiki/Kernel_density_estimation)\nwith the\n[Von Mises-Fisher distribution](https://en.wikipedia.org/wiki/Von_Mises-Fisher_distribution).\n\nBandwidth estimation is still rough-and-ready.\n\n![](https://raw.github.com/williamjameshandley/spherical_kde/master/plot.png)\n\nExample Usage\n-------------\n\n```python\nimport numpy\nfrom spherical_kde import SphericalKDE\nimport matplotlib.pyplot as plt\nimport cartopy.crs\nfrom matplotlib.gridspec import GridSpec, GridSpecFromSubplotSpec\n\n# Choose a seed for deterministic plot\nnumpy.random.seed(seed=0)\n\n# Set up a grid of figures\nfig = plt.figure(figsize=(10, 10))\ngs_vert = GridSpec(3, 1)\ngs_lower = GridSpecFromSubplotSpec(1, 2, subplot_spec=gs_vert[1])\n\nfig.add_subplot(gs_vert[0], projection=cartopy.crs.Mollweide())\nfig.add_subplot(gs_lower[0], projection=cartopy.crs.Orthographic())\nfig.add_subplot(gs_lower[1], projection=cartopy.crs.Orthographic(-10, 45))\nfig.add_subplot(gs_vert[2], projection=cartopy.crs.PlateCarree())\n\n# Choose parameters for samples\nnsamples = 100\npi = numpy.pi\n\n# Generate some samples centered on (1,1) +/- 0.3 radians\ntheta_samples = numpy.random.normal(loc=1, scale=0.3, size=nsamples)\nphi_samples = numpy.random.normal(loc=1, scale=0.3, size=nsamples)\nphi_samples = numpy.mod(phi_samples, pi*2)\nkde_green = SphericalKDE(phi_samples, theta_samples)\n\n# Generate some samples centered on (-1,1) +/- 0.4 radians\ntheta_samples = numpy.random.normal(loc=1, scale=0.4, size=nsamples)\nphi_samples = numpy.random.normal(loc=-1, scale=0.4, size=nsamples)\nphi_samples = numpy.mod(phi_samples, pi*2)\nkde_red = SphericalKDE(phi_samples, theta_samples)\n\n# Generate a spread of samples along latitude 2, height 0.1\ntheta_samples = numpy.random.normal(loc=2, scale=0.1, size=nsamples)\nphi_samples = numpy.random.uniform(low=-pi/2, high=pi/2, size=nsamples)\nphi_samples = numpy.mod(phi_samples, pi*2)\nkde_blue = SphericalKDE(phi_samples, theta_samples, bandwidth=0.1)\n\nfor ax in fig.axes:\n    ax.set_global()\n    ax.gridlines()\n    ax.coastlines(linewidth=0.1)\n    kde_green.plot(ax, 'g')\n    kde_green.plot_samples(ax)\n    kde_red.plot(ax, 'r')\n    kde_blue.plot(ax, 'b')\n\n# Save to plot\nfig.tight_layout()\nfig.savefig('plot.png')\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliamjameshandley%2Fspherical_kde","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilliamjameshandley%2Fspherical_kde","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliamjameshandley%2Fspherical_kde/lists"}