{"id":21494122,"url":"https://github.com/grburgess/pynchrotron","last_synced_at":"2025-07-15T19:31:26.621Z","repository":{"id":53682635,"uuid":"222061128","full_name":"grburgess/pynchrotron","owner":"grburgess","description":"Implements synchrotron emission from cooling electrons","archived":false,"fork":false,"pushed_at":"2021-03-19T13:13:41.000Z","size":419,"stargazers_count":11,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-02-15T13:04:23.855Z","etag":null,"topics":["astromodels","chang-cooper","electrons","gamma-ray-astronomy","grb","numerics","synchrotron","threeml"],"latest_commit_sha":null,"homepage":"https://grburgess.github.io/portfolio/grbs/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grburgess.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2019-11-16T07:07:29.000Z","updated_at":"2024-02-15T13:04:23.856Z","dependencies_parsed_at":"2022-09-18T22:24:12.703Z","dependency_job_id":null,"html_url":"https://github.com/grburgess/pynchrotron","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grburgess%2Fpynchrotron","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grburgess%2Fpynchrotron/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grburgess%2Fpynchrotron/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grburgess%2Fpynchrotron/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grburgess","download_url":"https://codeload.github.com/grburgess/pynchrotron/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226064567,"owners_count":17568035,"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":["astromodels","chang-cooper","electrons","gamma-ray-astronomy","grb","numerics","synchrotron","threeml"],"created_at":"2024-11-23T15:49:10.221Z","updated_at":"2024-11-23T15:49:11.118Z","avatar_url":"https://github.com/grburgess.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/grburgess/pynchrotron.svg?branch=master)](https://travis-ci.org/grburgess/pynchrotron)\n[![codecov](https://codecov.io/gh/grburgess/pynchrotron/branch/master/graph/badge.svg)](https://codecov.io/gh/grburgess/pynchrotron)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3544259.svg)](https://doi.org/10.5281/zenodo.3544259)\n\n# pynchrotron\n![alt text](https://raw.githubusercontent.com/grburgess/pynchrotron/master/logo.png)\n\nImplements synchrotron emission from cooling electrons. This is the model used in [Burgess et al (2019)](https://www.nature.com/articles/s41550-019-0911-z?utm_source=feedburner\u0026utm_medium=feed\u0026utm_campaign=Feed%3A+natastron%2Frss%2Fcurrent+%28Nature+Astronomy%29\u0026utm_content=Google+Feedfetcher). Please cite if you find this code useful for your research.\n\n* This code gets rid of the need for GSL which was originally relied on for a quick computation of the of the synchrotron kernel which is an integral over a  Bessel function. \n* This code has been ported from GSL and written directly in python as well as accelerated with numba\n* An astromodels function is also supplied for direct use in 3ML.\n\n\n## Usage\n\n```python\nimport numpy as np\nimport matplotlib as mpl\nimport matplotlib.pyplot as plt\n%matplotlib inline \n\nimport pynchrotron\n```\n\n    /Users/jburgess/.environs/pynchro/lib/python3.7/site-packages/astromodels/core/parameter.py:555: UserWarning: We have set the min_value of K to 1e-99 because there was a postive transform\n      warnings.warn('We have set the min_value of %s to 1e-99 because there was a postive transform' % self.path)\n    /Users/jburgess/.environs/pynchro/lib/python3.7/site-packages/astromodels/core/parameter.py:555: UserWarning: We have set the min_value of xc to 1e-99 because there was a postive transform\n      warnings.warn('We have set the min_value of %s to 1e-99 because there was a postive transform' % self.path)\n\n\n## Create an astromodels model\n\n\n```python\nmodel = pynchrotron.SynchrotronNumerical()\n\nmodel\n\n\n```\n\n\n\n\n\u003cul\u003e\n\n\u003cli\u003edescription: Synchrotron emission from cooling electrions\u003c/li\u003e\n\n\u003cli\u003eformula: $  $\u003c/li\u003e\n\n\u003cli\u003eparameters: \n\u003cul\u003e\n\n\u003cli\u003eK: \n\u003cul\u003e\n\n\u003cli\u003evalue: 1.0\u003c/li\u003e\n\n\u003cli\u003edesc: normalization\u003c/li\u003e\n\n\u003cli\u003emin_value: 0.0\u003c/li\u003e\n\n\u003cli\u003emax_value: None\u003c/li\u003e\n\n\u003cli\u003eunit: \u003c/li\u003e\n\n\u003cli\u003eis_normalization: False\u003c/li\u003e\n\n\u003cli\u003edelta: 0.1\u003c/li\u003e\n\n\u003cli\u003efree: True\u003c/li\u003e\n\n\u003c/ul\u003e\n\n\u003c/li\u003e\n\n\u003cli\u003eB: \n\u003cul\u003e\n\n\u003cli\u003evalue: 100.0\u003c/li\u003e\n\n\u003cli\u003edesc: energy scaling\u003c/li\u003e\n\n\u003cli\u003emin_value: 0.01\u003c/li\u003e\n\n\u003cli\u003emax_value: None\u003c/li\u003e\n\n\u003cli\u003eunit: \u003c/li\u003e\n\n\u003cli\u003eis_normalization: False\u003c/li\u003e\n\n\u003cli\u003edelta: 10.0\u003c/li\u003e\n\n\u003cli\u003efree: True\u003c/li\u003e\n\n\u003c/ul\u003e\n\n\u003c/li\u003e\n\n\u003cli\u003eindex: \n\u003cul\u003e\n\n\u003cli\u003evalue: 3.5\u003c/li\u003e\n\n\u003cli\u003edesc: spectral index of electrons\u003c/li\u003e\n\n\u003cli\u003emin_value: 2.0\u003c/li\u003e\n\n\u003cli\u003emax_value: 6.0\u003c/li\u003e\n\n\u003cli\u003eunit: \u003c/li\u003e\n\n\u003cli\u003eis_normalization: False\u003c/li\u003e\n\n\u003cli\u003edelta: 0.35000000000000003\u003c/li\u003e\n\n\u003cli\u003efree: True\u003c/li\u003e\n\n\u003c/ul\u003e\n\n\u003c/li\u003e\n\n\u003cli\u003egamma_min: \n\u003cul\u003e\n\n\u003cli\u003evalue: 500000.0\u003c/li\u003e\n\n\u003cli\u003edesc: minimum electron lorentz factor\u003c/li\u003e\n\n\u003cli\u003emin_value: 1.0\u003c/li\u003e\n\n\u003cli\u003emax_value: None\u003c/li\u003e\n\n\u003cli\u003eunit: \u003c/li\u003e\n\n\u003cli\u003eis_normalization: False\u003c/li\u003e\n\n\u003cli\u003edelta: 50000.0\u003c/li\u003e\n\n\u003cli\u003efree: False\u003c/li\u003e\n\n\u003c/ul\u003e\n\n\u003c/li\u003e\n\n\u003cli\u003egamma_cool: \n\u003cul\u003e\n\n\u003cli\u003evalue: 90000000.0\u003c/li\u003e\n\n\u003cli\u003edesc: cooling time of electrons\u003c/li\u003e\n\n\u003cli\u003emin_value: None\u003c/li\u003e\n\n\u003cli\u003emax_value: None\u003c/li\u003e\n\n\u003cli\u003eunit: \u003c/li\u003e\n\n\u003cli\u003eis_normalization: False\u003c/li\u003e\n\n\u003cli\u003edelta: 9000000.0\u003c/li\u003e\n\n\u003cli\u003efree: True\u003c/li\u003e\n\n\u003c/ul\u003e\n\n\u003c/li\u003e\n\n\u003cli\u003egamma_max: \n\u003cul\u003e\n\n\u003cli\u003evalue: 100000000.0\u003c/li\u003e\n\n\u003cli\u003edesc: minimum electron lorentz factor\u003c/li\u003e\n\n\u003cli\u003emin_value: 1000000.0\u003c/li\u003e\n\n\u003cli\u003emax_value: None\u003c/li\u003e\n\n\u003cli\u003eunit: \u003c/li\u003e\n\n\u003cli\u003eis_normalization: False\u003c/li\u003e\n\n\u003cli\u003edelta: 10000000.0\u003c/li\u003e\n\n\u003cli\u003efree: False\u003c/li\u003e\n\n\u003c/ul\u003e\n\n\u003c/li\u003e\n\n\u003cli\u003ebulk_gamma: \n\u003cul\u003e\n\n\u003cli\u003evalue: 1.0\u003c/li\u003e\n\n\u003cli\u003edesc: bulk Lorentz factor\u003c/li\u003e\n\n\u003cli\u003emin_value: 1.0\u003c/li\u003e\n\n\u003cli\u003emax_value: None\u003c/li\u003e\n\n\u003cli\u003eunit: \u003c/li\u003e\n\n\u003cli\u003eis_normalization: False\u003c/li\u003e\n\n\u003cli\u003edelta: 0.1\u003c/li\u003e\n\n\u003cli\u003efree: False\u003c/li\u003e\n\n\u003c/ul\u003e\n\n\u003c/li\u003e\n\n\u003c/ul\u003e\n\n\u003c/li\u003e\n\n\u003c/ul\u003e\n\n\n\n\n## Plot the model\n\n\n```python\nfig, ax = plt.subplots()\n\n\nene = np.logspace(1,6,400)\n\nax.loglog(ene, ene**2 * model(ene))\nax.set_xlabel('energy')\nax.set_ylabel(r'$\\nu F_{\\nu}$')\n```\n\n\n\n\n    Text(0, 0.5, '$\\\\nu F_{\\\\nu}$')\n\n\n\n\n![png](demo_files/demo_4_1.png)\n\n\n\n```python\nfig, ax = plt.subplots()\n\ngamma_min = 500000.\n\ngamma_cool = np.linspace(.1 * gamma_min, 5* gamma_min, 10)\n\n\n\nene = np.logspace(-1,6,400)\n\nfor gc in gamma_cool:\n    model.gamma_cool = gc\n    model.gamma_min = gamma_min\n    \n    ax.loglog(ene, ene**2 * model(ene))\nax.set_xlabel('energy')\nax.set_ylabel(r'$\\nu F_{\\nu}$')\n```\n\n\n\n\n    Text(0, 0.5, '$\\\\nu F_{\\\\nu}$')\n\n\n\n\n![png](demo_files/demo_5_1.png)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrburgess%2Fpynchrotron","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrburgess%2Fpynchrotron","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrburgess%2Fpynchrotron/lists"}