Image

Image is a class to interact with MaNGA optical images for each galaxy.

Getting Started

The Image tool behaves similar to all other Marvin Tools with regards to multi-modal access. Call an image with an input and it will either grab it locally or remotely with the API. It accepts all the standard keywords as the Core Marvin Tools.

from marvin.tools.image import Image

im = Image('8485-1901')
print(im)
<Marvin Image (plateifu='8485-1901', mode='local', data-origin='file')>

# or remotely
im = Image('8485-1902')
MarvinUserWarning: local mode failed. Trying remote now.
<Marvin Image (plateifu='8485-1902', mode='remote', data-origin='api')>

Marvin will access the image file, and open it using as a PIL Image Object (using the Python Image Library python package.). To quickly show the image, use Image.show.

# show the image
im.show()

The PIL image object is stored in the Image.data attribute. You can quickly access a Marvin Cube or Maps associated with this image with the getXXX methods.

# get a cube
cube = im.getCube()

# get a maps
maps = im.getMaps()

Or conversely, quickly access the image from any of the Marvin Tools

# get the Image from a Cube
cube = Cube('8485-1901')
im = cube.getImage()
print(im)
<Marvin Image (plateifu='8485-1901', mode='local', data-origin='file')>

Using Image

Basic Information

Each Image comes with a simple header, WCS transformation, and the central RA, Dec coordinate.

# Get the central RA, Dec
im.ra, im.dec
(235.57977, 48.465725)

# Get the WCS information
im.wcs
WCS Keywords

Number of WCS axes: 2
CTYPE : 'RA---TAN'  'DEC--TAN'
CRVAL : 235.57977  48.465725
CRPIX : 281.0  281.0
PC1_1 PC1_2  : -2.47222222222e-05  0.0
PC2_1 PC2_2  : 0.0  2.47222222222e-05
CDELT : 1.0  1.0
NAXIS : 0  0

Each Image also has a bundle associated with it. This is a new utility class, marvin.utils.general.bundle.Bundle which provides IFU, sky fiber, and hex coordinates, among other things.

# get the image fiber bundle
im.bundle
<Bundle (ra=235.57977, dec=48.465725, ifu=19)>

# get at the RA, Dec coordinates for the fibers in this bundle
im.bundle.fibers

Displaying

While Image.show produces a raw image, you have finer control over the image as a Matplotlib figure, using Image.plot. This renders the image using matplotlib.pyplot.imshow.

# plot the image and return the axis object
from marvin.tools.image import Image
im = Image('8553-9102')
ax = im.plot()

(Source code)

Once you have the plot, you can overlay additional features, such as the IFU or sky fibers, or change the hexagon.

from marvin.tools.image import Image
im = Image('8553-9102')
ax = im.plot()

# overlay the IFU fibers
im.overlay_fibers(ax)

# change the style of the hexagon
im.overlay_hexagon(ax, color='cyan', linewidth=1)

(Source code)

By default the sky fibers are not loaded in the bundle. Image.bundle.skies will be None. Overlaying the sky fibers will automatically load them.

# overlay the sky fibers
im.overlay_skies(ax)

Note however that the sky fibers are often positioned far away from the central galaxy. If the sky fiber coordinates are outside the range of your image, you will see the error message, MarvinError: Cannot overlay sky fibers.  Image is too small.  Please retrieve a bigger image cutout. You will need to generate a larger cutout image of the galaxy.

Generating a new Image Cutout

There is a new utility class, marvin.utils.general.bundle.Cutout which provides the ability to generate a new SDSS image cutout using the SDSS SkyServer Image Cutout Service.

from marvin.tools.image import Image
im = Image('8553-9102')

# generate a new image
# inputs are height and width in arcsec, and a arcsec/pixel scale
im.get_new_cutout(100, 100, scale=0.192)

# plot the new image cutout
ax = im.plot()

(Source code)

You can also use the Cutout service by itself, in a limited fashion.

from marvin.utils.general import Cutout
cutout = Cutout(235.57977, 48.465725, 50, 50, scale=0.192)
cutout.show()

# save the image
cutout.save('mycutout.png')

Initializing Lists of Images

Rather than dealing with individual image objects at a time, you can generate lists of them at once. You can generate from a straight list of ids.

# generate from a list
from marvin.tools.image import Image
images = Image.from_list(['8485-1901', '7443-12701'])

Or by a plateid, getting all the images on the plate

# generate from a plate id
from marvin.tools.image import Image
images = Image.by_plate(8485)

Or you can generate a random set of images just for fun

# generate a random list
from marvin.tools.image import Image
images = Image.get_random(5)

Utility Functions

The old Image Utilities functions documented there have been deprecated and replaced with the following.

They all work in much the same way except now they utilize the Marvin Image tool. The get_xxx functions now return a list of Marvin Images. Each function accepts a download keyword argument that, when set, will download all the images in the list in bulk using sdss_access.

Reference/API

Class Inheritance Diagram

Inheritance diagram of marvin.tools.image.Image

Class

marvin.tools.image.Image([input, filename, …])

A class to interface with MaNGA images.

Methods

marvin.tools.image.Image.show()

Show the image

marvin.tools.image.Image.save(filename[, …])

Save the image to a file

marvin.tools.image.Image.download()

Downloads the image using sdss_access - Rsync,

marvin.tools.image.Image.plot([…])

Creates a Matplotlib plot the image

marvin.tools.image.Image.overlay_hexagon(ax)

Overlay the IFU hexagon on a plot

marvin.tools.image.Image.overlay_fibers(ax)

Overlay the individual fibers within an IFU on a plot.

marvin.tools.image.Image.overlay_skies(ax[, …])

Overlay the sky fibers on a plot

marvin.tools.image.Image.get_new_cutout(…)

Get a new Image Cutout using Skyserver

marvin.tools.image.Image.get_random([num, …])

Generate a set of random Marvin Images

marvin.tools.image.Image.by_plate(plateid[, …])

Generate a list of Marvin Images by plate

marvin.tools.image.Image.from_list(values[, …])

Generate a list of Marvin Image objects