Utilities used by wiimatch¶
This module provides utility functions for use by wiimatch module.
| Author: | Mihai Cara (contact: help@stsci.edu) |
|---|
-
jwst.wiimatch.utils.create_coordinate_arrays(image_shape, center=None, image2world=None, center_cs='image')[source]¶ Create a list of coordinate arrays/grids for each dimension in the image shape. This function is similar to
numpy.indicesexcept it returns the list of arrays in reversed order. In addition, it can center image coordinates to a providedcenterand also convert image coordinates to world coordinates using providedimage2worldfunction.- image_shape : sequence of int
- The shape of the image/grid.
- center : iterable, None, optional
- An iterable of length equal to the number of dimensions in
image_shapethat indicates the center of the coordinate system in image coordinates whencenter_csis'image'otherwise center is assumed to be in world coordinates (whencenter_csis'world'). WhencenterisNonethencenteris set to the middle of the “image” ascenter[i]=image_shape[i]//2. Ifimage2worldis notNoneandcenter_csis'image', then supplied center will be converted to world coordinates. - image2world : function, None, optional
- Image-to-world coordinates transformation function. This function
must be of the form
f(x,y,z,...)and accept a number of argumentsnumpy.ndarrayarguments equal to the dimensionality of images. - center_cs : {‘image’, ‘world’}, optional
- Indicates whether
centeris in image coordinates or in world coordinates. This parameter is ignored whencenteris set toNone: it is assumed to beFalse.center_cscannot be'world'whenimage2worldisNoneunlesscenterisNone.
- coord_arrays : list
- A list of
numpy.ndarraycoordinate arrays each ofimage_shapeshape. - eff_center : tuple
- A tuple of coordinates of the effective center as used in generating coordinate arrays.
- coord_system : {‘image’, ‘world’}
- Coordinate system of the coordinate arrays and returned
centervalue.
>>> import wiimatch >>> wiimatch.utils.create_coordinate_arrays((3,5,4)) ((array([[[-1., 0., 1., 2.], [-1., 0., 1., 2.], [-1., 0., 1., 2.], [-1., 0., 1., 2.], [-1., 0., 1., 2.]], [[-1., 0., 1., 2.], [-1., 0., 1., 2.], [-1., 0., 1., 2.], [-1., 0., 1., 2.], [-1., 0., 1., 2.]], [[-1., 0., 1., 2.], [-1., 0., 1., 2.], [-1., 0., 1., 2.], [-1., 0., 1., 2.], [-1., 0., 1., 2.]]]), array([[[-2., -2., -2., -2.], [-1., -1., -1., -1.], [ 0., 0., 0., 0.], [ 1., 1., 1., 1.], [ 2., 2., 2., 2.]], [[-2., -2., -2., -2.], [-1., -1., -1., -1.], [ 0., 0., 0., 0.], [ 1., 1., 1., 1.], [ 2., 2., 2., 2.]], [[-2., -2., -2., -2.], [-1., -1., -1., -1.], [ 0., 0., 0., 0.], [ 1., 1., 1., 1.], [ 2., 2., 2., 2.]]]), array([[[-2., -2., -2., -2.], [-2., -2., -2., -2.], [-2., -2., -2., -2.], [-2., -2., -2., -2.], [-2., -2., -2., -2.]], [[-1., -1., -1., -1.], [-1., -1., -1., -1.], [-1., -1., -1., -1.], [-1., -1., -1., -1.], [-1., -1., -1., -1.]], [[ 0., 0., 0., 0.], [ 0., 0., 0., 0.], [ 0., 0., 0., 0.], [ 0., 0., 0., 0.], [ 0., 0., 0., 0.]]])), (1.0, 2.0, 2.0), u'image')