trim_image

ccdproc.trim_image(ccd, fits_section=None)[source]

Trim the image to the dimensions indicated.

Parameters:
ccdCCDData

CCD image to be trimmed, sliced if desired.

fits_sectionstr or None, optional

Region of ccd from which the overscan is extracted; see subtract_overscan for details. Default is None.

add_keywordstr, Keyword or dict-like, optional

Item(s) to add to metadata of result. Set to False or None to completely disable logging. Default is to add a dictionary with a single item: The key is the name of this function and the value is a string containing the arguments the function was called with, except the value of this argument.

Returns:
trimmed_ccdCCDData

Trimmed image.

Examples

Given an array that is 100x100,

>>> import numpy as np
>>> from astropy import units as u
>>> arr1 = CCDData(np.ones([100, 100]), unit=u.adu)

the syntax for trimming this to keep all of the first index but only the first 90 rows of the second index is

>>> trimmed = trim_image(arr1[:, :90])
>>> trimmed.shape
(100, 90)
>>> trimmed.data[0, 0] = 2
>>> arr1.data[0, 0]
1.0

This both trims and makes a copy of the image.

Indexing the image directly does not do the same thing, quite:

>>> not_really_trimmed = arr1[:, :90]
>>> not_really_trimmed.data[0, 0] = 2
>>> arr1.data[0, 0]
2.0

In this case, not_really_trimmed is a view of the underlying array arr1, not a copy.