/usr/lib/python3/dist-packages/reproject/healpix/high_level.py is in python3-reproject 0.3.1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | from .core import healpix_to_image, image_to_healpix
from .utils import parse_input_healpix_data, parse_coord_system
from ..utils import parse_input_data, parse_output_projection
__all__ = ['reproject_from_healpix', 'reproject_to_healpix']
def reproject_from_healpix(input_data, output_projection, shape_out=None, hdu_in=None, order='bilinear', nested=False, field=0):
"""
Reproject data from a HEALPIX projection to a standard projection.
.. note:: This function uses healpy, which is licensed
under the GPLv2, so any package using this funtions has to (for
now) abide with the GPLv2 rather than the BSD license.
Parameters
----------
input_data : str or `~astropy.io.fits.TableHDU` or `~astropy.io.fits.BinTableHDU` or tuple
The input data to reproject. This can be:
* The name of a HEALPIX FITS file
* A `~astropy.io.fits.TableHDU` or `~astropy.io.fits.BinTableHDU`
instance
* A tuple where the first element is a `~numpy.ndarray` and the
second element is a `~astropy.coordinates.BaseCoordinateFrame`
instance or a string alias for a coordinate frame.
output_projection : `~astropy.wcs.WCS` or `~astropy.io.fits.Header`
The output projection, which can be either a `~astropy.wcs.WCS`
or a `~astropy.io.fits.Header` instance.
shape_out : tuple, optional
If ``output_projection`` is a `~astropy.wcs.WCS` instance, the
shape of the output data should be specified separately.
hdu_in : int or str, optional
If ``input_data`` is a FITS file, specifies the HDU to use.
order : int or str, optional
The order of the interpolation (if ``mode`` is set to
``'interpolation'``). This can be either one of the following strings:
* 'nearest-neighbor'
* 'bilinear'
or an integer. A value of ``0`` indicates nearest neighbor
interpolation.
nested : bool, optional
The order of the healpix_data, either nested (True) or ring (False)
field : int, optional
The column to read from the HEALPIX FITS file. If the fits file is a
partial-sky file, field=0 corresponds to the first column after the
pixel index column.
Returns
-------
array_new : `~numpy.ndarray`
The reprojected array
footprint : `~numpy.ndarray`
Footprint of the input array in the output array. Values of 0 indicate
no coverage or valid values in the input image, while values of 1
indicate valid values.
"""
array_in, coord_system_in = parse_input_healpix_data(input_data, hdu_in=hdu_in, field=field)
wcs_out, shape_out = parse_output_projection(output_projection, shape_out=shape_out)
return healpix_to_image(array_in, coord_system_in, wcs_out, shape_out, order=order, nested=nested)
def reproject_to_healpix(input_data, coord_system_out, hdu_in=None, order='bilinear', nested=False, nside=128):
"""
Reproject data from a standard projection to a HEALPIX projection.
.. note:: This function uses healpy, which is licensed
under the GPLv2, so any package using this funtions has to (for
now) abide with the GPLv2 rather than the BSD license.
Parameters
----------
input_data : str or `~astropy.io.fits.HDUList` or `~astropy.io.fits.PrimaryHDU` or `~astropy.io.fits.ImageHDU` or tuple
The input data to reproject. This can be:
* The name of a FITS file
* An `~astropy.io.fits.HDUList` object
* An image HDU object such as a `~astropy.io.fits.PrimaryHDU` or
`~astropy.io.fits.ImageHDU` instance
* A tuple where the first element is a `~numpy.ndarray` and the
second element is either a `~astropy.wcs.WCS` or a
`~astropy.io.fits.Header` object
coord_system_out : `~astropy.coordinates.BaseCoordinateFrame` or str
The output coordinate system for the HEALPIX projection
hdu_in : int or str, optional
If ``input_data`` is a FITS file or an `~astropy.io.fits.HDUList`
instance, specifies the HDU to use.
order : int or str, optional
The order of the interpolation (if ``mode`` is set to
``'interpolation'``). This can be either one of the following strings:
* 'nearest-neighbor'
* 'bilinear'
* 'biquadratic'
* 'bicubic'
or an integer. A value of ``0`` indicates nearest neighbor
interpolation.
nested : bool
The order of the healpix_data, either nested (True) or ring (False)
nside : int, optional
The resolution of the HEALPIX projection.
Returns
-------
array_new : `~numpy.ndarray`
The reprojected array
footprint : `~numpy.ndarray`
Footprint of the input array in the output array. Values of 0 indicate
no coverage or valid values in the input image, while values of 1
indicate valid values.
"""
array_in, wcs_in = parse_input_data(input_data, hdu_in=hdu_in)
coord_system_out = parse_coord_system(coord_system_out)
if wcs_in.has_celestial and wcs_in.naxis == 2:
return image_to_healpix(array_in, wcs_in, coord_system_out, nside=nside, order=order, nested=nested)
else:
raise NotImplementedError("Only data with a 2-d celestial WCS can be reprojected to a HEALPIX projection")
|