Comments (6)
Thanks @micheledoro! Can you please share a minimal reproducible example?
from gammapy.
> for channel, label, linestyle, linewidth, color in zip(channels, labels, linestyles, linewidths, colors):
> fluxes.channel = channel
> fluxes.table_model.plot(
> energy_bounds=[mDM / 100, mDM],
> ax=ax,
> label=label,
> linestyle=linestyle,
> energy_power=2,
> linewidth=linewidth,
> color=color,
> yunits=u.Unit("1/TeV"),
I suppose fixing yunits=u.Unit("1/TeV")
is creating the issue as energy_power=2
expects units of energy
and not 1/energy
from gammapy.
Could you please confirm which version of gammapy you are using?
Along with a short piece of code which replicates the error?
from gammapy.
System:
python_executable : /Users/mdoro/opt/mambaforge/envs/gammapy-1.1/bin/python
python_version : 3.9.18
machine : x86_64
system : Darwin
Gammapy package:
version : 1.1
path : /Users/mdoro/opt/mambaforge/envs/gammapy-1.1/lib/python3.9/site-packages/gammapy
Other packages:
numpy : 1.24.4
scipy : 1.10.1
astropy : 5.3.4
regions : 0.7
click : 8.1.3
yaml : 6.0.1
IPython : 8.7.0
jupyterlab : 3.5.3
matplotlib : 3.7.3
pandas : 1.5.2
healpy : 1.16.6
iminuit : 2.21.3
sherpa : 4.15.1
naima : 0.10.0
emcee : 3.1.3
corner : 2.2.1
ray : not installed
from gammapy.
@axel, e.g.
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from gammapy.astro.darkmatter import (
profiles,
JFactory,
PrimaryFlux,
DarkMatterAnnihilationSpectralModel,
)
from gammapy.maps import WcsGeom, WcsNDMap
from astropy.coordinates import SkyCoord
from matplotlib.colors import LogNorm
from regions import CircleSkyRegion
import astropy.units as u
fig, axes = plt.subplots(1, 3, figsize=(13, 4))
mDMs = [0.5, 5, 50] * u.TeV
labels = [r'$b\bar{b}$', r'$\tau^+\tau^-$',r'$W^+W^-$',r'$\mu^+\mu^-$' ]
linestyles = ['-', '--', 'dotted','dashdot']
linewidths = [2,2,1,1]
colors = ['tab:blue','tab:orange','black','black']
channels = ["b", "tau", "W", "mu"]
# zip it for the loop
for mDM, ax in zip(mDMs, axes):
fluxes.mDM = mDM
ax.set_title(rf"m$_{{\mathrm{{DM}}}}$ = {mDM}")
ax.set_yscale("log")
ax.set_ylabel("dN/dE")
for channel, label, linestyle, linewidth, color in zip(channels, labels, linestyles, linewidths, colors):
fluxes.channel = channel
fluxes.table_model.plot(
energy_bounds=[mDM / 100, mDM],
ax=ax,
label=label,
linestyle=linestyle,
energy_power=2,
linewidth=linewidth,
color=color,
yunits=u.Unit("1/TeV"),
)
axes[0].legend()
plt.tight_layout()
plt.subplots_adjust(wspace=0.3)
plt.subplots_adjust(hspace=0.3)
from gammapy.
Ah ah, thanks! It works with yunits=u.Unit("TeV")
...stupid me...thanks!
from gammapy.
Related Issues (20)
- Astropy 6.0 API Change HOT 3
- Angle wrapping fails for `PiecewiseNormSpatialModel`
- IRF Background interpolation produces peeks HOT 10
- Plot of a SpectralModel with the sed type `flux' HOT 6
- Integrate_geom is causing large memory load HOT 6
- Update `codemeta.py'
- MapDatasetEventSampler fails for very bright sources HOT 3
- Error in rebinning axis due to no stat profile HOT 1
- Broadcasting by `axis.center`, `axis.bin_wdith` in `gammapy.irf.core`
- Expect the `MapAxis` directly in `to_edisp_kernel`
- Incorrect return type for `Geom.energy_mask`
- Add call to file `AtProduction_gammas.dat` in `gammapy.astro.darkmatter` HOT 3
- Defaults for `methods` in signature of `SafeMaskMaker.__init__` is confusing
- No reoptimization for `confidence_iminuit` HOT 1
- Overhaul of dark matter `PrimaryFlux` class and data HOT 1
- Exposing `FitResult` ? HOT 1
- `FluxPoints.recompute_ul` fails for multidimensional flux points
- Allow `MapAxis` to be passed in `SpectralModel.plot()` ? HOT 1
- to_spectrum_dataset() loses background model
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gammapy.