mangadap.util.mapping module

Defines some utility routines used to map a provided set of quantities.


License

Copyright © 2019, SDSS-IV/MaNGA Pipeline Group


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_beam_patch(extent, ax, fwhm=2.5, pos=(0.1, 0.1), **kwargs)[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.HDUList) – Fits HDU list for the reference map.

  • hdu_2 (astropy.io.fits.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 on-sky extent of a map using the provided WCS coordinates.

Parameters:
  • hdu (astropy.io.fits.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) 2013-2014, Michele Cappellari E-mail: cappellari_at_astro.ox.ac.uk http://purl.org/cappellari/software

Revision history:
V1.0: Michele Cappellari, Paranal, 11 November 2013
V1.0.1: Clip values before contouring. MC, Oxford, 26 February 2014
V1.0.2: Include SAURON colormap. MC, Oxford, 29 January 2014
V1.0.3: Call set_aspect(1). MC, Oxford, 22 February 2014
V1.0.4: Call autoscale_view(tight=True). Overplot small dots by default. MC, Oxford, 25 February 2014
V1.0.5: Use axis(‘image’). MC, Oxford, 29 March 2014
V1.0.6: Allow changing colormap. MC, Oxford, 29 July 2014
V1.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 four-element 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=1e-06, 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 non-integer 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

mangadap.util.mapping.permute_wcs_axes(wcs, axes)[source]

Permute the axes in an astropy.wcs.WCS object.

The number of axes must match the number axes defined by the astropy.wcs.WCS object. Axes are iteratively swapped until they’re in the requested order. For example, to transpose the axes of a 3D WCS, set axes=[2,1,0].

Note

Method uses the deepcopy() method of the astropy.wcs.WCS object when altering and returning a new object. If the axes are already sorted, this function returns a deepcopy of the input wcs.

Parameters:
  • wcs (astropy.wcs.WCS) – Object with the world-coordinate system.

  • axes (array-like) – New locations for the current axes; i.e., the axis currently at index i (0-indexed) is moved to be at index axis[i]. For example, to swap the axes for a 2D WCS, set axes=[1,0].

Returns:

The world-coordinate system with re-ordered axes.

Return type:

astropy.wcs.WCS

Raises:

ValueError – Raised if the length of the axes vector is not the same as the number of axes defined by the astropy.wcs.WCS object, or if axes includes undefined axes (i.e., a value less than 0 or >= the number of axes in the WCS.)