[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Specification for a new array slicing function



Please find below a suggested specification for a new array slicing
function, formatted as a standard IDL prolog. The intention here is to
provide a means to extract n-dimensional array 'slices' from an existing
array in memory. The caller can choose to skip elements along any or all
dimensions if desired.

Comments are invited. There's no code yet, so now is the time.

Cheers,
Liam.

;+
; NAME:
;    ARRAY_SLICE
;
; PURPOSE:
;    Extract an n-dimensional slice from an array in memory.
;
; CATEGORY:
;    Array processing.
;
; CALLING SEQUENCE:
;    RESULT = ARRAY_SLICE( ARRAY )
;
; INPUTS:
;    ARRAY        The array from which data will be extracted.
;                 ARRAY must be defined and have one or more
;                 dimensions, otherwise execution will halt.
;
; OPTIONAL INPUTS:
;    None.
;
; INPUT KEYWORD PARAMETERS:
;    START        Set this keyword to a vector containing the start
;                 position for extraction along each dimension
;                 (default is [0,0,...,0]).
;                 START must have the same number of dimensions
;                 as ARRAY, otherwise execution will halt.
;                 START is automatically limited to minimum and
;                 maximum values suitable for ARRAY.
;    STRIDE       Set this keyword to a vector containing the
;                 sampling interval along each dimension
;                 (default is [1,1,...1] for contiguous extraction).
;                 STRIDE must have the same number of dimensions
;                 as ARRAY, otherwise execution will halt.
;                 STRIDE is automatically limited to minimum and
;                 maximum values suitable for ARRAY.
;    COUNT        Set this keyword to a vector containing the
;                 number of items to extract along each dimension
;                 (default is to extract all data).
;                 COUNT must have the same number of dimensions
;                 as ARRAY, otherwise execution will halt.
;                 COUNT is automatically limited to minimum and
;                 maximum values suitable for ARRAY.
;
; OUTPUT KEYWORD PARAMETERS:
;    None.
;
; OUTPUTS:
;    RESULT       The extracted array (all dimensions are left intact).
;                 If none of START, STRIDE, COUNT are specified,
;                 returns a copy of the input array.
;
; OPTIONAL OUTPUTS:
;    None.
;
; COMMON BLOCKS:
;    None.
;
; SIDE EFFECTS:
;    None.
;
; RESTRICTIONS:
;    None.
;
; EXAMPLE:
;
; ;Extract every other element along each dimension
;
; array = findgen( 1, 10, 5, 6, 7 )
; ndims = size( array, /n_dimensions )
; stride = replicate( 2L, ndims )
; result = array_slice( array, stride=stride )
; help, result
;
; ;RESULT          FLOAT     = Array[1, 5, 2, 3, 3]
;
; MODIFICATION HISTORY:
; $Id: array_slice.pro,v 1.1 1999/05/19 19:44:27 gumley Exp $
;-

---
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
http://cimss.ssec.wisc.edu/~gumley