Git Product home page Git Product logo

pynchrotron's Introduction

Build Status codecov DOI

pynchrotron

alt text

Implements synchrotron emission from cooling electrons. This is the model used in Burgess et al (2019). 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

import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
%matplotlib inline 

import 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

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

Plot the model

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

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

pynchrotron's People

Contributors

bjoernbiltzinger avatar grburgess avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pynchrotron's Issues

Problem in installation

Hi,

The following error when installing occurs
"ERROR: Could not find a version that satisfies the requirement pytables (from astromodels->pynchrotron==1.0.0+1.g9ff0de2) (from versions: none)
ERROR: No matching distribution found for pytables (from astromodels->pynchrotron==1.0.0+1.g9ff0de2)"

I have pytables installed.

Please help with this.
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.