Trim the image to the dimensions indicated.
Parameters: | ccd : CCDData
fits_section : str
add_keyword : str, Keyword or dict-like, optional
|
---|---|
Returns: | trimmed_ccd : CCDData
|
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.