Check of an issue with Map reproject
# !wget https://fermi.gsfc.nasa.gov/ssc/data/analysis/software/aux/gll_iem_v02.fit
# !ds9 gll_iem_v02.fit
%matplotlib inline
from astropy.coordinates import SkyCoord
from gammapy.maps import Map
m_allsky_cube = Map.read('gll_iem_v02.fit')
# import os
# path = os.environ['CTADATA'] + '/models/cube_iem.fits.gz'
# m_allsky_cube = Map.read(path)
m_allsky_image = m_allsky_cube.interp_image([1])
position = SkyCoord(0, 5, frame='galactic', unit='deg')
m_gc_ref = Map.create(binsz=0.1, map_type='wcs', skydir=position, width=20, coordsys='GAL')
geom = m_gc_ref.geom
m_gc_image = m_allsky_image.reproject(geom)
# m_allsky_image.plot()
m_gc_image.plot()
(<matplotlib.figure.Figure at 0x10c319f98>, <matplotlib.axes._subplots.WCSAxesSubplot at 0x10e113630>, <matplotlib.image.AxesImage at 0x10ef826a0>)
# m_allsky_image.write('diffuse_model_allsky.fits.gz')
m_gc_image.write('diffuse_model_gc.fits.gz')
m2 = Map.read('diffuse_model_gc.fits.gz')
m2.plot()
(<matplotlib.figure.Figure at 0x10ef82a58>, <matplotlib.axes._subplots.WCSAxesSubplot at 0x10e445710>, <matplotlib.image.AxesImage at 0x10e46da58>)
# This confirms that the image is incorrectly written to FITS
# !ds9 diffuse_model_gc.fits.gz