trim_image¶
-
ccdproc.
trim_image
(ccd, fits_section=None, add_keyword=True)[source]¶ Trim the image to the dimensions indicated.
Parameters: - ccd :
CCDData
CCD image to be trimmed, sliced if desired.
- fits_section : str or None, optional
Region of
ccd
from which the overscan is extracted; seesubtract_overscan
for details. Default isNone
.- add_keyword : str,
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_ccd :
CCDData
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 arrayarr1
, not a copy.- ccd :