Source code for casatasks.analysis.imsubimage

#
# stub function definition file for docstring parsing
#

[docs]def imsubimage(imagename, outfile='', box='', region='', chans='', stokes='', mask='', dropdeg=False, overwrite=False, verbose=True, stretch=False, keepaxes=''): r""" Create a (sub)image from a region of the image [`Description`_] [`Examples`_] [`Development`_] [`Details`_] Parameters - imagename_ (path) - Input image name. Default is unset. - outfile_ (string='') - Output image name. Default is unset. .. raw:: html <details><summary><i> outfile != '' </i></summary> - overwrite_ (bool=False) - Overwrite (unprompted) pre-existing output file? .. raw:: html </details> - box_ (string='') - Rectangular region to select in direction plane. Default is to use the entire direction plane. - region_ (string='') - Region selection. Default is to use the full image. - chans_ (string='') - Channels to use. Default is to use all channels. - stokes_ (string='') - Stokes planes to use. Default is to use all Stokes planes. - mask_ (variant='') - Mask to use. Default is none. .. raw:: html <details><summary><i> mask != '' </i></summary> - stretch_ (bool=False) - Stretch the mask if necessary and possible? .. raw:: html </details> - dropdeg_ (bool=False) - Drop degenerate axes .. raw:: html <details><summary><i> dropdeg = True </i></summary> - keepaxes_ (intVec='') - If dropdeg=True, these are the degenerate axes to keep. Nondegenerate axes are implicitly always kept. .. raw:: html </details> - verbose_ (bool=True) - Post additional informative messages to the logger .. _Description: Description This task copies all or part of the image to a new image specified by *outfile*. Both float and complex valued images are supported. Sometimes it is useful to drop axes of length one (degenerate axes). Set *dropdeg* equal to True if you want to do this. The output mask is the union (logical AND) of the default input pixel mask (if any) and the OTF mask. Any other input pixel masks will not be copied. Use function **ia.maskhandler** if you need to copy other masks too. If the mask has fewer dimensions than the image and if the shape of the dimensions the mask and image have in common are the same, the mask will automatically have the missing dimensions added so it conforms to the image. If *stretch=True* and if the number of mask dimensions is less than or equal to the number of image dimensions and some axes in the mask are degenerate while the corresponding axes in the image are not, the mask will be stretched in the degenerate dimensions. For example, if the input image has shape [100, 200, 10] and the input mask has shape [100, 200, 1] and *stretch=True*, the mask will be stretched along the third dimension to shape [100, 200, 10]. However if the mask has shape [100, 200, 2], stretching is not possible and an error will result. .. rubric:: Task-specific parameters *dropdeg* Exclude axes from output image if they would have a length of one pixel. *verbose* Post additional informative, possibly useful, messages to the logger? *keepaxes* If dropdeg=True, these are the degenerate axes to keep. Nondegenerate axes are implicitly always kept. Ignored if dropdeg=False; all axes are kept in that case. .. _Examples: Examples :: # make a subimage containing only channels 4 to 6 of the original image, imsubimage(imagename="my.im", outfile="first.im", chans="4~6") :: # Same as above command, just specifying chans in an alternate, more verbose way imsubimage(imagename="my.im", outfile="second.im", chans="range=[4pix,6pix]") :: # Same as the above command, but even more verbose way of # specifying the spectral selection. Assumes the direction axes # are axes numbers 0 and 1. ia.open("my.im") shape = ia.shape() axes = ia.coordsys().names() ia.done() xmax = shape[axes.index("Right Ascension")] - 1 ymax = shape[axes.index("Declination")] - 1 reg = "box[[0pix,0pix],[" + str(xmax) + "pix, " + str(ymax) + "pix]] range=[4pix,6pix]" imsubimage(imagename="my.im", outfile="third.im", region=reg) :: # As an example of the usage of the keepaxes parameter, consider an image # that has axes RA, Dec, Stokes, and Freq. The Stokes and Freq axes are both # degenerate while the RA and Dec axes are not, and it is desired to make a # subimage in which the Stokes axis is discarded. The following command will # accomplish that. imsubimage(imagename="my.im", outfile="discarded_stokes.im", dropdeg=True, keepaxes=[3]) .. _Development: Development No additional development details .. _Details: Parameter Details Detailed descriptions of each function parameter .. _imagename: | ``imagename (path)`` - Input image name. Default is unset. .. _outfile: | ``outfile (string='')`` - Output image name. Default is unset. .. _box: | ``box (string='')`` - Rectangular region to select in direction plane. Default is to use the entire direction plane. .. _region: | ``region (string='')`` - Region selection. Default is to use the full image. .. _chans: | ``chans (string='')`` - Channels to use. Default is to use all channels. .. _stokes: | ``stokes (string='')`` - Stokes planes to use. Default is to use all Stokes planes. .. _mask: | ``mask (variant='')`` - Mask to use. Default is none. .. _dropdeg: | ``dropdeg (bool=False)`` - Drop degenerate axes .. _overwrite: | ``overwrite (bool=False)`` - Overwrite (unprompted) pre-existing output file? .. _verbose: | ``verbose (bool=True)`` - Post additional informative messages to the logger .. _stretch: | ``stretch (bool=False)`` - Stretch the mask if necessary and possible? .. _keepaxes: | ``keepaxes (intVec='')`` - If dropdeg=True, these are the degenerate axes to keep. Nondegenerate axes are implicitly always kept. """ pass