When specifying the name of an image to be opened, you can select a rectangular subsection of the image to be extracted and opened by the application program. The application program then opens a virtual image that only contains the pixels within the specified subsection. To do this, specify the the range of pixels (start:end) along each axis to be extracted from the original image enclosed in square brackets. You can also specify an optional pixel increment (start:end:step) for each axis of the input image. A pixel step = 1 will be assumed if it is not specified. If the starting pixel is larger then the end pixel, then the image will be flipped (producing a mirror image) along that dimension. An asterisk, '*', may be used to specify the entire range of an axis, and '-*' will flip the entire axis. In the following examples, assume that myfile.fits contains a 512 x 512 pixel 2D image.
myfile.fits[201:210, 251:260] - opens a 10 x 10 pixel subimage. myfile.fits[*, 512:257] - opens a 512 x 256 image consisting of all the columns in the input image, but only rows 257 through 512. The image will be flipped along the Y axis since the starting row is greater than the ending row. myfile.fits[*:2, 512:257:2] - creates a 256 x 128 pixel image. Similar to the previous example, but only every other row and column is read from the input image. myfile.fits[-*, *] - creates an image containing all the rows and columns in the input image, but flips it along the X axis.
If the array to be opened is in an Image extension, and not in the primary array of the file, then you need to specify the extension name or number in square brackets before giving the subsection range, as in myfile.fits[1][-*, *] to read the image in the first extension in the file.