mangadap.util.mapping module¶
Defines some utility routines used to map a provided set of quantities.
 License:
 Copyright (c) 2015, SDSSIV/MaNGA Pipeline Group
 Licensed under BSD 3clause license  see LICENSE.rst
 Source location:
 $MANGADAP_DIR/python/mangadap/util/mapping.py
 Imports and python version compliance:
from __future__ import print_function from __future__ import division from __future__ import absolute_import from __future__ import unicode_literals import sys if sys.version > '3': long = int import numpy from matplotlib import pyplot from mpl_toolkits.axes_grid1 import make_axes_locatable from matplotlib.ticker import MaxNLocator
 Revision history:
 10 Jun 2015: Pulled out functions by Michele Cappellari into a utility file (K. Westfall; KBW)07 Jul 2017: (KBW) Added map matching functions

mangadap.util.mapping.
_match_map_arrays_integer_pixel_shift
(arr1, ext1, arr2, ext2, dx, dy, swap=False)[source]¶

mangadap.util.mapping.
_match_map_arrays_sub_pixel_shift
(arr1, ext1, arr2, ext2, dx, dy, swap=False, truncate=False, pixelscale=0.5)[source]¶

mangadap.util.mapping.
map_center_pixel_offset
(hdu_1, hdu_2, ext, quiet=False)[source]¶ Determine the offset in pixels between the object center in two the maps of two fits files.
Parameters:  hdu_1 (astropy.io.fits.hdu.hdulist.HDUList) – Fits HDU list for the reference map.
 hdu_2 (astropy.io.fits.hdu.hdulist.HDUList) – Fits HDU list for the comparison map.
 ext (str) – Extension in both files with the maps.
 quiet (bool) – (Optional) Suppress terminal output.
Returns: Two floats with the offset in x and y between the two maps.
Return type: float

mangadap.util.mapping.
map_extent
(hdu, ext, offset=True)[source]¶ Get the onsky extent of a map using the provided WCS coordinates.
Parameters:  hdu (astropy.io.fits.hdu.hdulist.HDUList) – Fits HDU list.
 ext (str) – Extension of the file with the map.
 offset (bool) – (Optional) Return the extent as the offset from the coordinates of the object in arcseconds. The WCS is assumed to provide RA and declination in units of degrees, and the header must contain the coordinates of the object with keywords OBJRA and OBJDEC. If offset is True and these keywords do not exist, the function will throw a warning and proceed without applying any offset. Default is just to return the extent of the WCS coordinates.
Returns: List of four floats: minimum and maximum x and minimum and maximum y.
Return type: list

mangadap.util.mapping.
map_quantity
(x, y, z, zmin=None, zmax=None, ncolors=64, dots=False, cmap='coolwarm', colorbar=False, nticks=7, clabel=None, flux=None, fixpdf=False, xlim=None, xlabel=None, ylim=None, ylabel=None, pixelscale=None, fill_value=0.0, contour_levels=None, **kwargs)[source]¶ Copyright (C) 20132014, Michele Cappellari Email: cappellari_at_astro.ox.ac.uk http://purl.org/cappellari/software
 Revision history:
 V1.0: Michele Cappellari, Paranal, 11 November 2013V1.0.1: Clip values before contouring. MC, Oxford, 26 February 2014V1.0.2: Include SAURON colormap. MC, Oxford, 29 January 2014V1.0.3: Call set_aspect(1). MC, Oxford, 22 February 2014V1.0.4: Call autoscale_view(tight=True). Overplot small dots by default. MC, Oxford, 25 February 2014V1.0.5: Use axis(‘image’). MC, Oxford, 29 March 2014V1.0.6: Allow changing colormap. MC, Oxford, 29 July 2014V1.0.7: Added optional fixpdf keyword to remove PDF artifacts like stackoverflow_15822159 . Make nice tick levels for colorbar. Added nticks keyword for colorbar. MC, Oxford, 16 October 2014

mangadap.util.mapping.
masked_pixelized_image
(x, y, z, pixelscale=1.0, zmin=None, zmax=None, imshow_prep=False, fill_value=0.0)[source]¶ Provided a set of pixelized data, return a masked image with a type numpy.ma.MaskedArray. The \(x\) coordinates are organized along rows and the \(y\) coordinates are organized along columns. I.e., i.e., img[0,1] = \(z(x_0,y_1)\), unless imshow_prep is requested (see below).
Parameters:  x (numpy.ndarray) – X coordinates of the pixels
 y (numpy.ndarray) – Y coordinates of the pixels
 z (numpy.ndarray) – Image values at \(x,y\).
 pixelscale (float) – (Optional) Pixelscale of the image in arcsec/pixel.
 zmin (float) – (Optional) Minimum z value to include in the output image. Default is to allow all pixel values.
 zmax (float) – (Optional) Maximum z value to include in the output image. Default is to allow all pixel values.
 imshow_prep (bool) –
(Optional) Prepare the matrix for use with pyplot.imshow. If imshow_prep is True, before output, the matrix is reordered such that increasing \(x\) values are along columns and increasing \(y\) values are along rows; i.e., the output is the transpose of the default behavior. The appropriate call to imshow that will then put increasing x values along the abcissa and increasing y values along the ordinate is, e.g.:
ext, img = masked_pixelized_image(x, y, z, imshow_prep=True) pyplot.imshow(img, interpolation='nearest', extent=ext, origin='lower')
Note that origin must be “lower” when calling pyplot.imshow on the array produced by this routine for the \(x,y\) ordering to be as expected!
 fill_value (float) – (Optional) The default value to use for pixels without any data.
Returns: The first object returned is a fourelement array with the extent of the image from the bottom edge to the top edge of the x and y pixels, respectively. The second object returned is the image data and associated (boolean) mask.
Return type: numpy.ndarray, numpy.ma.MaskedArray

mangadap.util.mapping.
match_map_arrays
(arr1, ext1, arr2, ext2, dx, dy, tol=1e06, truncate=True, pixelscale=0.5)[source]¶ Match the centers and extent of two map arrays by applying the previously calculated pixel offsets. See
map_center_pixel_offset()
.This is just a wrapper for the two supporting functions below.
Both maps must be two dimensional; i.e., a single map, not a set of maps arranged in different channels.
Parameters:  arr1 (numpy.ma.MaskedArray) – Reference map data array.
 ext1 (list) – Reference map extent in arcseconds.
 arr2 (numpy.ma.MaskedArray) – Comparison map data array.
 ext1 – Comparison map extent in arcseconds.
 dx (float) – Pixel offset in the first dimension (x).
 dy (float) – Pixel offset in the second dimension (y).
 tol (float) – (Optional) Tolerance for noninteger pixel shifts.
 truncate (float) – (Optional) Truncate the shape of the shifted array to match the unshifted array. If False, the unshifted array is padded to match the shifted array.
 pixelscale (float) – (Optional) The pixel scale (extent units per array pixel) that must be common to both input arrays.
Returns: The two matched arrays and the extent that is common to both.
Return type: numpy.ma.MaskedArray, list