Trying to plot on top of an all-sky fermi map

24 views
Skip to first unread message

Josh Tan

unread,
May 1, 2020, 3:56:49 PM5/1/20
to gammapy
Hello All:

We have a list of sources we would like to plot on top of an All-Sky Fermi Map. Unfortunately, we cannot figure out how to do this straightforwardly. From the tutorials and docs we've got the following code to produce the All-Sky Fermi map:

gc_pos = SkyCoord(0, 0, unit="deg", frame="galactic")

energy_axis = MapAxis.from_edges(
    [1e4, 3e4, 1e5, 3e5, 2e6], name="energy", unit="MeV", interp="log"
)

counts = Map.create(
    skydir=gc_pos,
    npix=(3600, 1800),
    proj="AIT",
    frame="galactic",
    binsz=0.1,
    axes=[energy_axis],
    dtype=float,
)

_,ax,_=counts.sum_over_axes().smooth(2).plot(stretch="log", vmax=30);


The intent is to creat a matplotlib axes object called ax that we can then plot against. However, this doesn't seem to actually work in this fashion.

Instead, we can use pyplot to overlay pixel coordinates which makes it pretty difficult to plot the sources. It seems other plotting functions don't have this issue, or maybe there is something simple we're missing?

Cheers,

Josh Tan

Atreyee Sinha

unread,
May 1, 2020, 4:27:58 PM5/1/20
to gam...@googlegroups.com
Hello Josh,

If I understand your question correctly, adding the following lines to your script should work (eg: If you want to plot Sgr A).

gc_pos = SkyCoord(0, 0, unit="deg", frame="galactic")
energy_axis = MapAxis.from_edges( [1e4, 3e4, 1e5, 3e5, 2e6], name="energy", unit="MeV", interp="log")
counts = Map.create( 
    skydir=gc_pos,   
    npix=(3600, 1800),  proj="AIT",  frame="galactic",    binsz=0.1,    axes=[energy_axis],    dtype=float,)
_,ax,_=counts.sum_over_axes().smooth(2).plot(stretch="log", vmax=30);
 
## Lines to be added
wcs = counts.geom.wcs
src_pos = SkyCoord.from_name("Sgr A").galactic 
ax.plot(src_pos.to_pixel(wcs=wcs)[0], src_pos.to_pixel(wcs=wcs)[1],  "o", color="red")

Let us know if this helps or if you have further questions!

regards,
Atreyee

--
You received this message because you are subscribed to the Google Groups "gammapy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gammapy+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gammapy/57baa50f-63ec-47fd-a0e4-3623e45cad9f%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages