Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/grburgess/pynchrotron
Implements synchrotron emission from cooling electrons
https://github.com/grburgess/pynchrotron
astromodels chang-cooper electrons gamma-ray-astronomy grb numerics synchrotron threeml
Last synced: 30 days ago
JSON representation
Implements synchrotron emission from cooling electrons
- Host: GitHub
- URL: https://github.com/grburgess/pynchrotron
- Owner: grburgess
- License: gpl-3.0
- Created: 2019-11-16T07:07:29.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-19T13:13:41.000Z (almost 4 years ago)
- Last Synced: 2024-02-15T13:04:23.855Z (10 months ago)
- Topics: astromodels, chang-cooper, electrons, gamma-ray-astronomy, grb, numerics, synchrotron, threeml
- Language: Python
- Homepage: https://grburgess.github.io/portfolio/grbs/
- Size: 409 KB
- Stars: 11
- Watchers: 1
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/grburgess/pynchrotron.svg?branch=master)](https://travis-ci.org/grburgess/pynchrotron)
[![codecov](https://codecov.io/gh/grburgess/pynchrotron/branch/master/graph/badge.svg)](https://codecov.io/gh/grburgess/pynchrotron)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3544259.svg)](https://doi.org/10.5281/zenodo.3544259)# pynchrotron
![alt text](https://raw.githubusercontent.com/grburgess/pynchrotron/master/logo.png)Implements 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&utm_medium=feed&utm_campaign=Feed%3A+natastron%2Frss%2Fcurrent+%28Nature+Astronomy%29&utm_content=Google+Feedfetcher). Please cite if you find this code useful for your research.
* 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.
* This code has been ported from GSL and written directly in python as well as accelerated with numba
* An astromodels function is also supplied for direct use in 3ML.## Usage
```python
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
%matplotlib inlineimport pynchrotron
```/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
warnings.warn('We have set the min_value of %s to 1e-99 because there was a postive transform' % self.path)
/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
warnings.warn('We have set the min_value of %s to 1e-99 because there was a postive transform' % self.path)## Create an astromodels model
```python
model = pynchrotron.SynchrotronNumerical()model
```
- description: Synchrotron emission from cooling electrions
- formula: $ $
- parameters:
- K:
- value: 1.0
- desc: normalization
- min_value: 0.0
- max_value: None
- unit:
- is_normalization: False
- delta: 0.1
- free: True
- B:
- value: 100.0
- desc: energy scaling
- min_value: 0.01
- max_value: None
- unit:
- is_normalization: False
- delta: 10.0
- free: True
- index:
- value: 3.5
- desc: spectral index of electrons
- min_value: 2.0
- max_value: 6.0
- unit:
- is_normalization: False
- delta: 0.35000000000000003
- free: True
- gamma_min:
- value: 500000.0
- desc: minimum electron lorentz factor
- min_value: 1.0
- max_value: None
- unit:
- is_normalization: False
- delta: 50000.0
- free: False
- gamma_cool:
- value: 90000000.0
- desc: cooling time of electrons
- min_value: None
- max_value: None
- unit:
- is_normalization: False
- delta: 9000000.0
- free: True
- gamma_max:
- value: 100000000.0
- desc: minimum electron lorentz factor
- min_value: 1000000.0
- max_value: None
- unit:
- is_normalization: False
- delta: 10000000.0
- free: False
- bulk_gamma:
- value: 1.0
- desc: bulk Lorentz factor
- min_value: 1.0
- max_value: None
- unit:
- is_normalization: False
- delta: 0.1
- free: False
- K:
## Plot the model
```python
fig, ax = plt.subplots()
ene = np.logspace(1,6,400)
ax.loglog(ene, ene**2 * model(ene))
ax.set_xlabel('energy')
ax.set_ylabel(r'$\nu F_{\nu}$')
```
Text(0, 0.5, '$\\nu F_{\\nu}$')
![png](demo_files/demo_4_1.png)
```python
fig, ax = plt.subplots()
gamma_min = 500000.
gamma_cool = np.linspace(.1 * gamma_min, 5* gamma_min, 10)
ene = np.logspace(-1,6,400)
for gc in gamma_cool:
model.gamma_cool = gc
model.gamma_min = gamma_min
ax.loglog(ene, ene**2 * model(ene))
ax.set_xlabel('energy')
ax.set_ylabel(r'$\nu F_{\nu}$')
```
Text(0, 0.5, '$\\nu F_{\\nu}$')
![png](demo_files/demo_5_1.png)