Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to naima scripts #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Advanced_Topics/naima_examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ Recent-ish versions of matplotlib and astropy are needed.
`fitting_IC_spectrum.ipynb` is a very minimal example of how to fit parameters of an underlying electron population to VHE gamma-ray measurements.

All scripts are also provided as standalone python scripts that can be run outside of jupyter notebooks.

# For Fermibottle users

As of summer 2021, `naima 0.8.4` is installed as part of the fermit bottle. Unfortunately, there is a conflict in one of the depdencencies, `emcee`. Naima needs an older version: `emcee<3.0,>=2.2.0`, whereas `pint-pulsar 0.7` (also part of the fermi bottle) requires `emcee>=3.0`. If you just want to run the "exploring ..." scripts, this does not matter. If you want to run the `fitting_IC_spectrum` script or notebook, you will have to downgrade `emcee`. One way to do that is to run `pip install --upgrade naima`. This will install `naima 0.9.1` and `emcee 2.2.1`. Unfortunately, this might cause issues with `threeML` and `pint-pulsar`, both of which require newer versions of `emcee`. If you want to use `emcee` with either of those packages, you will have to create separate conda environments with the old and new versions of `naima`.
46 changes: 22 additions & 24 deletions Advanced_Topics/naima_examples/exploring_electron_spectra.ipynb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Advanced_Topics/naima_examples/exploring_electron_spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#naima models are phyical and accept/return astropy quantities.
#Try: electrons( 2.0 ) without a unit...
for E in [ 1*u.GeV, 1000*u.GeV, 1*u.TeV]:
print "dN/dE(", E, ") = ", electrons(E)
print( "dN/dE(", E, ") = ", electrons(E) )



Expand All @@ -66,8 +66,8 @@
synch.set_We(10**50 * u.erg)

#units check...
print "Flux dN/dE:", synch.flux([1]*u.keV, distance=2*u.kpc)
print "SED E^2dN/dE:", synch.sed([1]*u.keV, distance=2*u.kpc)
print( "Flux dN/dE:", synch.flux([1]*u.keV, distance=2*u.kpc) )
print( "SED E^2dN/dE:", synch.sed([1]*u.keV, distance=2*u.kpc) )


# In[47]:
Expand Down
100 changes: 45 additions & 55 deletions Advanced_Topics/naima_examples/exploring_pion_decay_spectra.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#naima models are phyical and accept/return astropy quantities.
#Try: protonsPL( 2.0 ) without a unit...
for E in [ 1*u.GeV, 1000*u.GeV, 1*u.TeV]:
print "dN/dE(", E, ") = ", protonsPL(E)
print( "dN/dE(", E, ") = ", protonsPL(E) )



Expand All @@ -68,8 +68,8 @@
pionsCutoff.set_Wp(10**50 * u.erg)

#units check...
print "Flux dN/dE:", pionsPL.flux([1]*u.TeV, distance=2*u.kpc)
print "SED E^2dN/dE:", pionsPL.sed([1]*u.TeV, distance=2*u.kpc)
print( "Flux dN/dE:", pionsPL.flux([1]*u.TeV, distance=2*u.kpc) )
print( "SED E^2dN/dE:", pionsPL.sed([1]*u.TeV, distance=2*u.kpc) )


# In[43]:
Expand Down
410 changes: 182 additions & 228 deletions Advanced_Topics/naima_examples/fitting_IC_spectrum.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Advanced_Topics/naima_examples/fitting_IC_spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

data = ascii.read("RXJ1713_HESS_2007.dat")

print data
print(data)


# In[3]:
Expand Down