'Slice a WCS instance using a Numpy slice. The order of the slice should
be reversed (as for the data) compared to the natural WCS order.
Parameters
view : tuple
A tuple containing the same number of slices as the WCS system.
The ``step`` method, the third argument to a slice, is not
presently supported.
numpy_order : bool
Use numpy order, i.e. slice the WCS so that an identical slice
applied to a numpy array will slice the array and WCS in the same
way. If set to `False`, the WCS will be sliced in FITS order,
meaning the first slice will be applied to the *last* numpy index
but the *first* WCS axis.
Returns
wcs_new : `~astropy.wcs.WCS`
A new resampled WCS axis'

def slice(self, view, numpy_order=True):

    if (hasattr(view, u'__len__') and (len(view) > self.wcs.naxis)):
        raise ValueError(u'Must    have    #    of    slices    <=    #    of    WCS    axes')
    elif (not hasattr(view, u'__len__')):
        view = [view]
    if (not all((isinstance(x, slice) for x in view))):
        raise ValueError(u'Cannot    downsample    a    WCS    with    indexing.        Use    wcs.sub    or    wcs.dropaxis    if    you    want    to    remove    axes.')
    wcs_new = self.deepcopy()
    for (i, iview) in enumerate(view):
        if ((iview.step is not None) and (iview.step < 0)):
            raise NotImplementedError(u'Reversing    an    axis    is    not    implemented.')
        if numpy_order:
            wcs_index = ((self.wcs.naxis - 1) - i)
        else:
            wcs_index = i
        if ((iview.step is not None) and (iview.start is None)):
            iview = slice(0, iview.stop, iview.step)
        if (iview.start is not None):
            if (iview.step not in (None, 1)):
                crpix = self.wcs.crpix[wcs_index]
                cdelt = self.wcs.cdelt[wcs_index]
                crp = (((((crpix - iview.start) - 1.0) / iview.step) + 0.5) + ((1.0 / iview.step) / 2.0))
                wcs_new.wcs.crpix[wcs_index] = crp
                wcs_new.wcs.cdelt[wcs_index] = (cdelt * iview.step)
            else:
                wcs_new.wcs.crpix[wcs_index] -= iview.start
        try:
            nitems = len(builtins.range(self._naxis[wcs_index])[iview])
        except TypeError as exc:
            if (u'indices    must    be    integers' not in str(exc)):
                raise
            warnings.warn(u"NAXIS{0}    attribute    is    not    updated    because    at    least    one    indix    ('{1}')    is    no    integer.".format(wcs_index, iview), AstropyUserWarning)
        else:
            wcs_new._naxis[wcs_index] = nitems
    return wcs_new
