In [1]:
try:
# import block for Python 3
from urllib.request import urlopen
except ImportError:
# if that fails, fall back to Python 2 import block
from urllib2 import urlopen
import gzip
fits_filenames = ["2MASS_h.fits",
"2MASS_j.fits",
"2MASS_k.fits"]
template_URL = "https://github.com/aplpy/aplpy-examples/blob/master/data/{0}.gz?raw=true"
for fits_filename in fits_filenames:
url = template_URL.format(fits_filename)
url_request = urlopen(url)
data = url_request.read()
data_uncompressed = gzip.decompress(data)
with open(fits_filename, "wb") as f:
f.write(data_uncompressed)
In [2]:
%matplotlib inline
import aplpy
aplpy.make_rgb_cube(['2MASS_k.fits',
'2MASS_h.fits',
'2MASS_j.fits'], '2MASS_cube.fits')
aplpy.make_rgb_image('2MASS_cube.fits', '2MASS_rgb.png',
stretch_r = "log", stretch_g = "log", stretch_b= "log", #change the stretch
)
In [3]:
f = aplpy.FITSFigure('2MASS_h.fits')
f.show_contour(smooth=5, colors="w", levels=3)
f.show_rgb('2MASS_rgb.png' )
f.set_theme("publication")