Git Product home page Git Product logo

Comments (6)

adonath avatar adonath commented on September 26, 2024 1

Thanks @micheledoro! Can you please share a minimal reproducible example?

from gammapy.

AtreyeeS avatar AtreyeeS commented on September 26, 2024 1
>     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.

Astro-Kirsty avatar Astro-Kirsty commented on September 26, 2024

Could you please confirm which version of gammapy you are using?
Along with a short piece of code which replicates the error?

from gammapy.

micheledoro avatar micheledoro commented on September 26, 2024
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.

micheledoro avatar micheledoro commented on September 26, 2024

@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.

micheledoro avatar micheledoro commented on September 26, 2024

Ah ah, thanks! It works with yunits=u.Unit("TeV")...stupid me...thanks!

from gammapy.

Related Issues (20)

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.