imutils Documentation Release 0.0.dev116
STScI
December 09, 2015
Contents
I
Imutils Overview
1
Installation 1.1 Requirements . . . . . . . . . 1.2 Installing Imutils Using pip . 1.3 Obtaining the Source Package 1.4 Testing an Installed Imutils .
2
II
1 . . . .
5 5 5 6 6
Changelog 2.1 0.1 (unreleased) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7 7
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
Tools Documentation
9
3
Command-line Scripts 3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11 11
4
Statistics 4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13 13
5
Image Arithmetic 5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15 15
6
Interpolation 6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
17 17
7
Filtering Tools 7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
19 19
8
Misc Tools 8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21 21
9
Reference/API 9.1 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.2 Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.3 Class Inheritance Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23 23 30 36
i
III
Reporting Issues
37
IV
Contributing
41
Python Module Index
45
ii
Part I
Imutils Overview
1
imutils Documentation, Release 0.0.dev116
Imutils is an open-source Python package to provide convenience tools, including some command-line tools, for image statistics, interpolation, filtering, and arithmetic. It is an open source (BSD licensed) Python package. Bug reports, comments, and help with development are very welcome.
3
imutils Documentation, Release 0.0.dev116
4
CHAPTER 1
Installation
1.1 Requirements Imutils has the following strict requirements: • Python 2.7, 3.3, 3.4 or 3.5 • Numpy 1.6 or later • Astropy 1.0 or later Some functionality is available only if the following optional dependencies are installed: • Scipy 0.15 or later
1.2 Installing Imutils Using pip To install the latest imutils stable version with pip, simply run: pip install --no-deps imutils
To install the current imutils development version using pip: pip install --no-deps git+https://github.com/spacetelescope/imutils.git
Note: The --no-deps flag is optional, but highly recommended if you already have Numpy and Astropy installed, since otherwise pip will sometimes try to “help” you by upgrading your Numpy and Astropy installations, which may not always be desired. Note: If you get a PermissionError this means that you do not have the required istrative access to install new packages to your Python installation. In this case you may consider using the -- option to install the package into your home directory. You can read more about how to do this in the pip documentation. Do not install imutils or other third-party packages using sudo unless you are fully aware of the risks.
5
imutils Documentation, Release 0.0.dev116
1.3 Obtaining the Source Package 1.3.1 Stable Version The latest stable source package for imutils will be available from PyPI once released.
1.3.2 Development Version The latest development version of imutils can be cloned from github using this command: git clone https://github.com/spacetelescope/imutils.git
1.4 Testing an Installed Imutils The easiest way to test your installed version of imutils is running correctly is to use the imutils.test() function: >>> import imutils >>> imutils.test()
The tests should run and print out any failures, which you can report to the Imutils issue tracker. Note: This way of running the tests may not work if you do it in the imutils source distribution directory.
6
Chapter 1. Installation
CHAPTER 2
Changelog
2.1 0.1 (unreleased) imutils requires Astropy version 1.0 or later.
7
imutils Documentation, Release 0.0.dev116
8
Chapter 2. Changelog
Part II
Tools Documentation
9
CHAPTER 3
Command-line Scripts
3.1 Introduction
11
imutils Documentation, Release 0.0.dev116
12
Chapter 3. Command-line Scripts
CHAPTER 4
Statistics
4.1 Introduction
13
imutils Documentation, Release 0.0.dev116
14
Chapter 4. Statistics
CHAPTER 5
Image Arithmetic
5.1 Introduction
15
imutils Documentation, Release 0.0.dev116
16
Chapter 5. Image Arithmetic
CHAPTER 6
Interpolation
6.1 Introduction
17
imutils Documentation, Release 0.0.dev116
18
Chapter 6. Interpolation
CHAPTER 7
Filtering Tools
7.1 Introduction
19
imutils Documentation, Release 0.0.dev116
20
Chapter 7. Filtering Tools
CHAPTER 8
Misc Tools
8.1 Introduction
21
imutils Documentation, Release 0.0.dev116
22
Chapter 8. Misc Tools
CHAPTER 9
Reference/API
This is an Astropy d package.
9.1 Functions basic_fits_to_nddata(filename[, exten]) basic_nddata_to_fits(nddata, filename[, clobber]) circular_annulus_footprint(radius_inner, ...) circular_footprint(radius[, dtype]) elliptical_annulus_footprint(a_inner, ...[, ...]) elliptical_footprint(a, b[, theta, dtype]) imarith(nddata1, nddata2, operator[, ...]) imstats(nddata[, sigma, iters, cenfunc, ...]) listpixels(data, position, shape[, ...]) mask_databounds(nddata[, mask, lower_bound, ...]) minmax(data[, mask, axis]) radial_distance(shape, position) test([package, test_path, args, plugins, ...])
Read a single FITS extension into a NDData object. Write a NDData object to a FITS file. Create a circular annulus footprint. Create a circular footprint. Create an elliptical annulus footprint. Create an elliptical footprint. Perform basic arithmetic on two NDData objects and return a new NDData obje Compute image statistics. Return a Table listing the (row, col) ((y, x)) positions and data values fo Update a NDData mask by masking data values that are below a lower bound, Return the minimum and maximum values of an array or the minimum and m Return an array where each value is the Euclidean distance from a given posit Run the tests using py.test.
9.1.1 basic_fits_to_nddata imutils.basic_fits_to_nddata(filename, exten=0) Read a single FITS extension into a NDData object. This is an extremely simple reader that reads data from only a single FITS extension. Parameters filename : str The path to a FITS file. exten : int, optional The FITS extension number for the data array. Default is 0. Returns nddata : NDData An NDData object with a data attribute containing the FITS data array and a meta attribute, containing the FITS header as a python dict.
23
imutils Documentation, Release 0.0.dev116
9.1.2 basic_nddata_to_fits imutils.basic_nddata_to_fits(nddata, filename, clobber=False) Write a NDData object to a FITS file.
9.1.3 circular_annulus_footprint imutils.circular_annulus_footprint(radius_inner, radius_outer, dtype=
) Create a circular annulus footprint. A pixel is considered to be entirely in or out of the footprint depending on whether its center is in or out of the footprint. The size of the output array is the minimal bounding box for the footprint. Parameters radius_inner : int The inner radius of the circular annulus. radius_outer : int The outer radius of the circular annulus. dtype : data-type, optional The data type of the output ndarray. Returns footprint : ndarray A footprint where array elements are 1 within the footprint and 0 otherwise.
9.1.4 circular_footprint imutils.circular_footprint(radius, dtype=
) Create a circular footprint. A pixel is considered to be entirely in or out of the footprint depending on whether its center is in or out of the footprint. The size of the output array is the minimal bounding box for the footprint. Parameters radius : int The radius of the circular footprint. dtype : data-type, optional The data type of the output ndarray. Returns footprint : ndarray A footprint where array elements are 1 within the footprint and 0 otherwise.
9.1.5 elliptical_annulus_footprint imutils.elliptical_annulus_footprint(a_inner, a_outer, b_outer, theta=0, dtype=
) Create an elliptical annulus footprint. A pixel is considered to be entirely in or out of the footprint depending on whether its center is in or out of the footprint. The size of the output array is the minimal bounding box for the footprint. 24
Chapter 9. Reference/API
imutils Documentation, Release 0.0.dev116
Parameters a_inner : int The inner semimajor axis. a_outer : int The outer semimajor axis. b_outer : int The outer semimajor axis. theta : float, optional The angle in radians of the semimajor axis. The angle is measured counterclockwise from the positive x axis. dtype : data-type, optional The data type of the output ndarray. Returns footprint : ndarray A footprint where array elements are 1 within the footprint and 0 otherwise.
9.1.6 elliptical_footprint imutils.elliptical_footprint(a, b, theta=0, dtype=
) Create an elliptical footprint. A pixel is considered to be entirely in or out of the footprint depending on whether its center is in or out of the footprint. The size of the output array is the minimal bounding box for the footprint. Parameters a : int The semimajor axis. b : int The semiminor axis. theta : float, optional The angle in radians of the semimajor axis. The angle is measured counterclockwise from the positive x axis. dtype : data-type, optional The data type of the output ndarray. Returns footprint : ndarray A footprint where array elements are 1 within the footprint and 0 otherwise.
9.1.7 imarith imutils.imarith(nddata1, nddata2, operator, fill_value=0.0, keywords=None) Perform basic arithmetic on two NDData objects and return a new NDData object.
9.1. Functions
25
imutils Documentation, Release 0.0.dev116
Parameters nddata1 : NDData or scalar nddata1 and nddata2 cannot both be scalars. nddata2 : NDData or scalar nddata1 and nddata2 cannot both be scalars.
9.1.8 imstats imutils.imstats(nddata, sigma=None, iters=1, cenfunc=
, varfunc=
, columns=None, lower_bound=None, upper_bound=None, mask_value=None) Compute image statistics. Set the sigma keyword to perform sigma clipping. Parameters nddata : NDData or list of NDData NDData object containing the data array and optional mask on which to calculate statistics. Masked pixels are excluded when computing the image statistics. sigma : None or float, optional The number of standard deviations to use as the sigma clipping limit. If None (default), then sigma clipping is not performed. iters : int or None, optional The number of sigma clipping iterations to perform, or None to clip until convergence is achieved (i.e. continue until the last iteration clips nothing). cenfunc : callable, optional The technique to compute the center for the sigma clipping. Must be a callable that takes in a masked array and outputs the central value. Defaults to the median (numpy.ma.median). varfunc : callable, optional The technique to compute the standard deviation about the center for the sigma clipping. Must be a callable that takes in a masked array and outputs a width estimator. Masked (rejected) pixels are those where: deviation**2 > sigma**2 * varfunc(deviation)
Defaults to the variance (numpy.var). columns : str or list of str, optional The names of columns, in order, to include in the output Table. The column names can include any of the statistic names: ‘biweight_location’, ‘biweight_midvariance’, ‘kurtosis’, ‘mad_std’, ‘max’, ‘mean’, ‘median’, ‘min’, ‘mode’, ‘npixels’, ‘nrejected’, ‘skew’, ‘std’ or a name of a key in the astropy.nddata.NDData.meta dictionary. The default is [’npixels’, ’mean’, ’std’, ’min’, ’max’]. lower_bound : float, optional The minimum data value to include in the statistics. All pixel values less than lower_bound will be ignored. None means that no lower bound is applied (default). upper_bound : float, optional
26
Chapter 9. Reference/API
imutils Documentation, Release 0.0.dev116
The maximum data value to include in the statistics. All pixel values greater than upper_bound will be ignored. None means that no upper bound is applied (default). mask_value : float, optional A data value (e.g., 0.0) to be masked. mask_value will be masked in addition to any input mask. Returns table : Table A table containing the calculated image statistics. Each table row corresponds to a single data array. Examples >>> import numpy as np >>> from imutils import imstats >>> data = np.arange(10) >>> columns = ['mean', 'median', 'mode', 'std', 'mad_std', 'min', 'max'] >>> tbl = imstats(data, columns=columns) >>> tbl
, varfunc=
, lower_bound=None, upper_bound=None, mask_value=None) Bases: object Class to calculate (sigma-clipped) image statistics. Set the sigma keyword to perform sigma clipping. Parameters nddata : NDData
30
Chapter 9. Reference/API
imutils Documentation, Release 0.0.dev116
NDData object containing the data array and optional mask on which to calculate statistics. Masked pixels are excluded when computing the image statistics. sigma : None or float, optional The number of standard deviations to use as the sigma clipping limit. If None (default), then sigma clipping is not performed. iters : int or None, optional The number of sigma clipping iterations to perform, or None to clip until convergence is achieved (i.e. continue until the last iteration clips nothing). cenfunc : callable, optional The technique to compute the center for the sigma clipping. Must be a callable that takes in a masked array and outputs the central value. Defaults to the median (numpy.ma.median). varfunc : callable, optional The technique to compute the standard deviation about the center for the sigma clipping. Must be a callable that takes in a masked array and outputs a width estimator. Masked (rejected) pixels are those where: deviation**2 > sigma**2 * varfunc(deviation)
Defaults to the variance (numpy.var). lower_bound : float, optional The minimum data value to include in the statistics. All pixel values less than lower_bound will be ignored. None means that no lower bound is applied (default). upper_bound : float, optional The maximum data value to include in the statistics. All pixel values greater than upper_bound will be ignored. None means that no upper bound is applied (default). mask_value : float, optional A data value (e.g., 0.0) to be masked. mask_value will be masked in addition to any input mask. Attributes Summary
Attributes Documentation
biweight_location The biweight location of the pixel values. biweight_midvariance The biweight midvariance of the pixel values. kurtosis The kurtosis of the pixel values. mad_std A robust standard deviation using the median absolute deviation (MAD). The MAD is defined as
9.2. Classes
31
imutils Documentation, Release 0.0.dev116
median(abs(a - median(a))). The standard deviation estimator is given by: 𝜎≈
MAD Φ−1 (3/4)
≈ 1.4826 MAD
where Φ−1 (𝑃 ) is the normal inverse cumulative distribution function evaluated at probability 𝑃 = 3/4. max The maximum pixel value. mean The mean of pixel values. median The median of the pixel values. min The minimum pixel value. mode The mode of the pixel values. npixels The number of unclipped pixels. nrejected The number of rejected (clipped) pixels. skew The skew of the pixel values. std The standard deviation of the pixel values.
9.2.2 NDDataCutout class imutils.NDDataCutout(nddata, position, shape) Bases: object Attributes Summary
Attributes Documentation
bbox_large bbox_small
9.2.3 ShepardIDWInterpolator class imutils.ShepardIDWInterpolator(coord, vals, weights=None, leafsize=10) Bases: object 32
Chapter 9. Reference/API
imutils Documentation, Release 0.0.dev116
Class to perform Inverse Distance Weighted (IDW) interpolation on unstructured data using a modified version of the Shepard’s method (see Notes section for details). Parameters coord : int, float, 1D vector, or NxM-array-like of int or float Coordinates of the known data points. In general, it is expected that these coordinates are in a form of a NxM-like array where N is the number of points and M is dimention of the coordinate space. When N=1 (1D space), then the coord parameter may be entered as a 1D-like array (vector) or, if only one data point is available, coord can be a simple number representing the 1D coordinate of the data point. Note: If dimensionality of the coord argument is larger than 2, e.g., if it is of the form N1xN2xN3x...xNnxM then it will be flattened down to the last dimention to form an array of size NxM where N=N1*N2*...Nn. vals : int, float, complex, or 1D vector of int, float, or complex Values of the data points corresponding to each point coordinate provided in coord. In general a 1D-array like structure is expected. When a single data point is available, then vals can be a scalar (int, float, or complex). Note: If dimensionality of vals is larger than one then it will be flattened. weights : None, int, float, complex, or 1D vector of int, float, or complex (Default = None) Weights to be associated with each data point value. These weights, if provided, will be combined with inverse distance weights (see Notes section for details). When weights is None (default), then only IDW will be used. When provided, this input parameter must be of the same form as vals. leafsize : float The number of points at which the k-d tree algorithm switches over to brute-force. leafsize must be positive. See scipy.spacial.cKDTree for further information. Notes
The interpolator provided by ShepardIDWInterpolator uses a slightly modified Shepard’s method. The essential difference is the introduction of a “regularization” parameter r that is used when computing the inverse distance weights: 𝑤𝑖 = 1/(𝑑(𝑥, 𝑥𝑖 )𝑝 + 𝑟) By supplying a positive regularization parameter, one can avoid singularities at locations of the data points as well as control the “smoothness” of the interpolation (e.g., make weights of the neighors less varied). The “smoothness” of interpolation can also be controlled by the power parameter p. Examples
This class can can be instantiated using the following syntax: >>> import imutils.ShepardIDWInterpolator as idw >>> import numpy as np
Example of interpolating 1D data:
9.2. Classes
33
imutils Documentation, Release 0.0.dev116
>>> x = np.random.random(100) >>> y = np.sin(2.0*x) >>> f = idw(x, y) >>> f(0.4) 0.38939783923570831 >>> np.sin(2.0*0.4) 0.38941834230865052 >>> xi = np.random.random(10) >>> print(xi) [ 0.36959095 0.13393148 0.06462452 0.12486564 0.85216626 0.26699299 0.18332824 0.07311128 0.41488567 0.75356603] >>> f(xi) array([ 0.6908391 , 0.25915542, 0.12856382, 0.2471138 , 0.98924021, 0.51959816, 0.35847361, 0.16208274, 0.73641671, 0.9979987 ]) >>> np.sin(2.0*xi) array([ 0.67368354, 0.2646712 , 0.12888948, 0.24714359, 0.99109728, 0.50896845, 0.35849616, 0.14570204, 0.73777703, 0.99797412])
NOTE: In the last example, xi may be a Nx1 array instead of a 1D vector. Example of interpolating 2D data:: >>> x = np.random.rand(1000,2) >>> v = np.sin(x[:,0]+x[:,1]) >>> f = idw(x, v) >>> f([0.5,0.6]) 0.88677703934471241 >>> np.sin(0.5+0.6) 0.89120736006143542
Notice that when a single coordinate is ed as an argument to the interpolator, then a single (interpolated) value is returned (instead of a 1D vector of values). Methods Summary
Methods Documentation
__call__(self, pts, nbr=8, eps=0.0, p=1, reg=0.0, confdist=1e-12, dtype=np.float) Evaluate interpolator at given points. Parameters pts : int, float, 1D vector, or NxM-array-like of int or float Coordinates of the point(s) at which the interpolator should be evaluated. In general, it is expected that these coordinates are in a form of a NxM-like array where N is the number of points and M is dimention of the coordinate space. When N=1 (1D space), then the pts parameter may be entered as a 1D-like array (vector) or, if only one data point is available, pts can be a simple number representing the 1D coordinate of the data point. Note: If dimensionality of the pts argument is larger than 2, e.g., if it is of the form N1xN2xN3x...xNnxM then it will be flattened down to the last dimention to form an array of size NxM where N=N1*N2*...Nn.
34
Chapter 9. Reference/API
imutils Documentation, Release 0.0.dev116
Warning: The dimensionality of coordinate space of the pts must match the dimensionality of the coordinates used during the initialization of the interpolator. nbr : int (Default = 8) Maximum number of closest neighbors to be used during the interpolation. eps : float (Default = 0.0) Use approximate nearest neighbors; the kth neighbor is guaranteed to be no further than (1+eps) times the distance to the real k-th nearest neighbor. See scipy.spacial.cKDTree.query for further information. p : int, float (Default = 1) Power parameter of the inverse distance. reg : float (Default = 0.0) Regularization parameter. It may be used to control smoothness of the interpolator. See Notes section in ShepardIDWInterpolator for more details. confdist : float (Default = 1.0e-12) Confusion distance below which the interpolator should use the value of the closest data point instead of attempting to interpolate. This is used to avoid singularities at the known data points especially if reg is 0.0. dtype : data-type (Default = numpy.float) The type of the output interpolated values. If None then the type will be inferred from the type of the vals parameter used during the initialization of the interpolator.
9.2.4 StdUncertainty class imutils.StdUncertainty(value) Bases: object NDData uncertainty class to hold 1-sigma standard deviations. Attributes Summary
uncertainty_type Attributes Documentation
uncertainty_type
9.2. Classes
35
imutils Documentation, Release 0.0.dev116
9.3 Class Inheritance Diagram
StdUncertainty
ShepardIDWInterpolator
NDDataCutout
ImageStatistics
36
Chapter 9. Reference/API
Part III
Reporting Issues
37
imutils Documentation, Release 0.0.dev116
If you have found a bug in imutils please report it by creating a new issue on the imutils GitHub issue tracker. Please include an example that demonstrates the issue that will allow the developers to reproduce and fix the problem. You may be asked to also provide information about your operating system and a full Python stack trace. The developers will walk you through obtaining a stack trace if it is necessary. Imutils uses a package of utilities called astropy-helpers during building and installation. If you have any build or installation issue mentioning the astropy_helpers or ah_bootstrap modules please send a report to the astropyhelpers issue tracker. If you are unsure, then it’s fine to report to the main imutils issue tracker.
39
imutils Documentation, Release 0.0.dev116
40
Part IV
Contributing
41
imutils Documentation, Release 0.0.dev116
Like the Astropy project, imutils is made both by and for its s. We accept contributions at all levels, spanning the gamut from fixing a typo in the documentation to developing a major new feature. We welcome contributors who will abide by the Python Software Foundation Code of Conduct. Imutils follows the same workflow and coding guidelines as Astropy. The following pages will help you get started with contributing fixes, code, or documentation (no git or GitHub experience necessary): • How to make a code contribution • Coding Guidelines • Try the development version • Developer Documentation
43
imutils Documentation, Release 0.0.dev116
44
Python Module Index
i imutils, 23
45
imutils Documentation, Release 0.0.dev116
46
Python Module Index
Index
Symbols __call__() (imutils.ShepardIDWInterpolator method), 34
minmax() (in module imutils), 28 mode (imutils.ImageStatistics attribute), 32
B
N
basic_fits_to_nddata() (in module imutils), 23 basic_nddata_to_fits() (in module imutils), 24 bbox_large (imutils.NDDataCutout attribute), 32 bbox_small (imutils.NDDataCutout attribute), 32 biweight_location (imutils.ImageStatistics attribute), 31 biweight_midvariance (imutils.ImageStatistics attribute), 31
NDDataCutout (class in imutils), 32 npixels (imutils.ImageStatistics attribute), 32 nrejected (imutils.ImageStatistics attribute), 32
C circular_annulus_footprint() (in module imutils), 24 circular_footprint() (in module imutils), 24
E elliptical_annulus_footprint() (in module imutils), 24 elliptical_footprint() (in module imutils), 25
R radial_distance() (in module imutils), 29
S ShepardIDWInterpolator (class in imutils), 32 skew (imutils.ImageStatistics attribute), 32 std (imutils.ImageStatistics attribute), 32 StdUncertainty (class in imutils), 35
T test() (in module imutils), 29
I
U
ImageStatistics (class in imutils), 30 imarith() (in module imutils), 25 imstats() (in module imutils), 26 imutils (module), 23
uncertainty_type (imutils.StdUncertainty attribute), 35
K kurtosis (imutils.ImageStatistics attribute), 31
L listpixels() (in module imutils), 27
M mad_std (imutils.ImageStatistics attribute), 31 mask_databounds() (in module imutils), 28 max (imutils.ImageStatistics attribute), 32 mean (imutils.ImageStatistics attribute), 32 median (imutils.ImageStatistics attribute), 32 min (imutils.ImageStatistics attribute), 32
47
Related Documents 3h463d
Imutils 29142w
September 2022 0
More Documents from "Vaziel Ivans" 4t1i4q
Imutils 29142w
September 2022 0
Cuento Sobre El Agua 1p6y5a
November 2019 57
Guidelines International Fire Engineering 2005 c4y18
November 2019 71
Quien Creo El Microscopio 3g2b4r
December 2019 34
Unidad I Sistemas De Negocio Y Niveles De Aplicacion En Las Organizaciones 5lu68
December 2019 15
mean median mode std mad_std min max float64 float64 float64 float64 float64 int64 int64 ------- ------- ------- ------------- ------------- ----- ----4.5 4.5 4.5 2.87228132327 3.70650554626 0 9 9.1.9 listpixels imutils.listpixels(data, position, shape, subarray_indices=False, wcs=None) Return a Table listing the (row, col) ((y, x)) positions and data values for a subarray. Given a position of the center of the subarray, with respect to the large array, the array indices and values are returned. This function takes care of the correct behavior at the boundaries, where the small array is appropriately trimmed. Parameters data : array-like The input data. position : tuple (int) or SkyCoord The position of the subarray center with respect to the data array. The position can be specified either as an integer (row, col) ((y, x)) tuple of pixel coordinates or a SkyCoord, in which case wcs is a required input. shape : tuple (int) The integer shape ((ny, nx)) of the subarray. subarray_indices : bool, optional If True then the returned positions are relative to the small subarray. If False (default) then the returned positions are relative to the data array. wcs : WCS, optional The WCS transformation to use if position is a SkyCoord. 9.1. Functions 27 imutils Documentation, Release 0.0.dev116 Returns table : Table A table containing the x and y positions and data values. See also: astropy.nddata.utils.overlap_slices() Notes This function is decorated with _nddata and thus s NDData objects as input. Examples >>> >>> >>> >>> >>> 3 import numpy as np from imutils import listpixels data = np.arange(625).reshape(25, 25) tbl = listpixels(data, (10, 12), (3, 3)) print(len(tbl)) >>> x --11 12 13 11 12 13 11 12 13 tbl.pprint(max_lines=-1) y value --- ----9 236 9 237 9 238 10 261 10 262 10 263 11 286 11 287 11 288 9.1.10 mask_databounds imutils.mask_databounds(nddata, mask=None, lower_bound=None, upper_bound=None, mask_value=None) Update a NDData mask by masking data values that are below a lower bound, above an upper bound, equal to particular value, or are invalid (e.g. np.nan or np.inf). 9.1.11 minmax imutils.minmax(data, mask=None, axis=None) Return the minimum and maximum values of an array or the minimum and maximum along an axis. Parameters data : array-like The input data. mask : array_like (bool), optional 28 Chapter 9. Reference/API imutils Documentation, Release 0.0.dev116 A boolean mask, with the same shape as data, where a True value indicates the corresponding element of data is masked. axis : int, optional The axis along which to operate. By default, flattened input is used. Returns min : scalar or ndarray The minimum value of data. If axis is None, the result is a scalar value. If axis is input, the result is an array of dimension data.ndim - 1. max : scalar or ndarray The maximum value of data. If axis is None, the result is a scalar value. If axis is input, the result is an array of dimension data.ndim - 1. Notes This function is decorated with _nddata and thus s NDData objects as input. 9.1.12 radial_distance imutils.radial_distance(shape, position) Return an array where each value is the Euclidean distance from a given position. 9.1.13 test imutils.test(package=None, test_path=None, args=None, plugins=None, verbose=False, pastebin=None, remote_data=False, pep8=False, pdb=False, coverage=False, open_files=False, **kwargs) Run the tests using py.test. A proper set of arguments is constructed and ed to pytest.main. Parameters package : str, optional The name of a specific package to test, e.g. ‘io.fits’ or ‘utils’. If nothing is specified all default tests are run. test_path : str, optional Specify location to test by path. May be a single file or directory. Must be specified absolutely or relative to the calling directory. args : str, optional Additional arguments to be ed to pytest.main in the args keyword argument. plugins : list, optional Plugins to be ed to pytest.main in the plugins keyword argument. verbose : bool, optional Convenience option to turn on verbose output from py.test. ing True is the same as specifying ’-v’ in args. pastebin : {‘failed’,’all’,None}, optional 9.1. Functions 29 imutils Documentation, Release 0.0.dev116 Convenience option for turning on py.test pastebin output. Set to ’failed’ to info for failed tests, or ’all’ to info for all tests. remote_data : bool, optional Controls whether to run tests marked with @remote_data. These tests use online data and are not run by default. Set to True to run these tests. pep8 : bool, optional Turn on PEP8 checking via the pytest-pep8 plugin and disable normal tests. Same as specifying ’--pep8 -k pep8’ in args. pdb : bool, optional Turn on PDB post-mortem analysis for failing tests. Same as specifying ’--pdb’ in args. coverage : bool, optional Generate a test coverage report. The result will be placed in the directory htmlcov. open_files : bool, optional Fail when any tests leave files open. Off by default, because this adds extra run time to the test suite. Requires the psutil package. parallel : int, optional When provided, run the tests in parallel on the specified number of Us. If parallel is negative, it will use the all the cores on the machine. Requires the pytest-xdist plugin installed. Only available when using Astropy 0.3 or later. kwargs Any additional keywords ed into this function will be ed on to the astropy test runner. This allows use of test-related functionality implemented in later versions of astropy without explicitly updating the package template. 9.2 Classes ImageStatistics(nddata[, sigma, iters, ...]) NDDataCutout(nddata, position, shape) ShepardIDWInterpolator(coord, vals[, ...]) StdUncertainty(value) Class to calculate (sigma-clipped) image statistics. Class to perform Inverse Distance Weighted (IDW) interpolation on unstructured data NDData uncertainty class to hold 1-sigma standard 9.2.1 ImageStatistics class imutils.ImageStatistics(nddata, sigma=None, iters=1, cenfunc=