I have added a 'slice' capability to the data descriptor where you can specify the coordinates of a sub-array of data to be handled by a data descriptor. dat_slices() can be used to slice up a data descriptor into multiple data descriptors pointing to different slices of the original descriptor without allocating new data arrays. For example, a cube stored in dd0 can be sliced into its constituent image planes using:
dd = dat_slices(dd0)
The new data descriptors dd each describe a single plane of the cube, but no new data arrays are allocated; they all point to the appropriate elements of the full cube stored in dd0. GRIM now uses this scheme to handle cubes.
dat_slices() can be used more generally by specifying the coordinates of the desired slice:
dd = dat_slices(dd0, slice),
where 'slice' is an array giving the coordinates of the desired sub-array in the full data array. The dimensions of the slice are determined by the dimensionality of the slice coordinates. For example, if dd0 is a cube, then:
dd = dat_slices(dd0, [1])
would return a data descriptor for image plane 1 in the cube, If dd0 is an image, then dd will contain the second line in the image. To extract line 10 from image plane 1 in the cube in dd0, use:
dd = dat_slices(dd0, [10,1]).
So the dimensionality of the returned slice is the number of dimensions in the input data array minus the number of slice coordinates specified. Note that this arrangement assumes planar interleaving.
This should address Paulo's issue of how to provide input to pg_map when map projecting various channels of a spectral cube: slice the cube with dat_slices, and project each one with a separate call to pg_map.
From @jnspitale on June 7, 2017 8:38
I have added a 'slice' capability to the data descriptor where you can specify the coordinates of a sub-array of data to be handled by a data descriptor. dat_slices() can be used to slice up a data descriptor into multiple data descriptors pointing to different slices of the original descriptor without allocating new data arrays. For example, a cube stored in dd0 can be sliced into its constituent image planes using:
dd = dat_slices(dd0)
The new data descriptors dd each describe a single plane of the cube, but no new data arrays are allocated; they all point to the appropriate elements of the full cube stored in dd0. GRIM now uses this scheme to handle cubes.
dat_slices() can be used more generally by specifying the coordinates of the desired slice:
dd = dat_slices(dd0, slice),
where 'slice' is an array giving the coordinates of the desired sub-array in the full data array. The dimensions of the slice are determined by the dimensionality of the slice coordinates. For example, if dd0 is a cube, then:
dd = dat_slices(dd0, [1])
would return a data descriptor for image plane 1 in the cube, If dd0 is an image, then dd will contain the second line in the image. To extract line 10 from image plane 1 in the cube in dd0, use:
dd = dat_slices(dd0, [10,1]).
So the dimensionality of the returned slice is the number of dimensions in the input data array minus the number of slice coordinates specified. Note that this arrangement assumes planar interleaving.
This should address Paulo's issue of how to provide input to pg_map when map projecting various channels of a spectral cube: slice the cube with dat_slices, and project each one with a separate call to pg_map.
Copied from original issue: ppenteado/ominas#9